Files
OJ2/apps/web/src/App.vue
T
xuyueandClaude Opus 5.5 6216e1cf22 chore(依赖): 删掉三个没用到的 vue-flow 插件,代码高亮全站只注册一份
- @vue-flow/minimap、node-resizer、node-toolbar 一处引用都没有
- App.vue 给 n-code 另建了一份 highlight.js,还注册着判题机早就不认的 Java、
  JavaScript、Go;改成空闲时加载 shared/highlight.ts 那份。62 条这三种语言的
  历史提交改为不上色显示

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 20:22:32 +08:00

74 lines
2.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { darkTheme, dateZhCN, zhCN } from "naive-ui"
import "normalize.css"
import "./index.css"
import { useConfigStore } from "shared/store/config"
import { useConfigUpdate } from "shared/composables/configUpdate"
import { useMaxKB } from "shared/composables/maxkb"
import { useUserStore } from "shared/store/user"
import { useCollabStore } from "shared/store/collab"
import CollabHost from "shared/components/CollabHost.vue"
const isDark = useDark()
const configStore = useConfigStore()
const userStore = useUserStore()
const collabStore = useCollabStore()
// 初始化配置和实时更新
onMounted(() => {
configStore.getConfig()
userStore.getMyProfile()
})
// 配置实时推送 + MaxKB 挂件。阶段 2 时因为后端还没有 /ws/config 而暂时关掉,
// 阶段 3 迁完之后一直没接回来 —— 表现是管理员改站点配置后学生要刷新才生效、
// 知识库挂件根本不出现,且没有任何报错。两者现在都走新后端的 /ws/config。
useConfigUpdate()
useMaxKB()
// 课堂求助通道。和 /ws/config 一样是全局常驻的:老师可能正在后台改题时
// 收到求助,学生也要在排队期间一直挂着,所以不放在题目页里起落。
//
// 演示模式下整个关掉。它是超管把界面伪装成学生用来投屏的,而服务端只认库里的
// 真实身份:连着的话这个人会被算进「在线老师」,学生因此拿到 pending 而不是
// no_teacher,排队等一个顶栏里根本没有求助列表的人;反过来他自己看到的求助
// 按钮点下去,服务端回的是「教师不能发起求助」。两头都不对,索性对演示模式
// 关闭这个功能(EditorToolbar.vue 的按钮同步隐藏)。
watch(
() => userStore.isAuthed && !userStore.demoMode,
(available) => {
if (available) collabStore.connect()
else collabStore.disconnect()
},
{ immediate: true },
)
// n-code(提交详情、看代码的弹框)用的 highlight.js,空闲时再加载,不挡首屏
const hljsInstance = shallowRef<typeof import("shared/highlight").hljs>()
onMounted(() => {
const load = async () => {
hljsInstance.value = (await import("shared/highlight")).hljs
}
if ("requestIdleCallback" in window) requestIdleCallback(load)
else setTimeout(load, 1000)
})
</script>
<template>
<n-config-provider
:theme="isDark ? darkTheme : null"
:locale="zhCN"
:date-locale="dateZhCN"
:hljs="hljsInstance"
>
<n-dialog-provider>
<n-message-provider>
<router-view></router-view>
<!-- 求助提示 / 列表 / 协作弹框。和上面那条常驻连接同级,
这样切到 /admin(另一套布局、没有顶栏)也照常收得到 -->
<CollabHost />
</n-message-provider>
</n-dialog-provider>
</n-config-provider>
</template>