diff --git a/frontend/bindings/voidraft/internal/models/models.ts b/frontend/bindings/voidraft/internal/models/models.ts new file mode 100644 index 0000000..3f75f47 --- /dev/null +++ b/frontend/bindings/voidraft/internal/models/models.ts @@ -0,0 +1,630 @@ +// 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"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import * as time$0 from "../../../time/models.js"; + +/** + * AppConfig 应用配置 - 按照前端设置页面分类组织 + */ +export class AppConfig { + /** + * 通用设置 + */ + "general": GeneralConfig; + + /** + * 编辑设置 + */ + "editing": EditingConfig; + + /** + * 外观设置 + */ + "appearance": AppearanceConfig; + + /** + * 快捷键设置 + */ + "keyBindings": KeyBindingsConfig; + + /** + * 更新设置 + */ + "updates": UpdatesConfig; + + /** + * 配置元数据 + */ + "metadata": ConfigMetadata; + + /** Creates a new AppConfig instance. */ + constructor($$source: Partial = {}) { + if (!("general" in $$source)) { + this["general"] = (new GeneralConfig()); + } + if (!("editing" in $$source)) { + this["editing"] = (new EditingConfig()); + } + if (!("appearance" in $$source)) { + this["appearance"] = (new AppearanceConfig()); + } + if (!("keyBindings" in $$source)) { + this["keyBindings"] = (new KeyBindingsConfig()); + } + if (!("updates" in $$source)) { + this["updates"] = (new UpdatesConfig()); + } + if (!("metadata" in $$source)) { + this["metadata"] = (new ConfigMetadata()); + } + + Object.assign(this, $$source); + } + + /** + * Creates a new AppConfig instance from a string or object. + */ + static createFrom($$source: any = {}): AppConfig { + const $$createField0_0 = $$createType0; + const $$createField1_0 = $$createType1; + const $$createField2_0 = $$createType2; + const $$createField3_0 = $$createType3; + const $$createField4_0 = $$createType4; + const $$createField5_0 = $$createType5; + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + if ("general" in $$parsedSource) { + $$parsedSource["general"] = $$createField0_0($$parsedSource["general"]); + } + if ("editing" in $$parsedSource) { + $$parsedSource["editing"] = $$createField1_0($$parsedSource["editing"]); + } + if ("appearance" in $$parsedSource) { + $$parsedSource["appearance"] = $$createField2_0($$parsedSource["appearance"]); + } + if ("keyBindings" in $$parsedSource) { + $$parsedSource["keyBindings"] = $$createField3_0($$parsedSource["keyBindings"]); + } + if ("updates" in $$parsedSource) { + $$parsedSource["updates"] = $$createField4_0($$parsedSource["updates"]); + } + if ("metadata" in $$parsedSource) { + $$parsedSource["metadata"] = $$createField5_0($$parsedSource["metadata"]); + } + return new AppConfig($$parsedSource as Partial); + } +} + +/** + * AppearanceConfig 外观设置配置 + */ +export class AppearanceConfig { + /** + * 界面语言 + */ + "language": LanguageType; + + /** + * 编辑器主题 + */ + "theme": ThemeType; + + /** Creates a new AppearanceConfig instance. */ + constructor($$source: Partial = {}) { + if (!("language" in $$source)) { + this["language"] = ("" as LanguageType); + } + if (!("theme" in $$source)) { + this["theme"] = ("" as ThemeType); + } + + Object.assign(this, $$source); + } + + /** + * Creates a new AppearanceConfig instance from a string or object. + */ + static createFrom($$source: any = {}): AppearanceConfig { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new AppearanceConfig($$parsedSource as Partial); + } +} + +/** + * ConfigMetadata 配置元数据 + */ +export class ConfigMetadata { + /** + * 配置版本 + */ + "version": string; + + /** + * 最后更新时间 + */ + "lastUpdated": time$0.Time; + + /** Creates a new ConfigMetadata instance. */ + constructor($$source: Partial = {}) { + if (!("version" in $$source)) { + this["version"] = ""; + } + if (!("lastUpdated" in $$source)) { + this["lastUpdated"] = null; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new ConfigMetadata instance from a string or object. + */ + static createFrom($$source: any = {}): ConfigMetadata { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new ConfigMetadata($$parsedSource as Partial); + } +} + +/** + * Document 表示一个文档 + */ +export class Document { + /** + * 元数据 + */ + "meta": DocumentMeta; + + /** + * 文档内容 + */ + "content": string; + + /** Creates a new Document instance. */ + constructor($$source: Partial = {}) { + if (!("meta" in $$source)) { + this["meta"] = (new DocumentMeta()); + } + if (!("content" in $$source)) { + this["content"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new Document instance from a string or object. + */ + static createFrom($$source: any = {}): Document { + const $$createField0_0 = $$createType6; + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + if ("meta" in $$parsedSource) { + $$parsedSource["meta"] = $$createField0_0($$parsedSource["meta"]); + } + return new Document($$parsedSource as Partial); + } +} + +/** + * DocumentMeta 文档元数据 + */ +export class DocumentMeta { + /** + * 文档唯一标识 + */ + "id": string; + + /** + * 文档标题 + */ + "title": string; + + /** + * 最后更新时间 + */ + "lastUpdated": time$0.Time; + + /** + * 创建时间 + */ + "createdAt": time$0.Time; + + /** Creates a new DocumentMeta instance. */ + constructor($$source: Partial = {}) { + if (!("id" in $$source)) { + this["id"] = ""; + } + if (!("title" in $$source)) { + this["title"] = ""; + } + if (!("lastUpdated" in $$source)) { + this["lastUpdated"] = null; + } + if (!("createdAt" in $$source)) { + this["createdAt"] = null; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new DocumentMeta instance from a string or object. + */ + static createFrom($$source: any = {}): DocumentMeta { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new DocumentMeta($$parsedSource as Partial); + } +} + +/** + * EditingConfig 编辑设置配置 + */ +export class EditingConfig { + /** + * 字体设置 + * 字体大小 + */ + "fontSize": number; + + /** + * 字体族 + */ + "fontFamily": string; + + /** + * 字体粗细 + */ + "fontWeight": string; + + /** + * 行高 + */ + "lineHeight": number; + + /** + * Tab设置 + * 是否启用Tab缩进 + */ + "enableTabIndent": boolean; + + /** + * Tab大小 + */ + "tabSize": number; + + /** + * Tab类型(空格或Tab) + */ + "tabType": TabType; + + /** + * 保存选项 + * 自动保存延迟(毫秒) + */ + "autoSaveDelay": number; + + /** Creates a new EditingConfig instance. */ + constructor($$source: Partial = {}) { + if (!("fontSize" in $$source)) { + this["fontSize"] = 0; + } + if (!("fontFamily" in $$source)) { + this["fontFamily"] = ""; + } + if (!("fontWeight" in $$source)) { + this["fontWeight"] = ""; + } + if (!("lineHeight" in $$source)) { + this["lineHeight"] = 0; + } + if (!("enableTabIndent" in $$source)) { + this["enableTabIndent"] = false; + } + if (!("tabSize" in $$source)) { + this["tabSize"] = 0; + } + if (!("tabType" in $$source)) { + this["tabType"] = ("" as TabType); + } + if (!("autoSaveDelay" in $$source)) { + this["autoSaveDelay"] = 0; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new EditingConfig instance from a string or object. + */ + static createFrom($$source: any = {}): EditingConfig { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new EditingConfig($$parsedSource as Partial); + } +} + +/** + * GeneralConfig 通用设置配置 + */ +export class GeneralConfig { + /** + * 窗口是否置顶 + */ + "alwaysOnTop": boolean; + + /** + * 数据存储路径 + */ + "dataPath": string; + + /** + * 是否启用系统托盘 + */ + "enableSystemTray": boolean; + + /** + * 全局热键设置 + * 是否启用全局热键 + */ + "enableGlobalHotkey": boolean; + + /** + * 全局热键组合 + */ + "globalHotkey": HotkeyCombo; + + /** Creates a new GeneralConfig instance. */ + constructor($$source: Partial = {}) { + if (!("alwaysOnTop" in $$source)) { + this["alwaysOnTop"] = false; + } + if (!("dataPath" in $$source)) { + this["dataPath"] = ""; + } + if (!("enableSystemTray" in $$source)) { + this["enableSystemTray"] = false; + } + if (!("enableGlobalHotkey" in $$source)) { + this["enableGlobalHotkey"] = false; + } + if (!("globalHotkey" in $$source)) { + this["globalHotkey"] = (new HotkeyCombo()); + } + + Object.assign(this, $$source); + } + + /** + * Creates a new GeneralConfig instance from a string or object. + */ + static createFrom($$source: any = {}): GeneralConfig { + const $$createField4_0 = $$createType7; + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + if ("globalHotkey" in $$parsedSource) { + $$parsedSource["globalHotkey"] = $$createField4_0($$parsedSource["globalHotkey"]); + } + return new GeneralConfig($$parsedSource as Partial); + } +} + +/** + * HotkeyCombo 热键组合定义 + */ +export class HotkeyCombo { + /** + * Ctrl键 + */ + "ctrl": boolean; + + /** + * Shift键 + */ + "shift": boolean; + + /** + * Alt键 + */ + "alt": boolean; + + /** + * Win键 + */ + "win": boolean; + + /** + * 主键(如 'X', 'F1' 等) + */ + "key": string; + + /** Creates a new HotkeyCombo instance. */ + constructor($$source: Partial = {}) { + if (!("ctrl" in $$source)) { + this["ctrl"] = false; + } + if (!("shift" in $$source)) { + this["shift"] = false; + } + if (!("alt" in $$source)) { + this["alt"] = false; + } + if (!("win" in $$source)) { + this["win"] = false; + } + if (!("key" in $$source)) { + this["key"] = ""; + } + + Object.assign(this, $$source); + } + + /** + * Creates a new HotkeyCombo instance from a string or object. + */ + static createFrom($$source: any = {}): HotkeyCombo { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new HotkeyCombo($$parsedSource as Partial); + } +} + +/** + * KeyBindingsConfig 快捷键设置配置 + */ +export class KeyBindingsConfig { + + /** Creates a new KeyBindingsConfig instance. */ + constructor($$source: Partial = {}) { + + Object.assign(this, $$source); + } + + /** + * Creates a new KeyBindingsConfig instance from a string or object. + */ + static createFrom($$source: any = {}): KeyBindingsConfig { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new KeyBindingsConfig($$parsedSource as Partial); + } +} + +/** + * LanguageType 语言类型定义 + */ +export enum LanguageType { + /** + * The Go zero value for the underlying type of the enum. + */ + $zero = "", + + /** + * LangZhCN 中文简体 + */ + LangZhCN = "zh-CN", + + /** + * LangEnUS 英文-美国 + */ + LangEnUS = "en-US", +}; + +/** + * TabType 定义了制表符类型 + */ +export enum TabType { + /** + * The Go zero value for the underlying type of the enum. + */ + $zero = "", + + /** + * TabTypeSpaces 使用空格作为制表符 + */ + TabTypeSpaces = "spaces", + + /** + * TabTypeTab 使用Tab作为制表符 + */ + TabTypeTab = "tab", +}; + +/** + * ThemeType 主题类型定义 + */ +export enum ThemeType { + /** + * The Go zero value for the underlying type of the enum. + */ + $zero = "", + + /** + * ThemeDefaultDark 默认深色主题 + */ + ThemeDefaultDark = "default-dark", + + /** + * ThemeDracula Dracula主题 + */ + ThemeDracula = "dracula", + + /** + * ThemeAura Aura主题 + */ + ThemeAura = "aura", + + /** + * ThemeGithubDark GitHub深色主题 + */ + ThemeGithubDark = "github-dark", + + /** + * ThemeGithubLight GitHub浅色主题 + */ + ThemeGithubLight = "github-light", + + /** + * ThemeMaterialDark Material深色主题 + */ + ThemeMaterialDark = "material-dark", + + /** + * ThemeMaterialLight Material浅色主题 + */ + ThemeMaterialLight = "material-light", + + /** + * ThemeSolarizedDark Solarized深色主题 + */ + ThemeSolarizedDark = "solarized-dark", + + /** + * ThemeSolarizedLight Solarized浅色主题 + */ + ThemeSolarizedLight = "solarized-light", + + /** + * ThemeTokyoNight Tokyo Night主题 + */ + ThemeTokyoNight = "tokyo-night", + + /** + * ThemeTokyoNightStorm Tokyo Night Storm主题 + */ + ThemeTokyoNightStorm = "tokyo-night-storm", + + /** + * ThemeTokyoNightDay Tokyo Night Day主题 + */ + ThemeTokyoNightDay = "tokyo-night-day", +}; + +/** + * UpdatesConfig 更新设置配置 + */ +export class UpdatesConfig { + + /** Creates a new UpdatesConfig instance. */ + constructor($$source: Partial = {}) { + + Object.assign(this, $$source); + } + + /** + * Creates a new UpdatesConfig instance from a string or object. + */ + static createFrom($$source: any = {}): UpdatesConfig { + let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source; + return new UpdatesConfig($$parsedSource as Partial); + } +} + +// Private type creation functions +const $$createType0 = GeneralConfig.createFrom; +const $$createType1 = EditingConfig.createFrom; +const $$createType2 = AppearanceConfig.createFrom; +const $$createType3 = KeyBindingsConfig.createFrom; +const $$createType4 = UpdatesConfig.createFrom; +const $$createType5 = ConfigMetadata.createFrom; +const $$createType6 = DocumentMeta.createFrom; +const $$createType7 = HotkeyCombo.createFrom; diff --git a/frontend/bindings/voidraft/internal/services/index.ts b/frontend/bindings/voidraft/internal/services/index.ts index b7eb8df..ca32ba9 100644 --- a/frontend/bindings/voidraft/internal/services/index.ts +++ b/frontend/bindings/voidraft/internal/services/index.ts @@ -7,13 +7,15 @@ import * as DocumentService from "./documentservice.js"; import * as HotkeyService from "./hotkeyservice.js"; import * as MigrationService from "./migrationservice.js"; import * as SystemService from "./systemservice.js"; +import * as TrayService from "./trayservice.js"; export { ConfigService, DialogService, DocumentService, HotkeyService, MigrationService, - SystemService + SystemService, + TrayService }; export * from "./models.js"; diff --git a/frontend/bindings/voidraft/internal/services/trayservice.ts b/frontend/bindings/voidraft/internal/services/trayservice.ts new file mode 100644 index 0000000..9203612 --- /dev/null +++ b/frontend/bindings/voidraft/internal/services/trayservice.ts @@ -0,0 +1,63 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +/** + * TrayService 系统托盘服务 + * @module + */ + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import {Call as $Call, Create as $Create} from "@wailsio/runtime"; + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore: Unused imports +import * as application$0 from "../../../github.com/wailsapp/wails/v3/pkg/application/models.js"; + +/** + * HandleWindowClose 处理窗口关闭事件 + */ +export function HandleWindowClose(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(1824247204) as any; + return $resultPromise; +} + +/** + * HandleWindowMinimize 处理窗口最小化事件 + */ +export function HandleWindowMinimize(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(178686624) as any; + return $resultPromise; +} + +/** + * MinimizeButtonClicked 处理标题栏最小化按钮点击 + */ +export function MinimizeButtonClicked(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(2477618539) as any; + return $resultPromise; +} + +/** + * SetAppReferences 设置应用引用 + */ +export function SetAppReferences(app: application$0.App | null, mainWindow: application$0.WebviewWindow | null): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(3544515719, app, mainWindow) as any; + return $resultPromise; +} + +/** + * ShouldMinimizeToTray 检查是否应该最小化到托盘 + */ +export function ShouldMinimizeToTray(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(3403884012) as any; + return $resultPromise; +} + +/** + * ShowWindow 显示主窗口 + */ +export function ShowWindow(): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(1315913255) as any; + return $resultPromise; +} diff --git a/frontend/components.d.ts b/frontend/components.d.ts index f8c07ae..8c8d363 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -12,5 +12,6 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] Toolbar: typeof import('./src/components/toolbar/Toolbar.vue')['default'] + WindowTitleBar: typeof import('./src/components/titlebar/WindowTitleBar.vue')['default'] } } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ea0c8ed..ef7bd63 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,6 +1,7 @@ + + \ No newline at end of file diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 0cd374c..0c68889 100644 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -1,4 +1,10 @@ export default { + titlebar: { + minimize: 'Minimize', + maximize: 'Maximize', + restore: 'Restore Down', + close: 'Close' + }, toolbar: { editor: { lines: 'Ln', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 7c40de1..e5f7546 100644 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -1,4 +1,10 @@ export default { + titlebar: { + minimize: '最小化', + maximize: '最大化', + restore: '向下还原', + close: '关闭' + }, toolbar: { editor: { lines: 'Ln', diff --git a/internal/events/tray_events.go b/internal/events/tray_events.go index 57b376a..f8278af 100644 --- a/internal/events/tray_events.go +++ b/internal/events/tray_events.go @@ -29,15 +29,8 @@ func RegisterTrayEvents(app *application.App, systray *application.SystemTray, m trayService.HandleWindowClose() }) - // 处理窗口最小化事件 - 根据配置决定是隐藏到托盘还是正常最小化 - mainWindow.RegisterHook(wailsevents.Common.WindowMinimise, func(event *application.WindowEvent) { - if trayService.ShouldMinimizeToTray() { - // 取消默认最小化行为,隐藏到托盘 - event.Cancel() - trayService.HandleWindowMinimize() - } - // 如果不启用托盘,允许正常最小化(不取消事件) - }) + // 不再拦截窗口最小化事件,让任务栏点击保持正常行为 + // 最小化到托盘的逻辑由前端标题栏按钮直接处理 } // RegisterTrayMenuEvents 注册系统托盘菜单事件 diff --git a/internal/services/service_manager.go b/internal/services/service_manager.go index 2a5dd4a..35999ea 100644 --- a/internal/services/service_manager.go +++ b/internal/services/service_manager.go @@ -17,6 +17,7 @@ type ServiceManager struct { dialogService *DialogService websocketService *WebSocketService httpService *HTTPService + trayService *TrayService logger *log.LoggerService } @@ -49,6 +50,9 @@ func NewServiceManager() *ServiceManager { // 初始化 HTTP 服务 httpService := NewHTTPService(logger, websocketService) + // 初始化托盘服务 + trayService := NewTrayService(logger, configService) + // 设置迁移服务的WebSocket广播 migrationService.SetProgressBroadcaster(func(progress MigrationProgress) { websocketService.BroadcastMigrationProgress(progress) @@ -95,6 +99,7 @@ func NewServiceManager() *ServiceManager { dialogService: dialogService, websocketService: websocketService, httpService: httpService, + trayService: trayService, logger: logger, } } @@ -108,6 +113,7 @@ func (sm *ServiceManager) GetServices() []application.Service { application.NewService(sm.systemService), application.NewService(sm.hotkeyService), application.NewService(sm.dialogService), + application.NewService(sm.trayService), } } @@ -130,3 +136,8 @@ func (sm *ServiceManager) GetLogger() *log.LoggerService { func (sm *ServiceManager) GetConfigService() *ConfigService { return sm.configService } + +// GetTrayService 获取托盘服务实例 +func (sm *ServiceManager) GetTrayService() *TrayService { + return sm.trayService +} diff --git a/internal/services/tray_service.go b/internal/services/tray_service.go index 087c7b7..92bae90 100644 --- a/internal/services/tray_service.go +++ b/internal/services/tray_service.go @@ -77,3 +77,10 @@ func (ts *TrayService) ShowWindow() { ts.logger.Info("TrayService: Window shown from system tray") } } + +// MinimizeButtonClicked 处理标题栏最小化按钮点击 +func (ts *TrayService) MinimizeButtonClicked() { + // 最小化按钮总是执行正常最小化到任务栏,不隐藏到托盘 + ts.mainWindow.Minimise() + ts.logger.Info("TrayService: Window minimized to taskbar via titlebar button") +} diff --git a/main.go b/main.go index d442759..a9b74a1 100644 --- a/main.go +++ b/main.go @@ -75,10 +75,13 @@ func main() { // 'URL' is the URL that will be loaded into the webview. log.Println("Creating main window...") mainWindow := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ - Title: "voidraft", - Width: 700, - Height: 800, - Hidden: false, + Title: "voidraft", + Width: 700, + Height: 800, + Hidden: false, + Frameless: true, + DevToolsEnabled: false, + DefaultContextMenuDisabled: false, Mac: application.MacWindow{ InvisibleTitleBarHeight: 50, Backdrop: application.MacBackdropTranslucent, @@ -92,8 +95,8 @@ func main() { }) mainWindow.Center() - // 创建托盘服务 - trayService := services.NewTrayService(serviceManager.GetLogger(), serviceManager.GetConfigService()) + // 获取托盘服务并设置应用引用 + trayService := serviceManager.GetTrayService() trayService.SetAppReferences(app, mainWindow) // 设置系统托盘