fix: 收尾 P2——登录恒定耗时、AdminUsage N+1、用量索引重塑与时区缝

- 登录失败路径补 argon2 恒定耗时校验(用户不存在/被禁用与密码错误的时序不可区分,抹掉用户名枚举面)
- AdminUsage 每行 2 次查询改批量预取(100 行分页省 200 次查询)
- usage_logs 补 key_id 索引与 (user,created)/(channel,created) 复合索引(schema v6);AutoMigrate 按名跳过已存在索引,旧库的复合索引需一次性删掉重建,用 system_configs 打标记防 PG 每次启动重演
- 用量统计默认窗口改 UTC(usage_daily 的 date 键是 UTC,非 UTC 服务器上图表窗口偏移一天)
- 注册 email 大小写归一;并发撞唯一索引回查后返回 409 而非 500
- PatchKey 的 name 校验与 CreateKey 对齐(1-64 字符),PATCH 不再能绕过
- TrendChart 条宽不超过槽位(点数多时不再互相重叠),超过 32 个点隐藏标签行
This commit is contained in:
Sakurasan committed 2026-10-29 03:05:56 +08:00
1 parent 4df2506a74
commit 1f8af649ca
7 files changed
+107 -21

No files matched your search

+6 -2
View File
@@ -15,13 +15,17 @@ const chart = computed(() => {
const bw = 100 / props.points.length
const bars = props.points.map((p, i) => ({
x: i * bw,
w: Math.max(bw * 0.5, 2),
// 条宽最小 2 保证可点,但不得超过槽位宽 bw——点数多时(按模型分组)否则互相重叠
w: Math.min(Math.max(bw * 0.5, 2), bw),
h: (p.value / max) * 100,
label: p.label,
value: props.format(p.value),
}))
return { bars, maxLabel: props.format(max) }
})
// 标签行是 flex 均分:点数一多每个标签挤成竖排还与条形错位,超过阈值整行隐藏
const showLabels = computed(() => props.points.length > 0 && props.points.length <= 32)
</script>
<template>
@@ -50,7 +54,7 @@ const chart = computed(() => {
/>
</g>
</svg>
<div class="mt-1 flex justify-between font-mono text-[10px] text-muted">
<div v-if="showLabels" class="mt-1 flex justify-between font-mono text-[10px] text-muted">
<span v-for="b in chart.bars" :key="'l-' + b.label" class="truncate">{{ b.label }}</span>
</div>
</div>