This commit is contained in:
yumoqing 2025-07-31 15:51:00 +08:00
parent ccd01a82ab
commit 3d0253d297
2 changed files with 68 additions and 1 deletions

View File

@ -4,6 +4,7 @@
"params": {
"sortby":"id",
"confidential_fields":["secretkey"],
"noedit":true,
"browserfields": {
"exclouded": ["id", "secretkey" ],
"alters": {}
@ -17,7 +18,50 @@
"title":"apikey",
"subtable":"downapikey"
}
]
],
"toolbar":{
"tools":[
{
"name":"create_apikey",
"label":"创建apikey",
"icon":"{{entire_url('/imgs/newkey.svg')}}"
},
{
"name":"copy_apikey",
"label":"复制apikey",
"icon":"{{entire_url('/imgs/copy.svg')}}"
}
]
},
"binds":[
{
"wid":"self",
"event":"create_apikey",
"actiontype":"urlwidget",
"target":"PopupWindow",
"popup_options":{
"width":"50%",
"height":"50%",
"archor":"cr"
},
"options":{
"url":"{{entire_url('/dapi/create_apikey.ui')}}"
}
},
{
"wid":"self",
"event":"copy_apikey",
"actiontype":"urlwidget",
"target":"PopupWindow",
"popup_options":{
"width":"50%",
"height":"50%",
"archor":"cr"
},
"options":{
"url":"{{entire_url('/dapi/copy_apikey.ui')}}"
}
}
}
}

23
wwwroot/copy_apikey.dspy Normal file
View File

@ -0,0 +1,23 @@
debug(f'{params_kw=}')
dbname = get_module_dbname()
db = DBPools()
async with db.sqlorContext(dbname) as sor:
orgid = await get_userorgid()
userid = await get_user()
ns = {
"id": params_kw.id,
"orgid":orgid,
"userid":"userid
}
sql = """select a.*,
b.apikey
from downapp a, downapikey b
where a.id = b.dappid
and a.id = ${id}$
and a.orgid = ${orgid}$
and b.userid = ${userid}$"""
recs = await sor.sqlExe(sql, ns)
if len(recs):
r = recs[0]
return UiMessage(title="copy apikey", message=f'appid={r.id}, apikey={r.apikey} secretkey={r.secretkey}')
return UiError(title='copy apikey', message='copy apikey error')