Added system tray service

This commit is contained in:
2025-06-08 23:07:56 +08:00
parent d5a0b07f2a
commit 8522a47b5f
12 changed files with 136 additions and 646 deletions

View File

@@ -1,622 +0,0 @@
// 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<AppConfig> = {}) {
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<AppConfig>);
}
}
/**
* AppearanceConfig 外观设置配置
*/
export class AppearanceConfig {
/**
* 界面语言
*/
"language": LanguageType;
/**
* 编辑器主题
*/
"theme": ThemeType;
/** Creates a new AppearanceConfig instance. */
constructor($$source: Partial<AppearanceConfig> = {}) {
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<AppearanceConfig>);
}
}
/**
* ConfigMetadata 配置元数据
*/
export class ConfigMetadata {
/**
* 配置版本
*/
"version": string;
/**
* 最后更新时间
*/
"lastUpdated": time$0.Time;
/** Creates a new ConfigMetadata instance. */
constructor($$source: Partial<ConfigMetadata> = {}) {
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<ConfigMetadata>);
}
}
/**
* Document 表示一个文档
*/
export class Document {
/**
* 元数据
*/
"meta": DocumentMeta;
/**
* 文档内容
*/
"content": string;
/** Creates a new Document instance. */
constructor($$source: Partial<Document> = {}) {
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<Document>);
}
}
/**
* DocumentMeta 文档元数据
*/
export class DocumentMeta {
/**
* 文档唯一标识
*/
"id": string;
/**
* 文档标题
*/
"title": string;
/**
* 最后更新时间
*/
"lastUpdated": time$0.Time;
/**
* 创建时间
*/
"createdAt": time$0.Time;
/** Creates a new DocumentMeta instance. */
constructor($$source: Partial<DocumentMeta> = {}) {
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<DocumentMeta>);
}
}
/**
* 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<EditingConfig> = {}) {
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<EditingConfig>);
}
}
/**
* GeneralConfig 通用设置配置
*/
export class GeneralConfig {
/**
* 窗口是否置顶
*/
"alwaysOnTop": boolean;
/**
* 数据存储路径
*/
"dataPath": string;
/**
* 全局热键设置
* 是否启用全局热键
*/
"enableGlobalHotkey": boolean;
/**
* 全局热键组合
*/
"globalHotkey": HotkeyCombo;
/** Creates a new GeneralConfig instance. */
constructor($$source: Partial<GeneralConfig> = {}) {
if (!("alwaysOnTop" in $$source)) {
this["alwaysOnTop"] = false;
}
if (!("dataPath" in $$source)) {
this["dataPath"] = "";
}
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 $$createField3_0 = $$createType7;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("globalHotkey" in $$parsedSource) {
$$parsedSource["globalHotkey"] = $$createField3_0($$parsedSource["globalHotkey"]);
}
return new GeneralConfig($$parsedSource as Partial<GeneralConfig>);
}
}
/**
* 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<HotkeyCombo> = {}) {
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<HotkeyCombo>);
}
}
/**
* KeyBindingsConfig 快捷键设置配置
*/
export class KeyBindingsConfig {
/** Creates a new KeyBindingsConfig instance. */
constructor($$source: Partial<KeyBindingsConfig> = {}) {
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<KeyBindingsConfig>);
}
}
/**
* 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<UpdatesConfig> = {}) {
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<UpdatesConfig>);
}
}
// 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;

View File

@@ -76,6 +76,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

@@ -76,6 +76,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')">