fix: pricing as string, fixed cwidth 25, pagination (20/page)

- Handle llm.pricing_display when it's a string (not array)
- Card cwidth 15→25 to fill DynamicColumn properly
- Added page/page_size pagination with prev/next buttons
- page param forwarded through model_plaza→plaza_model_cards
This commit is contained in:
yumoqing 2026-07-29 13:37:58 +08:00
parent 7148656f99
commit 8a3d30c0c6
2 changed files with 122 additions and 76 deletions

View File

@ -135,7 +135,7 @@
"id": "plaza_cards",
"options": {
"period_seconds": 0,
"url": "{{entire_url('plaza_model_cards.ui')}}?providerid={{active_provider}}&catelogid={{active_catelog}}&search={{active_search}}",
"url": "{{entire_url('plaza_model_cards.ui')}}?providerid={{active_provider}}&catelogid={{active_catelog}}&search={{active_search}}&page={{params_kw.get('page','1')}}",
"css": "filler",
"width": "100%",
"height": "100%"

View File

@ -1,15 +1,22 @@
{% set providerid = params_kw.get('providerid', '') %}
{% set catelogid = params_kw.get('catelogid', '') %}
{% set search = params_kw.get('search', '') %}
{% set data = get_plaza_models(providerid, catelogid, search) %}
{% set page = (params_kw.get('page', '1') | int) %}
{% set page_size = 20 %}
{% set all_data = get_plaza_models(providerid, catelogid, search) %}
{% set total = all_data | length %}
{% set total_pages = ((total + page_size - 1) / page_size) | int %}
{% set start = (page - 1) * page_size %}
{% set end = [start + page_size, total] | min %}
{% set data = all_data[start:end] %}
{% set ns = namespace(first=true) %}
{
"widgettype": "VBox",
"options": {"css": "filler", "width": "100%", "height": "100%"},
"subwidgets": [
{
"widgettype": "VScrollPanel",
"options": {
"css": "filler",
"width": "100%",
"height": "100%"
},
"options": {"css": "filler", "flex": "1", "width": "100%"},
"subwidgets": [
{
"widgettype": "DynamicColumn",
@ -26,8 +33,8 @@
"widgettype": "VBox",
"options": {
"css": "card plaza-card",
"cwidth": 15,
"cheight": 12
"cwidth": 25,
"cheight": 14
},
"subwidgets": [
{
@ -58,11 +65,16 @@
}
}
{% if llm.pricing_display %}
{% if llm.pricing_display is string %}
{% set pricing_items = [llm.pricing_display] %}
{% else %}
{% set pricing_items = llm.pricing_display %}
{% endif %}
,{
"widgettype": "VBox",
"options": {"css": "filler"},
"subwidgets": [
{% for pt in llm.pricing_display %}
{% for pt in pricing_items %}
{
"widgettype": "Text",
"options": {
@ -107,4 +119,38 @@
]
}
]
},
{% if total_pages > 1 %}
{
"widgettype": "HBox",
"options": {"width": "100%", "cheight": 3, "gap": "8px", "alignItems": "center", "justifyContent": "center", "padding": "8px 0"},
"subwidgets": [
{% if page > 1 %}
{
"widgettype": "Button",
"options": {"label": "上一页", "cwidth": 10},
"binds": [{
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
"script": "var t=bricks.getWidgetById('sage_main_content',bricks.app);if(t){t.clear_widgets();bricks.widgetBuild({widgettype:'urlwidget',options:{url:'{{entire_url('model_plaza.ui')}}?providerid={{providerid}}&catelogid={{catelogid}}&search={{search}}&page={{page - 1}}'}},t);}"
}]
},
{% endif %}
{
"widgettype": "Text",
"options": {"text": "{{page}} / {{total_pages}} (共{{total}}个)"}
},
{% if page < total_pages %}
{
"widgettype": "Button",
"options": {"label": "下一页", "cwidth": 10},
"binds": [{
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
"script": "var t=bricks.getWidgetById('sage_main_content',bricks.app);if(t){t.clear_widgets();bricks.widgetBuild({widgettype:'urlwidget',options:{url:'{{entire_url('model_plaza.ui')}}?providerid={{providerid}}&catelogid={{catelogid}}&search={{search}}&page={{page + 1}}'}},t);}"
}]
}
{% endif %}
]
}
{% endif %}
]
}