Compare commits

2 Commits

Author SHA1 Message Date
7f97b4a937 Frameless Window 2025-06-09 01:00:15 +08:00
8522a47b5f Added system tray service 2025-06-08 23:07:56 +08:00
17 changed files with 506 additions and 34 deletions

View File

@@ -360,6 +360,11 @@ export class GeneralConfig {
*/
"dataPath": string;
/**
* 是否启用系统托盘
*/
"enableSystemTray": boolean;
/**
* 全局热键设置
* 是否启用全局热键
@@ -379,6 +384,9 @@ export class GeneralConfig {
if (!("dataPath" in $$source)) {
this["dataPath"] = "";
}
if (!("enableSystemTray" in $$source)) {
this["enableSystemTray"] = false;
}
if (!("enableGlobalHotkey" in $$source)) {
this["enableGlobalHotkey"] = false;
}
@@ -393,10 +401,10 @@ export class GeneralConfig {
* Creates a new GeneralConfig instance from a string or object.
*/
static createFrom($$source: any = {}): GeneralConfig {
const $$createField3_0 = $$createType7;
const $$createField4_0 = $$createType7;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("globalHotkey" in $$parsedSource) {
$$parsedSource["globalHotkey"] = $$createField3_0($$parsedSource["globalHotkey"]);
$$parsedSource["globalHotkey"] = $$createField4_0($$parsedSource["globalHotkey"]);
}
return new GeneralConfig($$parsedSource as Partial<GeneralConfig>);
}

View File

@@ -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";

View File

@@ -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<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(1824247204) as any;
return $resultPromise;
}
/**
* HandleWindowMinimize 处理窗口最小化事件
*/
export function HandleWindowMinimize(): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(178686624) as any;
return $resultPromise;
}
/**
* MinimizeButtonClicked 处理标题栏最小化按钮点击
*/
export function MinimizeButtonClicked(): Promise<void> & { 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<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(3544515719, app, mainWindow) as any;
return $resultPromise;
}
/**
* ShouldMinimizeToTray 检查是否应该最小化到托盘
*/
export function ShouldMinimizeToTray(): Promise<boolean> & { cancel(): void } {
let $resultPromise = $Call.ByID(3403884012) as any;
return $resultPromise;
}
/**
* ShowWindow 显示主窗口
*/
export function ShowWindow(): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(1315913255) as any;
return $resultPromise;
}

View File

