diff --git a/wwwroot/index.ui b/wwwroot/index.ui index c9d99c15..4a64f722 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -1,8 +1,3 @@ -{% set userorgid = get_userorgid() %} -{% set sor = db.sqlorContext() %} -{% set org = sor.execute_sql('SELECT orgname, iconid FROM organization WHERE id = ${orgid}$', {'orgid': userorgid}).first() %} -{% set orgname = org.orgname if org and org.orgname else 'OpenComputing' %} -{% set icon = org.iconid if org and org.iconid else 'imgs/ocai.svg' %} { "widgettype": "VBox", "options": { @@ -43,17 +38,19 @@ }, { "widgettype": "Svg", + "id": "tenant_logo", "options": { "css": "sage-logo", "rate": 2, - "url": "{{entire_url('/appbase/show_icon.dspy')}}?id={{icon}}" + "url": "{{entire_url('/imgs/ocai.svg')}}" } }, { "widgettype": "Title4", + "id": "tenant_brand_title", "options": { "css": "sage-brand-title", - "text": "{{orgname}}", + "text": "元境", "fontWeight": "bold", "marginLeft": "8px" } @@ -111,6 +108,15 @@ "url": "{{entire_url('/rbac/user/user_panel.ui')}}" } } + ], + "binds": [ + { + "wid": "app", + "event": "user_logined", + "actiontype": "script", + "target": "self", + "script": "fetch('{{entire_url('/tenant_brand_data.dspy')}}').then(r=>r.json()).then(d=>{var l=bricks.getWidgetById('tenant_logo',bricks.app);if(l&&d.iconid)l.opts.url='{{entire_url('/appbase/show_icon.dspy')}}?id='+d.iconid;l.refresh();var t=bricks.getWidgetById('tenant_brand_title',bricks.app);if(t)t.opts.text=d.orgname;t.refresh();})" + } ] }, { diff --git a/wwwroot/tenant_brand_data.dspy b/wwwroot/tenant_brand_data.dspy new file mode 100644 index 00000000..1c330e66 --- /dev/null +++ b/wwwroot/tenant_brand_data.dspy @@ -0,0 +1,10 @@ +# 返回租户品牌数据(系统名+图标) +userorgid = await get_userorgid() +env = request._run_ns +async with get_sor_context(env, 'sage') as sor: + orgs = await sor.sqlExe('SELECT orgname, iconid FROM organization WHERE id = ${orgid}$', {'orgid': userorgid}) + org = orgs[0] if orgs else None + orgname = org.orgname if org and org.orgname else 'OpenComputing' + iconid = org.iconid if org and org.iconid else '' + +result = json.dumps({"orgname": orgname, "iconid": iconid}, ensure_ascii=False)