diff --git a/CHANGELOG.md b/CHANGELOG.md index d927140..a233b4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v2.8.3 + +`2023-03-01` + +### Feature +- 消息已输出内容不会因为中断而消失[#167] +- 添加复制消息按钮[#133] + +### Other +- `README` 添加声明内容 + ## v2.8.2 `2023-02-28` diff --git a/README.md b/README.md index b1a1618..55e70fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ChatGPT Web -> 使用 `express` 和 `vue3` 搭建的支持 `ChatGPT` 双模型演示网页 +> 声明:此项目只发布于 Github,基于 MIT 协议,免费且作为开源学习使用。并且不会有任何形式的卖号、付费服务、讨论群、讨论组等行为。谨防受骗。 ![cover](./docs/c1-2.8.0.png) ![cover2](./docs/c2-2.8.0.png) diff --git a/package.json b/package.json index b9660f1..ac0c609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatgpt-web", - "version": "2.8.2", + "version": "2.8.3", "private": false, "description": "ChatGPT Web", "author": "ChenZhaoYu ", diff --git a/service/.env b/service/.env index 0bb4ad6..eafc0c4 100644 --- a/service/.env +++ b/service/.env @@ -8,4 +8,4 @@ OPENAI_ACCESS_TOKEN= API_REVERSE_PROXY= # timeout -TIMEOUT_MS=60000 +TIMEOUT_MS=100000 diff --git a/src/hooks/useIconRender.ts b/src/hooks/useIconRender.ts new file mode 100644 index 0000000..73b9114 --- /dev/null +++ b/src/hooks/useIconRender.ts @@ -0,0 +1,36 @@ +import { h } from 'vue' +import { SvgIcon } from '@/components/common' + +export const useIconRender = () => { + interface IconConfig { + icon?: string + color?: string + fontSize?: number + } + + interface IconStyle { + color?: string + fontSize?: string + } + + const iconRender = (config: IconConfig) => { + const { color, fontSize, icon } = config + + const style: IconStyle = {} + + if (color) + style.color = color + + if (fontSize) + style.fontSize = `${fontSize}px` + + if (!icon) + window.console.warn('iconRender: icon is required') + + return () => h(SvgIcon, { icon, style }) + } + + return { + iconRender, + } +} diff --git a/src/store/modules/chat/index.ts b/src/store/modules/chat/index.ts index b510a99..540954d 100644 --- a/src/store/modules/chat/index.ts +++ b/src/store/modules/chat/index.ts @@ -129,6 +129,22 @@ export const useChatStore = defineStore('chat-store', { } }, + updateChatSomeByUuid(uuid: number, index: number, chat: Partial) { + if (!uuid || uuid === 0) { + if (this.chat.length) { + this.chat[0].data[index] = { ...this.chat[0].data[index], ...chat } + this.recordState() + } + return + } + + const chatIndex = this.chat.findIndex(item => item.uuid === uuid) + if (chatIndex !== -1) { + this.chat[chatIndex].data[index] = { ...this.chat[chatIndex].data[index], ...chat } + this.recordState() + } + }, + deleteChatByUuid(uuid: number, index: number) { if (!uuid || uuid === 0) { if (this.chat.length) { diff --git a/src/utils/format/index.ts b/src/utils/format/index.ts index 8383187..8539b5c 100644 --- a/src/utils/format/index.ts +++ b/src/utils/format/index.ts @@ -13,3 +13,15 @@ export function includeCode(text: string | null | undefined) { const regexp = /^(?:\s{4}|\t).+/gm return !!(text?.includes(' = ') || text?.match(regexp)) } + +// 复制文本 +export function copyText(text: string) { + const input = document.createElement('input') + input.setAttribute('readonly', 'readonly') + input.setAttribute('value', text) + document.body.appendChild(input) + input.select() + if (document.execCommand('copy')) + document.execCommand('copy') + document.body.removeChild(input) +} diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index 1b45d97..36b0a74 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -1,7 +1,10 @@