MarkdownIt

This commit is contained in:
“zhuzihan”  2025-06-26 15:58:51 +08:00
parent 20530c8c17
commit 9ce656b9e5
3 changed files with 53 additions and 5 deletions

View File

@ -17,13 +17,14 @@
"axios": "^1.8.4",
"echarts": "^5.6.0",
"element-plus": "^2.9.8",
"markdown-it": "^14.1.0",
"vue": "^3.5.13"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.2",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"vite": "^6.3.1",
"ssh2-sftp-client": "^12.0.0"
"ssh2-sftp-client": "^12.0.0",
"vite": "^6.3.1"
}
}

44
pnpm-lock.yaml generated
View File

@ -20,6 +20,9 @@ importers:
element-plus:
specifier: ^2.9.8
version: 2.9.8(vue@3.5.13)
markdown-it:
specifier: ^14.1.0
version: 14.1.0
vue:
specifier: ^3.5.13
version: 3.5.13
@ -413,6 +416,9 @@ packages:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
argparse@2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
asn1@0.2.6:
resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}
@ -615,6 +621,9 @@ packages:
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
linkify-it@5.0.0:
resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==}
lodash-es@4.17.21:
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
@ -631,10 +640,17 @@ packages:
magic-string@0.30.17:
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
markdown-it@14.1.0:
resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==}
hasBin: true
math-intrinsics@1.1.0:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
mdurl@2.0.0:
resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==}
memoize-one@6.0.0:
resolution: {integrity: sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==}
@ -675,6 +691,10 @@ packages:
proxy-from-env@1.1.0:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
punycode.js@2.3.1:
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
engines: {node: '>=6'}
readable-stream@3.6.2:
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
engines: {node: '>= 6'}
@ -763,6 +783,9 @@ packages:
typedarray@0.0.6:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
uc.micro@2.1.0:
resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==}
util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
@ -1118,6 +1141,8 @@ snapshots:
dependencies:
color-convert: 2.0.1
argparse@2.0.1: {}
asn1@0.2.6:
dependencies:
safer-buffer: 2.1.2
@ -1357,6 +1382,10 @@ snapshots:
isexe@2.0.0: {}
linkify-it@5.0.0:
dependencies:
uc.micro: 2.1.0
lodash-es@4.17.21: {}
lodash-unified@1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21):
@ -1371,8 +1400,19 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.0
markdown-it@14.1.0:
dependencies:
argparse: 2.0.1
entities: 4.5.0
linkify-it: 5.0.0
mdurl: 2.0.0
punycode.js: 2.3.1
uc.micro: 2.1.0
math-intrinsics@1.1.0: {}
mdurl@2.0.0: {}
memoize-one@6.0.0: {}
mime-db@1.52.0: {}
@ -1402,6 +1442,8 @@ snapshots:
proxy-from-env@1.1.0: {}
punycode.js@2.3.1: {}
readable-stream@3.6.2:
dependencies:
inherits: 2.0.4
@ -1506,6 +1548,8 @@ snapshots:
typedarray@0.0.6: {}
uc.micro@2.1.0: {}
util-deprecate@1.0.2: {}
vite@6.3.2:

View File

@ -144,7 +144,7 @@
<div class="assistant-messages custom-scrollbar" ref="chatMessagesRef">
<div v-for="(message, index) in chatMessages" :key="index"
:class="['message', message.role === 'user' ? 'user-message' : 'assistant-message']">
{{ message.content }}
<div v-html="message.content"></div>
</div>
<div v-if="isLoading" class="assistant-message loading-message">
<span class="loading-dot"></span>
@ -175,7 +175,8 @@
LegendComponent
} from 'echarts/components'
import { CanvasRenderer } from 'echarts/renderers'
import MarkdownIt from 'markdown-it';
const md = new MarkdownIt();
//
const emit = defineEmits(['navigate', 'logout'])
const navigate = (page) => {
@ -285,8 +286,10 @@
const data = await response.json()
const aiResponse = data.choices && data.choices[0]?.message?.content || '抱歉,我无法回答这个问题。'
const aiResponseHtml = md.render(aiResponse)
// AI
chatMessages.value.push({ role: 'assistant', content: aiResponse })
chatMessages.value.push({ role: 'assistant', content: aiResponseHtml })
} catch (error) {
console.error('DeepSeek API调用失败:', error)