This commit is contained in:
cheney
2026-08-07 09:49:26 +08:00
parent ac8a4b8cd2
commit dbe04b7da3
16 changed files with 795 additions and 13 deletions
+4
View File
@@ -18,6 +18,10 @@ tauri-build = { version = "2", features = [] }
tauri = { version = "2", features = [] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# 前端 OTA 升级 (运行时覆盖 tauri://localhost 资源, 不动 Tauri 框架/原生层)
# 见 docs/architecture.md - 通过替换 Assets provider, webview 仍走 tauri:// 协议,
# 但优先从 AppData 读, 缺失回退到内置 dist
tauri-plugin-hotswap = "0.0.4"
# Android 平台需要的 JNI / Activity 启动能力
[target."cfg(target_os = \"android\")".dependencies]
+4 -3
View File
@@ -1,9 +1,10 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "默认能力: 允许 core API",
"description": "默认能力: 允许 core API + hotswap 插件 (前端 OTA 升级)",
"windows": ["main"],
"permissions": [
"core:default"
"core:default",
"hotswap:default"
]
}
}
+14 -3
View File
@@ -1,8 +1,19 @@
// 跨平台入口: 桌面从这里走, Android 走 mobile_entry_point 宏
// 启动流程:
// 1) 初始化 tauri-plugin-hotswap (前端 OTA 升级插件)
// - 必须在 build 之前调用, 插件会替换 tauri::generate_context! 的 asset provider,
// 后续可被 tauri::Builder 消费
// 2) 业务初始化
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
// 生成 context, 交给 hotswap 包装 (替换 Assets provider, 让 tauri://localhost 资源
// 优先从本地覆盖目录读, 走不到时回退到内置 dist)
let context = tauri::generate_context!();
let (hotswap, context) = tauri_plugin_hotswap::init(context)
.expect("failed to initialize tauri-plugin-hotswap");
tauri::Builder::default()
.setup(|_app| Ok(()))
.run(tauri::generate_context!())
.plugin(hotswap)
.run(context)
.expect("error while running iBoard");
}
}
+9 -1
View File
@@ -9,6 +9,14 @@
"devUrl": "http://localhost:5173",
"frontendDist": "../dist"
},
"plugins": {
"hotswap": {
"endpoint": "http://bh.vps.honor3.com:3001/api/ota/check/{{current_sequence}}",
"pubkey": "RWQQ4/wfHjJiC/O6NmA7eIQYUNRpCsz5wLLsLqJXgHmsUraAavUWx0HA",
"require_https": false,
"headers": {}
}
},
"app": {
"windows": [
{
@@ -39,4 +47,4 @@
"minSdkVersion": 24
}
}
}
}