From c77177155831e3228d581b4ad8f71e7fd9769e73 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 1 Jul 2026 13:55:22 +0800 Subject: [PATCH] bugfix --- json/upapp.json | 118 +++++++++++++++++++++++++++++++++++++++++-- models/upapp.json | 8 +-- scripts/load_path.py | 2 + uapi/init.py | 15 ++++++ 4 files changed, 132 insertions(+), 11 deletions(-) diff --git a/json/upapp.json b/json/upapp.json index e234cd1..4eb7f9b 100644 --- a/json/upapp.json +++ b/json/upapp.json @@ -6,6 +6,116 @@ "sortby":"name", "logined_userorgid":"ownerid", "confidential_fields":["secretkey"], + "toolbar":{ + "tools":[ + { + "name":"jumpin", + "label":"跳转到", + "selected_data":true + }, + { + "selected_row":true, + "name":"upappkey", + "icon":"{{entire_url('/imgs/upappkey.svg')}}", + "label":"APIKEY" + }, + { + "selected_row":true, + "name":"uapi", + "icon":"{{entire_url('/imgs/uapi.svg')}}", + "label":"API" + }, + { + "selected_row":true, + "name":"copy_api", + "label":"复制API" + } + ] + }, + "binds":[ + { + "wid":"self", + "event":"jumpin", + "actiontype":"urlwidget", + "target":"self", + "options":{ + "url":"{{entire_url('/uapi/jump_in.dspy')}}" + } + }, + { + "wid":"self", + "event":"upappkey", + "actiontype":"urlwidget", + "target":"PopupWindow", + "popup_options":{ + "title":"APIKEY", + "icon":"{{entire_url('/appbase/get_icon.dspy')}}?id=upappkey", + "resizable":true, + "height":"70%", + "width":"70%" + }, + "params_mapping":{ + "mapping":{ + "id":"upappid", + "referer_widget":"referer_widget" + }, + "need_other":false + }, + "options":{ + "method":"POST", + "params":{}, + "url":"{{entire_url('../upappkey')}}" + } + }, + { + "wid":"self", + "event":"uapi", + "actiontype":"urlwidget", + "target":"PopupWindow", + "popup_options":{ + "title":"API", + "icon":"{{entire_url('/appbase/get_icon.dspy')}}?id=uapi", + "resizable":true, + "height":"70%", + "width":"70%" + }, + "params_mapping":{ + "mapping":{ + "id":"upappid", + "referer_widget":"referer_widget" + }, + "need_other":false + }, + "options":{ + "method":"POST", + "params":{}, + "url":"{{entire_url('../uapi')}}" + } + }, + { + "wid":"self", + "event":"copy_api", + "actiontype":"urlwidget", + "target":"PopupWindow", + "popup_options":{ + "title":"复制API到其他上位系统", + "dismiss_events":["cancel","submited"], + "height":"auto", + "width":"500px" + }, + "params_mapping":{ + "mapping":{ + "id":"upappid" + }, + "need_other":false + }, + "options":{ + "method":"GET", + "params":{}, + "url":"{{entire_url('../copy_uapi.ui')}}" + } + } + ], "browserfields":{ "exclouded":["ownerid"], "alters":{} @@ -14,13 +124,13 @@ "subtables":[ { "field":"upappid", - "subtable": "upappkey", - "title": "APIKEY" + "subtable":"upappkey", + "title":"APIKEY" }, { "field":"upappid", - "subtable": "uapi", - "title": "API" + "subtable":"uapi", + "title":"API" } ] } diff --git a/models/upapp.json b/models/upapp.json index cf87b9c..ca07f99 100644 --- a/models/upapp.json +++ b/models/upapp.json @@ -34,12 +34,6 @@ "length": 32, "nullable": "yes" }, - { - "name": "apisetid", - "title": "api集id", - "type": "str", - "length": 32 - }, { "name": "secretkey", "title": "加密密钥", @@ -80,4 +74,4 @@ "textfield": "orgname" } ] -} \ No newline at end of file +} diff --git a/scripts/load_path.py b/scripts/load_path.py index 8a758ce..26eacb2 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -23,6 +23,8 @@ paths = [ ("/uapi/minimax_callback.dspy", "any"), ("/uapi/uptask_callback.dspy", "any"), ("/uapi/viducallback", "any"), + ("/uapi/copy_uapi.ui", "logined"), + ("/uapi/api/copy_uapi.dspy", "logined"), ] diff --git a/uapi/init.py b/uapi/init.py index 8e49e78..a6e7e89 100644 --- a/uapi/init.py +++ b/uapi/init.py @@ -1,4 +1,5 @@ from ahserver.serverenv import ServerEnv +from sqlor.dbpools import get_sor_context from .appapi import ( UAPI, deerer, @@ -17,6 +18,19 @@ from .uptask import ( from .uapi import UpAppApi from .apidata import UAPIData +async def get_upapps_for_copy(request): + """获取所有upapp供复制API时选择目标(排除源upapp)""" + source_upappid = (request._run_ns.params_kw or {}).get('upappid', '') + env = ServerEnv() + async with get_sor_context(env, 'uapi') as sor: + sql = "select id as value, name as text from upapp" + ns = {} + if source_upappid: + sql += " where id != ${source_upappid}$" + ns['source_upappid'] = source_upappid + recs = await sor.sqlExe(sql, ns) + return recs + def load_uapi(): g = ServerEnv() g.UAPI = UAPI @@ -32,6 +46,7 @@ def load_uapi(): g.get_my_uptasks = get_my_uptasks g.uptask_feedback = uptask_feedback g.uptask_started = uptask_started + g.get_upapps_for_copy = get_upapps_for_copy # Bind hot_reload event — instance method, WeakMethod safe (stored on g) if hasattr(g, 'event_dispatcher'): g.event_dispatcher.bind('hot_reload', g.uapi_data.on_hot_reload)