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:
|
with io.open(IDX, encoding='utf-8') as f:
|
||||||
old = f.read()
|
old = f.read()
|
||||||
|
|
||||||
# 幂等:已生成过则先还原工作区分支(用 git show HEAD 由调用方保证,这里检测标记)
|
# 幂等:若已是双分支版本,先抽出工作台分支(old),再重拼门户分支
|
||||||
assert '{% if get_user() %}' not in old, 'index.ui 已经是双分支版本,勿重复生成(用 git checkout 还原后重跑)'
|
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):
|
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'}
|
o = {'otext': s, 'text': s, 'i18n': True, 'halign': 'left'}
|
||||||
if css:
|
if css:
|
||||||
o['css'] = css
|
o['css'] = css
|
||||||
|
top = {k: kw.pop(k) for k in ('binds', 'id') if k in kw}
|
||||||
o.update(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):
|
def TN(s, css=None, **kw):
|
||||||
"""不翻译的 Text(数字/英文装饰字)"""
|
"""不翻译的 Text(数字/英文装饰字)。binds/id 同样提到顶层。"""
|
||||||
o = {'text': s, 'halign': 'left'}
|
o = {'text': s, 'halign': 'left'}
|
||||||
if css:
|
if css:
|
||||||
o['css'] = css
|
o['css'] = css
|
||||||
|
top = {k: kw.pop(k) for k in ('binds', 'id') if k in kw}
|
||||||
o.update(kw)
|
o.update(kw)
|
||||||
return {'widgettype': 'Text', 'options': o}
|
w = {'widgettype': 'Text', 'options': o}
|
||||||
|
w.update(top)
|
||||||
|
return w
|
||||||
|
|
||||||
def login_bind():
|
def login_bind():
|
||||||
return {'wid': 'self', 'event': 'click', 'actiontype': 'urlwidget', 'target': 'self',
|
return {'wid': 'self', 'event': 'click', 'actiontype': 'urlwidget', 'target': 'self',
|
||||||
|
|||||||
@ -724,6 +724,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{
|
{
|
||||||
"id": "app",
|
"id": "app",
|
||||||
@ -796,17 +797,17 @@
|
|||||||
"i18n": true,
|
"i18n": true,
|
||||||
"halign": "left",
|
"halign": "left",
|
||||||
"css": "pl-nav",
|
"css": "pl-nav",
|
||||||
"mobile_hidden": true,
|
"mobile_hidden": true
|
||||||
"binds": [
|
},
|
||||||
{
|
"binds": [
|
||||||
"wid": "self",
|
{
|
||||||
"event": "click",
|
"wid": "self",
|
||||||
"actiontype": "script",
|
"event": "click",
|
||||||
"target": "self",
|
"actiontype": "script",
|
||||||
"script": "var e=document.getElementById(\"sec_caps\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
"target": "self",
|
||||||
}
|
"script": "var e=document.getElementById(\"sec_caps\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
@ -816,17 +817,17 @@
|
|||||||
"i18n": true,
|
"i18n": true,
|
||||||
"halign": "left",
|
"halign": "left",
|
||||||
"css": "pl-nav",
|
"css": "pl-nav",
|
||||||
"mobile_hidden": true,
|
"mobile_hidden": true
|
||||||
"binds": [
|
},
|
||||||
{
|
"binds": [
|
||||||
"wid": "self",
|
{
|
||||||
"event": "click",
|
"wid": "self",
|
||||||
"actiontype": "script",
|
"event": "click",
|
||||||
"target": "self",
|
"actiontype": "script",
|
||||||
"script": "var e=document.getElementById(\"sec_pipes\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
"target": "self",
|
||||||
}
|
"script": "var e=document.getElementById(\"sec_pipes\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
@ -836,17 +837,17 @@
|
|||||||
"i18n": true,
|
"i18n": true,
|
||||||
"halign": "left",
|
"halign": "left",
|
||||||
"css": "pl-nav",
|
"css": "pl-nav",
|
||||||
"mobile_hidden": true,
|
"mobile_hidden": true
|
||||||
"binds": [
|
},
|
||||||
{
|
"binds": [
|
||||||
"wid": "self",
|
{
|
||||||
"event": "click",
|
"wid": "self",
|
||||||
"actiontype": "script",
|
"event": "click",
|
||||||
"target": "self",
|
"actiontype": "script",
|
||||||
"script": "var e=document.getElementById(\"sec_flow\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
"target": "self",
|
||||||
}
|
"script": "var e=document.getElementById(\"sec_flow\");if(e){e.scrollIntoView({behavior:'smooth',block:'start'});}"
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype": "Button",
|
"widgettype": "Button",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user