use default props
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-06-06 05:49:02 -06:00
parent 31d7f4d274
commit 4b05086ba1
13 changed files with 63 additions and 80 deletions

View File

@@ -31,9 +31,7 @@ interface Props {
isConnected?: boolean // WebSocket 实际的连接状态(已建立/未建立)
}
const props = withDefaults(defineProps<Props>(), {
isConnected: false,
})
const { storageKey, isConnected = false } = defineProps<Props>()
// 注入同步状态
const syncStatus = injectSyncStatus()
@@ -102,7 +100,7 @@ const reset = () => {
problem.value!.template[codeStore.code.language] ||
SOURCES[codeStore.code.language],
)
storage.remove(props.storageKey)
storage.remove(storageKey)
message.success("代码重置成功")
}
@@ -228,7 +226,7 @@ onMounted(() => {
/>
<!-- 同步状态标签 -->
<template v-if="props.isConnected">
<template v-if="isConnected">
<n-tag v-if="syncStatus.otherUser.value" type="info">
{{ SYNC_MESSAGES.SYNCING_WITH(syncStatus.otherUser.value.name) }}
</n-tag>

View File

@@ -67,7 +67,7 @@
{{ content }}
</n-form-item>
<n-button
v-if="hasCommented && props.showStatistics"
v-if="hasCommented && showStatistics"
type="primary"
@click="getComments"
>
@@ -77,7 +77,7 @@
提交
</n-button>
</n-form>
<div v-if="props.showStatistics">
<div v-if="showStatistics">
<n-descriptions
class="list"
v-if="count"
@@ -117,9 +117,7 @@ interface Props {
showStatistics?: boolean
}
const props = withDefaults(defineProps<Props>(), {
showStatistics: true,
})
const { showStatistics = true } = defineProps<Props>()
const userStore = useUserStore()
const problemStore = useProblemStore()

View File

@@ -40,10 +40,7 @@ interface Props {
problemSetId?: string
}
const props = withDefaults(defineProps<Props>(), {
contestID: "",
problemSetId: "",
})
const { problemID, contestID = "", problemSetId = "" } = defineProps<Props>()
const errMsg = ref("无数据")
const route = useRoute()
@@ -67,7 +64,7 @@ const tabOptions = computed(() => {
options.push("editor")
}
options.push("info")
if (!props.contestID) {
if (!contestID) {
options.push("comment")
}
if (myFlowchartStore.showing) {
@@ -110,7 +107,7 @@ watch(
async function init() {
screenModeStore.resetScreenMode()
try {
const res = await getProblem(props.problemID, props.contestID)
const res = await getProblem(problemID, contestID)
problem.value = res.data
} catch (err: any) {
problem.value = null
@@ -120,7 +117,7 @@ async function init() {
}
}
onMounted(init)
watch(() => props.problemID, init)
watch(() => problemID, init)
onBeforeUnmount(() => {
problem.value = null
errMsg.value = "无数据"
@@ -159,15 +156,15 @@ watch(isMobile, (value) => {
<n-tab-pane
name="info"
tab="题目统计"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemInfo />
</n-tab-pane>
<n-tab-pane
v-if="!props.contestID"
v-if="!contestID"
name="comment"
tab="题目点评"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemComment />
</n-tab-pane>
@@ -181,7 +178,7 @@ watch(isMobile, (value) => {
<n-tab-pane
name="submission"
tab="我的提交"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemSubmission />
</n-tab-pane>
@@ -215,15 +212,15 @@ watch(isMobile, (value) => {
<n-tab-pane
name="info"
tab="题目统计"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemInfo />
</n-tab-pane>
<n-tab-pane
v-if="!props.contestID"
v-if="!contestID"
name="comment"
tab="题目点评"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemComment />
</n-tab-pane>
@@ -237,7 +234,7 @@ watch(isMobile, (value) => {
<n-tab-pane
name="submission"
tab="我的提交"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemSubmission />
</n-tab-pane>
@@ -256,14 +253,14 @@ watch(isMobile, (value) => {
<n-tab-pane name="editor" tab="代码">
<component :is="inProblem ? ProblemEditor : ContestEditor" />
</n-tab-pane>
<n-tab-pane name="info" tab="统计" :disabled="!!props.problemSetId">
<n-tab-pane name="info" tab="统计" :disabled="!!problemSetId">
<ProblemInfo />
</n-tab-pane>
<n-tab-pane
v-if="!props.contestID"
v-if="!contestID"
name="comment"
tab="点评"
:disabled="!!props.problemSetId"
:disabled="!!problemSetId"
>
<ProblemComment />
</n-tab-pane>
@@ -274,7 +271,7 @@ watch(isMobile, (value) => {
>
<MyFlowchartTab />
</n-tab-pane>
<n-tab-pane name="submission" tab="提交" :disabled="!!props.problemSetId">
<n-tab-pane name="submission" tab="提交" :disabled="!!problemSetId">
<ProblemSubmission />
</n-tab-pane>
</n-tabs>