This commit is contained in:
2025-03-30 16:04:33 +08:00
parent cce7920dcc
commit b1fcecb9d4
7 changed files with 39 additions and 27 deletions

1
components.d.ts vendored
View File

@@ -36,6 +36,7 @@ declare module 'vue' {
NSelect: typeof import('naive-ui')['NSelect'] NSelect: typeof import('naive-ui')['NSelect']
NSplit: typeof import('naive-ui')['NSplit'] NSplit: typeof import('naive-ui')['NSplit']
NSwitch: typeof import('naive-ui')['NSwitch'] NSwitch: typeof import('naive-ui')['NSwitch']
NTab: typeof import('naive-ui')['NTab']
NTabPane: typeof import('naive-ui')['NTabPane'] NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs'] NTabs: typeof import('naive-ui')['NTabs']
NTag: typeof import('naive-ui')['NTag'] NTag: typeof import('naive-ui')['NTag']

View File

@@ -1,7 +1,13 @@
<template> <template>
<n-flex align="center" class="corner"> <n-flex align="center" class="corner">
<n-button secondary v-if="!show" @click="showTutorial">教程</n-button> <n-button quaternary v-if="!show" @click="showTutorial">教程</n-button>
<template v-if="user.loaded && authed"> <template v-if="user.loaded && authed">
<n-button
quaternary
@click="$router.push({ name: 'submissions', params: { page: 1 } })"
>
所有提交
</n-button>
<n-button <n-button
type="primary" type="primary"
secondary secondary
@@ -9,7 +15,7 @@
:loading="submitLoading" :loading="submitLoading"
@click="submit" @click="submit"
> >
提交 提交代码
</n-button> </n-button>
<n-dropdown :options="menu" @select="clickMenu"> <n-dropdown :options="menu" @select="clickMenu">
<n-button>{{ user.username }}</n-button> <n-button>{{ user.username }}</n-button>
@@ -67,7 +73,7 @@ const menu = computed(() => [
}), }),
}, },
{ {
label: "提交列表", label: "我的提交",
key: "submissions", key: "submissions",
icon: () => icon: () =>
h(Icon, { h(Icon, {
@@ -98,7 +104,11 @@ function clickMenu(name: string) {
window.open(ADMIN_URL) window.open(ADMIN_URL)
break break
case "submissions": case "submissions":
router.push({ name: "submissions", params: { page: 1 } }) router.push({
name: "submissions",
params: { page: 1 },
query: { username: user.username },
})
break break
case "logout": case "logout":
handleLogout() handleLogout()

View File

@@ -18,7 +18,7 @@
</n-form-item> </n-form-item>
<n-alert <n-alert
type="error" type="error"
v-if="showMeesage" v-if="showMessage"
class="message" class="message"
title="登录失败,请检查用户名和密码" title="登录失败,请检查用户名和密码"
></n-alert> ></n-alert>
@@ -39,7 +39,7 @@ import { user } from "../store/user"
const name = ref("") const name = ref("")
const password = ref("") const password = ref("")
const loading = ref(false) const loading = ref(false)
const showMeesage = ref(false) const showMessage = ref(false)
async function submit() { async function submit() {
loading.value = true loading.value = true
@@ -51,7 +51,7 @@ async function submit() {
loginModal.value = false loginModal.value = false
loading.value = false loading.value = false
} catch (err) { } catch (err) {
showMeesage.value = true showMessage.value = true
loading.value = false loading.value = false
} }
} }

View File

@@ -1,12 +1,9 @@
<template> <template>
<n-flex align="center" justify="space-between" class="title"> <n-flex align="center" justify="space-between" class="title">
<n-flex align="center"> <n-text class="titleText">预览</n-text>
<Icon icon="noto:eyes" :width="20"></Icon>
<n-text class="titleText">预览</n-text>
</n-flex>
<n-flex> <n-flex>
<n-button quaternary @click="download" :disabled="!showDL">下载</n-button> <n-button quaternary @click="download" :disabled="!showDL">下载</n-button>
<n-button quaternary @click="open">展示</n-button> <n-button quaternary @click="open">全屏</n-button>
<n-flex v-if="!!submission.id"> <n-flex v-if="!!submission.id">
<n-button quaternary @click="emits('showCode')">查看代码</n-button> <n-button quaternary @click="emits('showCode')">查看代码</n-button>
<n-popover v-if="submission.my_score === 0"> <n-popover v-if="submission.my_score === 0">

View File

@@ -3,23 +3,30 @@
<n-flex align="center" justify="space-between" class="title"> <n-flex align="center" justify="space-between" class="title">
<n-flex align="center"> <n-flex align="center">
<Icon icon="twemoji:open-book" :width="20"></Icon> <Icon icon="twemoji:open-book" :width="20"></Icon>
<n-text class="preview">教程(测试版)</n-text> <n-tabs style="width: 140px" type="segment" animated>
<n-button text @click="prev" v-if="!hideNav" :disabled="prevDisabled"> <n-tab name="tutorial" tab="教程"></n-tab>
<Icon :width="24" icon="pepicons-pencil:arrow-left"></Icon> <n-tab name="challenge" tab="挑战"></n-tab>
</n-button> </n-tabs>
<n-button text @click="next" v-if="!hideNav" :disabled="nextDisabled"> <template v-if="!hideNav">
<Icon :width="24" icon="pepicons-pencil:arrow-right"></Icon> <n-button text @click="prev" :disabled="prevDisabled">
</n-button> <Icon :width="24" icon="pepicons-pencil:arrow-left"></Icon>
</n-button>
<n-button text @click="next" :disabled="nextDisabled">
<Icon :width="24" icon="pepicons-pencil:arrow-right"></Icon>
</n-button>
</template>
</n-flex> </n-flex>
<n-flex> <n-flex>
<n-button <n-button
text
v-if="authed && roleSuper" v-if="authed && roleSuper"
quaternary
@click="$router.push({ name: 'tutorial', params: { display: step } })" @click="$router.push({ name: 'tutorial', params: { display: step } })"
> >
编辑 <Icon :width="16" icon="lucide:edit"></Icon>
</n-button>
<n-button text @click="$emit('hide')">
<Icon :width="24" icon="material-symbols:close-rounded"></Icon>
</n-button> </n-button>
<n-button quaternary @click="$emit('hide')">隐藏</n-button>
</n-flex> </n-flex>
</n-flex> </n-flex>
<div class="markdown-body" v-html="content" ref="$content"></div> <div class="markdown-body" v-html="content" ref="$content"></div>
@@ -153,10 +160,6 @@ watch(step, render)
box-sizing: border-box; box-sizing: border-box;
} }
.preview {
font-size: 16px;
}
.markdown-body { .markdown-body {
padding: 16px; padding: 16px;
box-sizing: border-box; box-sizing: border-box;

View File

@@ -27,6 +27,7 @@ const menu = [
route: { name: "tutorial", params: { display: step.value } }, route: { name: "tutorial", params: { display: step.value } },
}, },
{ label: "用户", route: { name: "user-manage", params: { page: 1 } } }, { label: "用户", route: { name: "user-manage", params: { page: 1 } } },
{ label: "提交", route: { name: "submissions", params: { page: 1 } } },
] ]
</script> </script>
<style scoped> <style scoped>

View File

@@ -75,7 +75,7 @@ const data = ref<SubmissionOut[]>([])
const count = ref(0) const count = ref(0)
const query = reactive({ const query = reactive({
page: Number(route.params.page), page: Number(route.params.page),
username: "", username: route.query.username ?? "",
}) })
const html = computed(() => submission.value.html) const html = computed(() => submission.value.html)