From 8fce8bdca4ce74dbbbe473e3568d5c5a1a8cb272 Mon Sep 17 00:00:00 2001 From: landaiqing Date: Tue, 16 Dec 2025 23:20:40 +0800 Subject: [PATCH] :recycle: Refactor backup service complete. --- .../wails/v3/pkg/application/models.ts | 2 - .../voidraft/internal/common/helper/index.ts | 4 + .../voidraft/internal/common/helper/models.ts | 17 + .../voidraft/internal/models/ent/models.ts | 16 +- .../internal/services/configservice.ts | 13 +- .../internal/services/hotkeyservice.ts | 11 +- .../voidraft/internal/services/models.ts | 11 - .../internal/services/windowservice.ts | 15 - frontend/package-lock.json | 379 +---------------- frontend/src/stores/configStore.ts | 2 +- .../src/views/settings/pages/GeneralPage.vue | 90 ++-- .../helper}/config_observer.go | 91 +++- internal/models/ent/document.go | 11 +- internal/models/ent/document_create.go | 2 +- internal/models/ent/extension.go | 11 +- internal/models/ent/extension_create.go | 2 +- internal/models/ent/keybinding.go | 11 +- internal/models/ent/keybinding_create.go | 2 +- internal/models/ent/mutation.go | 8 +- internal/models/ent/theme.go | 11 +- internal/models/ent/theme_create.go | 2 +- internal/services/backup_service.go | 23 +- internal/services/config_service.go | 341 ++++++--------- internal/services/data_migration_service.go | 65 ++- internal/services/hotkey_service.go | 98 ++--- internal/services/hotkey_service_test.go | 387 ------------------ internal/services/service_manager.go | 7 +- internal/services/window_service.go | 4 +- internal/services/window_snap_service.go | 2 +- 29 files changed, 467 insertions(+), 1171 deletions(-) create mode 100644 frontend/bindings/voidraft/internal/common/helper/index.ts create mode 100644 frontend/bindings/voidraft/internal/common/helper/models.ts rename internal/{services => common/helper}/config_observer.go (67%) delete mode 100644 internal/services/hotkey_service_test.go diff --git a/frontend/bindings/github.com/wailsapp/wails/v3/pkg/application/models.ts b/frontend/bindings/github.com/wailsapp/wails/v3/pkg/application/models.ts index 857c1be..6056830 100644 --- a/frontend/bindings/github.com/wailsapp/wails/v3/pkg/application/models.ts +++ b/frontend/bindings/github.com/wailsapp/wails/v3/pkg/application/models.ts @@ -61,5 +61,3 @@ export class ServiceOptions { return new ServiceOptions($$parsedSource as Partial); } } - -export type Window = any; diff --git a/frontend/bindings/voidraft/internal/common/helper/index.ts b/frontend/bindings/voidraft/internal/common/helper/index.ts new file mode 100644 index 0000000..c9d993a --- /dev/null +++ b/frontend/bindings/voidraft/internal/common/helper/index.ts @@ -0,0 +1,4 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export * from "./models.js"; diff --git a/frontend/bindings/voidraft/internal/common/helper/models.ts b/frontend/bindings/voidraft/internal/common/helper/models.ts new file mode 100644 index 0000000..163a030 --- /dev/null +++ b/frontend/bindings/voidraft/internal/common/helper/models.ts @@ -0,0 +1,17 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import {Create as $Create} from "@wailsio/runtime"; + +/** + * CancelFunc 取消订阅函数 + * 调用此函数可以取消对配置的监听 + */ +export type CancelFunc = any; + +/** + * ObserverCallback 观察者回调函数 + */ +export type ObserverCallback = any; diff --git a/frontend/bindings/voidraft/internal/models/ent/models.ts b/frontend/bindings/voidraft/internal/models/ent/models.ts index cd43c8f..096a7b5 100644 --- a/frontend/bindings/voidraft/internal/models/ent/models.ts +++ b/frontend/bindings/voidraft/internal/models/ent/models.ts @@ -21,7 +21,7 @@ export class Document { /** * UUID for cross-device sync (UUIDv7) */ - "uuid": string; + "uuid": string | null; /** * creation time @@ -56,7 +56,7 @@ export class Document { /** Creates a new Document instance. */ constructor($$source: Partial = {}) { if (!("uuid" in $$source)) { - this["uuid"] = ""; + this["uuid"] = null; } if (!("created_at" in $$source)) { this["created_at"] = ""; @@ -98,7 +98,7 @@ export class Extension { /** * UUID for cross-device sync (UUIDv7) */ - "uuid": string; + "uuid": string | null; /** * creation time @@ -133,7 +133,7 @@ export class Extension { /** Creates a new Extension instance. */ constructor($$source: Partial = {}) { if (!("uuid" in $$source)) { - this["uuid"] = ""; + this["uuid"] = null; } if (!("created_at" in $$source)) { this["created_at"] = ""; @@ -179,7 +179,7 @@ export class KeyBinding { /** * UUID for cross-device sync (UUIDv7) */ - "uuid": string; + "uuid": string | null; /** * creation time @@ -219,7 +219,7 @@ export class KeyBinding { /** Creates a new KeyBinding instance. */ constructor($$source: Partial = {}) { if (!("uuid" in $$source)) { - this["uuid"] = ""; + this["uuid"] = null; } if (!("created_at" in $$source)) { this["created_at"] = ""; @@ -261,7 +261,7 @@ export class Theme { /** * UUID for cross-device sync (UUIDv7) */ - "uuid": string; + "uuid": string | null; /** * creation time @@ -296,7 +296,7 @@ export class Theme { /** Creates a new Theme instance. */ constructor($$source: Partial = {}) { if (!("uuid" in $$source)) { - this["uuid"] = ""; + this["uuid"] = null; } if (!("created_at" in $$source)) { this["created_at"] = ""; diff --git a/frontend/bindings/voidraft/internal/services/configservice.ts b/frontend/bindings/voidraft/internal/services/configservice.ts index ddf3cba..f7d5ecf 100644 --- a/frontend/bindings/voidraft/internal/services/configservice.ts +++ b/frontend/bindings/voidraft/internal/services/configservice.ts @@ -15,11 +15,10 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime"; import * as application$0 from "../../../github.com/wailsapp/wails/v3/pkg/application/models.js"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unused imports -import * as models$0 from "../models/models.js"; - +import * as helper$0 from "../common/helper/models.js"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unused imports -import * as $models from "./models.js"; +import * as models$0 from "../models/models.js"; /** * Get 获取配置项 @@ -50,7 +49,7 @@ export function MigrateConfig(): Promise & { cancel(): void } { } /** - * ResetConfig 强制重置所有配置为默认值 + * ResetConfig 重置所有配置为默认值 */ export function ResetConfig(): Promise & { cancel(): void } { let $resultPromise = $Call.ByID(3593047389) as any; @@ -66,7 +65,7 @@ export function ServiceShutdown(): Promise & { cancel(): void } { } /** - * ServiceStartup initializes the service when the application starts + * ServiceStartup 服务启动时初始化 */ export function ServiceStartup(options: application$0.ServiceOptions): Promise & { cancel(): void } { let $resultPromise = $Call.ByID(3311949428, options) as any; @@ -84,7 +83,7 @@ export function Set(key: string, value: any): Promise & { cancel(): void } /** * Watch 注册配置变更监听器 */ -export function Watch(path: string, callback: $models.ObserverCallback): Promise<$models.CancelFunc> & { cancel(): void } { +export function Watch(path: string, callback: helper$0.ObserverCallback): Promise & { cancel(): void } { let $resultPromise = $Call.ByID(1143583035, path, callback) as any; return $resultPromise; } @@ -92,7 +91,7 @@ export function Watch(path: string, callback: $models.ObserverCallback): Promise /** * WatchWithContext 使用 Context 注册监听器 */ -export function WatchWithContext(path: string, callback: $models.ObserverCallback): Promise & { cancel(): void } { +export function WatchWithContext(path: string, callback: helper$0.ObserverCallback): Promise & { cancel(): void } { let $resultPromise = $Call.ByID(1454973098, path, callback) as any; return $resultPromise; } diff --git a/frontend/bindings/voidraft/internal/services/hotkeyservice.ts b/frontend/bindings/voidraft/internal/services/hotkeyservice.ts index e4abeeb..02e3b05 100644 --- a/frontend/bindings/voidraft/internal/services/hotkeyservice.ts +++ b/frontend/bindings/voidraft/internal/services/hotkeyservice.ts @@ -18,12 +18,12 @@ import * as application$0 from "../../../github.com/wailsapp/wails/v3/pkg/applic import * as models$0 from "../models/models.js"; /** - * GetCurrentHotkey 获取当前热键 + * GetSupportedKeys 返回系统支持的快捷键列表 */ -export function GetCurrentHotkey(): Promise & { cancel(): void } { - let $resultPromise = $Call.ByID(2572811187) as any; +export function GetSupportedKeys(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(1511528650) as any; let $typingPromise = $resultPromise.then(($result: any) => { - return $$createType1($result); + return $$createType0($result); }) as any; $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); return $typingPromise; @@ -86,5 +86,4 @@ export function UpdateHotkey(enable: boolean, combo: models$0.HotkeyCombo | null } // Private type creation functions -const $$createType0 = models$0.HotkeyCombo.createFrom; -const $$createType1 = $Create.Nullable($$createType0); +const $$createType0 = $Create.Array($Create.Any); diff --git a/frontend/bindings/voidraft/internal/services/models.ts b/frontend/bindings/voidraft/internal/services/models.ts index ff881a3..f99485d 100644 --- a/frontend/bindings/voidraft/internal/services/models.ts +++ b/frontend/bindings/voidraft/internal/services/models.ts @@ -12,12 +12,6 @@ import * as http$0 from "../../../net/http/models.js"; // @ts-ignore: Unused imports import * as time$0 from "../../../time/models.js"; -/** - * CancelFunc 取消订阅函数 - * 调用此函数可以取消对配置的监听 - */ -export type CancelFunc = any; - /** * HttpRequest HTTP请求结构 */ @@ -251,11 +245,6 @@ export class OSInfo { } } -/** - * ObserverCallback 观察者回调函数 - */ -export type ObserverCallback = any; - /** * SelfUpdateResult 自我更新结果 */ diff --git a/frontend/bindings/voidraft/internal/services/windowservice.ts b/frontend/bindings/voidraft/internal/services/windowservice.ts index f4d6f55..8e1781c 100644 --- a/frontend/bindings/voidraft/internal/services/windowservice.ts +++ b/frontend/bindings/voidraft/internal/services/windowservice.ts @@ -14,18 +14,6 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime"; // @ts-ignore: Unused imports import * as application$0 from "../../../github.com/wailsapp/wails/v3/pkg/application/models.js"; -/** - * GetOpenWindows 获取所有打开的文档窗口 - */ -export function GetOpenWindows(): Promise & { cancel(): void } { - let $resultPromise = $Call.ByID(1464997251) as any; - let $typingPromise = $resultPromise.then(($result: any) => { - return $$createType0($result); - }) as any; - $typingPromise.cancel = $resultPromise.cancel.bind($resultPromise); - return $typingPromise; -} - /** * IsDocumentWindowOpen 检查指定文档的窗口是否已打开 */ @@ -57,6 +45,3 @@ export function ServiceStartup(options: application$0.ServiceOptions): Promise=6.0.0" @@ -1433,7 +1425,7 @@ "version": "0.3.31", "resolved": "https://registry.npmmirror.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -1444,8 +1436,7 @@ "version": "1.3.0", "resolved": "https://registry.npmmirror.com/@lezer/common/-/common-1.3.0.tgz", "integrity": "sha512-L9X8uHCYU310o99L3/MpJKYxPzXPOS7S0NmBaM7UO/x2Kb2WbmMLSkfvdr1KxRIFYOpbY0Jhn7CfLSUDzL8arQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@lezer/cpp": { "version": "1.1.3", @@ -1499,7 +1490,6 @@ "resolved": "https://registry.npmmirror.com/@lezer/highlight/-/highlight-1.2.3.tgz", "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", "license": "MIT", - "peer": true, "dependencies": { "@lezer/common": "^1.3.0" } @@ -1531,7 +1521,6 @@ "resolved": "https://registry.npmmirror.com/@lezer/javascript/-/javascript-1.5.1.tgz", "integrity": "sha512-ATOImjeVJuvgm3JQ/bpo2Tmv55HSScE2MTPnKRMRIPx2cLhHGyX2VnqpHhtIV1tVzIjZDbcWQm+NCTF40ggZVw==", "license": "MIT", - "peer": true, "dependencies": { "@lezer/common": "^1.2.0", "@lezer/highlight": "^1.1.3", @@ -1564,7 +1553,6 @@ "resolved": "https://registry.npmmirror.com/@lezer/lr/-/lr-1.4.4.tgz", "integrity": "sha512-LHL17Mq0OcFXm1pGQssuGTQFPPdxARjKM8f7GA5+sGtHi0K3R84YaSbmche0+RKWHnCsx9asEe5OWOI4FHfe4A==", "license": "MIT", - "peer": true, "dependencies": { "@lezer/common": "^1.0.0" } @@ -2773,7 +2761,7 @@ "version": "1.0.8", "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/@types/geojson": { @@ -2846,7 +2834,6 @@ "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2925,7 +2912,6 @@ "integrity": "sha512-jCzKdm/QK0Kg4V4IK/oMlRZlY+QOcdjv89U2NgKHZk1CYTj82/RVSx1mV/0gqCVMJ/DA+Zf/S4NBWNF8GQ+eqQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.48.0", "@typescript-eslint/types": "8.48.0", @@ -3619,7 +3605,6 @@ "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4008,35 +3993,6 @@ "dev": true, "license": "MIT" }, - "node_modules/c12": { - "version": "3.0.4", - "resolved": "https://registry.npmmirror.com/c12/-/c12-3.0.4.tgz", - "integrity": "sha512-t5FaZTYbbCtvxuZq9xxIruYydrAGsJ+8UdP0pZzMiK2xl/gNiSOy0OxhLzHUEEb0m1QXYqfzfvyIFEmz/g9lqg==", - "license": "MIT", - "optional": true, - "dependencies": { - "chokidar": "^4.0.3", - "confbox": "^0.2.2", - "defu": "^6.1.4", - "dotenv": "^16.5.0", - "exsolve": "^1.0.5", - "giget": "^2.0.0", - "jiti": "^2.4.2", - "ohash": "^2.0.11", - "pathe": "^2.0.3", - "perfect-debounce": "^1.0.0", - "pkg-types": "^2.1.0", - "rc9": "^2.1.2" - }, - "peerDependencies": { - "magicast": "^0.3.5" - }, - "peerDependenciesMeta": { - "magicast": { - "optional": true - } - } - }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.8.tgz", @@ -4162,7 +4118,6 @@ "resolved": "https://registry.npmmirror.com/chevrotain/-/chevrotain-11.0.3.tgz", "integrity": "sha512-ci2iJH6LeIkvP9eJW6gpueU8cnZhv85ELY8w8WiFtNjMHA5ad6pQLaJo9mEly/9qUyCpvqX8/POVUTf18/HFdw==", "license": "Apache-2.0", - "peer": true, "dependencies": { "@chevrotain/cst-dts-gen": "11.0.3", "@chevrotain/gast": "11.0.3", @@ -4213,16 +4168,6 @@ "node": ">= 0.10" } }, - "node_modules/citty": { - "version": "0.1.6", - "resolved": "https://registry.npmmirror.com/citty/-/citty-0.1.6.tgz", - "integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==", - "license": "MIT", - "optional": true, - "dependencies": { - "consola": "^3.2.3" - } - }, "node_modules/codemirror": { "version": "6.0.2", "resolved": "https://registry.npmmirror.com/codemirror/-/codemirror-6.0.2.tgz", @@ -4324,16 +4269,6 @@ "integrity": "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==", "license": "MIT" }, - "node_modules/consola": { - "version": "3.4.2", - "resolved": "https://registry.npmmirror.com/consola/-/consola-3.4.2.tgz", - "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", - "license": "MIT", - "optional": true, - "engines": { - "node": "^14.18.0 || >=16.10.0" - } - }, "node_modules/console-browserify": { "version": "1.2.0", "resolved": "https://registry.npmmirror.com/console-browserify/-/console-browserify-1.2.0.tgz", @@ -4522,7 +4457,6 @@ "resolved": "https://registry.npmmirror.com/cytoscape/-/cytoscape-3.33.1.tgz", "integrity": "sha512-iJc4TwyANnOGR1OmWhsS9ayRS3s+XQ185FmuHObThD+5AeJCakAAbWv8KimMTt08xCCLNgneQwFp+JRJOr9qGQ==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10" } @@ -4932,7 +4866,6 @@ "resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.0.tgz", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "license": "ISC", - "peer": true, "engines": { "node": ">=12" } @@ -5129,13 +5062,6 @@ "minimalistic-assert": "^1.0.0" } }, - "node_modules/destr": { - "version": "2.0.5", - "resolved": "https://registry.npmmirror.com/destr/-/destr-2.0.5.tgz", - "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", - "license": "MIT", - "optional": true - }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-1.0.3.tgz", @@ -5204,19 +5130,6 @@ "@types/trusted-types": "^2.0.7" } }, - "node_modules/dotenv": { - "version": "16.5.0", - "resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.5.0.tgz", - "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", - "license": "BSD-2-Clause", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -5267,13 +5180,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/errx": { - "version": "0.1.0", - "resolved": "https://registry.npmmirror.com/errx/-/errx-0.1.0.tgz", - "integrity": "sha512-fZmsRiDNv07K6s2KkKFTiD2aIvECa7++PKyD5NC32tpRw46qZA3sOz+aM+/V9V0GDHxVTKLziveV4JhzBHDp9Q==", - "license": "MIT", - "optional": true - }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz", @@ -5374,7 +5280,6 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5689,7 +5594,6 @@ "integrity": "sha512-v/Z8bvMCajtx4mEXmOo7QEsIzlIOqRXTIwgUfsFOF9gEsespdbD0AkPIka1bSXZ8Y8oZ+2IVDQZePkTfEHZl7Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "tabbable": "^6.3.0" } @@ -5774,24 +5678,6 @@ "node": ">= 0.4" } }, - "node_modules/giget": { - "version": "2.0.0", - "resolved": "https://registry.npmmirror.com/giget/-/giget-2.0.0.tgz", - "integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==", - "license": "MIT", - "optional": true, - "dependencies": { - "citty": "^0.1.6", - "consola": "^3.4.0", - "defu": "^6.1.4", - "node-fetch-native": "^1.6.6", - "nypm": "^0.6.0", - "pathe": "^2.0.3" - }, - "bin": { - "giget": "dist/cli.mjs" - } - }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-6.0.2.tgz", @@ -6351,19 +6237,14 @@ "version": "2.4.2", "resolved": "https://registry.npmmirror.com/jiti/-/jiti-2.4.2.tgz", "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "dev": true, "license": "MIT", "optional": true, + "peer": true, "bin": { "jiti": "lib/jiti-cli.mjs" } }, - "node_modules/js-tokens": { - "version": "9.0.1", - "resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-9.0.1.tgz", - "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", - "license": "MIT", - "optional": true - }, "node_modules/js-yaml": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", @@ -6429,23 +6310,6 @@ "resolved": "https://registry.npmmirror.com/khroma/-/khroma-2.1.0.tgz", "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==" }, - "node_modules/klona": { - "version": "2.0.6", - "resolved": "https://registry.npmmirror.com/klona/-/klona-2.0.6.tgz", - "integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/knitwork": { - "version": "1.2.0", - "resolved": "https://registry.npmmirror.com/knitwork/-/knitwork-1.2.0.tgz", - "integrity": "sha512-xYSH7AvuQ6nXkq42x0v5S8/Iry+cfulBz/DJQzhIyESdLD7425jXsPy4vn5cCXU+HhRN2kVw51Vd1K6/By4BQg==", - "license": "MIT", - "optional": true - }, "node_modules/kolorist": { "version": "1.8.0", "resolved": "https://registry.npmmirror.com/kolorist/-/kolorist-1.8.0.tgz", @@ -6916,13 +6780,6 @@ "license": "MIT", "optional": true }, - "node_modules/node-fetch-native": { - "version": "1.6.6", - "resolved": "https://registry.npmmirror.com/node-fetch-native/-/node-fetch-native-1.6.6.tgz", - "integrity": "sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==", - "license": "MIT", - "optional": true - }, "node_modules/node-stdlib-browser": { "version": "1.3.1", "resolved": "https://registry.npmmirror.com/node-stdlib-browser/-/node-stdlib-browser-1.3.1.tgz", @@ -6982,26 +6839,6 @@ "url": "https://github.com/fb55/nth-check?sponsor=1" } }, - "node_modules/nypm": { - "version": "0.6.0", - "resolved": "https://registry.npmmirror.com/nypm/-/nypm-0.6.0.tgz", - "integrity": "sha512-mn8wBFV9G9+UFHIrq+pZ2r2zL4aPau/by3kJb3cM7+5tQHMt6HGQB8FDIeKFYp8o0D2pnH6nVsO88N4AmUxIWg==", - "license": "MIT", - "optional": true, - "dependencies": { - "citty": "^0.1.6", - "consola": "^3.4.0", - "pathe": "^2.0.3", - "pkg-types": "^2.0.0", - "tinyexec": "^0.3.2" - }, - "bin": { - "nypm": "dist/cli.mjs" - }, - "engines": { - "node": "^14.16.0 || >=16.10.0" - } - }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.4.tgz", @@ -7074,13 +6911,6 @@ ], "license": "MIT" }, - "node_modules/ohash": { - "version": "2.0.11", - "resolved": "https://registry.npmmirror.com/ohash/-/ohash-2.0.11.tgz", - "integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==", - "license": "MIT", - "optional": true - }, "node_modules/oniguruma-parser": { "version": "0.12.1", "resolved": "https://registry.npmmirror.com/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz", @@ -7335,7 +7165,6 @@ "resolved": "https://registry.npmmirror.com/pinia/-/pinia-3.0.4.tgz", "integrity": "sha512-l7pqLUFTI/+ESXn6k3nu30ZIzW5E2WZF/LaHJEpoq6ElcLD+wduZoB2kBN19du6K/4FDpPMazY2wJr+IndBtQw==", "license": "MIT", - "peer": true, "dependencies": { "@vue/devtools-api": "^7.7.7" }, @@ -7484,7 +7313,6 @@ "resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.7.2.tgz", "integrity": "sha512-n3HV2J6QhItCXndGa3oMWvWFAgN1ibnS7R9mt6iokScBOC0Ul9/iZORmU2IWUMcyAQaMPjTlY3uT34TqocUxMA==", "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -7617,17 +7445,6 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/rc9": { - "version": "2.1.2", - "resolved": "https://registry.npmmirror.com/rc9/-/rc9-2.1.2.tgz", - "integrity": "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==", - "license": "MIT", - "optional": true, - "dependencies": { - "defu": "^6.1.4", - "destr": "^2.0.3" - } - }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-3.6.2.tgz", @@ -7749,7 +7566,6 @@ "integrity": "sha512-WMmLFI+Boh6xbop+OAGo9cQ3OgX9MIg7xOQjn+pTCwOkk+FNDAeAemXkJ3HzDJrVXleLOFVa1ipuc1AmEx1Dwg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -7852,7 +7668,6 @@ "resolved": "https://registry.npmmirror.com/sass/-/sass-1.94.2.tgz", "integrity": "sha512-N+7WK20/wOr7CzA2snJcUSSNTCzeCGUTFY3OgeQP3mZ1aj9NMQ0mSTXwlrnd89j33zzQJGqIN52GIOmYrfq46A==", "license": "MIT", - "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -7868,18 +7683,11 @@ "@parcel/watcher": "^2.4.1" } }, - "node_modules/scule": { - "version": "1.3.0", - "resolved": "https://registry.npmmirror.com/scule/-/scule-1.3.0.tgz", - "integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==", - "license": "MIT", - "optional": true - }, "node_modules/semver": { "version": "7.7.2", "resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.2.tgz", "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", - "devOptional": true, + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -8121,7 +7929,7 @@ "version": "3.10.0", "resolved": "https://registry.npmmirror.com/std-env/-/std-env-3.10.0.tgz", "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/stream-browserify": { @@ -8186,19 +7994,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/strip-literal": { - "version": "3.0.0", - "resolved": "https://registry.npmmirror.com/strip-literal/-/strip-literal-3.0.0.tgz", - "integrity": "sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==", - "license": "MIT", - "optional": true, - "dependencies": { - "js-tokens": "^9.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/style-mod": { "version": "4.1.2", "resolved": "https://registry.npmmirror.com/style-mod/-/style-mod-4.1.2.tgz", @@ -8280,14 +8075,14 @@ "version": "0.3.2", "resolved": "https://registry.npmmirror.com/tinyexec/-/tinyexec-0.3.2.tgz", "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.15.tgz", "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", @@ -8304,7 +8099,7 @@ "version": "6.5.0", "resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.5.0.tgz", "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=12.0.0" @@ -8322,9 +8117,8 @@ "version": "4.0.3", "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "devOptional": true, + "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -8444,7 +8238,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8483,29 +8276,6 @@ "integrity": "sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==", "license": "MIT" }, - "node_modules/unctx": { - "version": "2.4.1", - "resolved": "https://registry.npmmirror.com/unctx/-/unctx-2.4.1.tgz", - "integrity": "sha512-AbaYw0Nm4mK4qjhns67C+kgxR2YWiwlDBPzxrN8h8C6VtAdCgditAY5Dezu3IJy4XVqAnbrXt9oQJvsn3fyozg==", - "license": "MIT", - "optional": true, - "dependencies": { - "acorn": "^8.14.0", - "estree-walker": "^3.0.3", - "magic-string": "^0.30.17", - "unplugin": "^2.1.0" - } - }, - "node_modules/unctx/node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "license": "MIT", - "optional": true, - "dependencies": { - "@types/estree": "^1.0.0" - } - }, "node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.16.0.tgz", @@ -8513,68 +8283,6 @@ "dev": true, "license": "MIT" }, - "node_modules/unimport": { - "version": "5.0.1", - "resolved": "https://registry.npmmirror.com/unimport/-/unimport-5.0.1.tgz", - "integrity": "sha512-1YWzPj6wYhtwHE+9LxRlyqP4DiRrhGfJxdtH475im8ktyZXO3jHj/3PZ97zDdvkYoovFdi0K4SKl3a7l92v3sQ==", - "license": "MIT", - "optional": true, - "dependencies": { - "acorn": "^8.14.1", - "escape-string-regexp": "^5.0.0", - "estree-walker": "^3.0.3", - "local-pkg": "^1.1.1", - "magic-string": "^0.30.17", - "mlly": "^1.7.4", - "pathe": "^2.0.3", - "picomatch": "^4.0.2", - "pkg-types": "^2.1.0", - "scule": "^1.3.0", - "strip-literal": "^3.0.0", - "tinyglobby": "^0.2.13", - "unplugin": "^2.3.2", - "unplugin-utils": "^0.2.4" - }, - "engines": { - "node": ">=18.12.0" - } - }, - "node_modules/unimport/node_modules/escape-string-regexp": { - "version": "5.0.0", - "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", - "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/unimport/node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "license": "MIT", - "optional": true, - "dependencies": { - "@types/estree": "^1.0.0" - } - }, - "node_modules/unimport/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/unist-util-is": { "version": "6.0.1", "resolved": "https://registry.npmmirror.com/unist-util-is/-/unist-util-is-6.0.1.tgz", @@ -8652,7 +8360,7 @@ "version": "2.3.10", "resolved": "https://registry.npmmirror.com/unplugin/-/unplugin-2.3.10.tgz", "integrity": "sha512-6NCPkv1ClwH+/BGE9QeoTIl09nuiAt0gS28nn1PvYXsGKRwM2TCbFA2QiilmehPDTXIe684k4rZI1yl3A1PCUw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/remapping": "^2.3.5", @@ -8664,36 +8372,6 @@ "node": ">=18.12.0" } }, - "node_modules/unplugin-utils": { - "version": "0.2.4", - "resolved": "https://registry.npmmirror.com/unplugin-utils/-/unplugin-utils-0.2.4.tgz", - "integrity": "sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==", - "license": "MIT", - "optional": true, - "dependencies": { - "pathe": "^2.0.2", - "picomatch": "^4.0.2" - }, - "engines": { - "node": ">=18.12.0" - }, - "funding": { - "url": "https://github.com/sponsors/sxzz" - } - }, - "node_modules/unplugin-utils/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/unplugin-vue-components": { "version": "30.0.0", "resolved": "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-30.0.0.tgz", @@ -8764,7 +8442,7 @@ "version": "4.0.3", "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -8773,23 +8451,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/untyped": { - "version": "2.0.0", - "resolved": "https://registry.npmmirror.com/untyped/-/untyped-2.0.0.tgz", - "integrity": "sha512-nwNCjxJTjNuLCgFr42fEak5OcLuB3ecca+9ksPFNvtfYSLpjf+iJqSIaSnIile6ZPbKYxI5k2AfXqeopGudK/g==", - "license": "MIT", - "optional": true, - "dependencies": { - "citty": "^0.1.6", - "defu": "^6.1.4", - "jiti": "^2.4.2", - "knitwork": "^1.2.0", - "scule": "^1.3.0" - }, - "bin": { - "untyped": "dist/cli.mjs" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz", @@ -8891,7 +8552,6 @@ "integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -9002,7 +8662,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -9252,7 +8911,6 @@ "resolved": "https://registry.npmmirror.com/vue/-/vue-3.5.25.tgz", "integrity": "sha512-YLVdgv2K13WJ6n+kD5owehKtEXwdwXuj2TTyJMsO7pSeKw2bfRNZGjhB7YzrpbMYj5b5QsUebHpOqR3R3ziy/g==", "license": "MIT", - "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.25", "@vue/compiler-sfc": "3.5.25", @@ -9275,7 +8933,6 @@ "integrity": "sha512-CydUvFOQKD928UzZhTp4pr2vWz1L+H99t7Pkln2QSPdvmURT0MoC4wUccfCnuEaihNsu9aYYyk+bep8rlfkUXw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "^4.4.0", "eslint-scope": "^8.2.0", @@ -9381,7 +9038,7 @@ "version": "0.6.2", "resolved": "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz", "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/whatwg-mimetype": { diff --git a/frontend/src/stores/configStore.ts b/frontend/src/stores/configStore.ts index ca309e5..253ba5a 100644 --- a/frontend/src/stores/configStore.ts +++ b/frontend/src/stores/configStore.ts @@ -248,7 +248,7 @@ export const useConfigStore = defineStore('config', () => { setFontWeight: (value: string) => updateConfig('fontWeight', value), // 路径操作 - setDataPath: (value: string) => updateConfig('dataPath', value), + setDataPath: (value: string) => updateConfigLocal('dataPath', value), // 保存配置相关方法 setAutoSaveDelay: (value: number) => updateConfig('autoSaveDelay', value), diff --git a/frontend/src/views/settings/pages/GeneralPage.vue b/frontend/src/views/settings/pages/GeneralPage.vue index 3a16342..3a470a2 100644 --- a/frontend/src/views/settings/pages/GeneralPage.vue +++ b/frontend/src/views/settings/pages/GeneralPage.vue @@ -2,16 +2,28 @@ import {useConfigStore} from '@/stores/configStore'; import {useTabStore} from '@/stores/tabStore'; import {useI18n} from 'vue-i18n'; -import {computed, ref} from 'vue'; +import {computed, ref, onMounted} from 'vue'; import SettingSection from '../components/SettingSection.vue'; import SettingItem from '../components/SettingItem.vue'; import ToggleSwitch from '../components/ToggleSwitch.vue'; -import {DialogService, MigrationService} from '@/../bindings/voidraft/internal/services'; +import {DialogService, HotkeyService, MigrationService} from '@/../bindings/voidraft/internal/services'; import {useSystemStore} from "@/stores/systemStore"; import {useConfirm, usePolling} from '@/composables'; const {t} = useI18n(); -const configStore = useConfigStore(); +const { + config: {general}, + resetConfig, + setAlwaysOnTop, + setDataPath, + setEnableGlobalHotkey, + setEnableLoadingAnimation, + setEnableSystemTray, + setEnableTabs, + setEnableWindowSnap, + setGlobalHotkey, + setStartAtLogin +} = useConfigStore(); const systemStore = useSystemStore(); const tabStore = useTabStore(); @@ -60,57 +72,57 @@ const hideAll = () => { const {isConfirming: isResetConfirming, requestConfirm: requestResetConfirm} = useConfirm({ timeout: 3000, onConfirm: async () => { - await configStore.resetConfig(); + await resetConfig(); } }); -// 可选键列表 -const keyOptions = [ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12' -]; +// 可选键列表 - 从后端获取系统支持的快捷键 +const keyOptions = ref([]); + +// 初始化时从后端获取支持的键列表 +onMounted(async () => { + keyOptions.value = await HotkeyService.GetSupportedKeys(); +}); // 计算属性 - 启用全局热键 const enableGlobalHotkey = computed({ - get: () => configStore.config.general.enableGlobalHotkey, - set: (value: boolean) => configStore.setEnableGlobalHotkey(value) + get: () => general.enableGlobalHotkey, + set: (value: boolean) => setEnableGlobalHotkey(value) }); // 计算属性 - 窗口始终置顶 const alwaysOnTop = computed({ - get: () => configStore.config.general.alwaysOnTop, + get: () => general.alwaysOnTop, set: async (value: boolean) => { // 先更新配置 - await configStore.setAlwaysOnTop(value); + await setAlwaysOnTop(value); await systemStore.setWindowOnTop(value); } }); // 计算属性 - 启用系统托盘 const enableSystemTray = computed({ - get: () => configStore.config.general.enableSystemTray, - set: (value: boolean) => configStore.setEnableSystemTray(value) + get: () => general.enableSystemTray, + set: (value: boolean) => setEnableSystemTray(value) }); // 计算属性 - 启用窗口吸附 const enableWindowSnap = computed({ - get: () => configStore.config.general.enableWindowSnap, - set: (value: boolean) => configStore.setEnableWindowSnap(value) + get: () => general.enableWindowSnap, + set: (value: boolean) => setEnableWindowSnap(value) }); // 计算属性 - 启用加载动画 const enableLoadingAnimation = computed({ - get: () => configStore.config.general.enableLoadingAnimation, - set: (value: boolean) => configStore.setEnableLoadingAnimation(value) + get: () => general.enableLoadingAnimation, + set: (value: boolean) => setEnableLoadingAnimation(value) }); // 计算属性 - 启用标签页 const enableTabs = computed({ - get: () => configStore.config.general.enableTabs, + get: () => general.enableTabs, set: async (value: boolean) => { - await configStore.setEnableTabs(value); + await setEnableTabs(value); if (value) { // 开启tabs功能时,初始化当前文档到标签页 tabStore.initializeTab(); @@ -123,33 +135,33 @@ const enableTabs = computed({ // 计算属性 - 开机启动 const startAtLogin = computed({ - get: () => configStore.config.general.startAtLogin, - set: (value: boolean) => configStore.setStartAtLogin(value) + get: () => general.startAtLogin, + set: (value: boolean) => setStartAtLogin(value) }); // 修饰键配置 - 只读计算属性 const modifierKeys = computed(() => ({ - ctrl: configStore.config.general.globalHotkey.ctrl, - shift: configStore.config.general.globalHotkey.shift, - alt: configStore.config.general.globalHotkey.alt, - win: configStore.config.general.globalHotkey.win + ctrl: general.globalHotkey.ctrl, + shift: general.globalHotkey.shift, + alt: general.globalHotkey.alt, + win: general.globalHotkey.win })); // 主键配置 -const selectedKey = computed(() => configStore.config.general.globalHotkey.key); +const selectedKey = computed(() => general.globalHotkey.key); // 切换修饰键 const toggleModifier = (key: 'ctrl' | 'shift' | 'alt' | 'win') => { - const currentHotkey = configStore.config.general.globalHotkey; + const currentHotkey = general.globalHotkey; const newHotkey = {...currentHotkey, [key]: !currentHotkey[key]}; - configStore.setGlobalHotkey(newHotkey); + setGlobalHotkey(newHotkey); }; // 更新选择的键 const updateSelectedKey = (event: Event) => { const select = event.target as HTMLSelectElement; - const newHotkey = {...configStore.config.general.globalHotkey, key: select.value}; - configStore.setGlobalHotkey(newHotkey); + const newHotkey = {...general.globalHotkey, key: select.value}; + setGlobalHotkey(newHotkey); }; @@ -157,7 +169,7 @@ const updateSelectedKey = (event: Event) => { const hotkeyPreview = computed(() => { if (!enableGlobalHotkey.value) return ''; - const {ctrl, shift, alt, win, key} = configStore.config.general.globalHotkey; + const {ctrl, shift, alt, win, key} = general.globalHotkey; const modifiers = [ ctrl && 'Ctrl', shift && 'Shift', @@ -170,7 +182,7 @@ const hotkeyPreview = computed(() => { }); // 数据路径配置 -const currentDataPath = computed(() => configStore.config.general.dataPath); +const currentDataPath = computed(() => general.dataPath); // 选择数据存储目录 const selectDataDirectory = async () => { @@ -189,7 +201,7 @@ const selectDataDirectory = async () => { try { await MigrationService.MigrateDirectory(oldPath, newPath); - await configStore.setDataPath(newPath); + await setDataPath(newPath); } catch (e) { stop(); // 设置手动捕获的错误(当轮询还没获取到错误时) @@ -314,10 +326,6 @@ const selectDataDirectory = async () => {