houzhongjian
2024-08-08 820397e43a0b64d35c6d31d2a55475061438593b
提交 | 用户 | 时间
820397 1 <template>
H 2   <div class="w-[350px] p-5 flex flex-col bg-[#f5f7f9]">
3     <h3 class="w-full h-full h-7 text-5 text-center leading-[28px] title">思维导图创作中心</h3>
4     <!--下面表单部分-->
5     <div class="flex-grow overflow-y-auto">
6       <div class="mt-[30ppx]">
7         <el-text tag="b">您的需求?</el-text>
8         <el-input
9           v-model="formData.prompt"
10           maxlength="1024"
11           rows="5"
12           class="w-100% mt-15px"
13           input-style="border-radius: 7px;"
14           placeholder="请输入提示词,让AI帮你完善"
15           show-word-limit
16           type="textarea"
17         />
18         <el-button
19           class="!w-full mt-[15px]"
20           type="primary"
21           :loading="isGenerating"
22           @click="emits('submit', formData)"
23         >
24           智能生成思维导图
25         </el-button>
26       </div>
27       <div class="mt-[30px]">
28         <el-text tag="b">使用已有内容生成?</el-text>
29         <el-input
30           v-model="generatedContent"
31           maxlength="1024"
32           rows="5"
33           class="w-100% mt-15px"
34           input-style="border-radius: 7px;"
35           placeholder="例如:童话里的小屋应该是什么样子?"
36           show-word-limit
37           type="textarea"
38         />
39         <el-button
40           class="!w-full mt-[15px]"
41           type="primary"
42           @click="emits('directGenerate', generatedContent)"
43           :disabled="isGenerating"
44         >
45           直接生成
46         </el-button>
47       </div>
48     </div>
49   </div>
50 </template>
51
52 <script setup lang="ts">
53 import { MindMapContentExample } from '@/views/ai/utils/constants'
54
55 const emits = defineEmits(['submit', 'directGenerate'])
56 defineProps<{
57   isGenerating: boolean
58 }>()
59 // 提交的提示词字段
60 const formData = reactive({
61   prompt: ''
62 })
63
64 const generatedContent = ref(MindMapContentExample) // 已有的内容
65
66 defineExpose({
67   setGeneratedContent(newContent: string) {
68     // 设置已有的内容,在生成结束的时候将结果赋值给该值
69     generatedContent.value = newContent
70   }
71 })
72 </script>
73
74 <style lang="scss" scoped>
75 .title {
76   color: var(--el-color-primary);
77 }
78 </style>