diff --git a/examples/Button.ui b/examples/Button.ui new file mode 100644 index 0000000..fd35725 --- /dev/null +++ b/examples/Button.ui @@ -0,0 +1,16 @@ +{ + "widgettype": "Button", + "options": { + "text": "点击按钮", + "width": "200px", + "height": "50px" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "script", + "script": "alert('按钮被点击了!'); console.log('Button clicked');" + } + ] +} \ No newline at end of file diff --git a/examples/CompleteLayout.ui b/examples/CompleteLayout.ui new file mode 100644 index 0000000..76b5b03 --- /dev/null +++ b/examples/CompleteLayout.ui @@ -0,0 +1,91 @@ +{ + "widgettype": "VBox", + "options": { + "width": "100%", + "height": "100%" + }, + "subwidgets": [ + { + "widgettype": "HBox", + "options": { + "height": "60px" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "顶部导航栏", + "fontSize": "20px" + } + }, + { + "widgettype": "Filler" + }, + { + "widgettype": "Button", + "options": { + "text": "设置" + } + } + ] + }, + { + "widgettype": "Filler", + "subwidgets": [ + { + "widgettype": "VBox", + "options": { + "width": "100%", + "height": "100%" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "主要内容区域", + "fontSize": "18px" + } + }, + { + "widgettype": "Form", + "options": { + "fields": [ + { + "name": "message", + "label": "消息", + "uitype": "text" + } + ] + } + } + ] + } + ] + }, + { + "widgettype": "HBox", + "options": { + "height": "40px" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "状态栏", + "fontSize": "12px" + } + }, + { + "widgettype": "Filler" + }, + { + "widgettype": "Text", + "options": { + "text": "就绪", + "fontSize": "12px" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/DataViewer.ui b/examples/DataViewer.ui new file mode 100644 index 0000000..b1996dc --- /dev/null +++ b/examples/DataViewer.ui @@ -0,0 +1,31 @@ +{ + "widgettype": "DataViewer", + "options": { + "data_url": "/api/sample-data", + "page_rows": 10, + "row_options": { + "fields": [ + { + "name": "id", + "label": "ID", + "uitype": "int" + }, + { + "name": "name", + "label": "名称", + "uitype": "str" + }, + { + "name": "email", + "label": "邮箱", + "uitype": "email" + } + ] + }, + "editable": { + "add_icon": "fa fa-plus", + "update_icon": "fa fa-edit", + "delete_icon": "fa fa-trash" + } + } +} \ No newline at end of file diff --git a/examples/Filler.ui b/examples/Filler.ui new file mode 100644 index 0000000..f3c1527 --- /dev/null +++ b/examples/Filler.ui @@ -0,0 +1,8 @@ +{ + "widgettype": "Filler", + "options": { + "width": "100%", + "height": "50px", + "backgroundColor": "#f0f0f0" + } +} \ No newline at end of file diff --git a/examples/Form.ui b/examples/Form.ui new file mode 100644 index 0000000..99a903e --- /dev/null +++ b/examples/Form.ui @@ -0,0 +1,30 @@ +{ + "widgettype": "Form", + "options": { + "title": "表单示例", + "fields": [ + { + "name": "username", + "label": "用户名", + "uitype": "str", + "required": true + }, + { + "name": "email", + "label": "邮箱", + "uitype": "email", + "required": true + }, + { + "name": "age", + "label": "年龄", + "uitype": "int" + }, + { + "name": "active", + "label": "激活状态", + "uitype": "check" + } + ] + } +} \ No newline at end of file diff --git a/examples/HBox.ui b/examples/HBox.ui new file mode 100644 index 0000000..826db0c --- /dev/null +++ b/examples/HBox.ui @@ -0,0 +1,31 @@ +{ + "widgettype": "HBox", + "options": { + "width": "100%", + "height": "100px" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "HBox水平布局: ", + "fontSize": "18px" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮1" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮2" + } + }, + { + "widgettype": "Filler" + } + ] +} \ No newline at end of file diff --git a/examples/Image.ui b/examples/Image.ui new file mode 100644 index 0000000..3dd5dc0 --- /dev/null +++ b/examples/Image.ui @@ -0,0 +1,8 @@ +{ + "widgettype": "Image", + "options": { + "src": "/static/sample-image.png", + "width": "200px", + "height": "150px" + } +} \ No newline at end of file diff --git a/examples/Input.ui b/examples/Input.ui new file mode 100644 index 0000000..dfcf39d --- /dev/null +++ b/examples/Input.ui @@ -0,0 +1,8 @@ +{ + "widgettype": "Input", + "options": { + "placeholder": "请输入文本...", + "width": "300px", + "height": "40px" + } +} \ No newline at end of file diff --git a/examples/Modal.ui b/examples/Modal.ui new file mode 100644 index 0000000..13728be --- /dev/null +++ b/examples/Modal.ui @@ -0,0 +1,53 @@ +{ + "widgettype": "Modal", + "options": { + "title": "模态框示例", + "width": "400px", + "height": "300px", + "auto_open": true + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "这是一个模态对话框", + "fontSize": "18px" + } + }, + { + "widgettype": "Form", + "options": { + "fields": [ + { + "name": "input", + "label": "输入内容", + "uitype": "str" + } + ] + } + }, + { + "widgettype": "HBox", + "subwidgets": [ + { + "widgettype": "Filler" + }, + { + "widgettype": "Button", + "options": { + "text": "确定" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "method", + "target": "-@Modal", + "method": "dismiss" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/examples/ResponsableBox.ui b/examples/ResponsableBox.ui new file mode 100644 index 0000000..c8fca31 --- /dev/null +++ b/examples/ResponsableBox.ui @@ -0,0 +1,29 @@ +{ + "widgettype": "ResponsableBox", + "options": { + "width": "100%", + "height": "200px", + "title": "响应式布局示例" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "调整窗口大小查看布局变化", + "fontSize": "16px" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮1" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮2" + } + } + ] +} \ No newline at end of file diff --git a/examples/TabPanel.ui b/examples/TabPanel.ui new file mode 100644 index 0000000..8b81e5b --- /dev/null +++ b/examples/TabPanel.ui @@ -0,0 +1,46 @@ +{ + "widgettype": "TabPanel", + "options": { + "tab_pos": "top", + "items": [ + { + "name": "tab1", + "label": "首页", + "content": { + "widgettype": "Text", + "options": { + "text": "欢迎来到首页!", + "fontSize": "20px" + } + } + }, + { + "name": "tab2", + "label": "设置", + "content": { + "widgettype": "Form", + "options": { + "fields": [ + { + "name": "setting1", + "label": "设置项1", + "uitype": "str" + } + ] + } + } + }, + { + "name": "tab3", + "label": "关于", + "content": { + "widgettype": "Text", + "options": { + "text": "这是关于页面", + "fontSize": "16px" + } + } + } + ] + } +} \ No newline at end of file diff --git a/examples/Text.ui b/examples/Text.ui new file mode 100644 index 0000000..551ee3d --- /dev/null +++ b/examples/Text.ui @@ -0,0 +1,9 @@ +{ + "widgettype": "Text", + "options": { + "text": "这是一个文本控件示例", + "fontSize": "20px", + "color": "#333333", + "fontWeight": "normal" + } +} \ No newline at end of file diff --git a/examples/Tree.ui b/examples/Tree.ui new file mode 100644 index 0000000..3814491 --- /dev/null +++ b/examples/Tree.ui @@ -0,0 +1,29 @@ +{ + "widgettype": "Tree", + "options": { + "idField": "id", + "textField": "name", + "data": [ + { + "id": "1", + "name": "根节点", + "children": [ + { + "id": "1-1", + "name": "子节点1" + }, + { + "id": "1-2", + "name": "子节点2", + "children": [ + { + "id": "1-2-1", + "name": "孙子节点" + } + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/examples/VBox.ui b/examples/VBox.ui new file mode 100644 index 0000000..4d850ce --- /dev/null +++ b/examples/VBox.ui @@ -0,0 +1,36 @@ +{ + "widgettype": "VBox", + "options": { + "width": "100%", + "height": "100%" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "这是一个 VBox 垂直布局示例", + "fontSize": "24px", + "fontWeight": "bold" + } + }, + { + "widgettype": "Text", + "options": { + "text": "子控件会垂直排列", + "fontSize": "16px" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮1" + } + }, + { + "widgettype": "Button", + "options": { + "text": "按钮2" + } + } + ] +} \ No newline at end of file diff --git a/examples/VideoPlayer.ui b/examples/VideoPlayer.ui new file mode 100644 index 0000000..5eb8a40 --- /dev/null +++ b/examples/VideoPlayer.ui @@ -0,0 +1,9 @@ +{ + "widgettype": "VideoPlayer", + "options": { + "src": "/static/sample-video.mp4", + "width": "400px", + "height": "300px", + "controls": true + } +} \ No newline at end of file diff --git a/wwwroot/chat.ui b/wwwroot/chat.ui index 0bfc2e9..855e11b 100644 --- a/wwwroot/chat.ui +++ b/wwwroot/chat.ui @@ -1,34 +1,78 @@ { - "widgettype": "Page", + "widgettype": "VBox", "options": { - "title": "Hermes Chat" + "width": "100%", + "height": "100%" }, "subwidgets": [ { - "widgettype": "Card", + "widgettype": "HBox", "options": { - "title": "{service_name} - {session_name}" + "height": "60px" }, "subwidgets": [ { - "widgettype": "ChatInterface", + "widgettype": "Text", "options": { - "message_source": "/api/hermes-web-cli/sessions/{session_id}/messages/stream", - "send_endpoint": "/api/hermes-web-cli/sessions/{session_id}/messages", - "placeholder": "Type your message..." + "text": "{{params_kw.get('service_name')}} - {{params_kw.get('session_name')}}", + "fontSize": "20px" + } + }, + { + "widgettype": "Filler" + }, + { + "widgettype": "Button", + "options": { + "text": "关闭会话" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "method", + "target": "-@Modal", + "method": "dismiss" + } + ] + } + ] + }, + { + "widgettype": "Filler", + "subwidgets": [ + { + "widgettype": "LLMOut", + "options": { + "data_url": "/api/hermes-web-cli/sessions/{{params_kw.get('session_id')}}/messages", + "auto_scroll": true } } ] }, { - "widgettype": "Toolbar", + "widgettype": "HBox", "options": { - "buttons": [ - {"text": "New Session", "onclick": "createNewSession()"}, - {"text": "Switch Service", "onclick": "switchService()"}, - {"text": "Close Session", "onclick": "closeSession()"} - ] - } + "height": "80px" + }, + "subwidgets": [ + { + "widgettype": "Input", + "options": { + "placeholder": "输入您的消息...", + "width": "100%", + "height": "60px" + }, + "binds": [ + { + "wid": "self", + "event": "keydown", + "actiontype": "script", + "script": "if (event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); /* 发送消息逻辑 */ }" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/wwwroot/index.ui b/wwwroot/index.ui index c0f7811..8f3c328 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -1,35 +1,52 @@ { - "widgettype": "Page", + "widgettype": "VBox", "options": { - "title": "Hermes Services Manager" + "width": "100%", + "height": "100%" }, "subwidgets": [ { - "widgettype": "Card", + "widgettype": "Text", "options": { - "title": "Registered Services" - }, - "subwidgets": [ - { - "widgettype": "DataTable", - "options": { - "data_source": "/api/hermes-web-cli/services", - "columns": [ - {"field": "name", "header": "Service Name"}, - {"field": "service_url", "header": "URL"}, - {"field": "status", "header": "Status"}, - {"field": "last_connected", "header": "Last Connected"} - ], - "actions": ["edit", "test", "delete"] - } - } - ] + "text": "Hermes Services Manager", + "fontSize": "24px", + "fontWeight": "bold" + } }, { - "widgettype": "Button", + "widgettype": "DataViewer", "options": { - "text": "Add New Service", - "onclick": "showServiceForm()" + "data_url": "/api/hermes-web-cli/services", + "page_rows": 20, + "row_options": { + "fields": [ + { + "name": "name", + "label": "服务名称", + "uitype": "str" + }, + { + "name": "service_url", + "label": "服务地址", + "uitype": "str" + }, + { + "name": "status", + "label": "状态", + "uitype": "str" + }, + { + "name": "created_at", + "label": "创建时间", + "uitype": "date" + } + ] + }, + "editable": { + "add_icon": "fa fa-plus", + "update_icon": "fa fa-edit", + "delete_icon": "fa fa-trash" + } } } ] diff --git a/wwwroot/service-detail.ui b/wwwroot/service-detail.ui index c787c33..843ff9f 100644 --- a/wwwroot/service-detail.ui +++ b/wwwroot/service-detail.ui @@ -1,39 +1,99 @@ { - "widgettype": "Page", + "widgettype": "VBox", "options": { - "title": "Service Details" + "width": "100%", + "height": "100%" }, "subwidgets": [ { - "widgettype": "Form", + "widgettype": "Text", "options": { - "data_source": "/api/hermes-web-cli/services/{service_id}", - "fields": [ - {"name": "name", "type": "text", "label": "Service Name"}, - {"name": "service_url", "type": "text", "label": "Service URL"}, - {"name": "api_key", "type": "password", "label": "API Key (Optional)"}, - {"name": "description", "type": "textarea", "label": "Description"} - ], - "actions": ["save", "test_connection", "cancel"] + "text": "Service Details", + "fontSize": "24px", + "fontWeight": "bold" } }, { - "widgettype": "Card", + "widgettype": "Form", "options": { - "title": "Active Sessions" - }, + "data_source": "/api/hermes-web-cli/services/{{params_kw.get('service_id')}}", + "fields": [ + { + "name": "name", + "label": "服务名称", + "uitype": "str", + "required": true + }, + { + "name": "service_url", + "label": "服务地址", + "uitype": "str", + "required": true + }, + { + "name": "api_key", + "label": "API密钥", + "uitype": "password" + }, + { + "name": "description", + "label": "描述", + "uitype": "text" + }, + { + "name": "status", + "label": "状态", + "uitype": "str" + } + ] + } + }, + { + "widgettype": "HBox", "subwidgets": [ { - "widgettype": "DataTable", + "widgettype": "Filler" + }, + { + "widgettype": "Button", "options": { - "data_source": "/api/hermes-web-cli/sessions?service_id={service_id}", - "columns": [ - {"field": "session_name", "header": "Session"}, - {"field": "status", "header": "Status"}, - {"field": "created_at", "header": "Created"} - ], - "actions": ["open", "close"] + "text": "测试连接" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "urlwidget", + "target": "@DataViewer", + "options": { + "url": "{{entire_url('test-connection.ui')}}", + "params": { + "service_id": "{{params_kw.get('service_id')}}" + } + } + } + ] + }, + { + "widgettype": "Button", + "options": { + "text": "保存" } + }, + { + "widgettype": "Button", + "options": { + "text": "取消" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "method", + "target": "-@Modal", + "method": "dismiss" + } + ] } ] } diff --git a/wwwroot/settings.ui b/wwwroot/settings.ui index e384bb3..954db10 100644 --- a/wwwroot/settings.ui +++ b/wwwroot/settings.ui @@ -1,45 +1,81 @@ { - "widgettype": "Page", + "widgettype": "VBox", "options": { - "title": "Hermes Service Settings" + "width": "100%", + "height": "100%" }, "subwidgets": [ { - "widgettype": "Card", + "widgettype": "Text", "options": { - "title": "Service Management" - }, - "subwidgets": [ - { - "widgettype": "Form", - "options": { - "fields": [ - {"name": "default_service", "type": "select", "label": "Default Service"}, - {"name": "auto_connect", "type": "checkbox", "label": "Auto-connect on startup"}, - {"name": "connection_timeout", "type": "number", "label": "Connection Timeout (seconds)"} - ], - "actions": ["save", "reset"] - } - } - ] + "text": "Hermes Service Settings", + "fontSize": "24px", + "fontWeight": "bold" + } }, { - "widgettype": "Card", + "widgettype": "TabPanel", "options": { - "title": "Security Settings" - }, - "subwidgets": [ - { - "widgettype": "Form", - "options": { - "fields": [ - {"name": "require_https", "type": "checkbox", "label": "Require HTTPS for remote services"}, - {"name": "api_key_encryption", "type": "checkbox", "label": "Encrypt stored API keys"} - ], - "actions": ["save"] + "tab_pos": "top", + "items": [ + { + "name": "services", + "label": "服务管理", + "content": { + "widgettype": "DataViewer", + "options": { + "data_url": "/api/hermes-web-cli/services", + "page_rows": 10, + "row_options": { + "fields": [ + { + "name": "name", + "label": "服务名称", + "uitype": "str" + }, + { + "name": "service_url", + "label": "服务地址", + "uitype": "str" + }, + { + "name": "status", + "label": "状态", + "uitype": "str" + } + ] + }, + "editable": { + "add_icon": "fa fa-plus", + "update_icon": "fa fa-edit", + "delete_icon": "fa fa-trash" + } + } + } + }, + { + "name": "security", + "label": "安全设置", + "content": { + "widgettype": "Form", + "options": { + "fields": [ + { + "name": "require_https", + "label": "强制HTTPS", + "uitype": "check" + }, + { + "name": "api_key_encryption", + "label": "API密钥加密存储", + "uitype": "check" + } + ] + } + } } - } - ] + ] + } } ] } \ No newline at end of file