feat(t103): daemon 偵測雲端過舊+托盤更新入口——連動閉環
每輪 GET /health 取 bundle_version(5s timeout 失敗靜默);空或日期<minCloudBuilt → 托盤「⚠ 知識庫需要更新(點我)」開 install.arcrun.dev;結果進 status.json。 兩模組 go test 全綠(總管親跑)。leo:「daemon 和雲端是連動的」——自此用戶只看托盤。 (實作=子 CC;驗證+commit=總管)
This commit is contained in:
@@ -90,6 +90,28 @@ type traySyncStatus struct {
|
||||
Failures []trayExtFail `json:"failures,omitempty"`
|
||||
ExtractorOK bool `json:"extractor_ok"`
|
||||
ExtractorError string `json:"extractor_error,omitempty"`
|
||||
// t103:雲端版本偵測
|
||||
CloudVersion string `json:"cloud_version,omitempty"` // collector 每輪 GET /health 取得的 bundle_version
|
||||
CloudCheckOK bool `json:"cloud_check_ok"` // /health 可達才 true;false 不判定(靜默)
|
||||
}
|
||||
|
||||
// ── t103 雲端版本偵測 ──────────────────────────────────────────────────────────
|
||||
|
||||
// trayMinCloudBuilt 是雲端最低相容建置日期;與 collector/cloud_version.go 的 minCloudBuilt 保持同值。
|
||||
// 雲端契約變更時兩處一起升。
|
||||
const trayMinCloudBuilt = "2026-07-28"
|
||||
|
||||
// trayCloudVersionStale 判斷雲端是否需要更新(同 collector/cloudVersionStale 邏輯)。
|
||||
// checkOK=false(/health 不可達)回 false(靜默不判定)。
|
||||
func trayCloudVersionStale(version string, checkOK bool) bool {
|
||||
if !checkOK {
|
||||
return false
|
||||
}
|
||||
if version == "" {
|
||||
return true
|
||||
}
|
||||
date := strings.SplitN(version, "+", 2)[0]
|
||||
return date < trayMinCloudBuilt
|
||||
}
|
||||
|
||||
type trayExtFail struct {
|
||||
@@ -665,6 +687,14 @@ func main() {
|
||||
})
|
||||
items = append(items, failItem)
|
||||
}
|
||||
// t103:雲端版本過舊(或老實例)時提示用戶更新,點了開瀏覽器到安裝頁。
|
||||
if trayCloudVersionStale(sync.CloudVersion, sync.CloudCheckOK) {
|
||||
items = append(items, fyne.NewMenuItem("⚠ 知識庫需要更新(點我)", func() {
|
||||
if u, err := neturl.Parse("https://install.arcrun.dev/"); err == nil {
|
||||
_ = a.OpenURL(u)
|
||||
}
|
||||
}))
|
||||
}
|
||||
items = append(items, fyne.NewMenuItemSeparator())
|
||||
for _, f := range cfg.Folders() {
|
||||
folder := f // capture
|
||||
|
||||
Reference in New Issue
Block a user