7070 </NFlex >
7171 </NFlex >
7272
73- <!-- 输入框 -->
73+ <!-- 输入框 - 使用变量感知输入框 (支持变量提取) -->
74+ <VariableAwareInput
75+ v-if =" enableVariableExtraction"
76+ :model-value =" modelValue"
77+ @update:model-value =" $emit('update:modelValue', $event)"
78+ :placeholder =" placeholder"
79+ :autosize =" { minRows: 4, maxRows: 12 }"
80+ :existing-global-variables =" existingGlobalVariables"
81+ :existing-temporary-variables =" existingTemporaryVariables"
82+ :predefined-variables =" predefinedVariables"
83+ @variable-extracted =" handleVariableExtracted"
84+ />
85+
86+ <!-- 原生输入框 (不支持变量提取) -->
7487 <NInput
88+ v-else
7589 :value =" modelValue"
7690 @update:value =" $emit('update:modelValue', $event)"
7791 type =" textarea"
@@ -164,19 +178,50 @@ import {
164178} from " naive-ui" ;
165179import { useFullscreen } from " ../composables/useFullscreen" ;
166180import FullscreenDialog from " ./FullscreenDialog.vue" ;
181+ import { VariableAwareInput } from " ./variable-extraction" ;
182+
183+ /**
184+ * 输入面板组件
185+ *
186+ * 功能:
187+ * 1. 提供输入框用于用户输入内容
188+ * 2. 支持全屏编辑模式
189+ * 3. 支持变量提取功能 (可选)
190+ * 4. 提供模型选择、模板选择等控制面板
191+ */
167192
168193interface Props {
194+ /** 输入框的值 */
169195 modelValue: string ;
196+ /** 选中的模型 */
170197 selectedModel: string ;
198+ /** 面板标题 */
171199 label: string ;
200+ /** 占位符文本 */
172201 placeholder? : string ;
202+ /** 模型选择标签 */
173203 modelLabel: string ;
204+ /** 模板选择标签 */
174205 templateLabel? : string ;
206+ /** 提交按钮文本 */
175207 buttonText: string ;
208+ /** 加载中文本 */
176209 loadingText: string ;
210+ /** 是否正在加载 */
177211 loading? : boolean ;
212+ /** 是否禁用 */
178213 disabled? : boolean ;
214+ /** 是否显示预览按钮 */
179215 showPreview? : boolean ;
216+
217+ /** 🆕 是否启用变量提取功能 */
218+ enableVariableExtraction? : boolean ;
219+ /** 🆕 已存在的全局变量名列表 */
220+ existingGlobalVariables? : string [];
221+ /** 🆕 已存在的临时变量名列表 */
222+ existingTemporaryVariables? : string [];
223+ /** 🆕 系统预定义变量名列表 */
224+ predefinedVariables? : string [];
180225}
181226
182227const props = withDefaults (defineProps <Props >(), {
@@ -185,6 +230,10 @@ const props = withDefaults(defineProps<Props>(), {
185230 loading: false ,
186231 disabled: false ,
187232 showPreview: false ,
233+ enableVariableExtraction: false ,
234+ existingGlobalVariables : () => [],
235+ existingTemporaryVariables : () => [],
236+ predefinedVariables : () => [],
188237});
189238
190239const emit = defineEmits <{
@@ -193,11 +242,28 @@ const emit = defineEmits<{
193242 submit: [];
194243 configModel: [];
195244 " open-preview" : [];
245+ /** 🆕 变量提取事件 */
246+ " variable-extracted" : [
247+ data : {
248+ variableName: string ;
249+ variableValue: string ;
250+ variableType: " global" | " temporary" ;
251+ },
252+ ];
196253}>();
197254
198255// 使用全屏组合函数
199256const { isFullscreen, fullscreenValue, openFullscreen } = useFullscreen (
200257 computed (() => props .modelValue ),
201258 (value ) => emit (" update:modelValue" , value ),
202259);
260+
261+ // 处理变量提取事件
262+ const handleVariableExtracted = (data : {
263+ variableName: string ;
264+ variableValue: string ;
265+ variableType: " global" | " temporary" ;
266+ }) => {
267+ emit (" variable-extracted" , data );
268+ };
203269 </script >
0 commit comments