diff --git a/jcloud/jcloud/pagetype/ai_node_schema/__init__.py b/jcloud/jcloud/pagetype/ai_node_schema/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jcloud/jcloud/pagetype/ai_node_schema/ai_node_schema.js b/jcloud/jcloud/pagetype/ai_node_schema/ai_node_schema.js new file mode 100644 index 0000000..486bb97 --- /dev/null +++ b/jcloud/jcloud/pagetype/ai_node_schema/ai_node_schema.js @@ -0,0 +1,303 @@ +// Copyright (c) 2025, Jingrow and contributors +// For license information, please see license.txt + +jingrow.ui.form.on("AI Node Schema", { + refresh(frm) { + console.log("AI Node Schema refresh called", frm); + + // 添加编辑节点Schema按钮到右上角 + if (frm.pg.node_type) { + frm.add_custom_button(__('编辑节点Schema'), function() { + open_schema_editor(frm); + }); + + frm.add_custom_button(__('保存到文件'), function() { + save_schema_to_file(frm); + }); + } + + console.log("AI Node Schema 按钮添加成功"); + }, + + node_type(frm) { + // 当节点类型改变时,自动加载对应的 schema + if (frm.pg.node_type && !frm.pg.node_schema) { + load_schema_for_node_type(frm, frm.pg.node_type); + } + } +}); + +function open_schema_editor(frm) { + // 检查是否有 node_type + if (!frm.pg.node_type) { + jingrow.msgprint(__("请先选择节点类型"), __("提示")); + return; + } + + // 创建 schema 编辑器对话框 + let d = new jingrow.ui.Dialog({ + title: __("编辑 {0} Schema", [frm.pg.node_type]), + size: "extra-large", + fields: [ + { + fieldtype: "HTML", + fieldname: "schema_editor", + options: ` +
{{ JSON.stringify(store.schema, null, 2) }}
+ {{ JSON.stringify(store.schema, null, 2) }}
+