Files
OJ2/apps/web/src/App.vue
T
xuyueandClaude Opus 5.5 df3b4f0dfd
Deploy / deploy (push) Canceled after 0s
style(代码配色): 全站代码换成 Dracula 配色(亮色用官方浅色版 Alucard);编辑器、题面和教程的代码块、练一练、提交详情的颜色一模一样了
原来三套配色各管一块:编辑器是 smoothy / One Dark,正文代码块和练一练是仿 GitHub,
提交详情是 Naive 自带的,同一段 printf 在一课里就有两种颜色。现在静态代码也走编辑器
那套 lezer 解析器,颜色只在 shared/highlight.css 写一份,highlight.js 删掉。

填空题顺手修好:空会把语法搅乱,(humidity ____ 40) 被认成类型声明、humidity 染成类型色,
现在空里先填上答案再解析,答案不输出。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 19:49:20 +08:00

73 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 "shared/highlight.css"
import { useConfigStore } from "shared/store/config"
import { useConfigUpdate } from "shared/composables/configUpdate"
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()
})
// 配置实时推送。阶段 2 时因为后端还没有 /ws/config 而暂时关掉,阶段 3 迁完之后一直
// 没接回来 —— 表现是管理员改站点配置后学生要刷新才生效,且没有任何报错。现在走新后端的 /ws/config。
useConfigUpdate()
// 课堂求助通道。和 /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 的接口,shared/highlight 给了一个同名的壳,里面是和编辑器同一套解析器
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>