From 7200998ea7d8a30977025d0235973c95d9628ffa Mon Sep 17 00:00:00 2001 From: Yule Hou <6761583+hyln9@users.noreply.github.com> Date: Sat, 4 Mar 2023 08:22:50 +0800 Subject: [PATCH] feat: add latex rendering (#247) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add latex rendering * perf: 提升 css 引入路径 --------- Co-authored-by: ChenZhaoYu <790348264@qq.com> --- .vscode/settings.json | 1 + package.json | 2 + pnpm-lock.yaml | 20 +++++++++ src/plugins/assets.ts | 1 + src/views/chat/components/Message/Text.vue | 49 ++++++++++++++++++++++ 5 files changed, 73 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fc60db..f96f070 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -31,6 +31,7 @@ "GPTAPI", "hljs", "iconify", + "katex", "logprobs", "nodata", "OPENAI", diff --git a/package.json b/package.json index 35ddaa9..9eff475 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "dependencies": { "@vueuse/core": "^9.13.0", "highlight.js": "^11.7.0", + "katex": "^0.16.4", "marked": "^4.2.12", "naive-ui": "^2.34.3", "pinia": "^2.0.32", @@ -38,6 +39,7 @@ "@commitlint/config-conventional": "^17.4.4", "@iconify/vue": "^4.1.0", "@types/crypto-js": "^4.1.1", + "@types/katex": "^0.16.0", "@types/marked": "^4.0.8", "@types/node": "^18.14.4", "@vitejs/plugin-vue": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12b75b3..90f3395 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/katex': ^0.16.0 '@types/marked': ^4.0.8 '@types/node': ^18.14.4 '@vitejs/plugin-vue': ^4.0.0 @@ -16,6 +17,7 @@ specifiers: eslint: ^8.35.0 highlight.js: ^11.7.0 husky: ^8.0.3 + katex: ^0.16.4 less: ^4.1.3 lint-staged: ^13.1.2 marked: ^4.2.12 @@ -35,6 +37,7 @@ specifiers: dependencies: '@vueuse/core': 9.13.0_vue@3.2.47 highlight.js: 11.7.0 + katex: 0.16.4 marked: 4.2.12 naive-ui: 2.34.3_vue@3.2.47 pinia: 2.0.32_hmuptsblhheur2tugfgucj7gc4 @@ -48,6 +51,7 @@ devDependencies: '@commitlint/config-conventional': 17.4.4 '@iconify/vue': 4.1.0_vue@3.2.47 '@types/crypto-js': 4.1.1 + '@types/katex': 0.16.0 '@types/marked': 4.0.8 '@types/node': 18.14.4 '@vitejs/plugin-vue': 4.0.0_vite@4.1.4+vue@3.2.47 @@ -772,6 +776,10 @@ packages: resolution: {integrity: sha512-+2FW2CcT0K3P+JMR8YG846bmDwplKUTsWgT2ENwdQ1UdVfRk3GQrh6Mi4sTopy30gI8Uau5CEqHTDZ6YvWIUPA==} dev: false + /@types/katex/0.16.0: + resolution: {integrity: sha512-hz+S3nV6Mym5xPbT9fnO8dDhBFQguMYpY0Ipxv06JMi1ORgnEM4M1ymWDUhUNer3ElLmT583opRo4RzxKmh9jw==} + dev: true + /@types/lodash-es/4.17.6: resolution: {integrity: sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==} dependencies: @@ -1530,6 +1538,11 @@ packages: delayed-stream: 1.0.0 dev: true + /commander/8.3.0: + resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} + engines: {node: '>= 12'} + dev: false + /commander/9.5.0: resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} engines: {node: ^12.20.0 || >=14} @@ -3076,6 +3089,13 @@ packages: engines: {'0': node >= 0.2.0} dev: true + /katex/0.16.4: + resolution: {integrity: sha512-WudRKUj8yyBeVDI4aYMNxhx5Vhh2PjpzQw1GRu/LVGqL4m1AxwD1GcUp0IMbdJaf5zsjtj8ghP0DOQRYhroNkw==} + hasBin: true + dependencies: + commander: 8.3.0 + dev: false + /kind-of/6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} diff --git a/src/plugins/assets.ts b/src/plugins/assets.ts index 27054cb..365a91a 100644 --- a/src/plugins/assets.ts +++ b/src/plugins/assets.ts @@ -1,3 +1,4 @@ +import 'katex/dist/katex.min.css' import '@/styles/lib/tailwind.css' import '@/styles/lib/highlight.less' import '@/styles/lib/github-markdown.less' diff --git a/src/views/chat/components/Message/Text.vue b/src/views/chat/components/Message/Text.vue index 445f68a..5d3cd5c 100644 --- a/src/views/chat/components/Message/Text.vue +++ b/src/views/chat/components/Message/Text.vue @@ -1,5 +1,6 @@