From 92d2ea48d343fc00d81905167d033c40200ea716 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 04 三月 2025 15:56:19 +0800 Subject: [PATCH] 快速引用;去重 --- customer_list/common/static/fonts/ywiconfont/iconfont.ttf | 0 customer_list/common/static/fonts/ywiconfont/iconfont.woff | 0 src/components/chat/components/playBar/PlayBar.vue | 44 ++++++++++++++++----- src/components/chat/components/playBar/hook/useUploadFile.ts | 21 ++++++++-- src/components/chat/components/playBar/businessTable/ChartDisplay.vue | 22 +++++++++++ src/components/chat/user/index.vue | 13 ++++++ src/types/mitt.d.ts | 8 ++- customer_list/common/static/fonts/ywiconfont/iconfont.css | 10 +++- customer_list/common/static/fonts/ywiconfont/iconfont.woff2 | 0 9 files changed, 95 insertions(+), 23 deletions(-) diff --git a/customer_list/common/static/fonts/ywiconfont/iconfont.css b/customer_list/common/static/fonts/ywiconfont/iconfont.css index 1d759cb..055e4ff 100644 --- a/customer_list/common/static/fonts/ywiconfont/iconfont.css +++ b/customer_list/common/static/fonts/ywiconfont/iconfont.css @@ -1,8 +1,8 @@ @font-face { font-family: "ywifont"; /* Project id 4655417 */ - src: url('iconfont.woff2?t=1741057349776') format('woff2'), - url('iconfont.woff?t=1741057349776') format('woff'), - url('iconfont.ttf?t=1741057349776') format('truetype'); + src: url('iconfont.woff2?t=1741074367091') format('woff2'), + url('iconfont.woff?t=1741074367091') format('woff'), + url('iconfont.ttf?t=1741074367091') format('truetype'); } .ywifont { @@ -13,6 +13,10 @@ -moz-osx-font-smoothing: grayscale; } +.ywicon-quote:before { + content: "\e699"; +} + .ywicon-txt:before { content: "\e64d"; } diff --git a/customer_list/common/static/fonts/ywiconfont/iconfont.ttf b/customer_list/common/static/fonts/ywiconfont/iconfont.ttf index b57225d..be8452e 100644 --- a/customer_list/common/static/fonts/ywiconfont/iconfont.ttf +++ b/customer_list/common/static/fonts/ywiconfont/iconfont.ttf Binary files differ diff --git a/customer_list/common/static/fonts/ywiconfont/iconfont.woff b/customer_list/common/static/fonts/ywiconfont/iconfont.woff index 0af47ca..e8cbd58 100644 --- a/customer_list/common/static/fonts/ywiconfont/iconfont.woff +++ b/customer_list/common/static/fonts/ywiconfont/iconfont.woff Binary files differ diff --git a/customer_list/common/static/fonts/ywiconfont/iconfont.woff2 b/customer_list/common/static/fonts/ywiconfont/iconfont.woff2 index fadb572..082a2dd 100644 --- a/customer_list/common/static/fonts/ywiconfont/iconfont.woff2 +++ b/customer_list/common/static/fonts/ywiconfont/iconfont.woff2 Binary files differ diff --git a/src/components/chat/components/playBar/PlayBar.vue b/src/components/chat/components/playBar/PlayBar.vue index f1874bd..df8b1d8 100644 --- a/src/components/chat/components/playBar/PlayBar.vue +++ b/src/components/chat/components/playBar/PlayBar.vue @@ -144,14 +144,14 @@ @updateInput="updateInputValue" /> <BusinessTable v-model="businessTableIsShow" @submit="submitBusinessTable" /> - <BusinessTablePreview :data="attachPreviewData" v-model="attachPreviewIsShow" @submit="submitBusinessTable" /> + <BusinessTablePreview :data="attachPreviewData" v-model="attachPreviewIsShow" /> </div> </div> </template> <script setup lang="ts"> import type { InputInstance } from 'element-plus'; -import { nextTick, ref } from 'vue'; +import { nextTick, onActivated, onDeactivated, ref } from 'vue'; import BusinessTable from './businessTable/index.vue'; import BusinessTablePreview from './businessTablePreview/index.vue'; import type { Attach } from './hook/useAttach'; @@ -163,6 +163,7 @@ import SceneSwitch from './SceneSwitch.vue'; import VoicePage from './voicePage/VoicePage.vue'; import { useCompRef } from '/@/utils/types'; +import emitter from '/@/utils/mitt'; const emits = defineEmits(['sendClick', 'stopGenClick']); const props = defineProps({ @@ -255,17 +256,27 @@ } removeAttach(index); }; +const checkTableAttachExist = (data: any) => { + const dataStr = JSON.stringify(data); + const exist = attachList.value.find((item) => item.type === 'table' && JSON.stringify(item.model) === dataStr); + if (exist) { + return true; + } + return false; +}; const submitBusinessTable = (data) => { attachList.value.push( - ...data.map((item) => { - return { - title: item.title, - type: 'table', - model: item, - icon: 'biaoge', - iconClass: 'ywicon-biaoge text-[#c5e0ff]', - }; - }) + ...data + .filter((item) => !checkTableAttachExist(item)) + .map((item) => { + return { + title: item.title, + type: 'table', + model: item, + icon: 'biaoge', + iconClass: 'ywicon-biaoge text-[#c5e0ff]', + }; + }) ); }; @@ -285,6 +296,17 @@ attachPreviewData.value = item; }; //#endregion + +const quoteAttach = (item: Attach) => { + submitBusinessTable([item.model]); +}; +onActivated(() => { + emitter.on('quoteAttach', quoteAttach); +}); + +onDeactivated(() => { + emitter.off('quoteAttach', quoteAttach); +}); defineExpose({ addPhrase, showSyncTip, diff --git a/src/components/chat/components/playBar/businessTable/ChartDisplay.vue b/src/components/chat/components/playBar/businessTable/ChartDisplay.vue new file mode 100644 index 0000000..c711040 --- /dev/null +++ b/src/components/chat/components/playBar/businessTable/ChartDisplay.vue @@ -0,0 +1,22 @@ +<template> + <div v-show="!tableIsShow"> + <div> + <div ref="chartRef"></div> + </div> + </div> +</template> + +<script setup lang="ts" name="ChartDisplay"> +import { ref } from 'vue'; +import { useDrawChatChart } from '/@/components/chat/chatComponents/hooks/useDrawChatChart'; + +const props = defineProps({ + tableIsShow: { + type: Boolean, + default: false, + }, +}); +const chartRef = ref<HTMLDivElement>(); +const { chartContainerResize, chartInstance } = useDrawChatChart({ chartRef, drawChart }); +</script> +<style scoped lang="scss"></style> diff --git a/src/components/chat/components/playBar/hook/useUploadFile.ts b/src/components/chat/components/playBar/hook/useUploadFile.ts index a2f4bb0..f7f04ea 100644 --- a/src/components/chat/components/playBar/hook/useUploadFile.ts +++ b/src/components/chat/components/playBar/hook/useUploadFile.ts @@ -8,6 +8,14 @@ attachFileList: Ref<Attach<UploadFile>[]>; }; +const compareFiles = (file1: File, file2: File) => { + if (file1.type !== file2.type) return false; + if (file1.name !== file2.name) return false; + if (file1.size !== file2.size) return false; + if (file1.lastModified !== file2.lastModified) return false; + return true; +}; + export type FileType = 'doc' | 'docx' | 'pdf' | 'md' | 'xls' | 'xlsx' | 'png' | 'jpg' | 'jpeg' | 'gif' | 'json' | 'txt' | 'csv'; export type FileGroupType = 'word' | 'pdf' | 'excel' | 'image' | 'json' | 'md' | 'csv' | 'txt'; export type UploadFile = { @@ -16,6 +24,7 @@ groupType: FileGroupType; size: string; file: File; + icon?: string; iconClass?: string; previewUrl?: string; @@ -96,16 +105,19 @@ // const supportFileType = ['doc', 'docx', 'md', 'xls', 'xlsx', 'png', 'jpg', 'jpeg', 'gif', 'json', 'pdf']; const supportFileType = ['csv', 'txt']; -export const getFileSuffix = (name:string):FileType=>{ - if(!name) return 'txt'; +export const getFileSuffix = (name: string): FileType => { + if (!name) return 'txt'; const suffix = name.split('.').pop() as FileType; - return suffix -} + return suffix; +}; export const useUploadFile = (options: UseUploadFileOptions) => { const { attachFileList } = options; const parseFiles = (files: FileList) => { const filterFiles: UploadFile[] = []; for (const file of files) { + if (attachFileList.value.find((item) => compareFiles(item.model.file, file))) { + continue; + } const suffix = getFileSuffix(file.name); if (supportFileType.includes(suffix)) { const groupType = getFileGroupType(suffix); @@ -162,7 +174,6 @@ const files = data.files as FileList; parseFiles(files); }; - const { files, diff --git a/src/components/chat/user/index.vue b/src/components/chat/user/index.vue index f07fa3a..cbe49f4 100644 --- a/src/components/chat/user/index.vue +++ b/src/components/chat/user/index.vue @@ -37,6 +37,9 @@ <div class="font-bold over-ellipsis w-full">{{ item.title }}</div> <div class="text-info text-sm over-ellipsis w-full">{{ `涓氬姟琛ㄦ牸锛�${item.model.values?.length} 鏉¤褰昤 }}</div> </div> + <el-tooltip effect="dark" content="寮曠敤" placement="top"> + <span class="group-hover:visible invisible ywifont ywicon-quote absolute right-2" @click.stop="quoteAttach(item)"></span> + </el-tooltip> </template> </div> </div> @@ -110,9 +113,10 @@ import { ElMessage } from 'element-plus'; import { AnswerState, answerTypeMapCom, roleImageMap, type ChatMessage } from '../model/types'; import { isSharePage } from '/@/stores/chatRoom'; -import { ref } from 'vue'; +import { onActivated, ref } from 'vue'; import BusinessTablePreview from '../components/playBar/businessTablePreview/index.vue'; import { Attach } from '../components/playBar/hook/useAttach'; +import emitter from '/@/utils/mitt'; const emit = defineEmits<{ (event: 'copyMsg', msgObj: ChatMessage): void; @@ -151,5 +155,12 @@ attachPreviewData.value = item; }; //#endregion + +//#region ====================== 闄勪欢寮曠敤 ====================== +const quoteAttach = (item: Attach) => { + emitter.emit('quoteAttach', item); +}; +//#endregion + </script> <style scoped lang="scss"></style> diff --git a/src/types/mitt.d.ts b/src/types/mitt.d.ts index ac63dea..1a2339a 100644 --- a/src/types/mitt.d.ts +++ b/src/types/mitt.d.ts @@ -35,9 +35,11 @@ instance: any; }; - updateHeaderTitle?:string; - newChatClick?:T; - isShowHomePage?:boolean; + updateHeaderTitle?: string; + newChatClick?: T; + isShowHomePage?: boolean; + + quoteAttach: T; }; // mitt 鍙傛暟绫诲瀷瀹氫箟 -- Gitblit v1.9.3