feat: 增强代码节点编辑器与放大阅读体验

- tinyflow-ui: 新增 CodeScriptEditor(CodeMirror 6)并支持语法高亮、上下文补全、自动括号与 _result 高亮

- tinyflow-ui: 代码节点接入引擎能力列表与节点说明提示,统一 JS/Python 编辑体验

- tinyflow-ui: 增加放大编辑模式,支持居中弹层、ESC 与点击外部关闭

- app/workflow: 对接 supportedCodeEngines 能力并透传 codeEngine provider
This commit is contained in:
2026-03-01 19:57:28 +08:00
parent beeb62c4fc
commit ac8de7dbb8
11 changed files with 1541 additions and 23 deletions

View File

@@ -0,0 +1,5 @@
declare module '@tinyflow-ai/vue' {
import type { DefineComponent } from 'vue';
export const Tinyflow: DefineComponent<Record<string, any>, Record<string, any>, any>;
}

View File

@@ -31,6 +31,7 @@ onMounted(async () => {
loadCustomNode(),
getLlmList(),
getKnowledgeList(),
getCodeEngineList(),
getWorkflowInfo(workflowId.value),
]);
showTinyFlow.value = true;
@@ -46,6 +47,13 @@ const runParams = ref<any>(null);
const tinyFlowData = ref<any>(null);
const llmList = ref<any>([]);
const knowledgeList = ref<any>([]);
const codeEngineList = ref<any[]>([
{
value: 'js',
label: 'JavaScript',
available: true,
},
]);
const provider = computed(() => ({
llm: () => llmList.value.map((item: any) => {
let iconStr = undefined;
@@ -83,6 +91,20 @@ const provider = computed(() => ({
label: $t('aiWorkflow.bochaSearch'),
},
],
codeEngine: (): any => codeEngineList.value.map((item: any) => {
if (item.available === false) {
const reason = item.reason || '未满足运行条件';
return {
value: item.value,
label: `${item.label}(不可用:${reason}`,
selectable: false,
};
}
return {
value: item.value,
label: item.label,
};
}),
}));
const customNode = ref();
const showTinyFlow = ref(false);
@@ -166,6 +188,13 @@ async function getKnowledgeList() {
knowledgeList.value = res.data;
});
}
async function getCodeEngineList() {
api.get('/api/v1/workflow/supportedCodeEngines').then((res) => {
if (res?.errorCode === 0 && Array.isArray(res.data) && res.data.length > 0) {
codeEngineList.value = res.data;
}
});
}
function getRunningParams() {
api
.get(`/api/v1/workflow/getRunningParameters?id=${workflowId.value}`)