add view count
Some checks failed
Deploy / deploy (build, debian, 22) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822) (push) Has been cancelled

This commit is contained in:
2026-03-30 19:03:52 -06:00
parent 8db17aba12
commit e9596e28a3
3 changed files with 16 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
<template> <template>
<n-flex align="center" justify="space-between" class="title"> <n-flex align="center" justify="space-between" class="title">
<n-text class="titleText">预览</n-text> <div>
<n-text class="titleText">预览</n-text>
<n-text v-if="!!submission.id" depth="3">({{ submission.view_count || 0 }})</n-text>
</div>
<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>
@@ -14,7 +17,7 @@
<n-button quaternary v-if="props.submissionId" @click="copyLink"> <n-button quaternary v-if="props.submissionId" @click="copyLink">
链接 链接
</n-button> </n-button>
<n-flex v-if="!!submission.id"> <n-flex v-if="!!submission.id" align="center">
<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">
<template #trigger> <template #trigger>
@@ -22,7 +25,6 @@
</template> </template>
<n-rate :size="30" @update:value="updateScore" /> <n-rate :size="30" @update:value="updateScore" />
</n-popover> </n-popover>
<!-- <n-button secondary type="info">智能打分</n-button> -->
</n-flex> </n-flex>
</n-flex> </n-flex>
</n-flex> </n-flex>

View File

@@ -275,6 +275,12 @@ const columns: DataTableColumn<SubmissionOut>[] = [
width: 60, width: 60,
render: (row) => row.submit_count || "-", render: (row) => row.submit_count || "-",
}, },
{
title: "浏览",
key: "view_count",
width: 60,
render: (row) => row.view_count || "-",
},
] ]
async function handleExpand(keys: (string | number)[]) { async function handleExpand(keys: (string | number)[]) {
@@ -398,6 +404,8 @@ onUnmounted(() => {
html: "", html: "",
css: "", css: "",
js: "", js: "",
submit_count: 0,
view_count: 0,
created: new Date(), created: new Date(),
modified: new Date(), modified: new Date(),
} }

View File

@@ -81,6 +81,7 @@ export interface SubmissionOut {
flag?: FlagType flag?: FlagType
zone?: "featured" | "low" | "pending" | null zone?: "featured" | "low" | "pending" | null
submit_count: number submit_count: number
view_count: number
created: Date created: Date
modified: Date modified: Date
} }
@@ -99,6 +100,8 @@ export interface SubmissionAll {
html: "" html: ""
css: "" css: ""
js: "" js: ""
submit_count: number
view_count: number
created: Date created: Date
modified: Date modified: Date
} }