题目点评按钮改成大图标按钮
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

七个按钮放大到 48px 高、图标 28px,去掉按钮内的中文标签(移到 hover
tooltip 里),计数改成 ×N 形式。不再用 n-button,改成原生 button 自己写
样式。窄面板下从横向滚动改成换行,避免按钮被滚动条藏起来。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 05:55:29 -06:00
parent c4d55bb88e
commit b3d0c3fcc7

View File

@@ -1,21 +1,17 @@
<template> <template>
<n-alert v-if="!userStore.isAuthed" type="error" title="请先登录" /> <n-alert v-if="!userStore.isAuthed" type="error" title="请先登录" />
<div v-else ref="container" class="reactions"> <div v-else class="reactions">
<n-tooltip v-for="item in REACTIONS" :key="item.key" trigger="hover"> <n-tooltip v-for="item in REACTIONS" :key="item.key" trigger="hover">
<template #trigger> <template #trigger>
<span class="reaction-trigger"> <button
<n-button class="reaction-button"
size="small" :class="{ active: mine.includes(item.key) }"
:disabled="isDisabled(item.key)" :disabled="isDisabled(item.key)"
:type="mine.includes(item.key) ? 'primary' : 'default'" @click="toggle(item.key)"
:ghost="mine.includes(item.key)" >
@click="toggle(item.key)" <Icon :icon="item.icon" :width="28" />
> <span v-if="counts" class="count">×{{ counts[item.key] }}</span>
<Icon :icon="item.icon" :width="18" /> </button>
<span v-if="showLabel" class="label">{{ item.label }}</span>
<span v-if="counts" class="count">{{ counts[item.key] }}</span>
</n-button>
</span>
</template> </template>
{{ tooltipOf(item.key, item.label) }} {{ tooltipOf(item.key, item.label) }}
</n-tooltip> </n-tooltip>
@@ -36,11 +32,6 @@ const problemStore = useProblemStore()
const { problem } = storeToRefs(problemStore) const { problem } = storeToRefs(problemStore)
const message = useMessage() const message = useMessage()
const container = ref<HTMLElement | null>(null)
const { width } = useElementSize(container)
// 七个按钮带中文标签大约需要 560px放不下就只留图标和计数
const showLabel = computed(() => width.value >= 560)
const mine = ref<ReactionKey[]>([]) const mine = ref<ReactionKey[]>([])
const counts = ref<ReactionCounts | null>(null) const counts = ref<ReactionCounts | null>(null)
@@ -55,7 +46,6 @@ function isDisabled(key: ReactionKey) {
function tooltipOf(key: ReactionKey, label: string) { function tooltipOf(key: ReactionKey, label: string) {
if (!solved.value) return "完成本题后可以评价" if (!solved.value) return "完成本题后可以评价"
if (isDisabled(key)) return `最多选 ${MAX_REACTIONS} 个,先取消一个` if (isDisabled(key)) return `最多选 ${MAX_REACTIONS} 个,先取消一个`
if (counts.value) return `${counts.value[key]} 人选了「${label}`
return label return label
} }
@@ -102,21 +92,43 @@ onMounted(() => {
</script> </script>
<style scoped> <style scoped>
/* 七个按钮一行约需 700px窄面板放不下就换行不做横向滚动免得按钮被藏起来 */
.reactions { .reactions {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: wrap;
gap: 8px; gap: 8px;
overflow-x: auto;
} }
.reaction-trigger { .reaction-button {
display: inline-flex;
flex-shrink: 0; flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 6px;
height: 48px;
padding: 0 14px;
border: 1px solid rgba(128, 128, 128, 0.3);
border-radius: 8px;
background: transparent;
color: inherit;
font: inherit;
cursor: pointer;
transition:
border-color 0.2s,
background-color 0.2s;
} }
.label { .reaction-button:hover:not(:disabled) {
margin-left: 4px; border-color: rgba(128, 128, 128, 0.6);
background: rgba(128, 128, 128, 0.1);
}
.reaction-button.active {
border-color: #18a058;
background: rgba(24, 160, 88, 0.12);
}
.reaction-button:disabled {
opacity: 0.5;
cursor: not-allowed;
} }
.count { .count {
margin-left: 6px; font-size: 15px;
opacity: 0.7; opacity: 0.7;
} }
</style> </style>