diff --git a/apps/api/src/routes/ranking.ts b/apps/api/src/routes/ranking.ts index 09bef46..76655d7 100644 --- a/apps/api/src/routes/ranking.ts +++ b/apps/api/src/routes/ranking.ts @@ -202,8 +202,11 @@ rankingRoutes.get("/rankings/board", optionalAuth, async (c) => { ) } + // 全服 100 名以外:不报具体名次,前后一名、走势都不给,只给第 100 名算还差几道 + const beyond = !!(cap && me && me.rank > cap) + let trend: RankBoard["trend"] = null - if (me && period.data !== "week") { + if (me && !beyond && period.data !== "week") { const thisWeek = Date.parse(weekStart()) const points = Array.from( { length: TREND_WEEKS }, @@ -237,9 +240,10 @@ rankingRoutes.get("/rankings/board", optionalAuth, async (c) => { rows: picked.map((row) => rowOf(row)!), complete: picked.length === listable.length, cap, + lastListed: beyond ? rowOf(listable.at(-1)) : null, me: rowOf(me), - ahead: rowOf(meIndex > 0 ? now[meIndex - 1] : undefined), - behind: rowOf(meIndex >= 0 ? now[meIndex + 1] : undefined), + ahead: beyond ? null : rowOf(meIndex > 0 ? now[meIndex - 1] : undefined), + behind: beyond ? null : rowOf(meIndex >= 0 ? now[meIndex + 1] : undefined), trend, hidden: !!mine?.rankHiddenAt, hiddenUsers: hiddenUsers.map((row): SampleUser => sampleUser(row, null)), diff --git a/apps/web/src/oj/rank/components/RankMe.vue b/apps/web/src/oj/rank/components/RankMe.vue index 2f26836..9a7267f 100644 --- a/apps/web/src/oj/rank/components/RankMe.vue +++ b/apps/web/src/oj/rank/components/RankMe.vue @@ -11,6 +11,8 @@ export interface MiniRank { label: string rank: number | null total: number | null + /** 那张榜最多列到第几名(全服 100);名次在这之外就只写「100 名以外」 */ + cap?: number | null go: () => void } @@ -31,6 +33,10 @@ const props = defineProps<{ /** 领奖台第 3 名(我不在台上时用来算「再做对几道上领奖台」) */ third: RankRow | null total: number + /** 名单最多列到第几名(全服 100)。我在这之外只写「100 名以外」,不报具体名次 */ + cap?: number | null + /** 我在 cap 名以外时,名单上最后那一位:算「再做对几道进前 100」 */ + lastListed?: RankRow | null label: string minis: MiniRank[] /** 手机:前后一名的说明换到名字下面一行,别被截断 */ @@ -70,8 +76,12 @@ async function saveMood() { } } +const beyond = computed(() => !!props.cap && props.me.rank > props.cap) + const headline = computed(() => { const { me, ahead, third } = props + if (beyond.value) + return props.lastListed ? `再做对 ${toPass(me, props.lastListed)} 道就进前 ${props.cap}` : "" if (me.rank === 1) return "你是第一名" if (me.rank <= 3 && ahead) return `你在领奖台上 · 再做对 ${toPass(me, ahead)} 道就是第 ${ahead.rank} 名` @@ -105,9 +115,12 @@ function threatNote(me: RankRow, behind: RankRow) {
{{ label }}
- 第{{ me.rank }}名 - / {{ total }} + {{ cap }} 名以外 + ↑{{ me.change }} ↓{{ -me.change! }}
@@ -219,7 +232,8 @@ function threatNote(me: RankRow, behind: RankRow) {