diff --git a/api.py b/api.py index 52c97c8..f68afa4 100644 --- a/api.py +++ b/api.py @@ -1036,6 +1036,28 @@ async def use_account_token(id: int): error(traceback.format_exc()) return {"success": False, "message": f"使用Token失败: {str(e)}"} +# 添加"重置设备id"功能 +@app.get("/reset-machine", tags=["System"]) +async def reset_machine(): + """重置设备id""" + try: + # 重置Cursor的机器ID + from cursor_shadow_patcher import CursorShadowPatcher + + resetter = CursorShadowPatcher() + patch_success = resetter.reset_machine_ids() + if patch_success: + return { + "success": True, + "message": f"成功重置了机器ID", + } + else: + return {"success": False, "message": "重置机器ID失败"} + except Exception as e: + error(f"重置机器ID失败: {str(e)}") + error(traceback.format_exc()) + return {"success": False, "message": f"重置机器ID失败: {str(e)}"} + # 添加配置相关模型 class ConfigModel(BaseModel): diff --git a/index.html b/index.html index 067fc9c..ada8329 100644 --- a/index.html +++ b/index.html @@ -382,6 +382,28 @@ + +
+
+
系统维护
+
+
+
+
+ +

某些配置更改需要重启服务才能生效

+
+
+ +

解决设备绑定或配额限制问题

+
+
+
+
diff --git a/static/css/styles.css b/static/css/styles.css index 2163142..9c65bf4 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -898,3 +898,33 @@ h2, h3, h4, h5 { border-color: #86b7fe; box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25); } + +/* 系统维护按钮样式 - 更新蓝色按钮样式 */ +.config-section .btn-danger, +.config-section .btn-primary { + transition: all 0.3s ease; + font-weight: 500; +} + +.config-section .btn-primary { + background-color: #0b5ed7; + border-color: #0a58ca; +} + +.config-section .btn-danger:hover { + background-color: #dc2626; + box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3); + transform: translateY(-2px); +} + +.config-section .btn-primary:hover { + background-color: #0a4fbf; + box-shadow: 0 4px 8px rgba(11, 94, 215, 0.3); + transform: translateY(-2px); +} + +/* 系统维护卡片强调 */ +.config-section.card { + border-color: #e2e8f0; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); +} diff --git a/static/js/app.js b/static/js/app.js index 6d12278..42fe86d 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -96,6 +96,17 @@ function bindEventHandlers() { } ); }); + + // 重置机器ID按钮事件 + $("#reset-machine-btn").click(function() { + showConfirmDialog( + '重置机器ID', + '确定要重置机器ID吗?这将解除当前设备的绑定限制,但可能需要重新登录所有账号。', + function() { + resetMachineId(); + } + ); + }); } // 全局变量 @@ -1529,4 +1540,37 @@ function formatTimeLeft(seconds) { const minutes = Math.floor((seconds % 3600) / 60); return `${hours}小时${minutes}分`; } +} + +// 添加重置机器ID函数 +function resetMachineId() { + showLoading(); + + $.ajax({ + url: '/reset-machine', + method: 'GET', + success: function(response) { + hideLoading(); + if (response.success) { + showAlert('success', '成功重置机器ID。' + (response.message || '')); + + // 询问是否需要重启服务以应用更改 + setTimeout(function() { + showConfirmDialog( + '重启服务', + '机器ID已重置,建议重启服务以确保更改生效。是否立即重启?', + function() { + restartService(); + } + ); + }, 1000); + } else { + showAlert('danger', '重置机器ID失败: ' + (response.message || '未知错误')); + } + }, + error: function(xhr) { + hideLoading(); + showAlert('danger', '重置机器ID失败: ' + (xhr.responseJSON?.message || xhr.statusText || '未知错误')); + } + }); } \ No newline at end of file