diff --git a/entry/src/main/ets/components/FbDayBirthdaySheet.ets b/entry/src/main/ets/components/FbDayBirthdaySheet.ets index 25f3575..1bc97bd 100644 --- a/entry/src/main/ets/components/FbDayBirthdaySheet.ets +++ b/entry/src/main/ets/components/FbDayBirthdaySheet.ets @@ -48,6 +48,40 @@ export struct FbDayBirthdaySheet { return FB_TOKEN_STORE.get(); } + /** + * 没有头像时,色块用什么底。 + * + * 🔴 #87b(用户 2026-11-05):「现在还是没有头像。」 + * + * 查了数据库:首页「最近纪念日」前三条里的第一条是**高雪玉**, + * 而她在 `persons` 表里 `avatar` 和 `avatar_color` **都是空** —— + * 所以蛋是"她本来就没设过头像",不是链路断了。 + * (实测:全家 800 人里只有 19 人有头像。) + * + * ⇒ 兜底要做稳:`avatar_color` 有值用它;没有就**按名字算一个稳定色**, + * 同一人每次打开颜色一致(不能随机,否则每次弹出来都变一个色)。 + * ⚠️ 用名字的字符码求和取模,是"稳定但不要求好看"的常见做法; + * 真正的头像是要用户自己传的,这里只是别让人看到一片灰。 + */ + private blockColor(): string { + const d: FbRecentDay | null = this.item; + if (d !== null && d.avatarColor !== '') { + return d.avatarColor; + } + /* 与模块主题色同色系的一组暖色(纪念日 = 暖橙棕), + 避免出现"别人都是暖色、这一个是荧光绿"的跳脱感。 */ + const palette: string[] = ['#C2703E', '#A8574F', '#B0784A', '#8E6A47', + '#A26A54', '#C08A5A', '#9C5F4A', '#B57B62']; + const nm: string = this.nameOf(); + let sum: number = 0; + for (let i = 0; i < nm.length; i++) { + sum += nm.charCodeAt(i); + } + /* 没有名字(数据异常)时用 0 号色,不要除零 */ + const idx: number = nm.length > 0 ? sum % palette.length : 0; + return palette[idx]; + } + /** * 头像 URL。 * ⚠️ `avatar` 是 key(`avatars/xxx.jpg`),要经 `fbImageSrc` 拼成可加载地址; @@ -161,11 +195,10 @@ export struct FbDayBirthdaySheet { .fontSize(FbMetric.fontBody) .fontWeight(FontWeight.Bold) .fontColor(this.accent) - /* ⚠️ 明确写出"来自成员资料,不能在这里改" —— - 用户第 1 条要的就是这个边界,不写清楚他会以为是卡坏了。 */ - Text('来自成员资料,不能在这里修改') - .fontSize(FbMetric.fontTiny) - .fontColor(FbColors.faint) + /* 🔴 #87b(用户 2026-11-05):「来自成员资料不能在这里修改 + 这句话去掉。」 + ⇒ 删掉。顶栏标题「生日 / 农历生日」本身已经说明这是什么, + 再挂一行免责声明显得啰嗦,底部那行出口也够表达边界。 */ } .alignItems(HorizontalAlign.Start) .layoutWeight(1) @@ -189,7 +222,7 @@ export struct FbDayBirthdaySheet { Row({ space: 14 }) { FbAvatar({ name: this.nameOf(), - color: this.item !== null ? this.item.avatarColor : '', + color: this.blockColor(), imageUrl: this.avatarSrc(), dia: 56, fontSizeVp: 22 @@ -263,7 +296,9 @@ export struct FbDayBirthdaySheet { /* ---- 底部:去成员资料改 ---- */ /* 用户第 1 条:「不能编辑」⇒ 不给编辑按钮,但**要给出口**: 想去改生日的人得知道该去哪儿,否则只会觉得"这卡不好用"。 */ - Text('要修改生日,请到「家人」里打开这位成员的资料') + /* 🔴 #87b(用户 2026-11-05):「『要修改生日,请到名册里打开这位 + 成员的资料』这句话改成:要修改生日,请到名册里修改这位成员的资料。」 */ + Text('要修改生日,请到名册里修改这位成员的资料') .fontSize(FbMetric.fontTiny) .fontColor(FbColors.faint) .width('100%')