diff --git a/CHANGELOG.md b/CHANGELOG.md index db5c044..d67631a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,21 @@ +## v2.5.2 + +`2023-02-21` +### Feature +- 增加对 `markdown` 格式的支持 [Demo](https://github.com/Chanzhaoyu/chatgpt-web/pull/77) +### BugFix +- 重载会话时滚动条保持 + ## v2.5.1 `2023-02-21` + ### Enhancement - 调整路由模式为 `hash` -- 调整新增会话添加到列表最前 +- 调整新增会话添加到 - 调整移动端样式 + ## v2.5.0 `2023-02-20` diff --git a/README.md b/README.md index 4ed6b3f..3c2143b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ 使用 express 和 vue3 搭建的 ChartGPT 演示网页 -![PC](./docs/cover.png) +![cover](./docs/cover.png) +![cover2](./docs/cover2.png) > 提示:目前 `OpenAI` 开放的模型最高只有 `GPT-3`,和现在网页所使用的 `GPT-3.5` 或 `GPT-4` 有很大差距,需要等官方开放最新的模型接口。 diff --git a/docs/cover.png b/docs/cover.png index d4376c1..19602eb 100644 Binary files a/docs/cover.png and b/docs/cover.png differ diff --git a/docs/cover2.png b/docs/cover2.png new file mode 100644 index 0000000..9d801d4 Binary files /dev/null and b/docs/cover2.png differ diff --git a/package.json b/package.json index 180e049..d740f9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatgpt-web", - "version": "2.5.1", + "version": "2.5.2", "private": false, "description": "ChatGPT Web", "author": "ChenZhaoYu ", @@ -25,6 +25,7 @@ "dependencies": { "@vueuse/core": "^9.13.0", "highlight.js": "^11.7.0", + "marked": "^4.2.12", "naive-ui": "^2.34.3", "pinia": "^2.0.30", "vue": "^3.2.47", @@ -36,6 +37,7 @@ "@commitlint/config-conventional": "^17.4.4", "@iconify/vue": "^4.1.0", "@types/crypto-js": "^4.1.1", + "@types/marked": "^4.0.8", "@types/node": "^18.14.0", "@types/web-bluetooth": "^0.0.16", "@vitejs/plugin-vue": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d82d0cb..f9191da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,7 @@ specifiers: '@commitlint/config-conventional': ^17.4.4 '@iconify/vue': ^4.1.0 '@types/crypto-js': ^4.1.1 + '@types/marked': ^4.0.8 '@types/node': ^18.14.0 '@types/web-bluetooth': ^0.0.16 '@vitejs/plugin-vue': ^4.0.0 @@ -18,6 +19,7 @@ specifiers: husky: ^8.0.3 less: ^4.1.3 lint-staged: ^13.1.2 + marked: ^4.2.12 naive-ui: ^2.34.3 npm-run-all: ^4.1.5 pinia: ^2.0.30 @@ -33,6 +35,7 @@ specifiers: dependencies: '@vueuse/core': 9.13.0_vue@3.2.47 highlight.js: 11.7.0 + marked: 4.2.12 naive-ui: 2.34.3_vue@3.2.47 pinia: 2.0.30_hmuptsblhheur2tugfgucj7gc4 vue: 3.2.47 @@ -44,6 +47,7 @@ devDependencies: '@commitlint/config-conventional': 17.4.4 '@iconify/vue': 4.1.0_vue@3.2.47 '@types/crypto-js': 4.1.1 + '@types/marked': 4.0.8 '@types/node': 18.14.0 '@types/web-bluetooth': 0.0.16 '@vitejs/plugin-vue': 4.0.0_vite@4.1.2+vue@3.2.47 @@ -735,6 +739,10 @@ packages: resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==} dev: false + /@types/marked/4.0.8: + resolution: {integrity: sha512-HVNzMT5QlWCOdeuBsgXP8EZzKUf0+AXzN+sLmjvaB3ZlLqO+e4u0uXrdw9ub69wBKFs+c6/pA4r9sy6cCDvImw==} + dev: true + /@types/mdast/3.0.10: resolution: {integrity: sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==} dependencies: @@ -3229,6 +3237,12 @@ packages: engines: {node: '>=8'} dev: true + /marked/4.2.12: + resolution: {integrity: sha512-yr8hSKa3Fv4D3jdZmtMMPghgVt6TWbk86WQaWhDloQjRSQhMMYCAro7jP7VDJrjjdV8pxVxMssXS8B8Y5DZ5aw==} + engines: {node: '>= 12'} + hasBin: true + dev: false + /mdast-util-from-markdown/0.8.5: resolution: {integrity: sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==} dependencies: diff --git a/src/directives/highlight.ts b/src/directives/highlight.ts index 8589e36..b4d2d18 100644 --- a/src/directives/highlight.ts +++ b/src/directives/highlight.ts @@ -1,9 +1,9 @@ import type { App, Directive } from 'vue' import hljs from 'highlight.js' +import includeCode from '@/utils/functions/includeCode' function highlightCode(el: HTMLElement) { - const regexp = /^(?:\s{4}|\t).+/gm - if (el.textContent?.indexOf(' = ') !== -1 || el.textContent.match(regexp)) + if (includeCode(el.textContent)) hljs.highlightBlock(el) } diff --git a/src/utils/functions/includeCode.ts b/src/utils/functions/includeCode.ts new file mode 100644 index 0000000..af0949f --- /dev/null +++ b/src/utils/functions/includeCode.ts @@ -0,0 +1,8 @@ +function includeCode(text: string | null | undefined) { + const regexp = /^(?:\s{4}|\t).+/gm + if (text?.includes(' = ') || text?.match(regexp)) + return true + return false +} + +export default includeCode diff --git a/src/views/chat/components/Message/Text.vue b/src/views/chat/components/Message/Text.vue index 58c490f..caa827b 100644 --- a/src/views/chat/components/Message/Text.vue +++ b/src/views/chat/components/Message/Text.vue @@ -1,28 +1,60 @@ - diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index 473f478..cb5471c 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -37,10 +37,7 @@ function handleRegenerate() { {{ dateTime }}
- - - {{ text }} - +