asset_id = params_kw.get('asset_id', '') if not asset_id: return json.dumps({ "widgettype": "Error", "options": {"title": "错误", "message": "缺少素材ID"} }) org_id = (await get_userorgid()) or '0' user_id = (await get_user()) or '' result = await rl_sync_asset_status_user(org_id, asset_id, user_id) if result.get('success'): status = result.get('status', '') url = result.get('url', '') msg = f"素材状态:{status}" if url: msg += f"\n下载地址:{url}" subwidgets = [ { "widgettype": "Text", "options": {"text": msg} } ] # If still processing, show a retry button if status and status.lower() in ('processing', 'pending', 'submitted'): base_path = request.path.rsplit('/', 1)[0] check_url = base_path + '/submit_query_status.dspy' subwidgets.append({ "widgettype": "Button", "options": {"label": "再次查询"}, "binds": [ { "wid": "self", "event": "click", "actiontype": "script", "target": "self", "script": "(async function(){" "var url='" + check_url + "?_webbricks_=1&asset_id=" + asset_id + "';" "var r=await fetch(url);" "var j=await r.json();" "await bricks.show_resp_message_or_error({json:async function(){return j}});" "})()" } ] }) return json.dumps({ "widgettype": "Message", "id": "status_result_popup", "options": {"title": "素材状态", "message": ""}, "subwidgets": [ { "widgettype": "VBox", "options": {"padding": "8px", "gap": "12px"}, "subwidgets": subwidgets } ] }) else: return json.dumps({ "widgettype": "Error", "options": {"title": "查询失败", "message": result.get('message', '未知错误')} })