-
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 all commits
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,85 @@ | ||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| ;; | ||
| ;; 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 #f) | ||
|
|
||
| ;; ============================================ | ||
| ;; 内部实现 | ||
| ;; ============================================ | ||
|
|
||
| ;; 获取 Mock 远程版本号(优先从持久化存储读取) | ||
| (tm-define (get-mock-remote-version) | ||
| (:secure #t) | ||
| (let ((stored (persistent-get (get-texmacs-home-path) MOCK-VERSION-KEY))) | ||
| (if (and stored (!= stored "")) | ||
| stored | ||
| MOCK-REMOTE-VERSION))) | ||
|
|
||
| ;; 设置 Mock 远程版本号(同时保存到持久化存储) | ||
| (tm-define (set-mock-remote-version! version) | ||
| (:secure #t) | ||
| (set! MOCK-REMOTE-VERSION version) | ||
| (persistent-set (get-texmacs-home-path) MOCK-VERSION-KEY version)) | ||
|
|
||
| ;; 清除 Mock 远程版本号(恢复默认 #f) | ||
| (tm-define (clear-mock-remote-version) | ||
| (:secure #t) | ||
| (set! MOCK-REMOTE-VERSION #f) | ||
| (persistent-remove (get-texmacs-home-path) MOCK-VERSION-KEY)) | ||
|
|
||
| (define LAST-CHECK-KEY "version_last_check") | ||
| (define SNOOZE-UNTIL-KEY "version_snooze_until") | ||
| (define MOCK-VERSION-KEY "version_mock_remote") | ||
|
|
||
| (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) | ||
| (clear-mock-remote-version)) | ||
|
|
||
| ;; 稍后提醒(使用默认间隔) | ||
| (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)))) | ||
|
|
||
| ;; 获取下载页URL | ||
| ;; 社区版跳转到 mogan.app,商业版跳转到 liiistem.cn/com | ||
| (tm-define (get-update-download-url) | ||
| (:secure #t) | ||
| (if (community-stem?) | ||
| ;; 社区版官网 | ||
| (if (== (get-output-language) "chinese") | ||
| "https://mogan.app/zh/" | ||
| "https://mogan.app/en/") | ||
| ;; 商业版官网 | ||
| (if (== (get-output-language) "chinese") | ||
| "https://liiistem.cn/install.html" | ||
| "https://liiistem.com/install.html"))) | ||
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.