fix(home): 门户导航binds误塞options导致点击无反应——T/TN生成器把binds/id提升到widget顶层(bricks只读顶层binds)+生成器幂等重生成;playwright真点测三导航滚动到位
This commit is contained in:
parent
94d3b11921
commit
7034fbe190
@ -9,24 +9,37 @@ IDX = os.path.join(ROOT, 'wwwroot', 'index.ui')
|
||||
with io.open(IDX, encoding='utf-8') as f:
|
||||
old = f.read()
|
||||
|
||||
# 幂等:已生成过则先还原工作区分支(用 git show HEAD 由调用方保证,这里检测标记)
|
||||
assert '{% if get_user() %}' not in old, 'index.ui 已经是双分支版本,勿重复生成(用 git checkout 还原后重跑)'
|
||||
# 幂等:若已是双分支版本,先抽出工作台分支(old),再重拼门户分支
|
||||
PREFIX = '{% if get_user() %}\n'
|
||||
MARK = '\n{% else %}\n{'
|
||||
if old.startswith(PREFIX):
|
||||
i = old.rfind(MARK)
|
||||
assert i > 0, 'generated file but marker not found'
|
||||
old = old[len(PREFIX):i] + '\n'
|
||||
else:
|
||||
assert '{% if get_user() %}' not in old, 'unexpected mixed file'
|
||||
|
||||
def T(s, css=None, **kw):
|
||||
"""TextBase 三件套:otext+text+i18n(W1 规范)"""
|
||||
"""TextBase 三件套:otext+text+i18n(W1 规范)。binds/id 必须在 widget 顶层(bricks 不读 options.binds)。"""
|
||||
o = {'otext': s, 'text': s, 'i18n': True, 'halign': 'left'}
|
||||
if css:
|
||||
o['css'] = css
|
||||
top = {k: kw.pop(k) for k in ('binds', 'id') if k in kw}
|
||||
o.update(kw)
|
||||
return {'widgettype': 'Text', 'options': o}
|
||||
w = {'widgettype': 'Text', 'options': o}
|
||||
w.update(top)
|
||||
return w
|
||||
|
||||
def TN(s, css=None, **kw):
|
||||
"""不翻译的 Text(数字/英文装饰字)"""
|
||||
"""不翻译的 Text(数字/英文装饰字)。binds/id 同样提到顶层。"""
|
||||
o = {'text': s, 'halign': 'left'}
|
||||
if css:
|
||||
o['css'] = css
|
||||
top = {k: kw.pop(k) for k in ('binds', 'id') if k in kw}
|
||||
o.update(kw)
|
||||
return {'widgettype': 'Text', 'options': o}
|
||||
w = {'widgettype': 'Text', 'options': o}
|
||||
w.update(top)
|
||||
return w
|
||||
|
||||
def login_bind():
|
||||
return {'wid': 'self', 'event': 'click', 'actiontype': 'urlwidget', 'target': 'self',
|
||||
|
||||
@ -724,6 +724,7 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
{% else %}
|
||||
{
|
||||
"id": "app",
|
||||
@ -796,17 +797,17 @@
|
||||
"i18n": true,
|
||||
"halign": "left",
|
||||
"css": "pl-nav",
|
||||
"mobile_hidden": true,
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_caps\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
}
|
||||
"mobile_hidden": true
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_caps\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
@ -816,17 +817,17 @@
|
||||
"i18n": true,
|
||||
"halign": "left",
|
||||
"css": "pl-nav",
|
||||
"mobile_hidden": true,
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_pipes\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
}
|
||||
"mobile_hidden": true
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_pipes\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
@ -836,17 +837,17 @@
|
||||
"i18n": true,
|
||||
"halign": "left",
|
||||
"css": "pl-nav",
|
||||
"mobile_hidden": true,
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_flow\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
}
|
||||
"mobile_hidden": true
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var e=document.getElementById(\"sec_flow\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user