diff --git a/wwwroot/model_plaza.ui b/wwwroot/model_plaza.ui index a93ce28..d443242 100644 --- a/wwwroot/model_plaza.ui +++ b/wwwroot/model_plaza.ui @@ -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%" diff --git a/wwwroot/plaza_model_cards.ui b/wwwroot/plaza_model_cards.ui index d581308..6faf199 100644 --- a/wwwroot/plaza_model_cards.ui +++ b/wwwroot/plaza_model_cards.ui @@ -1,110 +1,156 @@ {% 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": "VScrollPanel", - "options": { - "css": "filler", - "width": "100%", - "height": "100%" - }, + "widgettype": "VBox", + "options": {"css": "filler", "width": "100%", "height": "100%"}, "subwidgets": [ { - "widgettype": "DynamicColumn", - "options": { - "css": "plaza-grid", - "width": "100%", - "col_cwidth": 25, - "col_cgap": 1 - }, + "widgettype": "VScrollPanel", + "options": {"css": "filler", "flex": "1", "width": "100%"}, "subwidgets": [ -{% for llm in data %} -{% if not ns.first %},{% endif %} { - "widgettype": "VBox", + "widgettype": "DynamicColumn", "options": { - "css": "card plaza-card", - "cwidth": 15, - "cheight": 12 + "css": "plaza-grid", + "width": "100%", + "col_cwidth": 25, + "col_cgap": 1 }, "subwidgets": [ +{% for llm in data %} +{% if not ns.first %},{% endif %} { - "widgettype": "HBox", - "options": {"cheight": 2, "alignItems": "center", "gap": "4px"}, + "widgettype": "VBox", + "options": { + "css": "card plaza-card", + "cwidth": 25, + "cheight": 14 + }, "subwidgets": [ { - "widgettype": "Svg", - "options": {"rate": 1.5, "url": "{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}"} + "widgettype": "HBox", + "options": {"cheight": 2, "alignItems": "center", "gap": "4px"}, + "subwidgets": [ + { + "widgettype": "Svg", + "options": {"rate": 1.5, "url": "{{entire_url('/appbase/show_icon.dspy')}}?id={{llm.iconid}}"} + }, + { + "widgettype": "Title6", + "options": {"text": "{{llm.name}}"} + } + ] }, { - "widgettype": "Title6", - "options": {"text": "{{llm.name}}"} - } - ] - }, - { - "widgettype": "VScrollPanel", - "options": {"css": "filler", "flex": "1"}, - "subwidgets": [ - { - "widgettype": "Text", - "options": { - "height": "auto", - "text": {{json.dumps(llm.description, ensure_ascii=False)}}, - "wrap": true, - "halign": "left" - } - } -{% if llm.pricing_display %} - ,{ - "widgettype": "VBox", - "options": {"css": "filler"}, + "widgettype": "VScrollPanel", + "options": {"css": "filler", "flex": "1"}, "subwidgets": [ -{% for pt in llm.pricing_display %} { "widgettype": "Text", "options": { - "text": {{json.dumps(pt, ensure_ascii=False)}}, + "height": "auto", + "text": {{json.dumps(llm.description, ensure_ascii=False)}}, "wrap": true, - "halign": "left", - "css": "pricing-text" + "halign": "left" } - }{% if not loop.last %},{% endif %} + } +{% 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 pricing_items %} + { + "widgettype": "Text", + "options": { + "text": {{json.dumps(pt, ensure_ascii=False)}}, + "wrap": true, + "halign": "left", + "css": "pricing-text" + } + }{% if not loop.last %},{% endif %} {% endfor %} + ] + } +{% endif %} ] } + ], + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "urlwidget", + "target": "PopupWindow", + "popup_options": { + "title": "{{llm.name}}", +{% if int(params_kw._is_mobile or 0) %} + "width": "100%", + "height": "100%" +{% else %} + "width": "40%", + "height": "85%" {% endif %} + }, + "options": { + "params": {"id": "{{llm.id}}"}, + "url": "{{entire_url('./llm_dialog.ui')}}" + } + } ] } - ], - "binds": [ - { - "wid": "self", - "event": "click", - "actiontype": "urlwidget", - "target": "PopupWindow", - "popup_options": { - "title": "{{llm.name}}", -{% if int(params_kw._is_mobile or 0) %} - "width": "100%", - "height": "100%" -{% else %} - "width": "40%", - "height": "85%" -{% endif %} - }, - "options": { - "params": {"id": "{{llm.id}}"}, - "url": "{{entire_url('./llm_dialog.ui')}}" - } - } - ] - } {% set ns.first = false %} {% endfor %} + ] + } + ] + }, +{% 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 %} ] }