桌面壳持久化窗口状态
新增 Tauri window-state 插件并只保存主窗口大小、位置和最大化状态 收紧桌面壳依赖版本、插件顺序和三端文件结构门禁 同步宿主壳方案文档和团队决策记录
This commit is contained in:
@@ -529,6 +529,11 @@ for (const [sectionName, dependencyName, expectedLine] of [
|
||||
'tauri-plugin-single-instance',
|
||||
'tauri-plugin-single-instance = { version = "2.4.2", features = ["deep-link"] }',
|
||||
],
|
||||
[
|
||||
'dependencies',
|
||||
'tauri-plugin-window-state',
|
||||
'tauri-plugin-window-state = "2.4.1"',
|
||||
],
|
||||
]) {
|
||||
assertCargoDependencyLine(sectionName, dependencyName, expectedLine);
|
||||
}
|
||||
@@ -545,6 +550,7 @@ for (const [packageName, expectedVersion] of [
|
||||
['tauri-plugin-notification', '2.3.3'],
|
||||
['tauri-plugin-opener', '2.5.4'],
|
||||
['tauri-plugin-single-instance', '2.4.2'],
|
||||
['tauri-plugin-window-state', '2.4.1'],
|
||||
]) {
|
||||
assertCargoLockPackageVersion(packageName, expectedVersion);
|
||||
}
|
||||
@@ -561,6 +567,7 @@ for (const [dependencyName, expectedVersion] of [
|
||||
['tauri-plugin-notification', '2.3.3'],
|
||||
['tauri-plugin-opener', '2.5.4'],
|
||||
['tauri-plugin-single-instance', '2.4.2'],
|
||||
['tauri-plugin-window-state', '2.4.1'],
|
||||
]) {
|
||||
assertCargoLockDirectDependency(
|
||||
'genarrative-desktop-shell',
|
||||
@@ -1079,9 +1086,13 @@ const requiredRustHostModules = [
|
||||
'shell/tray.rs',
|
||||
'shell/url.rs',
|
||||
'shell/webview.rs',
|
||||
'shell/window_state.rs',
|
||||
];
|
||||
const requiredRustHostSnippets = [
|
||||
'tauri_plugin_single_instance::init',
|
||||
'desktop_window_state_plugin()',
|
||||
'tauri_plugin_window_state::Builder::default()',
|
||||
'StateFlags::SIZE | StateFlags::POSITION | StateFlags::MAXIMIZED',
|
||||
'tauri_plugin_deep_link::init()',
|
||||
'register_desktop_deep_link_events(app)',
|
||||
'register_desktop_deep_link_schemes(app)',
|
||||
@@ -1262,6 +1273,10 @@ if (!cargoManifest.includes('tauri-plugin-deep-link = "2.4.9"')) {
|
||||
throw new Error('desktop shell must depend on tauri-plugin-deep-link');
|
||||
}
|
||||
|
||||
if (!cargoManifest.includes('tauri-plugin-window-state = "2.4.1"')) {
|
||||
throw new Error('desktop shell must depend on tauri-plugin-window-state');
|
||||
}
|
||||
|
||||
if (
|
||||
!config.plugins ||
|
||||
!config.plugins['deep-link'] ||
|
||||
@@ -1278,11 +1293,28 @@ if (
|
||||
throw new Error('desktop shell must not configure updater without real signing and endpoint');
|
||||
}
|
||||
|
||||
if (
|
||||
main.indexOf('tauri_plugin_single_instance::init') >
|
||||
main.indexOf('tauri_plugin_clipboard_manager::init()')
|
||||
) {
|
||||
throw new Error('desktop shell must register the single-instance plugin first');
|
||||
const orderedDesktopPluginSnippets = [
|
||||
'tauri_plugin_single_instance::init',
|
||||
'desktop_window_state_plugin()',
|
||||
'tauri_plugin_deep_link::init()',
|
||||
'tauri_plugin_clipboard_manager::init()',
|
||||
'tauri_plugin_dialog::init()',
|
||||
'tauri_plugin_notification::init()',
|
||||
'tauri_plugin_opener::init()',
|
||||
];
|
||||
for (const pluginSnippet of orderedDesktopPluginSnippets) {
|
||||
if (!main.includes(pluginSnippet)) {
|
||||
throw new Error(`desktop shell main.rs missing plugin ${pluginSnippet}`);
|
||||
}
|
||||
}
|
||||
for (let index = 1; index < orderedDesktopPluginSnippets.length; index += 1) {
|
||||
const previousPlugin = orderedDesktopPluginSnippets[index - 1];
|
||||
const currentPlugin = orderedDesktopPluginSnippets[index];
|
||||
if (main.indexOf(previousPlugin) > main.indexOf(currentPlugin)) {
|
||||
throw new Error(
|
||||
`desktop shell plugin order drifted: ${previousPlugin} must be registered before ${currentPlugin}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (main.includes('single-instance",') || main.includes('"single-instance"')) {
|
||||
|
||||
Reference in New Issue
Block a user