diff --git a/.env.local b/.env.local index 82a3f72a..005d2f0d 100644 --- a/.env.local +++ b/.env.local @@ -29,9 +29,5 @@ VITE_BASE_PATH=/ # 商城H5会员端域名 VITE_MALL_H5_DOMAIN='http://localhost:3000' -# TODO puhui999:这个可以不走 cdn 地址么? -# 客户端静态资源地址 空=默认使用服务端指定的CDN资源地址前缀 | local=本地 | http(s)://xxx.xxx=自定义静态资源地址前缀 -VITE_STATIC_URL = https://file.sheepjs.com - # 验证码的开关 VITE_APP_CAPTCHA_ENABLE=false diff --git a/src/api/ai/chat/conversation/index.ts b/src/api/ai/chat/conversation/index.ts index 08ad26a1..9f5f70f2 100644 --- a/src/api/ai/chat/conversation/index.ts +++ b/src/api/ai/chat/conversation/index.ts @@ -43,8 +43,8 @@ export const ChatConversationApi = { }, // 删除【我的】所有对话,置顶除外 - deleteMyAllExceptPinned: async () => { - return await request.delete({ url: `/ai/chat/conversation/delete-my-all-except-pinned` }) + deleteChatConversationMyByUnpinned: async () => { + return await request.delete({ url: `/ai/chat/conversation/delete-by-unpinned` }) }, // 获得【我的】聊天对话列表 diff --git a/src/assets/ai/dall2.jpg b/src/assets/ai/dall2.jpg index f80a4a4d..c07374dc 100644 Binary files a/src/assets/ai/dall2.jpg and b/src/assets/ai/dall2.jpg differ diff --git a/src/assets/ai/dall3.jpg b/src/assets/ai/dall3.jpg index d4c87687..7f45803b 100644 Binary files a/src/assets/ai/dall3.jpg and b/src/assets/ai/dall3.jpg differ diff --git a/src/assets/ai/qingxi.jpg b/src/assets/ai/qingxi.jpg index 6e2739df..d76b8156 100644 Binary files a/src/assets/ai/qingxi.jpg and b/src/assets/ai/qingxi.jpg differ diff --git a/src/assets/ai/ziran.jpg b/src/assets/ai/ziran.jpg index 3e1b4b1c..62907242 100644 Binary files a/src/assets/ai/ziran.jpg and b/src/assets/ai/ziran.jpg differ diff --git a/src/utils/download.ts b/src/utils/download.ts index fe24ee27..ab200149 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -29,7 +29,7 @@ const download = { html: (data: Blob, fileName: string) => { download0(data, fileName, 'text/html') }, - // 下载 MarkdownView 方法 + // 下载 Markdown 方法 markdown: (data: Blob, fileName: string) => { download0(data, fileName, 'text/markdown') } diff --git a/src/views/ai/chat/Conversation.vue b/src/views/ai/chat/Conversation.vue index 2afeb9ac..5976171b 100644 --- a/src/views/ai/chat/Conversation.vue +++ b/src/views/ai/chat/Conversation.vue @@ -1,11 +1,10 @@ diff --git a/src/views/mall/promotion/kefu/components/constants.ts b/src/views/mall/promotion/kefu/components/tools/constants.ts similarity index 50% rename from src/views/mall/promotion/kefu/components/constants.ts rename to src/views/mall/promotion/kefu/components/tools/constants.ts index f8599160..e171e363 100644 --- a/src/views/mall/promotion/kefu/components/constants.ts +++ b/src/views/mall/promotion/kefu/components/tools/constants.ts @@ -1,3 +1,4 @@ +// 客服消息类型枚举类 export const KeFuMessageContentTypeEnum = { TEXT: 1, // 文本消息 IMAGE: 2, // 图片消息 @@ -8,3 +9,8 @@ export const KeFuMessageContentTypeEnum = { PRODUCT: 10, // 商品消息 ORDER: 11 // 订单消息" } +// Promotion 的 WebSocket 消息类型枚举类 +export const WebSocketMessageTypeConstants = { + KEFU_MESSAGE_TYPE: 'kefu_message_type', // 客服消息类型 + KEFU_MESSAGE_ADMIN_READ: 'kefu_message_read_status_change' // 客服消息管理员已读 +} diff --git a/src/views/mall/promotion/kefu/components/emoji.ts b/src/views/mall/promotion/kefu/components/tools/emoji.ts similarity index 58% rename from src/views/mall/promotion/kefu/components/emoji.ts rename to src/views/mall/promotion/kefu/components/tools/emoji.ts index 765d2a6e..449f51c0 100644 --- a/src/views/mall/promotion/kefu/components/emoji.ts +++ b/src/views/mall/promotion/kefu/components/tools/emoji.ts @@ -1,4 +1,6 @@ -export const emojiList = [ +import { isEmpty } from '@/utils/is' + +const emojiList = [ { name: '[笑掉牙]', file: 'xiaodiaoya.png' }, { name: '[可爱]', file: 'keai.png' }, { name: '[冷酷]', file: 'lengku.png' }, @@ -54,53 +56,60 @@ export interface Emoji { url: string } -export const emojiPage = {} -emojiList.forEach((item, index) => { - if (!emojiPage[Math.floor(index / 30) + 1]) { - emojiPage[Math.floor(index / 30) + 1] = [] - } - emojiPage[Math.floor(index / 30) + 1].push(item) -}) - -// 后端上传地址 -const staticUrl = import.meta.env.VITE_STATIC_URL -// 后缀 -const suffix = '/static/img/chat/emoji/' - -// 处理表情 -export function replaceEmoji(data: string) { - let newData = data - if (typeof newData !== 'object') { - const reg = /\[(.+?)\]/g // [] 中括号 - const zhEmojiName = newData.match(reg) - if (zhEmojiName) { - zhEmojiName.forEach((item) => { - const emojiFile = selEmojiFile(item) - newData = newData.replace( - item, - `` - ) - }) +export const useEmoji = () => { + const emojiPathList = ref([]) + // 加载本地图片 + const getStaticEmojiPath = async () => { + const pathList = import.meta.glob( + '@/views/mall/promotion/kefu/components/images/*.{png,jpg,jpeg,svg}' + ) + for (const path in pathList) { + const imageModule: any = await pathList[path]() + emojiPathList.value.push(imageModule.default) } } - return newData -} - -// 获得所有表情 -export function getEmojiList(): Emoji[] { - return emojiList.map((item) => ({ - url: staticUrl + suffix + item.file, - name: item.name - })) as Emoji[] -} - -function selEmojiFile(name: string) { - for (const index in emojiList) { - if (emojiList[index].name === name) { - return emojiList[index].file + // 初始化 + onMounted(async () => { + if (isEmpty(emojiPathList.value)) { + await getStaticEmojiPath() } + }) + + // 处理表情 + function replaceEmoji(data: string) { + let newData = data + if (typeof newData !== 'object') { + const reg = /\[(.+?)\]/g // [] 中括号 + const zhEmojiName = newData.match(reg) + if (zhEmojiName) { + zhEmojiName.forEach((item) => { + const emojiFile = selEmojiFile(item) + newData = newData.replace( + item, + `` + ) + }) + } + } + return newData } - return false + + // 获得所有表情 + function getEmojiList(): Emoji[] { + return emojiList.map((item) => ({ + url: selEmojiFile(item.name), + name: item.name + })) as Emoji[] + } + + function selEmojiFile(name: string) { + for (const emoji of emojiList) { + if (emoji.name === name) { + return emojiPathList.value.find((item: string) => item.indexOf(emoji.file) > -1) + } + } + return false + } + + return { replaceEmoji, getEmojiList } } diff --git a/src/views/mall/promotion/kefu/index.vue b/src/views/mall/promotion/kefu/index.vue index 1204b8dc..1cfea211 100644 --- a/src/views/mall/promotion/kefu/index.vue +++ b/src/views/mall/promotion/kefu/index.vue @@ -16,19 +16,77 @@ diff --git a/types/env.d.ts b/types/env.d.ts index 63d9c3ee..057b5268 100644 --- a/types/env.d.ts +++ b/types/env.d.ts @@ -19,7 +19,6 @@ interface ImportMetaEnv { readonly VITE_UPLOAD_URL: string readonly VITE_API_URL: string readonly VITE_BASE_PATH: string - readonly VITE_STATIC_URL: string readonly VITE_DROP_DEBUGGER: string readonly VITE_DROP_CONSOLE: string readonly VITE_SOURCEMAP: string