This commit is contained in:
2025-10-05 15:59:07 +08:00
parent 70d4629e27
commit be3b644531
6 changed files with 80 additions and 766 deletions

View File

@@ -2,6 +2,7 @@
import { copyToClipboard } from "~/utils/functions"
import { code, input, output } from "oj/composables/code"
import { problem } from "oj/composables/problem"
import { injectSyncStatus } from "oj/composables/syncStatus"
import { LANGUAGE_SHOW_VALUE, SOURCES, STORAGE_KEY } from "utils/constants"
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
import { useUserStore } from "~/shared/store/user"
@@ -15,17 +16,17 @@ import IconButton from "~/shared/components/IconButton.vue"
interface Props {
storageKey: string
withTest?: boolean
otherUserInfo?: { name: string; isSuperAdmin: boolean }
isConnected?: boolean // WebSocket 实际的连接状态(已建立/未建立)
hadConnection?: boolean
}
const props = withDefaults(defineProps<Props>(), {
withTest: false,
isConnected: false,
hadConnection: false,
})
// 注入同步状态
const syncStatus = injectSyncStatus()
const emit = defineEmits<{
changeLanguage: [v: LANGUAGE]
toggleSync: [v: boolean]
@@ -191,11 +192,11 @@ defineExpose({
<!-- 同步状态标签 -->
<template v-if="props.isConnected">
<n-tag v-if="otherUserInfo" type="info">
{{ otherUserInfo.name }} 同步中
<n-tag v-if="syncStatus.otherUser.value" type="info">
{{ syncStatus.otherUser.value.name }} 同步中
</n-tag>
<n-tag
v-if="userStore.isSuperAdmin && !otherUserInfo && hadConnection"
v-if="userStore.isSuperAdmin && !syncStatus.otherUser.value && syncStatus.hadConnection.value"
type="warning"
>
学生已退出可以关闭同步