diff --git a/src/api/variable.js b/src/api/variable.js
index 37dd80e869c378271e5ebc0fb4c73b6e5b5a12ca..42ea4a72af6de112d1ab6ad5c05dcbab8cece311 100644
--- a/src/api/variable.js
+++ b/src/api/variable.js
@@ -63,6 +63,7 @@ export async function getVariable(params) {
* @param {string} params.scope 变量作用域 (user|env|system|conversation)
* @param {string} [params.flow_id] 流程ID(环境级和对话级变量必需)
* @param {string} [params.conversation_id] 对话ID(系统级和对话级变量必需)
+ * @param {string} [params.current_step_id] 当前步骤ID(用于获取前置节点变量,仅对话变量有效)
*/
export async function listVariables(params = {}) {
const [error, response] = await get(`${BASE_URL}/list`, params)
diff --git a/src/components/SafeStartNodeEditor.vue b/src/components/SafeStartNodeEditor.vue
deleted file mode 100644
index f45c2d8a2c7984be877dd130ed862fc993007541..0000000000000000000000000000000000000000
--- a/src/components/SafeStartNodeEditor.vue
+++ /dev/null
@@ -1,436 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 输入参数
-
-
-
- 输出参数
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 正在初始化...
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/components/StartNodeEditor.vue b/src/components/StartNodeEditor.vue
index b1d7db1c561ceddf5ecf58029ff8ad2585cf3164..f45c2d8a2c7984be877dd130ed862fc993007541 100644
--- a/src/components/StartNodeEditor.vue
+++ b/src/components/StartNodeEditor.vue
@@ -1,5 +1,5 @@
@@ -173,6 +248,7 @@ onMounted(async () => {
:size="800"
direction="rtl"
:close-on-click-modal="false"
+ :destroy-on-close="true"
@close="handleClose"
>
@@ -185,7 +261,7 @@ onMounted(async () => {
-
+
@@ -207,7 +283,7 @@ onMounted(async () => {
:key="key"
class="parameter-item"
>
-
+
{
删除
@@ -237,7 +313,7 @@ onMounted(async () => {
:key="key"
class="parameter-item"
>
-
+
{
删除
@@ -264,18 +340,33 @@ onMounted(async () => {
+
+
+
+ 正在初始化...
+
+
@@ -319,6 +410,22 @@ onMounted(async () => {
}
}
+.loading-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 200px;
+ gap: 16px;
+ color: var(--el-text-color-secondary);
+}
+
+.no-conversation {
+ text-align: center;
+ padding: 32px;
+ color: var(--el-text-color-secondary);
+}
+
.drawer-footer {
display: flex;
justify-content: flex-end;
diff --git a/src/components/StartNodeVariableManager.vue b/src/components/StartNodeVariableManager.vue
index ad8ec9de189a23386061b84b90ef1c1e59ec2f8e..9e19b886ae5c6664a8877b8855aa879740fce1c3 100644
--- a/src/components/StartNodeVariableManager.vue
+++ b/src/components/StartNodeVariableManager.vue
@@ -65,8 +65,9 @@ const typeLabels = computed(() => ({
boolean: '布尔值',
object: '对象',
secret: '密钥',
+ group: '分组',
file: '文件',
- 'array[any]': '数组',
+ 'array[any]': '任意数组',
'array[string]': '字符串数组',
'array[number]': '数字数组',
'array[object]': '对象数组',
@@ -111,7 +112,7 @@ const loadSystemVariables = async () => {
}
const response = await listVariables(params)
- systemVariables.value = response.result?.variables || []
+ systemVariables.value = response?.result?.variables || []
console.log('✅ 系统变量加载成功:', systemVariables.value.length, '个')
} catch (error) {
console.error('加载系统变量失败:', error)
@@ -130,7 +131,7 @@ const loadConversationVariables = async () => {
scope: 'conversation',
conversation_id: props.conversationId
})
- conversationVariables.value = response.result?.variables || []
+ conversationVariables.value = response?.result?.variables || []
} catch (error) {
console.error('加载对话变量失败:', error)
ElMessage.error('加载对话变量失败')
@@ -142,7 +143,7 @@ const loadConversationVariables = async () => {
const loadVariableTypes = async () => {
try {
const response = await getVariableTypes()
- variableTypes.value = response.result || {types: [], scopes: []}
+ variableTypes.value = response?.result || {types: [], scopes: []}
} catch (error) {
console.error('加载变量类型失败:', error)
}
@@ -162,14 +163,93 @@ const handleSaveVariable = async () => {
try {
await addVariableForm.value.validate()
- await createVariable({
+ // 根据变量类型转换值
+ let processedValue: any = newVariable.value.value
+
+
+
+ // 类型转换处理
+ switch (newVariable.value.var_type) {
+ case 'number':
+ processedValue = processedValue === '' ? 0 : Number(processedValue)
+ if (isNaN(processedValue)) {
+ ElMessage.error('请输入有效的数字')
+ return
+ }
+ break
+ case 'boolean':
+ processedValue = processedValue === 'true' || processedValue === true
+ break
+ case 'object':
+ try {
+ processedValue = JSON.parse(processedValue)
+ } catch (error) {
+ ElMessage.error('请输入有效的JSON格式')
+ return
+ }
+ break
+ case 'array[string]':
+ if (typeof processedValue === 'string') {
+ processedValue = processedValue.split(',').map(item => item.trim()).filter(item => item)
+ }
+ break
+ case 'array[number]':
+ if (typeof processedValue === 'string') {
+ try {
+ processedValue = JSON.parse(processedValue)
+ if (!Array.isArray(processedValue) || !processedValue.every(item => typeof item === 'number')) {
+ throw new Error('Invalid array')
+ }
+ } catch (error) {
+ ElMessage.error('请输入有效的数字数组,如:[1,2,3]')
+ return
+ }
+ }
+ break
+ case 'array[boolean]':
+ if (typeof processedValue === 'string') {
+ try {
+ processedValue = JSON.parse(processedValue)
+ if (!Array.isArray(processedValue) || !processedValue.every(item => typeof item === 'boolean')) {
+ throw new Error('Invalid array')
+ }
+ } catch (error) {
+ ElMessage.error('请输入有效的布尔数组,如:[true,false]')
+ return
+ }
+ }
+ break
+ case 'array[object]':
+ if (typeof processedValue === 'string') {
+ try {
+ processedValue = JSON.parse(processedValue)
+ if (!Array.isArray(processedValue)) {
+ throw new Error('Invalid array')
+ }
+ } catch (error) {
+ ElMessage.error('请输入有效的对象数组')
+ return
+ }
+ }
+ break
+ default:
+ // 保持字符串类型
+ processedValue = String(processedValue)
+ }
+
+ const requestData = {
name: newVariable.value.name,
var_type: newVariable.value.var_type,
scope: 'conversation',
- value: newVariable.value.value,
+ value: processedValue,
description: newVariable.value.description,
+ flow_id: props.flowId,
conversation_id: props.conversationId
- })
+ }
+
+
+
+ await createVariable(requestData)
ElMessage.success('变量创建成功')
addVariableDialogVisible.value = false
diff --git a/src/components/VariableChooser.vue b/src/components/VariableChooser.vue
index 84cb1ec3b69fc10ea26b359b0887b0feae7407fb..c1623bf961be1d4035847d03c17036a223c44e62 100644
--- a/src/components/VariableChooser.vue
+++ b/src/components/VariableChooser.vue
@@ -28,7 +28,7 @@
- {{ getVariableDisplayName(selectedVariable) }}
+ {{ modelValue || getVariableDisplayName(selectedVariable) }}