zhangwencui
7 天以前 7619c19a67c2ac824f803090bab753fc5ea14408
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<script setup lang="ts">
import { reactive, ref } from 'vue';
 
import { MindMapContentExample } from '@vben/constants';
 
import { Button, Textarea } from 'ant-design-vue';
 
defineProps<{
  isGenerating: boolean;
}>();
 
const emits = defineEmits(['submit', 'directGenerate']);
 
const formData = reactive({
  prompt: '',
});
 
const generatedContent = ref(MindMapContentExample); // 已有的内容
 
defineExpose({
  setGeneratedContent(newContent: string) {
    // 设置已有的内容,在生成结束的时候将结果赋值给该值
    generatedContent.value = newContent;
  },
});
</script>
<template>
  <div class="flex w-80 flex-col rounded-lg bg-card p-5">
    <h3 class="h-7 w-full text-center text-xl leading-7 text-primary">
      思维导图创作中心
    </h3>
    <div class="mt-4 flex-grow overflow-y-auto">
      <div>
        <b>您的需求?</b>
        <Textarea
          v-model:value="formData.prompt"
          :maxlength="1024"
          :rows="8"
          class="mt-4 w-full"
          placeholder="请输入提示词,让AI帮你完善"
          show-count
        />
        <Button
          class="mt-4 !w-full"
          type="primary"
          :loading="isGenerating"
          @click="emits('submit', formData)"
        >
          智能生成思维导图
        </Button>
      </div>
      <div class="mt-7">
        <b>使用已有内容生成?</b>
        <Textarea
          v-model:value="generatedContent"
          :maxlength="1024"
          :rows="8"
          class="mt-4 w-full"
          placeholder="例如:童话里的小屋应该是什么样子?"
          show-count
        />
        <Button
          class="mt-4 !w-full"
          type="primary"
          @click="emits('directGenerate', generatedContent)"
          :disabled="isGenerating"
        >
          直接生成
        </Button>
      </div>
    </div>
  </div>
</template>