|
|
@@ -35,7 +35,7 @@ const (
|
|
|
DefaultNewsRefreshMinutes = 120 // 新闻自动刷新间隔(分钟)
|
|
|
DefaultNewsCount = 30 // 新闻页显示条数
|
|
|
DefaultGithubRefreshMinutes = 120 // Github 自动刷新间隔(分钟)
|
|
|
- AppVersion = "0.1.8" // 应用自身版本(与 build/windows/info.json 的 ProductVersion 一致),用于仓库更新提示
|
|
|
+ AppVersion = "0.1.10" // 应用自身版本(与 build/windows/info.json 的 ProductVersion 一致),用于仓库更新提示
|
|
|
|
|
|
// 鼠标提醒默认配置
|
|
|
DefaultMouseAlertFontSize = 20 // 字号(px)
|
|
|
@@ -53,6 +53,13 @@ type LinkItem struct {
|
|
|
URL string `json:"url"` // 网站地址
|
|
|
}
|
|
|
|
|
|
+// LinkGroup 「网址」页分组(设置中以缩进层级定义,类似快捷启动)
|
|
|
+// 未分组的条目放在 LinkGroups 的第一个 Name 为空分组的 Items 中(前端解析时统一按组渲染)
|
|
|
+type LinkGroup struct {
|
|
|
+ Name string `json:"name"` // 分组名(空表示未分组)
|
|
|
+ Items []LinkItem `json:"items"` // 组内网址
|
|
|
+}
|
|
|
+
|
|
|
// CustomTab 用户自定义 Tab 页面
|
|
|
type CustomTab struct {
|
|
|
Name string `json:"name"` // 页面名称(Tab 按钮显示文字)
|
|
|
@@ -95,6 +102,9 @@ type MouseAlertConfig struct {
|
|
|
Duration int `json:"duration"` // 显示时长(秒)
|
|
|
OutlineColor string `json:"outlineColor"` // 文字描边颜色(白边/黑边,与文字形成反差)
|
|
|
OutlineWidth int `json:"outlineWidth"` // 文字描边宽度(px),0 表示关闭描边
|
|
|
+ // Scroll 是否滚动显示超长文字:nil 表示未设置(兼容旧配置,用 Speed>0 决定);
|
|
|
+ // true=超长时水平滚动跑马灯,false=超长部分右侧裁剪不滚动。
|
|
|
+ Scroll *bool `json:"scroll"`
|
|
|
}
|
|
|
|
|
|
// GitLabConfig 自动升级配置(静态更新站方案)。
|
|
|
@@ -131,45 +141,46 @@ type QuickGroup struct {
|
|
|
|
|
|
// AppSettings 保存全部可自定义配置,序列化为 JSON 存于用户配置目录
|
|
|
type AppSettings struct {
|
|
|
- Theme string `json:"theme"` // 界面主题:dark / light
|
|
|
- Autostart bool `json:"autostart"` // 系统启动时运行
|
|
|
- AlwaysOnTop bool `json:"alwaysOnTop"` // 窗口置顶
|
|
|
- StartCompact bool `json:"startCompact"` // 启动时自动收拢为圆点(窗口缩小)
|
|
|
- WindowWidth int `json:"windowWidth"` // 主窗口宽度(px),随窗口调整自动保存
|
|
|
- WindowHeight int `json:"windowHeight"` // 主窗口高度(px),随窗口调整自动保存
|
|
|
- Hotkey string `json:"hotkey"` // 呼出(显示)窗口的全局热键
|
|
|
- QuickHotkey string `json:"quickHotkey"` // 在鼠标位置弹出「快捷」菜单的全局热键
|
|
|
- ProxyHotkey string `json:"proxyHotkey"` // 开关「网络代理」的全局热键(空=不设热键)
|
|
|
- TabOrder []string `json:"tabOrder"` // Tab 显示顺序(tabId 列表,未列出的追加到末尾)
|
|
|
- StockCodes []string `json:"stockCodes"` // 股市页展示的股票代码列表
|
|
|
- Links []LinkItem `json:"links"` // 常用网址列表
|
|
|
- NewsKeywords string `json:"newsKeywords"` // 新闻关注关键词,逗号分隔
|
|
|
- BiliCookie string `json:"biliCookie"` // B站登录 cookie(含 SESSDATA),用于抓取「关注的人最新动态」
|
|
|
- BiliPopularEnabled bool `json:"biliPopularEnabled"` // 新闻页是否显示 B站热门视频区块(默认开启)
|
|
|
- GithubRepos []RepoItem `json:"githubRepos"` // 关注的 GitHub 仓库列表
|
|
|
- CustomTabs []CustomTab `json:"customTabs"` // 用户自定义 Tab 页面(名字 + 网址)
|
|
|
- LocalTools []LocalTool `json:"localTools"` // 「本地」页资源(标题|启动命令|说明,在设置中维护)
|
|
|
- QuickGroups []QuickGroup `json:"quickGroups"` // 「快捷」页分组(缩进分层,名称|路径|说明 条目)
|
|
|
- ControlKeys []ControlKeyConfig `json:"controlKeys"` // 控制页按键配置(前 5 键固定 上/下/左/右/休眠,第 6 键起为额外按键)
|
|
|
- ControlRepeatSecs float64 `json:"controlRepeatSecs"` // 控制页长按连发频率(秒,0.0-10.0,默认 1.0)
|
|
|
- APIAddr string `json:"apiAddr"` // 内置 API 服务监听地址
|
|
|
- ServiceAddr string `json:"serviceAddr"` // Windows 服务模式(--service)监听地址,仅电源类接口
|
|
|
- APIAutoStart bool `json:"apiAutoStart"` // 应用启动时自动启动内置 API 服务(默认开启)
|
|
|
- UploadPassword string `json:"uploadPassword"` // 文件上传密码(空=不启用上传/下载接口)
|
|
|
- UploadDir string `json:"uploadDir"` // 文件上传保存目录(空=用户配置目录/uploads)
|
|
|
- UploadMaxSize int `json:"uploadMaxSize"` // 单个上传文件大小上限(MB),<=0 用默认 512
|
|
|
- TodoPath string `json:"todoPath"` // 待办(TODO)文件路径
|
|
|
- RecordPath string `json:"recordPath"` // 记录(Record)文件路径:每行「姓名|名称|值」(保留兼容)
|
|
|
- RecordDBPath string `json:"recordDBPath"` // 记录数据库路径:SQLite3 数据库文件(记录 Tab 实际存储)
|
|
|
- TagDBPath string `json:"tagDBPath"` // 文件标签数据库路径:SQLite3(资源管理器右键「标签」与悬停标签提示使用)
|
|
|
- TagMenuEnabled bool `json:"tagMenuEnabled"` // 资源管理器右键「标签」功能开关:false=关闭右键菜单+停止监听悬停(默认启用)
|
|
|
- BackupDir string `json:"backupDir"` // 文本文件备份目录(文件类自定义 Tab「备份」按钮使用)
|
|
|
- StockTicker TickerConfig `json:"stockTicker"` // 股票滚动条配置
|
|
|
- NewsTicker TickerConfig `json:"newsTicker"` // 新闻滚动条配置
|
|
|
- Poem PoemConfig `json:"poem"` // 随机古诗显示配置
|
|
|
- MouseAlert MouseAlertConfig `json:"mouseAlert"` // 系统级鼠标提醒气泡配置
|
|
|
- BrowserPath string `json:"browserPath"` // 指定浏览器 exe 路径(空=系统默认浏览器)
|
|
|
- LEDColor string `json:"ledColor"` // LED 滚动文字点阵颜色(如 #ff4d4d)
|
|
|
+ Theme string `json:"theme"` // 界面主题:dark / light
|
|
|
+ Autostart bool `json:"autostart"` // 系统启动时运行
|
|
|
+ AlwaysOnTop bool `json:"alwaysOnTop"` // 窗口置顶
|
|
|
+ StartCompact bool `json:"startCompact"` // 启动时自动收拢为圆点(窗口缩小)
|
|
|
+ WindowWidth int `json:"windowWidth"` // 主窗口宽度(px),随窗口调整自动保存
|
|
|
+ WindowHeight int `json:"windowHeight"` // 主窗口高度(px),随窗口调整自动保存
|
|
|
+ Hotkey string `json:"hotkey"` // 呼出(显示)窗口的全局热键
|
|
|
+ QuickHotkey string `json:"quickHotkey"` // 在鼠标位置弹出「快捷」菜单的全局热键
|
|
|
+ ProxyHotkey string `json:"proxyHotkey"` // 开关「网络代理」的全局热键(空=不设热键)
|
|
|
+ TabOrder []string `json:"tabOrder"` // Tab 显示顺序(tabId 列表,未列出的追加到末尾)
|
|
|
+ StockCodes []string `json:"stockCodes"` // 股市页展示的股票代码列表
|
|
|
+ Links []LinkItem `json:"links"` // 常用网址列表(扁平,未分组;分组请用 LinkGroups)
|
|
|
+ LinkGroups []LinkGroup `json:"linkGroups"` // 「网址」页分组(缩进层级定义,空 Name 表示未分组)
|
|
|
+ NewsKeywords string `json:"newsKeywords"` // 新闻关注关键词,逗号分隔
|
|
|
+ BiliCookie string `json:"biliCookie"` // B站登录 cookie(含 SESSDATA),用于抓取「关注的人最新动态」
|
|
|
+ BiliPopularEnabled bool `json:"biliPopularEnabled"` // 新闻页是否显示 B站热门视频区块(默认开启)
|
|
|
+ GithubRepos []RepoItem `json:"githubRepos"` // 关注的 GitHub 仓库列表
|
|
|
+ CustomTabs []CustomTab `json:"customTabs"` // 用户自定义 Tab 页面(名字 + 网址)
|
|
|
+ LocalTools []LocalTool `json:"localTools"` // 「本地」页资源(标题|启动命令|说明,在设置中维护)
|
|
|
+ QuickGroups []QuickGroup `json:"quickGroups"` // 「快捷」页分组(缩进分层,名称|路径|说明 条目)
|
|
|
+ ControlKeys []ControlKeyConfig `json:"controlKeys"` // 控制页按键配置(前 5 键固定 上/下/左/右/休眠,第 6 键起为额外按键)
|
|
|
+ ControlRepeatSecs float64 `json:"controlRepeatSecs"` // 控制页长按连发频率(秒,0.0-10.0,默认 1.0)
|
|
|
+ APIAddr string `json:"apiAddr"` // 内置 API 服务监听地址
|
|
|
+ ServiceAddr string `json:"serviceAddr"` // Windows 服务模式(--service)监听地址,仅电源类接口
|
|
|
+ APIAutoStart bool `json:"apiAutoStart"` // 应用启动时自动启动内置 API 服务(默认开启)
|
|
|
+ UploadPassword string `json:"uploadPassword"` // 文件上传密码(空=不启用上传/下载接口)
|
|
|
+ UploadDir string `json:"uploadDir"` // 文件上传保存目录(空=程序所在目录/上传)
|
|
|
+ UploadMaxSize int `json:"uploadMaxSize"` // 单个上传文件大小上限(MB),<=0 用默认 512
|
|
|
+ TodoPath string `json:"todoPath"` // 待办(TODO)文件路径
|
|
|
+ RecordPath string `json:"recordPath"` // 记录(Record)文件路径:每行「姓名|名称|值」(保留兼容)
|
|
|
+ RecordDBPath string `json:"recordDBPath"` // 记录数据库路径:SQLite3 数据库文件(记录 Tab 实际存储)
|
|
|
+ TagDBPath string `json:"tagDBPath"` // 文件标签数据库路径:SQLite3(资源管理器右键「标签」与悬停标签提示使用)
|
|
|
+ TagMenuEnabled bool `json:"tagMenuEnabled"` // 资源管理器右键「标签」功能开关:false=关闭右键菜单+停止监听悬停(默认启用)
|
|
|
+ BackupDir string `json:"backupDir"` // 文本文件备份目录(文件类自定义 Tab「备份」按钮使用)
|
|
|
+ StockTicker TickerConfig `json:"stockTicker"` // 股票滚动条配置
|
|
|
+ NewsTicker TickerConfig `json:"newsTicker"` // 新闻滚动条配置
|
|
|
+ Poem PoemConfig `json:"poem"` // 随机古诗显示配置
|
|
|
+ MouseAlert MouseAlertConfig `json:"mouseAlert"` // 系统级鼠标提醒气泡配置
|
|
|
+ BrowserPath string `json:"browserPath"` // 指定浏览器 exe 路径(空=系统默认浏览器)
|
|
|
+ LEDColor string `json:"ledColor"` // LED 滚动文字点阵颜色(如 #ff4d4d)
|
|
|
|
|
|
StockUpColor string `json:"stockUpColor"` // 股票上涨颜色
|
|
|
StockDownColor string `json:"stockDownColor"` // 股票下跌颜色
|
|
|
@@ -185,6 +196,8 @@ type AppSettings struct {
|
|
|
YTDLP YTDLPConfig `json:"ytdlp"` // 视频下载配置(yt-dlp 保存目录)
|
|
|
Memos MemosConfig `json:"memos"` // Memos 速记配置(地址/访问令牌)
|
|
|
Brightness BrightnessConfig `json:"brightness"` // 显示器亮度配置(记住亮度、启动恢复)
|
|
|
+ FooterDocsLabel string `json:"footerDocsLabel"` // 页面右下角「官方文档」显示的标题文字
|
|
|
+ FooterDocsURL string `json:"footerDocsURL"` // 页面右下角标题文字点击打开的网址
|
|
|
ToolOrder []string `json:"toolOrder"` // 工具页卡片显示顺序(工具 id 列表,未列出的追加到末尾)
|
|
|
GitLab GitLabConfig `json:"gitLab"` // 私有 GitLab 自动升级配置
|
|
|
SkippedUpdateVersion string `json:"skippedUpdateVersion"` // 已跳过的版本(启动检查时视为无更新)
|
|
|
@@ -226,7 +239,7 @@ func defaultSettings() AppSettings {
|
|
|
{Name: "头条", URL: "https://www.toutiao.com/"},
|
|
|
{Name: "GitHub", URL: "https://github.com/"},
|
|
|
},
|
|
|
- NewsKeywords: "",
|
|
|
+ NewsKeywords: "",
|
|
|
BiliPopularEnabled: true, // 新闻页默认显示 B站热门视频区块
|
|
|
GithubRepos: []RepoItem{
|
|
|
{URL: "https://github.com/wailsapp/wails", Desc: "Wails:Go + Web 桌面应用框架"},
|
|
|
@@ -235,16 +248,16 @@ func defaultSettings() AppSettings {
|
|
|
ServiceAddr: DefaultServiceAddr,
|
|
|
APIAutoStart: true, // 内置 API 服务随应用启动(默认开启)
|
|
|
UploadPassword: "", // 上传密码:默认空(不启用上传/下载)
|
|
|
- UploadDir: "", // 上传保存目录:默认空(回退到用户配置目录/uploads)
|
|
|
+ UploadDir: "", // 上传保存目录:默认空(回退到程序所在目录/上传)
|
|
|
UploadMaxSize: 512, // 上传大小上限:默认 512MB
|
|
|
ControlKeys: DefaultControlKeys(), // 控制页 5 键默认配置(图标↑↓←→休眠,命令空回退指令信箱)
|
|
|
ControlRepeatSecs: 1.0, // 长按连发频率默认 1 秒
|
|
|
- TodoPath: "", // 待办路径:无默认值,用户须在设置中配置(空值时强制进入设置)
|
|
|
- RecordPath: "", // 记录路径:无默认值,用户须在设置中配置(空值时强制进入设置)
|
|
|
- RecordDBPath: "", // 记录数据库路径:无默认值,用户须在设置中配置(空值时强制进入设置)
|
|
|
- TagDBPath: "", // 文件标签数据库路径:无默认值,用户须在设置中配置(空值时标签功能不生效)
|
|
|
+ TodoPath: "", // 待办路径:默认空(回退到程序所在目录/待办.txt)
|
|
|
+ RecordPath: "", // 记录路径:默认空(回退到程序所在目录/记录.txt)
|
|
|
+ RecordDBPath: "", // 记录数据库路径:默认空(回退到程序所在目录/记录.db)
|
|
|
+ TagDBPath: "", // 文件标签数据库路径:默认空(回退到程序所在目录/标签.db)
|
|
|
TagMenuEnabled: true, // 资源管理器右键「标签」功能默认启用
|
|
|
- BackupDir: "", // 备份目录:无默认值,用户须在设置中配置(空值时强制进入设置)
|
|
|
+ BackupDir: "", // 备份目录:默认空(回退到程序所在目录/备份)
|
|
|
StockTicker: TickerConfig{Enabled: false, Width: 1400, FontSize: 14, Color: "#ff4d4d", Speed: 80, Transparent: true, X: -1, Y: -1},
|
|
|
NewsTicker: TickerConfig{Enabled: false, Width: 1400, FontSize: 14, Color: "#3ddc84", Speed: 60, Transparent: true, X: -1, Y: -1},
|
|
|
Poem: PoemConfig{Enabled: false, Color: DefaultPoemColor, FontSize: DefaultPoemFontSize, TTS: false, Interval: DefaultPoemInterval, Speed: DefaultPoemSpeed},
|
|
|
@@ -260,6 +273,8 @@ func defaultSettings() AppSettings {
|
|
|
NewsCount: DefaultNewsCount,
|
|
|
GithubRefreshMinutes: DefaultGithubRefreshMinutes,
|
|
|
FontDelta: 0, // 全局字号偏移默认 0
|
|
|
+ FooterDocsLabel: "官方文档", // 右下角标题文字默认「官方文档」
|
|
|
+ FooterDocsURL: "https://v3.wails.io", // 右下角标题文字默认打开的网址
|
|
|
Memos: MemosConfig{
|
|
|
URL: "https://m.scwy.net", // 默认 Memos 实例
|
|
|
},
|
|
|
@@ -300,6 +315,7 @@ func DefaultToolOrder() []string {
|
|
|
"memos", // Memos 速记
|
|
|
"brightness", // 显示器设置(DDC/CI 优先,失败回退 Gamma;含一键息屏)
|
|
|
"proxy", // 网络代理(设置并启用/禁用 Windows 系统代理)
|
|
|
+ "renamer", // 智能重命名(AI 推断命名规律,批量重命名文件)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -314,6 +330,17 @@ func DefaultControlKeys() []ControlKeyConfig {
|
|
|
return keys
|
|
|
}
|
|
|
|
|
|
+// appDir 返回程序所在目录(可执行文件所在文件夹),取不到时回退到当前工作目录
|
|
|
+func appDir() string {
|
|
|
+ if exe, err := os.Executable(); err == nil && exe != "" {
|
|
|
+ return filepath.Dir(exe)
|
|
|
+ }
|
|
|
+ if wd, err := os.Getwd(); err == nil && wd != "" {
|
|
|
+ return wd
|
|
|
+ }
|
|
|
+ return "."
|
|
|
+}
|
|
|
+
|
|
|
// settingsFilePath 返回配置文件路径:<用户配置目录>/TengTuToolbox/settings.json
|
|
|
func settingsFilePath() (string, error) {
|
|
|
dir, err := os.UserConfigDir() // 例如 C:\Users\<用户名>\AppData\Roaming
|
|
|
@@ -400,6 +427,12 @@ func normalizeSettings(settings AppSettings) AppSettings {
|
|
|
if settings.WindowHeight <= 0 {
|
|
|
settings.WindowHeight = DefaultWindowHeight
|
|
|
}
|
|
|
+ if strings.TrimSpace(settings.FooterDocsLabel) == "" {
|
|
|
+ settings.FooterDocsLabel = "官方文档" // 右下角标题文字为空时回退默认
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.FooterDocsURL) == "" {
|
|
|
+ settings.FooterDocsURL = "https://v3.wails.io" // 右下角标题网址为空时回退默认
|
|
|
+ }
|
|
|
// 先清洗自定义 Tab(生成 custom-N id 白名单供下方 Tab 顺序校验使用)
|
|
|
tabs := make([]CustomTab, 0, len(settings.CustomTabs))
|
|
|
for _, tab := range settings.CustomTabs {
|
|
|
@@ -534,8 +567,27 @@ func normalizeSettings(settings AppSettings) AppSettings {
|
|
|
settings.ServiceAddr = DefaultServiceAddr
|
|
|
}
|
|
|
settings.UploadPassword = strings.TrimSpace(settings.UploadPassword) // 上传密码:空表示不启用
|
|
|
- settings.UploadDir = strings.TrimSpace(settings.UploadDir) // 上传目录:空回退到默认目录
|
|
|
- // TodoPath / RecordPath / RecordDBPath / BackupDir 无默认值:空值保留,前端据此强制用户进入设置配置(不做硬编码回填)
|
|
|
+ settings.UploadDir = strings.TrimSpace(settings.UploadDir) // 上传目录
|
|
|
+ // 数据类路径默认值:未填写时统一取程序所在目录(exe 所在文件夹),避免用户每次都要手动配置
|
|
|
+ appDir := appDir()
|
|
|
+ if strings.TrimSpace(settings.TodoPath) == "" {
|
|
|
+ settings.TodoPath = filepath.Join(appDir, "待办.txt")
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.RecordPath) == "" {
|
|
|
+ settings.RecordPath = filepath.Join(appDir, "记录.txt")
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.RecordDBPath) == "" {
|
|
|
+ settings.RecordDBPath = filepath.Join(appDir, "记录.db")
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.TagDBPath) == "" {
|
|
|
+ settings.TagDBPath = filepath.Join(appDir, "标签.db")
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.BackupDir) == "" {
|
|
|
+ settings.BackupDir = filepath.Join(appDir, "备份")
|
|
|
+ }
|
|
|
+ if strings.TrimSpace(settings.UploadDir) == "" {
|
|
|
+ settings.UploadDir = filepath.Join(appDir, "上传")
|
|
|
+ }
|
|
|
settings.StockTicker = normalizeTicker(settings.StockTicker, "#ff4d4d", 80) // 股票条默认红字
|
|
|
settings.NewsTicker = normalizeTicker(settings.NewsTicker, "#3ddc84", 60) // 新闻条默认绿字
|
|
|
settings.Poem = normalizePoemConfig(settings.Poem) // 古诗显示配置校正
|
|
|
@@ -623,6 +675,28 @@ func normalizeSettings(settings AppSettings) AppSettings {
|
|
|
}
|
|
|
settings.Links = links
|
|
|
|
|
|
+ // 网址分组归一:清理空白;若未配置分组,则把扁平 Links 归为一个未分组(Name 为空)
|
|
|
+ linkGroups := make([]LinkGroup, 0, len(settings.LinkGroups))
|
|
|
+ for _, g := range settings.LinkGroups {
|
|
|
+ g.Name = strings.TrimSpace(g.Name)
|
|
|
+ items := make([]LinkItem, 0, len(g.Items))
|
|
|
+ for _, link := range g.Items {
|
|
|
+ link.Name = strings.TrimSpace(link.Name)
|
|
|
+ link.URL = strings.TrimSpace(link.URL)
|
|
|
+ if link.Name != "" && link.URL != "" {
|
|
|
+ items = append(items, link)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(items) > 0 {
|
|
|
+ g.Items = items
|
|
|
+ linkGroups = append(linkGroups, g)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(linkGroups) == 0 {
|
|
|
+ linkGroups = append(linkGroups, LinkGroup{Name: "", Items: links})
|
|
|
+ }
|
|
|
+ settings.LinkGroups = linkGroups
|
|
|
+
|
|
|
repos := make([]RepoItem, 0, len(settings.GithubRepos))
|
|
|
for _, repo := range settings.GithubRepos {
|
|
|
repo.URL = strings.TrimSpace(repo.URL)
|