Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
344 changes: 344 additions & 0 deletions PLUGINS.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![CI](https://img.shields.io/github/actions/workflow/status/ExpTechTW/TREM-Lite/ci.yml?branch=main&label=CI)](https://github.com/ExpTechTW/TREM-Lite/actions/workflows/ci.yml)
[![Discord](https://img.shields.io/discord/926545182407688273?logo=discord&logoColor=white&label=Discord&color=5865F2)](https://discord.gg/5dbHqV8ees)

[官網](https://exptech.dev/trem) • [網頁版](https://exptechtw.github.io/TREM-Lite/) • [更新日誌](https://github.com/ExpTechTW/TREM-Lite/releases) • [Commit 規則](commit.md)
[官網](https://exptech.dev/trem) • [網頁版](https://exptechtw.github.io/TREM-Lite/) • [更新日誌](https://github.com/ExpTechTW/TREM-Lite/releases) • [擴充功能開發](PLUGINS.md) • [Commit 規則](commit.md)

</div>

Expand All @@ -31,6 +31,7 @@ TREM(Taiwan Real-time Earthquake Monitoring,臺灣即時地震監測)是
| **通知與子母畫面** | 主視窗隱藏時,以系統通知和子母畫面小視窗提醒 |
| **常駐系統匣** | 關閉視窗後持續監測,也可以隨開機在背景啟動 |
| **自動更新** | 在背景下載新版本,下次啟動時套用,不會打斷正在使用的視窗 |
| **擴充功能** | 安裝社群開發的擴充功能,替 TREM-Lite 加上自己的功能(僅桌面版) |

## 下載

Expand All @@ -48,7 +49,7 @@ Linux 在下載的資料夾執行 `sudo apt install ./<檔名>.deb`,需要的

結尾是 `.sig` 或 `.app.tar.gz` 的檔案是自動更新用的,不需要下載。

不想安裝的話,可以直接用 **[網頁版](https://exptechtw.github.io/TREM-Lite/)**。網頁版有地圖、即時震度、強震即時警報、地震報告和語音播報;音效、系統通知、子母畫面、系統匣常駐與自動更新只有桌面版提供。
不想安裝的話,可以直接用 **[網頁版](https://exptechtw.github.io/TREM-Lite/)**。網頁版有地圖、即時震度、強震即時警報、地震報告和語音播報;音效、系統通知、子母畫面、系統匣常駐、自動更新與擴充功能只有桌面版提供。

### 版本命名

Expand Down Expand Up @@ -97,7 +98,7 @@ git config core.hooksPath .githooks # 啟用 commit 規則檢查
| `packages/core` | 桌面版與網頁版共用的前端:React、MapLibre、地震資料處理 |
| `apps/desktop` | Tauri 桌面版。Rust 負責音效、HTTP 代理與快取、自動更新、設定與視窗 |
| `apps/web` | 網頁版(GitHub Pages) |
| `tool/` | commit 規則檢查、版本號與發布說明的產生 |
| `tool/` | commit 規則檢查、版本號與發布說明的產生、擴充功能簽章工具 |
| `legacy/` | 舊版 Electron 原始碼,僅作為移植參照,不再修改 |

> [!NOTE]
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/src-tauri/capabilities/plugin-window.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "plugin-window",
"description": "擴充功能自己的視窗:只讓它把訊息送回去,以及操作自己那個視窗。",
"windows": ["plugin-*"],
"permissions": ["core:default"]
}
28 changes: 28 additions & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mod logging;
mod math;
mod ml_intensity;
mod ntp;
mod plugin;
mod plugin_window;
#[cfg(desktop)]
mod updater;
#[cfg(not(desktop))]
Expand Down Expand Up @@ -58,6 +60,10 @@ pub fn run() {
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_notification::init());

// Extensions get their own windows, served over a scheme of our own, and
// the protocol has to exist before the first one asks for a page.
builder = plugin_window::register(builder);

#[cfg(desktop)]
{
builder = builder
Expand Down Expand Up @@ -204,6 +210,20 @@ pub fn run() {
http_proxy::http_report,
math::eew_area_intensity,
ntp::ntp_sync,
plugin::plugin_root,
plugin::plugin_list,
plugin::plugin_write,
plugin::plugin_install,
plugin::plugin_remove,
plugin::plugin_packages,
plugin::plugin_discard,
plugin::plugin_keys,
plugin_window::plugin_window_open,
plugin_window::plugin_window_close,
plugin_window::plugin_window_send,
plugin_window::plugin_window_broadcast,
plugin_window::plugin_window_list,
plugin_window::plugin_window_ipc,
updater::update_check,
updater::update_pending,
updater::update_restart,
Expand All @@ -227,6 +247,14 @@ pub fn run() {
window::hide_main(window.app_handle());
}
}
// A plugin window is disposable: closed by the user, by its own
// page or by the extension being turned off, the main window hears
// about it under the name V3 used.
if window.label().starts_with("plugin-") {
if let WindowEvent::Destroyed = event {
plugin_window::closed(window.app_handle(), window.label());
}
}
})
.build(tauri::generate_context!())
.expect("error while building tauri application")
Expand Down
Loading