feat(reaction): 前端表情常量、类型与 API

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 03:19:39 -06:00
parent 8a46bae27d
commit d16e3dddb8
4 changed files with 67 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import type { AchievementRarity, SUBMISSION_RESULT } from "./types"
import type { AchievementRarity, SUBMISSION_RESULT, ReactionKey } from "./types"
export enum SubmissionStatus {
compile_error = -2,
@@ -346,3 +346,27 @@ export const USERNAME_CLASS_RE = new RegExp(
/** 班级号作为数字时的上下界,给 n-input-number 用 */
export const CLASS_NAME_MIN_VALUE = 10 ** (CLASS_NAME_MIN_DIGITS - 1)
export const CLASS_NAME_MAX_VALUE = 10 ** CLASS_NAME_MAX_DIGITS - 1
export const REACTIONS: {
key: ReactionKey
label: string
icon: string
}[] = [
{
key: "too_easy",
label: "太简单",
icon: "fluent-emoji:smiling-face-with-sunglasses",
},
{ key: "too_hard", label: "太难了", icon: "fluent-emoji:exploding-head" },
{
key: "confusing",
label: "没看懂",
icon: "fluent-emoji:face-with-spiral-eyes",
},
{ key: "buggy", label: "题目有错", icon: "fluent-emoji:bug" },
{ key: "learned", label: "学到了", icon: "fluent-emoji:light-bulb" },
{ key: "interesting", label: "有意思", icon: "fluent-emoji:star-struck" },
{ key: "want_explain", label: "想听讲解", icon: "fluent-emoji:books" },
]
export const MAX_REACTIONS = 3

View File

@@ -606,6 +606,28 @@ export interface Comment {
user: SampleUser
}
export type ReactionKey =
| "too_easy"
| "too_hard"
| "confusing"
| "buggy"
| "learned"
| "interesting"
| "want_explain"
export type ReactionCounts = Record<ReactionKey, number>
export interface ReactionState {
mine: ReactionKey[]
counts: ReactionCounts | null
}
export interface ReactionStatsRow extends ReactionCounts {
pid: string
title: string
users: number
}
export interface Tutorial {
id: number
title: string