diff --git a/web/src/api/autoCode.js b/web/src/api/autoCode.js
index cb3443f1..1ee16fcd 100644
--- a/web/src/api/autoCode.js
+++ b/web/src/api/autoCode.js
@@ -162,7 +162,6 @@ export const butler = (data) => {
})
}
-
export const eye = (data) => {
return service({
url: '/autoCode/llmAuto',
diff --git a/web/src/view/superAdmin/dictionary/sysDictionary.vue b/web/src/view/superAdmin/dictionary/sysDictionary.vue
index 7c1bd8a4..9fb2b339 100644
--- a/web/src/view/superAdmin/dictionary/sysDictionary.vue
+++ b/web/src/view/superAdmin/dictionary/sysDictionary.vue
@@ -37,6 +37,7 @@
>
+ AI
@@ -264,6 +265,30 @@
+
+
+
+
+
+
+
+
@@ -277,6 +302,7 @@
exportSysDictionary,
importSysDictionary
} from '@/api/sysDictionary' // 此处请自行替换地址
+ import { butler } from '@/api/autoCode'
import WarningBar from '@/components/warningBar/warningBar.vue'
import { ref, computed, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
@@ -338,6 +364,11 @@
const isDragging = ref(false)
const fileInputRef = ref(null)
+ // AI 相关
+ const aiDialogVisible = ref(false)
+ const aiPrompt = ref('')
+ const aiGenerating = ref(false)
+
// 监听JSON文本变化,实时预览
watch(importJsonText, (newVal) => {
if (!newVal.trim()) {
@@ -627,6 +658,56 @@
importing.value = false
}
}
+
+ // 打开 AI 对话框
+ const openAiDialog = () => {
+ aiDialogVisible.value = true
+ aiPrompt.value = ''
+ }
+
+ // 关闭 AI 对话框
+ const closeAiDialog = () => {
+ aiDialogVisible.value = false
+ aiPrompt.value = ''
+ }
+
+ // 处理 AI 生成
+ const handleAiGenerate = async () => {
+ if (!aiPrompt.value.trim()) {
+ ElMessage.warning('请输入描述内容')
+ return
+ }
+ try {
+ aiGenerating.value = true
+ const aiRes = await butler({
+ prompt: aiPrompt.value,
+ command: 'dict'
+ })
+ if (aiRes && aiRes.code === 0) {
+ ElMessage.success('AI 生成成功')
+ try {
+ // 将 AI 返回的数据填充到导入文本框(支持字符串或对象)
+ if (typeof aiRes.data === 'string') {
+ importJsonText.value = aiRes.data
+ } else {
+ importJsonText.value = JSON.stringify(aiRes.data, null, 2)
+ }
+ // 清除可能的解析错误并打开导入抽屉
+ jsonPreviewError.value = ''
+ importDrawerVisible.value = true
+ closeAiDialog()
+ } catch (e) {
+ ElMessage.error('处理 AI 返回结果失败: ' + (e.message || e))
+ }
+ } else {
+ ElMessage.error(aiRes.msg || 'AI 生成失败')
+ }
+ } catch (err) {
+ ElMessage.error('AI 调用失败: ' + (err.message || err))
+ } finally {
+ aiGenerating.value = false
+ }
+ }