This commit is contained in:
2025-10-07 01:32:58 +08:00
parent ed3cfaacd4
commit 97baf85611
9 changed files with 207 additions and 185 deletions

View File

@@ -35,7 +35,12 @@
</n-flex>
</n-gi>
<n-gi :span="5">
<AI v-if="aiStore.detailsData.solved.length > 0 && aiStore.detailsData.solved.length < 10" />
<AI
v-if="
aiStore.detailsData.solved.length > 0 &&
aiStore.detailsData.solved.length < 10
"
/>
</n-gi>
</n-grid>
</n-spin>

View File

@@ -66,4 +66,4 @@ watch(
:deep(.md-editor-preview h1) {
margin-top: 0;
}
</style>
</style>

View File

@@ -31,7 +31,9 @@ ChartJS.register(
const aiStore = useAIStore()
const show = computed(() => {
return Object.values(aiStore.detailsData.difficulty).reduce((a, b) => a + b, 0) > 0
return (
Object.values(aiStore.detailsData.difficulty).reduce((a, b) => a + b, 0) > 0
)
})
const data = computed(() => {

View File

@@ -138,11 +138,10 @@ const options = computed<ChartOptions<"bar" | "line">>(() => {
},
}
})
</script>
<style scoped>
.chart {
height: 300px;
width: 100%;
}
</style>
</style>

View File

@@ -14,7 +14,12 @@
</g>
<g v-for="(day, i) in WEEK_DAYS" :key="i">
<text :x="0" :y="MONTH_HEIGHT + i * CELL_TOTAL + 8" class="label" font-size="9">
<text
:x="0"
:y="MONTH_HEIGHT + i * CELL_TOTAL + 8"
class="label"
font-size="9"
>
{{ day }}
</text>
</g>
@@ -39,7 +44,11 @@
<div class="legend">
<span></span>
<div class="legend-colors">
<div v-for="(color, i) in COLORS" :key="i" :style="{ backgroundColor: color }" />
<div
v-for="(color, i) in COLORS"
:key="i"
:style="{ backgroundColor: color }"
/>
</div>
<span></span>
</div>
@@ -72,13 +81,18 @@ const LEGEND_HEIGHT = 20
const COLORS = ["#ebedf0", "#c6e48b", "#7bc96f", "#239a3b", "#196127"]
const WEEK_DAYS = ["", "一", "", "三", "", "五", ""]
const getColor = (count: number) =>
count === 0 ? COLORS[0] :
count <= 2 ? COLORS[1] :
count <= 4 ? COLORS[2] :
count <= 7 ? COLORS[3] : COLORS[4]
const getColor = (count: number) =>
count === 0
? COLORS[0]
: count <= 2
? COLORS[1]
: count <= 4
? COLORS[2]
: count <= 7
? COLORS[3]
: COLORS[4]
const cells = computed(() =>
const cells = computed(() =>
aiStore.heatmapData.map((item, i) => ({
date: new Date(item.timestamp),
count: item.value,
@@ -87,17 +101,17 @@ const cells = computed(() =>
day: i % 7,
x: Math.floor(i / 7) * CELL_TOTAL,
y: (i % 7) * CELL_TOTAL,
}))
})),
)
const monthLabels = computed(() => {
const labels: { text: string; x: number }[] = []
let lastMonth = -1
cells.value.forEach((cell, i) => {
const month = cell.date.getMonth()
const isWeekStart = cell.date.getDay() === 0 || i === 0
if (month !== lastMonth && (isWeekStart || cell.date.getDay() <= 3)) {
labels.push({
text: `${month + 1}`,
@@ -106,17 +120,16 @@ const monthLabels = computed(() => {
lastMonth = month
}
})
return labels
})
const svgWidth = computed(() =>
DAY_WIDTH + Math.ceil(cells.value.length / 7) * CELL_TOTAL + RIGHT_PADDING
const svgWidth = computed(
() =>
DAY_WIDTH + Math.ceil(cells.value.length / 7) * CELL_TOTAL + RIGHT_PADDING,
)
const svgHeight = computed(() =>
MONTH_HEIGHT + 7 * CELL_TOTAL + LEGEND_HEIGHT
)
const svgHeight = computed(() => MONTH_HEIGHT + 7 * CELL_TOTAL + LEGEND_HEIGHT)
interface Cell {
date: Date
@@ -141,13 +154,13 @@ const tooltipStyle = computed(() => ({
top: `${tooltip.value?.y}px`,
}))
const getTooltipText = (count: number) =>
const getTooltipText = (count: number) =>
count === 0 ? "没有提交记录" : `提交了 ${count}`
const showTooltip = (e: MouseEvent, cell: Cell) => {
const rect = (e.target as HTMLElement).getBoundingClientRect()
const containerRect = containerRef.value?.getBoundingClientRect()
if (containerRect) {
tooltip.value = {
x: rect.left - containerRect.left + rect.width / 2,

View File

@@ -130,42 +130,40 @@ function rowProps(row: Contest) {
</script>
<template>
<n-flex vertical size="large">
<n-card embedded>
<n-space>
<n-form :show-feedback="false" label-placement="left" inline>
<n-form-item label="比赛状态">
<n-select
style="width: 120px"
:options="options"
v-model:value="query.status"
/>
</n-form-item>
<n-form-item label="标签">
<n-select
style="width: 120px"
:options="tags"
v-model:value="query.tag"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" label-placement="left" inline>
<n-form-item>
<n-input
style="width: 200px"
clearable
v-model:value="query.keyword"
placeholder="比赛标题"
/>
</n-form-item>
<n-form-item>
<n-flex>
<n-button @click="search(query.keyword)">搜索</n-button>
<n-button @click="clear" quaternary>重置</n-button>
</n-flex>
</n-form-item>
</n-form>
</n-space>
</n-card>
<n-space>
<n-form :show-feedback="false" label-placement="left" inline>
<n-form-item label="比赛状态">
<n-select
style="width: 120px"
:options="options"
v-model:value="query.status"
/>
</n-form-item>
<n-form-item label="标签">
<n-select
style="width: 120px"
:options="tags"
v-model:value="query.tag"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" label-placement="left" inline>
<n-form-item>
<n-input
style="width: 180px"
clearable
v-model:value="query.keyword"
placeholder="比赛标题"
/>
</n-form-item>
<n-form-item>
<n-flex :wrap="false">
<n-button @click="search(query.keyword)">搜索</n-button>
<n-button @click="clear" quaternary>重置</n-button>
</n-flex>
</n-form-item>
</n-form>
</n-space>
<n-data-table
:bordered="false"
:columns="columns"

View File

@@ -195,54 +195,52 @@ function rowProps(row: ProblemFiltered) {
<template>
<n-flex vertical size="large">
<n-card embedded>
<n-flex justify="space-between">
<n-space>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item label="难度">
<n-select
style="width: 120px"
v-model:value="query.difficulty"
:options="difficultyOptions"
/>
</n-form-item>
<n-form-item label="出题者">
<AuthorSelect v-model:value="query.author" />
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item>
<n-input
clearable
style="width: 200px"
v-model:value="query.keyword"
placeholder="编号或者标题"
/>
</n-form-item>
<n-form-item>
<n-button @click="clearQuery" quaternary>重置</n-button>
</n-form-item>
<!-- <n-form-item>
<n-flex justify="space-between">
<n-space>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item label="难度">
<n-select
style="width: 120px"
v-model:value="query.difficulty"
:options="difficultyOptions"
/>
</n-form-item>
<n-form-item label="出题者">
<AuthorSelect v-model:value="query.author" />
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item>
<n-input
clearable
style="width: 200px"
v-model:value="query.keyword"
placeholder="编号或者标题"
/>
</n-form-item>
<n-form-item>
<n-button @click="clearQuery" quaternary>重置</n-button>
</n-form-item>
<!-- <n-form-item>
<n-button @click="getRandom" quaternary>随机</n-button>
</n-form-item> -->
<n-form-item>
<n-button
@click="toggleShowTag()"
quaternary
icon-placement="right"
>
<template #icon>
<Icon v-if="showTag" icon="ph:caret-down"></Icon>
<Icon v-else icon="ph:caret-up"></Icon>
</template>
标签
</n-button>
</n-form-item>
</n-form>
</n-space>
<Hitokoto v-if="isDesktop" />
</n-flex>
</n-card>
<n-form-item>
<n-button
@click="toggleShowTag()"
quaternary
icon-placement="right"
>
<template #icon>
<Icon v-if="showTag" icon="ph:caret-down"></Icon>
<Icon v-else icon="ph:caret-up"></Icon>
</template>
标签
</n-button>
</n-form-item>
</n-form>
</n-space>
<Hitokoto v-if="isDesktop" />
</n-flex>
<n-collapse-transition :show="showTag">
<n-flex>
<n-tag

View File

@@ -51,7 +51,11 @@ export const useAIStore = defineStore("ai", () => {
}
// 统一获取分析数据details + duration
async function fetchAnalysisData(start: string, end: string, duration: string) {
async function fetchAnalysisData(
start: string,
end: string,
duration: string,
) {
loading.fetching = true
try {
await Promise.all([

View File

@@ -240,84 +240,87 @@ const columns = computed(() => {
</script>
<template>
<n-flex vertical size="large">
<n-card embedded>
<n-space>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item v-if="isDesktop && userStore.isAuthed" label="只看自己">
<n-switch
v-model:value="query.myself"
checked-value="1"
unchecked-value="0"
/>
</n-form-item>
<n-form-item label="状态">
<n-select
class="select"
v-model:value="query.result"
:options="resultOptions"
/>
</n-form-item>
<n-form-item label="语言" v-if="route.name !== 'contest submissions'">
<n-select
class="select"
v-model:value="query.language"
:options="languageOptions"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item>
<n-input
class="input"
clearable
v-model:value="query.username"
placeholder="用户"
/>
</n-form-item>
<n-form-item>
<n-input
class="input"
clearable
v-model:value="query.problem"
placeholder="题号"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item v-if="isMobile && userStore.isAuthed" label="只看自己">
<n-switch
v-model:value="query.myself"
checked-value="1"
unchecked-value="0"
/>
</n-form-item>
<n-form-item>
<n-button @click="search(query.username, query.problem)">
搜索
</n-button>
</n-form-item>
<n-form-item>
<n-button @click="clear" quaternary>重置</n-button>
</n-form-item>
<n-form-item
v-if="userStore.isSuperAdmin && route.name === 'submissions'"
>
<IconButton
icon="streamline-emojis:bar-chart"
tip="数据统计"
@click="toggleStatisticPanel(true)"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item v-if="todayCount > 0">
<component :is="isDesktop ? NH2 : NText" class="todayCount">
<n-gradient-text>今日提交数{{ todayCount }}</n-gradient-text>
</component>
</n-form-item>
</n-form>
</n-space>
</n-card>
<n-space>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item v-if="isDesktop && userStore.isAuthed" label="只看自己">
<n-switch
v-model:value="query.myself"
checked-value="1"
unchecked-value="0"
/>
</n-form-item>
<n-form-item label="状态">
<n-select
class="select"
v-model:value="query.result"
:options="resultOptions"
/>
</n-form-item>
<n-form-item label="语言" v-if="route.name !== 'contest submissions'">
<n-select
class="select"
v-model:value="query.language"
:options="languageOptions"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item>
<n-input
class="input"
clearable
v-model:value="query.username"
placeholder="用户"
/>
</n-form-item>
<n-form-item>
<n-input
class="input"
clearable
v-model:value="query.problem"
placeholder="题号"
/>
</n-form-item>
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item v-if="isMobile && userStore.isAuthed" label="只看自己">
<n-switch
v-model:value="query.myself"
checked-value="1"
unchecked-value="0"
/>
</n-form-item>
<n-form-item>
<n-button @click="search(query.username, query.problem)">
搜索
</n-button>
</n-form-item>
<n-form-item>
<n-button @click="clear" quaternary>重置</n-button>
</n-form-item>
<n-form-item
v-if="userStore.isSuperAdmin && route.name === 'submissions'"
>
<IconButton
icon="streamline-emojis:bar-chart"
tip="数据统计"
@click="toggleStatisticPanel(true)"
/>
</n-form-item>
</n-form>
<n-form
:show-feedback="false"
inline
label-placement="left"
v-if="todayCount > 0"
>
<n-form-item>
<component :is="isDesktop ? NH2 : NText" class="todayCount">
<n-gradient-text>今日提交数{{ todayCount }}</n-gradient-text>
</component>
</n-form-item>
</n-form>
</n-space>
<n-data-table :bordered="false" :columns="columns" :data="submissions" />
</n-flex>
<Pagination