Преглед на файлове

fix: 修改变量选择

jiaxing.liao преди 1 месец
родител
ревизия
ccc0415ffd

+ 1 - 0
apps/web/src/features/setter/index.vue

@@ -248,6 +248,7 @@ provide('nodeVars', nodeVars)
 	.tab-pane {
 		height: 100%;
 		min-height: 0;
+		margin-top: 16px;
 	}
 
 	.tab-pane--fill {

+ 2 - 2
apps/web/src/nodes/_base/PromptEditor/index.vue

@@ -251,13 +251,13 @@ function onChange(editorState: any) {
 
 .editor-placeholder {
 	line-height: 30px;
-	color: #999;
+	color: #a8abb2;
 	overflow: hidden;
 	position: absolute;
 	text-overflow: ellipsis;
 	top: 0;
 	left: 10px;
-	font-size: 15px;
+	font-size: 14px;
 	user-select: none;
 	display: inline-block;
 	pointer-events: none;

+ 2 - 2
apps/web/src/nodes/_base/VarSelect.vue

@@ -117,7 +117,7 @@ const props = withDefaults(defineProps<Props>(), {
 
 const emit = defineEmits<{
 	(e: 'update:modelValue', value: string): void
-	(e: 'change', value: { value: string; type: string }): void
+	(e: 'change', value: { value: string; type: VarType }): void
 }>()
 
 const nodeVars = inject<Ref<NodeVar[]>>('nodeVars')
@@ -230,7 +230,7 @@ const filteredVars = computed(() => {
 	return options || []
 })
 
-const handleSelect = (variable: { value: string; type: string }) => {
+const handleSelect = (variable: { value: string; type: VarType }) => {
 	innerValue.value = variable.value
 	visible.value = false
 	keyword.value = ''

+ 21 - 5
apps/web/src/nodes/_base/condition/ConditionItem.vue

@@ -10,6 +10,7 @@
 				v-model="modelValue.left_value"
 				class="flex-1 max-w-[160px]"
 				placeholder="{x} 设置变量值"
+				@change="handleLeftValueChange"
 			/>
 			<el-divider direction="vertical" />
 			<!-- 运算符选择 -->
@@ -19,8 +20,8 @@
 				style="width: 80px"
 			></el-select>
 		</div>
-		<el-divider class="my-0!" />
-		<div>
+		<el-divider v-if="!modelValue.comparison_operator?.includes('empty')" class="my-0!" />
+		<div v-if="!modelValue.comparison_operator?.includes('empty')">
 			<div v-if="modelValue.varType !== 'number'" class="flex items-center gap-8px">
 				<VarInput
 					v-model="modelValue.right_value"
@@ -30,11 +31,13 @@
 				/>
 			</div>
 			<div v-else class="flex items-center gap-8px">
-				<el-select v-model="numberType" :options="numberValOptions"></el-select>
-				<VarInput
+				<el-select v-model="numberType" :options="numberValOptions" style="width: 80px"></el-select>
+				<el-divider direction="vertical" />
+				<Input
 					v-model="modelValue.right_value"
+					type="number"
 					variant="borderless"
-					placeholder="输入值,输入 / 选择变量"
+					placeholder="输入值"
 					class="flex-1"
 				/>
 			</div>
@@ -47,8 +50,10 @@ import { ref, computed } from 'vue'
 import VarInput from '../VarInput.vue'
 import VarSelect from '../VarSelect.vue'
 import { VARIABLE_TYPE_OPERATORS } from '@/constant'
+import { Input } from '@repo/ui'
 
 import type { ConditionType } from '../../Interface'
+import type { VarType } from '@/types/var'
 
 const modelValue = defineModel<ConditionType>('modelValue', { required: true })
 
@@ -63,6 +68,10 @@ const operators = computed(() => {
 	const type = modelValue.value.varType ?? 'string'
 	return VARIABLE_TYPE_OPERATORS?.[type as keyof typeof VARIABLE_TYPE_OPERATORS] ?? []
 })
+
+const handleLeftValueChange = (value: { value: string; type: VarType }) => {
+	modelValue.value.varType = value.type
+}
 </script>
 
 <style lang="less" scoped>
@@ -73,6 +82,13 @@ const operators = computed(() => {
 		box-shadow: 0 0 0 1px var(--el-input-focus-border-color) inset;
 	}
 }
+:deep(.el-input__wrapper) {
+	box-shadow: none;
+	&:hover,
+	&.is-focus {
+		box-shadow: 0 0 0 1px var(--el-input-focus-border-color) inset;
+	}
+}
 :deep(.el-select__wrapper) {
 	box-shadow: none;
 	&:hover,