Header.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!--
  2. - Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. -
  4. - Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. - you may not use this file except in compliance with the License.
  6. - You may obtain a copy of the License at
  7. -
  8. - https://www.gnu.org/licenses/agpl-3.0.html
  9. -
  10. - Unless required by applicable law or agreed to in writing, software
  11. - distributed under the License is distributed on an "AS IS" BASIS,
  12. - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. - See the License for the specific language governing permissions and
  14. - limitations under the License.
  15. -->
  16. <script lang="ts" setup>
  17. import SvgIcon from '@/components/SvgIcon/index.vue';
  18. import { useChatStore } from '@/views/chat/store/useChatStore';
  19. import { useDialog, useMessage } from 'naive-ui';
  20. import { clean } from '@/api/aigc/chat';
  21. import ModelSelect from '@/views/channel/ModelSelect.vue';
  22. defineProps<{
  23. title: string;
  24. }>();
  25. const emits = defineEmits(['reload']);
  26. const dialog = useDialog();
  27. const ms = useMessage();
  28. const chatStore = useChatStore();
  29. function handleClear() {
  30. if (chatStore.conversationId == null) {
  31. return;
  32. }
  33. dialog.warning({
  34. title: '清除聊天',
  35. content: '确认清除聊天',
  36. positiveText: '是',
  37. negativeText: '否',
  38. onPositiveClick: async () => {
  39. await clean(chatStore.conversationId);
  40. emits('reload');
  41. ms.success('聊天记录清除成功');
  42. },
  43. });
  44. }
  45. </script>
  46. <template>
  47. <div class="mb-3 flex flex-wrap justify-between items-center">
  48. <div class="font-bold flex justify-center items-center flex-wrap gap-2">
  49. <SvgIcon class="text-lg" icon="ion:sparkles-outline" />
  50. <span>{{ title }}</span>
  51. </div>
  52. <n-space align="center">
  53. <ModelSelect :id="chatStore.modelId" class="w-auto" style="min-width: 140px" />
  54. <n-button secondary size="small" type="warning" @click="handleClear">
  55. <template #icon>
  56. <SvgIcon class="text-[14px]" icon="fluent:delete-12-regular" />
  57. </template>
  58. 清空聊天
  59. </n-button>
  60. </n-space>
  61. </div>
  62. </template>
  63. <style lang="less" scoped></style>