diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e7b4f..52b0eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa ## Version 2026.10.12-it-tools-pro +### 🔑 修复:换电脑登录已授权账号仍提示未授权 +- 后端 `_account_license_ok` 改进:账号持有有效卡、或账号绑定过任一已授权机器,即视为账号已授权——登录该账号的所有设备自动继承授权(卡激活在设备、未关联账号的场景也覆盖) +- 前端授权闸门(LicenseGate)登录/登出后自动重新检查授权,不再停留在首次加载时缓存的「未授权」状态 +- 验证:新机器登录后 auth-status 返回 authorized=true,受控工具直接放行;无关机器仍为未授权 + + 基于 IT-Tools 深度定制的一次大版本更新:新增 7 个 AI 工具、专业编辑器、用户中心与管理后台,授权与体验全面升级。 ### 🤖 新增 AI 工具(受控授权,各 30 分钟免费试用) diff --git a/docker/it-tools-relay/server.py b/docker/it-tools-relay/server.py index d9f6888..0099dca 100644 --- a/docker/it-tools-relay/server.py +++ b/docker/it-tools-relay/server.py @@ -525,7 +525,14 @@ def check(machine: str, tool: str) -> int: def _account_license_ok(machine: str) -> bool: - """True when this device logged into an account holding an active card.""" + """True when this device logged into an authorized account. + + An account is authorized when either: + * it holds an active card (card_key + origin_machine active on CardAuth), or + * it is bound to at least one machine that itself is authorized on CardAuth + (covers cards activated on a device without account context). + Either way, every device that logs into this account inherits the license. + """ try: conn = _db() rows = conn.execute("SELECT card_key, origin_machine, bound_machines FROM users").fetchall() @@ -533,14 +540,20 @@ def _account_license_ok(machine: str) -> bool: except Exception: return False for card_key, origin, bm_json in rows: - if not card_key or not origin: + if not card_key and not bm_json: continue try: machines = json.loads(bm_json or "[]") except Exception: machines = [] - if machine in machines: - if origin == machine or query_authorized(origin): + if machine not in machines: + continue + # account carries an active card + if card_key and origin and (origin == machine or query_authorized(origin)): + return True + # account shares a device that is itself authorized (max 4 lookups, cached) + for bm in machines[:4]: + if bm and bm != machine and bm not in _load_revoked() and query_authorized(bm): return True return False diff --git a/src/tools/license/LicenseGate.vue b/src/tools/license/LicenseGate.vue index 22db1b8..c645459 100644 --- a/src/tools/license/LicenseGate.vue +++ b/src/tools/license/LicenseGate.vue @@ -109,6 +109,12 @@ onMounted(() => { timer = setInterval(() => { now.value = Date.now(); }, 1000); + // 登录/登出后重新检查授权:换电脑登录已授权账号后,立即解除未授权提示 + window.addEventListener('it-tools-auth-changed', init); +}); + +onBeforeUnmount(() => { + window.removeEventListener('it-tools-auth-changed', init); }); // 跨工具路由复用:路径变化时重新走授权检查