Files
webpreview/src/App.vue
yuetsh 2bd9382c8c
Some checks failed
Deploy / deploy (build, debian, 22) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822) (push) Has been cancelled
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>
2026-03-10 11:59:18 +08:00

53 lines
1.1 KiB
Vue

<script setup lang="ts">
import { dateZhCN, zhCN } from "naive-ui"
import Login from "./components/Login.vue"
import { onMounted, watch } from "vue"
import { Account } from "./api"
import { authed, user } from "./store/user"
import { STORAGE_KEY } from "./utils/const"
import hljs from "highlight.js/lib/core"
onMounted(async () => {
try {
const data = await Account.getMyProfile()
user.loaded = true
user.username = data.username
user.role = data.role
} catch {
user.loaded = true
}
})
watch(authed, (v) => {
if (v) {
localStorage.setItem(STORAGE_KEY.LOGIN, "true")
} else {
localStorage.removeItem(STORAGE_KEY.LOGIN)
}
})
</script>
<template>
<n-config-provider
class="myContainer"
:locale="zhCN"
:date-locale="dateZhCN"
:hljs="hljs"
>
<n-modal-provider>
<n-message-provider :max="1">
<n-dialog-provider>
<router-view></router-view>
<Login />
</n-dialog-provider>
</n-message-provider>
</n-modal-provider>
</n-config-provider>
</template>
<style scoped>
.myContainer {
height: 100vh;
width: 100vw;
}
</style>