接入桌面壳系统托盘
Tauri 桌面壳启用真实系统托盘 托盘菜单提供显示主窗口刷新和退出动作 托盘注册失败不阻断主窗口启动 补充桌面壳托盘检查测试和架构文档
This commit is contained in:
@@ -9,6 +9,8 @@ const capabilityPath = new URL(
|
||||
const capability = JSON.parse(fs.readFileSync(capabilityPath, 'utf8'));
|
||||
const buildScriptPath = new URL('../src-tauri/build.rs', import.meta.url);
|
||||
const buildScript = fs.readFileSync(buildScriptPath, 'utf8');
|
||||
const cargoManifestPath = new URL('../src-tauri/Cargo.toml', import.meta.url);
|
||||
const cargoManifest = fs.readFileSync(cargoManifestPath, 'utf8');
|
||||
const iconPath = new URL('../src-tauri/icons/icon.png', import.meta.url);
|
||||
const sharedContractPath = new URL(
|
||||
'../../../packages/shared/src/contracts/hostBridge.ts',
|
||||
@@ -133,6 +135,15 @@ const requiredPermissions = [
|
||||
const requiredBuildCommands = ['host_bridge_request'];
|
||||
const requiredMainSnippets = [
|
||||
'tauri_plugin_clipboard_manager::init()',
|
||||
'TrayIconBuilder::with_id',
|
||||
'register_desktop_tray(app)',
|
||||
'DESKTOP_TRAY_ID',
|
||||
'TRAY_MENU_SHOW',
|
||||
'TRAY_MENU_RELOAD',
|
||||
'TRAY_MENU_QUIT',
|
||||
'show_main_window',
|
||||
'reload_main_window',
|
||||
'desktop tray registration failed',
|
||||
'"appearance.getColorScheme"',
|
||||
'"app.lifecycle"',
|
||||
'"network.status"',
|
||||
@@ -196,6 +207,10 @@ if (buildScript.includes('resolve_desktop_shell_runtime')) {
|
||||
throw new Error('desktop shell build manifest exposes an unused runtime command');
|
||||
}
|
||||
|
||||
if (!cargoManifest.includes('features = ["tray-icon"]')) {
|
||||
throw new Error('desktop shell must enable the Tauri tray-icon feature');
|
||||
}
|
||||
|
||||
const icon = fs.readFileSync(iconPath);
|
||||
if (icon.length < 10000) {
|
||||
throw new Error('desktop shell icon must use a real brand asset');
|
||||
|
||||
Reference in New Issue
Block a user