-
Notifications
You must be signed in to change notification settings - Fork 93
[202_112] 增加版本更新的提示 #3043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[202_112] 增加版本更新的提示 #3043
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3fe38fe
[202_112]增加版本更新的提示
GatsbyUSTC 098a5fd
支持社区版的更新提示
GatsbyUSTC 584ede3
修复 mock 逻辑
GatsbyUSTC dc5b21a
fix bugs
GatsbyUSTC 53db65d
区分商业版和社区版的最新版本号接口
GatsbyUSTC 17965cf
增加 debug 日志
GatsbyUSTC 4436a57
删除无用的声明
GatsbyUSTC 805c8c8
增加提示和按钮之间的间距
GatsbyUSTC 4d50028
翻译按照字母排序
GatsbyUSTC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; | ||
| ;; MODULE : version-update.scm | ||
| ;; DESCRIPTION : 版本更新检查(开发者配置) | ||
| ;; COPYRIGHT : (C) 2026 Mogan STEM authors | ||
| ;; | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
|
||
| (texmacs-module (utils misc version-update)) | ||
|
|
||
| ;; ============================================ | ||
| ;; 开发者配置区(修改此处调整行为) | ||
| ;; ============================================ | ||
| (define SNOOZE-DAYS 3) ; 稍后提醒间隔,单位:天 | ||
|
|
||
| ;; Mock 远程版本号(用于测试,设为 #f 则使用真实网络请求) | ||
| ;; 示例:(define MOCK-REMOTE-VERSION "2026.3.0") | ||
| (define MOCK-REMOTE-VERSION "2026.3.0") | ||
|
|
||
| ;; 社区版是否显示版本更新提示(用于测试) | ||
| (define VERSION-UPDATE-FOR-COMMUNITY #f) | ||
|
|
||
| (tm-define (version-update-for-community?) | ||
| (:secure #t) | ||
| VERSION-UPDATE-FOR-COMMUNITY) | ||
|
|
||
| (tm-define (set-version-update-for-community! enabled) | ||
| (:secure #t) | ||
| (set! VERSION-UPDATE-FOR-COMMUNITY enabled)) | ||
|
|
||
| ;; ============================================ | ||
| ;; 内部实现 | ||
| ;; ============================================ | ||
|
|
||
| ;; 获取/设置 Mock 远程版本号(用于测试) | ||
| (tm-define (get-mock-remote-version) | ||
| (:secure #t) | ||
| MOCK-REMOTE-VERSION) | ||
|
|
||
| (tm-define (set-mock-remote-version! version) | ||
| (:secure #t) | ||
| (set! MOCK-REMOTE-VERSION version)) | ||
|
|
||
| (define LAST-CHECK-KEY "version_last_check") | ||
greptile-apps[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| (define IGNORED-VERSION-KEY "version_ignored") | ||
| (define SNOOZE-UNTIL-KEY "version_snooze_until") | ||
|
|
||
| (define (current-timestamp) | ||
| (current-time)) | ||
|
|
||
| ;; 检查是否应该检查更新(考虑稍后提醒时间) | ||
| (tm-define (should-check-version-update?) | ||
| (:secure #t) | ||
| (let* ((now (current-timestamp)) | ||
| (snooze-until (or (persistent-get (get-texmacs-home-path) SNOOZE-UNTIL-KEY) "0")) | ||
| (snooze-time (if (== snooze-until "") 0 (string->number snooze-until)))) | ||
| (>= now snooze-time))) | ||
|
|
||
| ;; 强制清除所有记录(用于测试) | ||
| (tm-define (clear-version-update-history) | ||
| (:secure #t) | ||
| (persistent-remove (get-texmacs-home-path) SNOOZE-UNTIL-KEY) | ||
| (persistent-remove (get-texmacs-home-path) IGNORED-VERSION-KEY) | ||
| (display "Version update history cleared\n")) | ||
|
|
||
| ;; 稍后提醒(使用默认间隔) | ||
| (tm-define (snooze-version-update) | ||
| (:secure #t) | ||
| (let* ((now (current-timestamp)) | ||
| (future (+ now (* SNOOZE-DAYS 24 3600)))) | ||
| (persistent-set (get-texmacs-home-path) SNOOZE-UNTIL-KEY | ||
| (number->string future)))) | ||
|
|
||
| ;; 跳过此版本 | ||
| (tm-define (ignore-version version) | ||
| (:secure #t) | ||
| (persistent-set (get-texmacs-home-path) IGNORED-VERSION-KEY version) | ||
| (persistent-remove (get-texmacs-home-path) SNOOZE-UNTIL-KEY)) | ||
|
|
||
| ;; 检查版本是否被忽略 | ||
| (tm-define (is-version-ignored? version) | ||
| (:secure #t) | ||
| (== (persistent-get (get-texmacs-home-path) IGNORED-VERSION-KEY) version)) | ||
|
|
||
| ;; 获取下载页URL | ||
| (tm-define (get-update-download-url) | ||
| (:secure #t) | ||
| (if (== (get-output-language) "chinese") | ||
| "https://liiistem.cn/install.html" | ||
GatsbyUSTC marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "https://liiistem.com/install.html")) | ||
GatsbyUSTC marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # 202_112 版本更新提示功能 | ||
|
|
||
| ## 2026年3月26日 | ||
|
|
||
| ### 如何测试 | ||
|
|
||
| **步骤1:清除历史记录(如需重置)** | ||
| 在 Scheme 会话中执行: | ||
| ```scheme | ||
| (clear-version-update-history) | ||
| ``` | ||
|
|
||
| **步骤2:在 Scheme 会话中配置测试参数** | ||
| ;; 如果是社区版,先开启版本更新提示,默认设置 Mock 远程版本("2026.3.0" 比当前版本高) | ||
| (set-version-update-for-community! #t) | ||
|
|
||
| **步骤3:重启应用**,等待10秒后查看提示条是否显示 | ||
|
|
||
| #### 3. 测试要点 | ||
| - 新版本可用时正确显示提示条 | ||
| - 点击"立即更新"打开浏览器,提示条不消失 | ||
| - 点击"稍后提醒"3天后再次提示 | ||
| - 版本号比较正确(如 2026.10.0 > 2026.2.0) | ||
| - 社区版通过 Scheme 指令可开启测试 | ||
|
|
||
| --- | ||
|
|
||
| ### What | ||
| 实现版本更新提示功能,当有新版本可用时,在窗口顶部显示提示条,引导用户更新到最新版本。 | ||
|
|
||
| ### 功能特性 | ||
| 1. **自动检查版本** - 启动后延迟10秒自动检查远程版本 | ||
| 2. **语义化版本比较** - 正确比较版本号(如 2026.10.0 > 2026.2.0) | ||
| 3. **多语言支持** - 根据语言环境显示不同官网链接 | ||
| 4. **社区版测试支持** - 通过 Scheme 指令可在社区版开启测试 | ||
|
|
||
| ### 用户操作按钮 | ||
| - **立即更新** - 打开浏览器跳转到官网下载页,提示条保持显示 | ||
| - **稍后提醒** - 3天后(开发者可配置)再次提示 | ||
| - **关闭** - 仅隐藏当前会话 | ||
|
|
||
| ### 新增文件 | ||
| ``` | ||
| src/Plugins/QWindowKit/updatenotificationbar.hpp | ||
| src/Plugins/QWindowKit/updatenotificationbar.cpp | ||
| TeXmacs/progs/utils/misc/version-update.scm | ||
| ``` | ||
|
|
||
| ### 修改文件 | ||
| ``` | ||
| src/Plugins/Qt/qt_tm_widget.hpp | ||
| src/Plugins/Qt/qt_tm_widget.cpp | ||
| TeXmacs/misc/themes/liii.css | ||
| TeXmacs/misc/themes/liii-night.css | ||
| TeXmacs/plugins/lang/dic/en_US/zh_CN.scm | ||
| ``` | ||
|
|
||
| ### 开发者配置 | ||
| 在 `TeXmacs/progs/utils/misc/version-update.scm` 中: | ||
|
|
||
| ```scheme | ||
| ;; 配置稍后提醒间隔(单位:天) | ||
| (define SNOOZE-DAYS 3) | ||
|
|
||
| ;; Mock 远程版本用于测试 | ||
| (define MOCK-REMOTE-VERSION "2026.3.0") | ||
|
|
||
| ;; 社区版开启版本更新提示(用于测试) | ||
| (set-version-update-for-community! #t) | ||
| ``` | ||
|
|
||
| ### Scheme 控制接口 | ||
| ```scheme | ||
| (use-modules (utils misc version-update)) | ||
|
|
||
| ;; 检查是否应该检查更新 | ||
| (should-check-version-update?) | ||
|
|
||
| ;; Mock 版本控制(用于测试) | ||
| (get-mock-remote-version) | ||
| (set-mock-remote-version! "2026.3.0") | ||
|
|
||
| ;; 稍后提醒 | ||
| (snooze-version-update) | ||
|
|
||
| ;; 清除所有记录 | ||
| (clear-version-update-history) | ||
|
|
||
| ;; 社区版控制 | ||
| (version-update-for-community?) | ||
| (set-version-update-for-community! #t) | ||
| ``` | ||
|
|
||
| ### UI 布局 | ||
| 版本更新提示条和登录提示条垂直堆叠显示: | ||
| ``` | ||
| ┌─────────────────────────────────────────┐ | ||
| │ 🎉 发现新版本 v2026.3.0(当前 v2026.2.1)│ | ||
| │ [立即更新] [稍后提醒] [×] │ | ||
| ├─────────────────────────────────────────┤ | ||
| │ 访客登录提示条(如有) │ | ||
| │ [立即登录] [×] │ | ||
| └─────────────────────────────────────────┘ | ||
| ``` | ||
|
|
||
| ### 官网链接 | ||
| - 中文:`https://liiistem.cn/install.html` | ||
| - 英文:`https://liiistem.com/install.html` | ||
|
|
||
| ### 记录存储位置 | ||
| | 平台 | 路径 | | ||
| |------|------| | ||
| | macOS | `~/Library/Application Support/moganlab/system/_/` | | ||
| | Linux | `~/.local/share/moganlab/system/_/` | | ||
| | Windows | `%APPDATA%/moganlab/system/_/` | | ||
|
|
||
| ### 提示显示判定逻辑 | ||
|
|
||
| 版本更新提示条的显示需要满足以下条件(按顺序检查): | ||
|
|
||
| ``` | ||
| 应用启动 | ||
| ↓ | ||
| 延迟10秒 | ||
| ↓ | ||
| 检查商业版/社区版开关 ──否──→ 结束(不显示) | ||
| ↓ 是(商业版 或 社区版已开启测试) | ||
| 检查稍后提醒时间 ──否──→ 结束(不显示) | ||
| ↓ 是(当前时间 > 设置的稍后提醒时间) | ||
| 获取远程版本号(Mock优先) | ||
| ↓ | ||
| 语义化版本比较(只比较前三位数字) | ||
| ↓ | ||
| 远程版本 > 本地版本 ──否──→ 结束(不显示) | ||
| ↓ 是 | ||
| 显示提示条 | ||
| ``` | ||
|
|
||
| **关键判定条件:** | ||
|
|
||
| | 检查项 | 说明 | Scheme变量/函数 | | ||
| |--------|------|-----------------| | ||
| | 社区版开关 | 社区版默认关闭,需手动开启 | `VERSION-UPDATE-FOR-COMMUNITY` | | ||
| | 稍后提醒时间 | 用户点击"稍后提醒"后记录的时间戳 | `version_snooze_until` | | ||
| | 版本号比较 | 取前三位数字比较,如 `2026.10.0` vs `2026.2.1` | `isVersionNewer()` | | ||
|
|
||
| **注意:** 目前没有"跳过此版本"功能,用户只能选择"稍后提醒"或保持提示条显示。 | ||
|
|
||
| ### Why | ||
| 帮助用户及时获取最新版本,提升用户体验和软件安全性。 | ||
|
|
||
| ### How | ||
| 1. 启动后延迟10秒检查版本 | ||
| 2. Mock 版本优先于网络请求(用于测试) | ||
| 3. 语义化版本号比较(取前三位数字) | ||
| 4. 商业版默认开启,社区版可通过 Scheme 指令测试 | ||
| 5. 用户操作后记录状态到本地持久化存储 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.