Spaces:
Sleeping
Sleeping
yu commited on
Commit ·
a8f56e0
1
Parent(s): 4ce6178
feat: 账户配置编辑器显示真实配置
Browse files- core/templates.py +3 -12
- main.py +11 -0
core/templates.py
CHANGED
|
@@ -693,18 +693,9 @@ def generate_admin_html(request: Request, show_hide_tip: bool = False) -> str:
|
|
| 693 |
let currentConfig = null;
|
| 694 |
|
| 695 |
async function showEditConfig() {{
|
| 696 |
-
const config = await fetch('/{main.PATH_PREFIX}/admin/accounts?key={main.ADMIN_KEY}').then(r => r.json());
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
csesidx: "***",
|
| 700 |
-
config_id: "***",
|
| 701 |
-
secure_c_ses: "***",
|
| 702 |
-
host_c_oses: null,
|
| 703 |
-
expires_at: acc.expires_at
|
| 704 |
-
}}));
|
| 705 |
-
|
| 706 |
-
currentConfig = accounts;
|
| 707 |
-
const json = JSON.stringify(accounts, null, 2);
|
| 708 |
document.getElementById('jsonEditor').value = json;
|
| 709 |
document.getElementById('jsonError').classList.remove('show');
|
| 710 |
document.getElementById('jsonModal').classList.add('show');
|
|
|
|
| 693 |
let currentConfig = null;
|
| 694 |
|
| 695 |
async function showEditConfig() {{
|
| 696 |
+
const config = await fetch('/{main.PATH_PREFIX}/admin/accounts-config?key={main.ADMIN_KEY}').then(r => r.json());
|
| 697 |
+
currentConfig = config.accounts;
|
| 698 |
+
const json = JSON.stringify(config.accounts, null, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 699 |
document.getElementById('jsonEditor').value = json;
|
| 700 |
document.getElementById('jsonError').classList.remove('show');
|
| 701 |
document.getElementById('jsonModal').classList.add('show');
|
main.py
CHANGED
|
@@ -1070,6 +1070,17 @@ async def admin_get_accounts(path_prefix: str, key: str = None, authorization: s
|
|
| 1070 |
"accounts": accounts_info
|
| 1071 |
}
|
| 1072 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
@app.put("/{path_prefix}/admin/accounts-config")
|
| 1074 |
@require_path_and_admin(PATH_PREFIX, ADMIN_KEY)
|
| 1075 |
async def admin_update_config(path_prefix: str, accounts_data: list = Body(...), key: str = None, authorization: str = Header(None)):
|
|
|
|
| 1070 |
"accounts": accounts_info
|
| 1071 |
}
|
| 1072 |
|
| 1073 |
+
@app.get("/{path_prefix}/admin/accounts-config")
|
| 1074 |
+
@require_path_and_admin(PATH_PREFIX, ADMIN_KEY)
|
| 1075 |
+
async def admin_get_config(path_prefix: str, key: str = None, authorization: str = Header(None)):
|
| 1076 |
+
"""获取完整账户配置"""
|
| 1077 |
+
try:
|
| 1078 |
+
accounts_data = load_accounts_from_source()
|
| 1079 |
+
return {"accounts": accounts_data}
|
| 1080 |
+
except Exception as e:
|
| 1081 |
+
logger.error(f"[CONFIG] 获取配置失败: {str(e)}")
|
| 1082 |
+
raise HTTPException(500, f"获取失败: {str(e)}")
|
| 1083 |
+
|
| 1084 |
@app.put("/{path_prefix}/admin/accounts-config")
|
| 1085 |
@require_path_and_admin(PATH_PREFIX, ADMIN_KEY)
|
| 1086 |
async def admin_update_config(path_prefix: str, accounts_data: list = Body(...), key: str = None, authorization: str = Header(None)):
|