1. json/downapp.json: 添加更新和删除工具栏按钮,移除noedit限制 2. wwwroot/update_apikey.dspy: 查询并返回预填充的更新表单 3. wwwroot/do_update_apikey.dspy: 处理更新表单提交 4. wwwroot/delete_apikey.dspy: 删除API Key及关联应用 5. wwwroot/apikey_manage.ui: 独立API Key管理页面 6. scripts/load_path.py: 使用通配符%/dapi/%注册所有路径
88 lines
1.8 KiB
Plaintext
88 lines
1.8 KiB
Plaintext
debug(f'{params_kw=}')
|
||
dbname = get_module_dbname('dapi')
|
||
db = DBPools()
|
||
userid = await get_user()
|
||
orgid = await get_userorgid()
|
||
if not userid:
|
||
return {
|
||
"widgettype": "Text",
|
||
"options": {"text": "需要登录"}
|
||
}
|
||
|
||
try:
|
||
async with db.sqlorContext(dbname) as sor:
|
||
# 查询当前downapp信息
|
||
ns = {
|
||
"id": params_kw.id,
|
||
"orgid": orgid
|
||
}
|
||
sql = """select * from downapp
|
||
where id = ${id}$ and orgid = ${orgid}$"""
|
||
recs = await sor.sqlExe(sql, ns)
|
||
if not recs:
|
||
return {
|
||
"widgettype": "Text",
|
||
"options": {"text": "API Key不存在或无权访问"}
|
||
}
|
||
|
||
r = recs[0]
|
||
# 返回预填充的表单
|
||
return {
|
||
"widgettype": "Form",
|
||
"options": {
|
||
"title": "更新API Key",
|
||
"description": "更新应用信息和API Key配置",
|
||
"fields": [
|
||
{
|
||
"name": "id",
|
||
"label": "应用ID",
|
||
"uitype": "str",
|
||
"value": r.id,
|
||
"readonly": True
|
||
},
|
||
{
|
||
"name": "appname",
|
||
"label": "应用名称",
|
||
"uitype": "str",
|
||
"value": r.name,
|
||
"required": True
|
||
},
|
||
{
|
||
"name": "description",
|
||
"label": "应用描述",
|
||
"uitype": "text",
|
||
"value": r.description or ""
|
||
},
|
||
{
|
||
"name": "allowedips",
|
||
"label": "允许的IP集",
|
||
"uitype": "str",
|
||
"value": r.allowedips or "",
|
||
"placeholder": "多个IP用逗号分隔"
|
||
},
|
||
{
|
||
"name": "regenerate_apikey",
|
||
"label": "重新生成API Key",
|
||
"uitype": "checkbox",
|
||
"description": "勾选后将重新生成API Key,原Key将失效"
|
||
}
|
||
]
|
||
},
|
||
"binds": [
|
||
{
|
||
"wid": "self",
|
||
"event": "submit",
|
||
"actiontype": "urlwidget",
|
||
"target": "self",
|
||
"options": {
|
||
"url": "{{entire_url('/dapi/do_update_apikey.dspy')}}"
|
||
}
|
||
}
|
||
]
|
||
}
|
||
except Exception as e:
|
||
return {
|
||
"widgettype": "Text",
|
||
"options": {"text": f"错误: {e}"}
|
||
}
|