tbutton.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <BubbleBox
  3. ref="bubbleBoxRef"
  4. trigger="none"
  5. position="left"
  6. backgroundColor="rgba(0,0,0,0.9)"
  7. :innerProps="{
  8. width: '400rpx',
  9. }"
  10. >
  11. <template #content>
  12. <FlexRow align="center" gap="gap.md">
  13. <Text :text="currentTipContent" fontConfig="contentText" color="white" touchable @click="openAiWindow" />
  14. <IconButton icon="close" @click="hideTip" />
  15. </FlexRow>
  16. </template>
  17. <Button icon="https://xy.wenlvti.net/app_static/images/village/IconAi.png" @click="openAiWindow">
  18. AI帮你写
  19. </Button>
  20. </BubbleBox>
  21. </template>
  22. <script setup lang="ts">
  23. import Button from '@/components/basic/Button.vue';
  24. import IconButton from '@/components/basic/IconButton.vue';
  25. import Text from '@/components/basic/Text.vue';
  26. import BubbleBox from '@/components/feedback/BubbleBox.vue';
  27. import FlexRow from '@/components/layout/FlexRow.vue';
  28. import { onMounted, ref } from 'vue';
  29. const props = defineProps<{
  30. title: string;
  31. content: string;
  32. images: {
  33. url: string;
  34. localUrl: string;
  35. }[];
  36. }>();
  37. const emit = defineEmits([ 'showAi' ]);
  38. /**
  39. * 能助手提示:
  40. * 0. 监听编辑器内容
  41. * 1. 当用户进入后,长时间 15s 没有内容变更,则触发 "不知道怎么写?来和我讨论灵感吧"
  42. * 2. 当用户上传图片后,则触发 “让我来为你根据素材智能编写吧”
  43. *
  44. * 3. 用户已写一段文字,防抖,一段时间内触发
  45. * “灵感枯竭?让我来为你拓展文化选题”
  46. * "让我来为你润色文稿叙述更优雅动人"
  47. * "让我来为你校对纠错精准修正文史细节"
  48. *
  49. */
  50. const bubbleBoxRef = ref<InstanceType<typeof BubbleBox>>();
  51. const currentTipContent = ref('');
  52. function hideTip() {
  53. bubbleBoxRef.value?.hide();
  54. }
  55. function showTip(message: string) {
  56. currentTipContent.value = message;
  57. bubbleBoxRef.value?.show();
  58. }
  59. function openAiWindow() {
  60. emit('showAi', currentTipContent.value);
  61. hideTip();
  62. }
  63. onMounted(() => {
  64. setTimeout(() => {
  65. showTip('不知道怎么写?让我来帮你吧');
  66. }, 1000);
  67. })
  68. </script>