- 批量建号先选班再贴名单,用户名就是名字;被别的班或注册的号占了自动加数字(xuyue2)。 查重改成查「这个班里有没有同名的」,老号按剥掉 ks 前缀的名字比 - 后台编辑、新建用户能直接选班级;以前班级只能从用户名的 ks 前缀推,改不了 - 登录点名字时名单接口一并给出用户名,新号老号都登得上;本机记的班级兼容旧的 ks257 写法 - 筛选、抽人、「看看他们的写法」都按班级认人,不再拼 ks 前缀(新号拼出来永远圈不进去) - 接口 PUT /me/profile 不再收真名:界面早没入口,但早几届有 44 人把真名改成了外号 - 0042:两个被推成非班号班级的老号(xrm、王仁杰)改成没填班级 - 老账号不改名,只认 ks 前缀的地方收在契约 username.ts 一处 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.0 KiB
Vue
73 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
import { useDark } from '@vueuse/core'
|
|
import { rgba } from 'shared/composables/tone'
|
|
import { displayName } from '@oj2/contract'
|
|
|
|
/**
|
|
* 排名页的头像。九成以上的学生没换过头像(1797 个号是 default.png),一排一模一样的
|
|
* 默认图分不出人,所以默认头像画成「名字最后一个字 + 彩色圆」,颜色按用户名固定 ——
|
|
* 同一个人在领奖台、赛道、「你」那张卡里是同一个颜色。自己是实心绿。
|
|
*/
|
|
const props = defineProps<{
|
|
username: string
|
|
avatar: string | null
|
|
size: number
|
|
me?: boolean
|
|
}>()
|
|
|
|
const isDark = useDark()
|
|
/** 头像文件丢了(备份恢复后没拷上传目录、被删)就退回名字那个字,别露出破图 */
|
|
const broken = ref(false)
|
|
watch(
|
|
() => props.avatar,
|
|
() => (broken.value = false),
|
|
)
|
|
|
|
const PALETTE = ['#2f6fd0', '#c76a12', '#6a4bd8', '#0f7a6c', '#b4315f', '#4d5967', '#8a6a00']
|
|
|
|
const letter = computed(() => {
|
|
const name = displayName(props.username)
|
|
return Array.from(name).at(-1) ?? '?'
|
|
})
|
|
|
|
const colors = computed(() => {
|
|
if (props.me) return { background: '#18a058', color: '#ffffff' }
|
|
let hash = 0
|
|
for (const char of props.username) hash = (hash * 31 + char.codePointAt(0)!) >>> 0
|
|
const base = PALETTE[hash % PALETTE.length]!
|
|
return { background: rgba(base, isDark.value ? 0.28 : 0.13), color: base }
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<img v-if="avatar && !broken" class="avatar" :src="avatar" alt="" @error="broken = true" :style="{ width: `${size}px`, height: `${size}px` }" />
|
|
<span
|
|
v-else
|
|
class="avatar letter"
|
|
aria-hidden="true"
|
|
:style="{
|
|
width: `${size}px`,
|
|
height: `${size}px`,
|
|
fontSize: `${Math.round(size * 0.5)}px`,
|
|
...colors,
|
|
}"
|
|
>{{ letter }}</span
|
|
>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.avatar {
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.letter {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: 700;
|
|
line-height: 1;
|
|
}
|
|
</style>
|