@@ -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']
}
}

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { onMounted } from 'vue';
import { useConfigStore } from '@/stores/configStore';
import WindowTitleBar from '@/components/titlebar/WindowTitleBar.vue';
const configStore = useConfigStore();
@@ -14,7 +15,10 @@ onMounted(async () => {
<template>
<div class="app-container">
<router-view/>
<WindowTitleBar />
<div class="app-content">
<router-view/>
</div>
</div>
</template>
@@ -24,5 +28,14 @@ onMounted(async () => {
height: 100vh;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
}
.app-content {
flex: 1;
margin-top: 32px;
overflow: hidden;
position: relative;
}
</style>

View File

@@ -0,0 +1,247 @@
<template>
<div class="windows-titlebar" style="--wails-draggable:drag" @contextmenu.prevent @mouseenter="checkMaximizedState" @mouseup="checkMaximizedState">
<div class="titlebar-content" @dblclick="toggleMaximize" @contextmenu.prevent>
<div class="titlebar-icon">
<img src="/appicon.png" alt="voidraft" />
</div>
<div class="titlebar-title">voidraft</div>
</div>
<div class="titlebar-controls" style="--wails-draggable:no-drag" @contextmenu.prevent>
<button
class="titlebar-button minimize-button"
@click="minimizeWindow"
:title="t('titlebar.minimize')"
>
<span class="titlebar-icon">&#xE921;</span>
</button>
<button
class="titlebar-button maximize-button"
@click="toggleMaximize"
:title="isMaximized ? t('titlebar.restore') : t('titlebar.maximize')"
>
<span class="titlebar-icon" v-html="maximizeIcon"></span>
</button>
<button
class="titlebar-button close-button"
@click="closeWindow"
:title="t('titlebar.close')"
>
<span class="titlebar-icon">&#xE8BB;</span>
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import * as runtime from '@wailsio/runtime';
const { t } = useI18n();
const isMaximized = ref(false);
// 计算属性用于图标,减少重复渲染
const maximizeIcon = computed(() => isMaximized.value ? '&#xE923;' : '&#xE922;');
const minimizeWindow = async () => {
try {
await runtime.Window.Minimise();
} catch (error) {
}
};
const toggleMaximize = async () => {
try {
// 立即更新UI状态提供即时反馈
const newState = !isMaximized.value;
isMaximized.value = newState;
// 然后执行实际操作
if (newState) {
await runtime.Window.Maximise();
} else {
await runtime.Window.UnMaximise();
}
// 操作完成后再次确认状态(防止操作失败时状态不一致)
setTimeout(async () => {
await checkMaximizedState();
}, 100);
} catch (error) {
// 如果操作失败,恢复原状态
isMaximized.value = !isMaximized.value;
}
};
const closeWindow = async () => {
try {
// 使用Window的Close方法会触发窗口关闭事件
await runtime.Window.Close();
} catch (error) {
}
};
const checkMaximizedState = async () => {
try {
isMaximized.value = await runtime.Window.IsMaximised();
} catch (error) {
}
};
onMounted(async () => {
// 检查初始最大化状态
await checkMaximizedState();
// 监听窗口状态变化事件
runtime.Events.On('window:maximised', () => {
isMaximized.value = true;
});
runtime.Events.On('window:unmaximised', () => {
isMaximized.value = false;
});
// 监听窗口焦点事件,确保状态同步
runtime.Events.On('window:focus', async () => {
await checkMaximizedState();
});
onUnmounted(() => {
// 清理事件监听器
runtime.Events.Off('window:maximised');
runtime.Events.Off('window:unmaximised');
runtime.Events.Off('window:focus');
});
});
</script>
<style scoped lang="scss">
.windows-titlebar {
display: flex;
height: 32px;
background: #202020;
user-select: none;
-webkit-user-select: none;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
/* 禁用右键菜单 */
-webkit-context-menu: none;
-moz-context-menu: none;
context-menu: none;
}
.titlebar-content {
display: flex;
align-items: center;
flex: 1;
padding-left: 8px;
gap: 8px;
color: #ffffff;
font-size: 12px;
font-weight: 400;
cursor: default;
/* 禁用右键菜单 */
-webkit-context-menu: none;
-moz-context-menu: none;
context-menu: none;
}
.titlebar-content .titlebar-icon {
width: 16px;
height: 16px;
img {
width: 100%;
height: 100%;
object-fit: contain;
}
}
.titlebar-title {
font-size: 12px;
color: #ffffff;
}
.titlebar-controls {
display: flex;
height: 100%;
/* 禁用右键菜单 */
-webkit-context-menu: none;
-moz-context-menu: none;
context-menu: none;
}
.titlebar-button {
width: 46px;
height: 32px;
border: none;
background: transparent;
color: #ffffff;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background-color 0.1s ease;
padding: 0;
margin: 0;
&:hover {
background: rgba(255, 255, 255, 0.0605);
}
&:active {
background: rgba(255, 255, 255, 0.0837);
}
}
.titlebar-button .titlebar-icon {
font-family: 'Segoe MDL2 Assets', 'Segoe UI Symbol', 'Segoe UI', system-ui;
font-size: 9px;
line-height: 1;
display: inline-block;
opacity: 0.9;
transition: opacity 0.1s ease;
.titlebar-button:hover & {
opacity: 1;
}
}
.minimize-button:hover,
.maximize-button:hover {
background: rgba(255, 255, 255, 0.0605);
}
.minimize-button:active,
.maximize-button:active {
background: rgba(255, 255, 255, 0.0837);
}
.close-button:hover {
background: #c42b1c;
color: #ffffff;
.titlebar-icon {
opacity: 1;
}
}
.close-button:active {
background: #a93226;
.titlebar-icon {
opacity: 1;
}
}
</style>

View File

@@ -1,4 +1,10 @@
export default {
titlebar: {
minimize: 'Minimize',
maximize: 'Maximize',
restore: 'Restore Down',
close: 'Close'
},
toolbar: {
editor: {
lines: 'Ln',
@@ -76,6 +82,7 @@ export default {
enableGlobalHotkey: 'Enable Global Hotkeys',
window: 'Window/Application',
showInSystemTray: 'Show in System Tray',
enableSystemTray: 'Enable System Tray',
alwaysOnTop: 'Always on Top',
dataStorage: 'Data Storage',
dataPath: 'Data Storage Path',

View File

@@ -1,4 +1,10 @@
export default {
titlebar: {
minimize: '最小化',
maximize: '最大化',
restore: '向下还原',
close: '关闭'
},
toolbar: {
editor: {
lines: 'Ln',
@@ -76,6 +82,7 @@ export default {
enableGlobalHotkey: '启用全局热键',
window: '窗口/应用程序',
showInSystemTray: '在系统托盘中显示',
enableSystemTray: '启用系统托盘',
alwaysOnTop: '窗口始终置顶',
dataStorage: '数据存储',
dataPath: '数据存储路径',

View File

@@ -49,6 +49,7 @@ type NumberConfigKey = 'fontSize' | 'tabSize' | 'lineHeight';
const GENERAL_CONFIG_KEY_MAP: GeneralConfigKeyMap = {
alwaysOnTop: 'general.always_on_top',
dataPath: 'general.data_path',
enableSystemTray: 'general.enable_system_tray',
enableGlobalHotkey: 'general.enable_global_hotkey',
globalHotkey: 'general.global_hotkey'
} as const;
@@ -116,6 +117,7 @@ const DEFAULT_CONFIG: AppConfig = {
general: {
alwaysOnTop: false,
dataPath: '',
enableSystemTray: true,
enableGlobalHotkey: false,
globalHotkey: {
ctrl: false,
@@ -406,6 +408,9 @@ export const useConfigStore = defineStore('config', () => {
// 热键配置相关方法
setEnableGlobalHotkey: (value: boolean) => safeCall(() => updateGeneralConfig('enableGlobalHotkey', value), 'config.saveFailed', 'config.saveSuccess'),
setGlobalHotkey: (hotkey: any) => safeCall(() => updateGeneralConfig('globalHotkey', hotkey), 'config.saveFailed', 'config.saveSuccess')
setGlobalHotkey: (hotkey: any) => safeCall(() => updateGeneralConfig('globalHotkey', hotkey), 'config.saveFailed', 'config.saveSuccess'),
// 系统托盘配置相关方法
setEnableSystemTray: (value: boolean) => safeCall(() => updateGeneralConfig('enableSystemTray', value), 'config.saveFailed', 'config.saveSuccess')
};
});

View File

@@ -187,6 +187,12 @@ const alwaysOnTop = computed({
}
});
// 计算属性 - 启用系统托盘
const enableSystemTray = computed({
get: () => configStore.config.general.enableSystemTray,
set: (value: boolean) => configStore.setEnableSystemTray(value)
});
// 修饰键配置 - 只读计算属性
const modifierKeys = computed(() => ({
ctrl: configStore.config.general.globalHotkey.ctrl,
@@ -338,6 +344,9 @@ onUnmounted(() => {
<SettingItem :title="t('settings.alwaysOnTop')">
<ToggleSwitch v-model="alwaysOnTop"/>
</SettingItem>
<SettingItem :title="t('settings.enableSystemTray')">
<ToggleSwitch v-model="enableSystemTray"/>
</SettingItem>
</SettingSection>
<SettingSection :title="t('settings.dataStorage')">

View File

@@ -2,13 +2,14 @@ package events
import (
"time"
"voidraft/internal/services"
"github.com/wailsapp/wails/v3/pkg/application"
wailsevents "github.com/wailsapp/wails/v3/pkg/events"
)
// RegisterTrayEvents 注册与系统托盘相关的所有事件
func RegisterTrayEvents(app *application.App, systray *application.SystemTray, mainWindow *application.WebviewWindow) {
func RegisterTrayEvents(app *application.App, systray *application.SystemTray, mainWindow *application.WebviewWindow, trayService *services.TrayService) {
// 不附加窗口到系统托盘,避免失去焦点自动缩小
// systray.AttachWindow(mainWindow)
@@ -17,32 +18,19 @@ func RegisterTrayEvents(app *application.App, systray *application.SystemTray, m
// 设置点击托盘图标显示主窗口
systray.OnClick(func() {
mainWindow.Show()
mainWindow.Restore()
mainWindow.Focus()
// 通知前端窗口已显示
app.EmitEvent("window:shown", nil)
trayService.ShowWindow()
})
// 处理窗口关闭事件 - 隐藏到托盘
// 处理窗口关闭事件 - 根据配置决定是隐藏到托盘还是直接退出
mainWindow.RegisterHook(wailsevents.Common.WindowClosing, func(event *application.WindowEvent) {
// 取消默认关闭行为
event.Cancel()
// 隐藏窗口到托盘
mainWindow.Hide()
// 通知前端窗口已隐藏
app.EmitEvent("window:hidden", nil)
// 使用托盘服务处理关闭事件
trayService.HandleWindowClose()
})
// 处理窗口最小化事件 - 也隐藏到托盘
mainWindow.RegisterHook(wailsevents.Common.WindowMinimise, func(event *application.WindowEvent) {
// 取消默认最小化行为
event.Cancel()
// 隐藏窗口到托盘
mainWindow.Hide()
// 通知前端窗口已隐藏
app.EmitEvent("window:hidden", nil)
})
// 不再拦截窗口最小化事件,让任务栏点击保持正常行为
// 最小化到托盘的逻辑由前端标题栏按钮直接处理
}
// RegisterTrayMenuEvents 注册系统托盘菜单事件

View File

@@ -58,8 +58,9 @@ const (
// GeneralConfig 通用设置配置
type GeneralConfig struct {
AlwaysOnTop bool `json:"alwaysOnTop" yaml:"always_on_top" mapstructure:"always_on_top"` // 窗口是否置顶
DataPath string `json:"dataPath" yaml:"data_path" mapstructure:"data_path"` // 数据存储路径
AlwaysOnTop bool `json:"alwaysOnTop" yaml:"always_on_top" mapstructure:"always_on_top"` // 窗口是否置顶
DataPath string `json:"dataPath" yaml:"data_path" mapstructure:"data_path"` // 数据存储路径
EnableSystemTray bool `json:"enableSystemTray" yaml:"enable_system_tray" mapstructure:"enable_system_tray"` // 是否启用系统托盘
// 全局热键设置
EnableGlobalHotkey bool `json:"enableGlobalHotkey" yaml:"enable_global_hotkey" mapstructure:"enable_global_hotkey"` // 是否启用全局热键
@@ -139,6 +140,7 @@ func NewDefaultAppConfig() *AppConfig {
General: GeneralConfig{
AlwaysOnTop: false,
DataPath: dataDir,
EnableSystemTray: true, // 默认启用系统托盘
EnableGlobalHotkey: false,
GlobalHotkey: HotkeyCombo{
Ctrl: false,

View File

@@ -106,6 +106,7 @@ func setDefaults(v *viper.Viper) {
// 通用设置默认值
v.SetDefault("general.always_on_top", defaultConfig.General.AlwaysOnTop)
v.SetDefault("general.data_path", defaultConfig.General.DataPath)
v.SetDefault("general.enable_system_tray", defaultConfig.General.EnableSystemTray)
v.SetDefault("general.enable_global_hotkey", defaultConfig.General.EnableGlobalHotkey)
v.SetDefault("general.global_hotkey.ctrl", defaultConfig.General.GlobalHotkey.Ctrl)
v.SetDefault("general.global_hotkey.shift", defaultConfig.General.GlobalHotkey.Shift)
@@ -240,6 +241,7 @@ func (cs *ConfigService) ResetConfig() {
// 通用设置 - 批量设置到viper中
cs.viper.Set("general.always_on_top", defaultConfig.General.AlwaysOnTop)
cs.viper.Set("general.data_path", defaultConfig.General.DataPath)
cs.viper.Set("general.enable_system_tray", defaultConfig.General.EnableSystemTray)
cs.viper.Set("general.enable_global_hotkey", defaultConfig.General.EnableGlobalHotkey)
cs.viper.Set("general.global_hotkey.ctrl", defaultConfig.General.GlobalHotkey.Ctrl)
cs.viper.Set("general.global_hotkey.shift", defaultConfig.General.GlobalHotkey.Shift)

View File

@@ -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),
}
}
@@ -120,3 +126,18 @@ func (sm *ServiceManager) GetHotkeyService() *HotkeyService {
func (sm *ServiceManager) GetDialogService() *DialogService {
return sm.dialogService
}
// GetLogger 获取日志服务实例
func (sm *ServiceManager) GetLogger() *log.LoggerService {
return sm.logger
}
// GetConfigService 获取配置服务实例
func (sm *ServiceManager) GetConfigService() *ConfigService {
return sm.configService
}
// GetTrayService 获取托盘服务实例
func (sm *ServiceManager) GetTrayService() *TrayService {
return sm.trayService
}

View File

@@ -0,0 +1,86 @@
package services
import (
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/services/log"
)
// TrayService 系统托盘服务
type TrayService struct {
logger *log.LoggerService
configService *ConfigService
app *application.App
mainWindow *application.WebviewWindow
}
// NewTrayService 创建新的系统托盘服务实例
func NewTrayService(logger *log.LoggerService, configService *ConfigService) *TrayService {
return &TrayService{
logger: logger,
configService: configService,
}
}
// SetAppReferences 设置应用引用
func (ts *TrayService) SetAppReferences(app *application.App, mainWindow *application.WebviewWindow) {
ts.app = app
ts.mainWindow = mainWindow
}
// ShouldMinimizeToTray 检查是否应该最小化到托盘
func (ts *TrayService) ShouldMinimizeToTray() bool {
config, err := ts.configService.GetConfig()
if err != nil {
ts.logger.Error("TrayService: Failed to get config", "error", err)
return true // 默认行为:隐藏到托盘
}
return config.General.EnableSystemTray
}
// HandleWindowClose 处理窗口关闭事件
func (ts *TrayService) HandleWindowClose() {
if ts.ShouldMinimizeToTray() {
// 隐藏到托盘
ts.mainWindow.Hide()
ts.app.EmitEvent("window:hidden", nil)
ts.logger.Info("TrayService: Window hidden to system tray")
} else {
// 直接退出应用
ts.app.Quit()
ts.logger.Info("TrayService: Application quit")
}
}
// HandleWindowMinimize 处理窗口最小化事件
func (ts *TrayService) HandleWindowMinimize() {
if ts.ShouldMinimizeToTray() {
// 隐藏到托盘
ts.mainWindow.Hide()
ts.app.EmitEvent("window:hidden", nil)
ts.logger.Info("TrayService: Window minimized to system tray")
} else {
// 允许正常最小化(不处理,让系统处理)
ts.logger.Info("TrayService: Window minimized normally")
}
}
// ShowWindow 显示主窗口
func (ts *TrayService) ShowWindow() {
if ts.mainWindow != nil {
ts.mainWindow.Show()
ts.mainWindow.Restore()
ts.mainWindow.Focus()
if ts.app != nil {
ts.app.EmitEvent("window:shown", nil)
}
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")
}

View File

@@ -4,10 +4,11 @@ import (
"embed"
"github.com/wailsapp/wails/v3/pkg/application"
"voidraft/internal/events"
"voidraft/internal/services"
)
// SetupSystemTray 设置系统托盘及其功能
func SetupSystemTray(app *application.App, mainWindow *application.WebviewWindow, assets embed.FS) {
func SetupSystemTray(app *application.App, mainWindow *application.WebviewWindow, assets embed.FS, trayService *services.TrayService) {
// 创建系统托盘
systray := app.NewSystemTray()
@@ -27,5 +28,5 @@ func SetupSystemTray(app *application.App, mainWindow *application.WebviewWindow
systray.SetMenu(menu)
// 注册托盘相关事件
events.RegisterTrayEvents(app, systray, mainWindow)
events.RegisterTrayEvents(app, systray, mainWindow, trayService)
}

20
main.go
View File

@@ -75,22 +75,32 @@ 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,
TitleBar: application.MacTitleBarHiddenInset,
},
Windows: application.WindowsWindow{
Theme: application.SystemDefault,
},
BackgroundColour: application.NewRGB(27, 38, 54),
URL: "/#/",
})
mainWindow.Center()
// 获取托盘服务并设置应用引用
trayService := serviceManager.GetTrayService()
trayService.SetAppReferences(app, mainWindow)
// 设置系统托盘
systray.SetupSystemTray(app, mainWindow, assets)
systray.SetupSystemTray(app, mainWindow, assets, trayService)
// 初始化热键服务
hotkeyService := serviceManager.GetHotkeyService()