forked from Leaf/amber-ui
移除 shiki,更换 highlight.js
修复 不支持语言的问题
This commit is contained in:
parent
d7d12a8b95
commit
b94fa6e1c1
@ -27,7 +27,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/types": "^7.18.10",
|
"@babel/types": "^7.18.10",
|
||||||
"@openapitools/openapi-generator-cli": "^2.13.5",
|
"@openapitools/openapi-generator-cli": "^2.13.5",
|
||||||
"@shikijs/markdown-it": "^1.17.6",
|
|
||||||
"@types/markdown-it": "^14.1.2",
|
"@types/markdown-it": "^14.1.2",
|
||||||
"@types/node": "^22.5.4",
|
"@types/node": "^22.5.4",
|
||||||
"@vicons/ionicons5": "^0.12.0",
|
"@vicons/ionicons5": "^0.12.0",
|
||||||
@ -47,7 +46,6 @@
|
|||||||
"naive-ui": "^2.39.0",
|
"naive-ui": "^2.39.0",
|
||||||
"postcss": "^8.4.45",
|
"postcss": "^8.4.45",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"shiki": "^1.17.6",
|
|
||||||
"tailwindcss": "^3.4.10",
|
"tailwindcss": "^3.4.10",
|
||||||
"typescript": "^5.5.2",
|
"typescript": "^5.5.2",
|
||||||
"unplugin-auto-import": "^0.18.2",
|
"unplugin-auto-import": "^0.18.2",
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
</n-divider>
|
</n-divider>
|
||||||
</div>
|
</div>
|
||||||
<n-image
|
<n-image
|
||||||
v-if="message.file && message.file.mime_type?.startsWith('image/')"
|
v-if="
|
||||||
|
message.file && message.file.mime_type?.startsWith('image/')
|
||||||
|
"
|
||||||
width="100"
|
width="100"
|
||||||
:src="fileBaseUrl + '/download/' + message.file.file_hash"
|
:src="fileBaseUrl + '/download/' + message.file.file_hash"
|
||||||
/>
|
/>
|
||||||
<n-text italic depth="3" v-else>
|
<n-text italic depth="3" v-else> 你上传了一个文件 </n-text>
|
||||||
你上传了一个文件
|
|
||||||
</n-text>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="relative h-full">
|
<div class="relative h-full">
|
||||||
@ -77,7 +77,7 @@
|
|||||||
round
|
round
|
||||||
size="large"
|
size="large"
|
||||||
:src="leaflowPng"
|
:src="leaflowPng"
|
||||||
class="min-w-10 min-h-10 p-1.5 absolute top-0 !bg-transparent "
|
class="min-w-10 min-h-10 p-1.5 absolute top-0 !bg-transparent"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -129,39 +129,44 @@ import leaflowPng from "@/assets/images/leaflow.png";
|
|||||||
import markdownKatex from "@traptitech/markdown-it-katex";
|
import markdownKatex from "@traptitech/markdown-it-katex";
|
||||||
import markdownIt from "markdown-it";
|
import markdownIt from "markdown-it";
|
||||||
// highlightjs
|
// highlightjs
|
||||||
// import hljs from "highlight.js";
|
import hljs from "highlight.js";
|
||||||
import config from "@/config/config";
|
import config from "@/config/config";
|
||||||
import Shiki from "@shikijs/markdown-it";
|
|
||||||
|
|
||||||
const mdIt = markdownIt();
|
const mdIt = markdownIt();
|
||||||
const mdInited = ref(false);
|
const mdInited = ref(true);
|
||||||
|
|
||||||
// set options
|
const unsupportedLanguages = ["assembly"];
|
||||||
// mdIt.options.highlight = function (str: string, lang: string) {
|
mdIt.options.highlight = function (str: string, lang: string) {
|
||||||
// if (!lang) {
|
if (!lang || unsupportedLanguages.includes(lang)) {
|
||||||
// return "";
|
return str;
|
||||||
// }
|
}
|
||||||
// return hljs.highlight(str, { language: lang }).value;
|
|
||||||
// };
|
|
||||||
|
|
||||||
async function initMD() {
|
return hljs.highlight(str, { language: lang }).value;
|
||||||
mdIt.use(
|
};
|
||||||
await Shiki({
|
mdIt.use(markdownKatex, {
|
||||||
themes: {
|
|
||||||
light: "vitesse-light",
|
|
||||||
dark: "vitesse-dark",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
mdIt.use(markdownKatex, {
|
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
errorColor: "#cc0000",
|
errorColor: "#cc0000",
|
||||||
output: "html",
|
output: "html",
|
||||||
});
|
});
|
||||||
|
|
||||||
mdInited.value = true;
|
// async function initMD() {
|
||||||
}
|
// mdIt.use(
|
||||||
|
// await Shiki({
|
||||||
|
// themes: {
|
||||||
|
// light: "vitesse-light",
|
||||||
|
// dark: "vitesse-dark",
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// );
|
||||||
|
|
||||||
|
// mdIt.use(markdownKatex, {
|
||||||
|
// throwOnError: false,
|
||||||
|
// errorColor: "#cc0000",
|
||||||
|
// output: "html",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// mdInited.value = true;
|
||||||
|
// }
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -175,6 +180,6 @@ const chat_messages = toRef(props, "chat_messages") as Ref<EntityChatMessage[]>;
|
|||||||
const fileBaseUrl = config.backend + "/api/v1/files";
|
const fileBaseUrl = config.backend + "/api/v1/files";
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initMD();
|
// initMD();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user