fix: register plaintext hljs language and handle profile fetch error
- Register highlight.js plaintext language to fix "Unknown language" error - Add try/catch around getMyProfile() to handle network errors gracefully - Add components.d.ts to .gitignore (auto-generated by unplugin-vue-components) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ node_modules
|
|||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
components.d.ts
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|||||||
@@ -8,10 +8,14 @@ import { STORAGE_KEY } from "./utils/const"
|
|||||||
import hljs from "highlight.js/lib/core"
|
import hljs from "highlight.js/lib/core"
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
const data = await Account.getMyProfile()
|
const data = await Account.getMyProfile()
|
||||||
user.loaded = true
|
user.loaded = true
|
||||||
user.username = data.username
|
user.username = data.username
|
||||||
user.role = data.role
|
user.role = data.role
|
||||||
|
} catch {
|
||||||
|
user.loaded = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(authed, (v) => {
|
watch(authed, (v) => {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import hljs from "highlight.js/lib/core"
|
|||||||
import xml from "highlight.js/lib/languages/xml"
|
import xml from "highlight.js/lib/languages/xml"
|
||||||
import css from "highlight.js/lib/languages/css"
|
import css from "highlight.js/lib/languages/css"
|
||||||
import javascript from "highlight.js/lib/languages/javascript"
|
import javascript from "highlight.js/lib/languages/javascript"
|
||||||
|
import plaintext from "highlight.js/lib/languages/plaintext"
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import "highlight.js/styles/github.min.css"
|
import "highlight.js/styles/github.min.css"
|
||||||
import { router } from "./router"
|
import { router } from "./router"
|
||||||
@@ -24,6 +25,7 @@ hljs.registerLanguage("html", xml)
|
|||||||
hljs.registerLanguage("css", css)
|
hljs.registerLanguage("css", css)
|
||||||
hljs.registerLanguage("js", javascript)
|
hljs.registerLanguage("js", javascript)
|
||||||
hljs.registerLanguage("javascript", javascript)
|
hljs.registerLanguage("javascript", javascript)
|
||||||
|
hljs.registerLanguage("plaintext", plaintext)
|
||||||
|
|
||||||
marked.use({
|
marked.use({
|
||||||
gfm: true,
|
gfm: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user