diff --git a/client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets b/client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets index 8e777b8..8df20ec 100644 --- a/client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets +++ b/client/harmony/entry/src/main/ets/pages/AdminUsersPage.ets @@ -390,8 +390,17 @@ struct AdminUsersPage { .onClick(() => { this.toggleEdit(user); }) } + /* + * 参数类型是 `ResourceColor` 而不是 `string`:底色/文字色可能来自**系统语义色** + * (`Theme.surfaceMuted` / `Theme.textSubtle` 是 `$r('sys.color.*')` ⇒ `Resource`), + * 也可能来自自写色值(`Theme.chipNeutralBg` ⇒ `string`)。写成 `string` 时 + * `user.role === 'admin' ? Theme.chipNeutralBg : Theme.surfaceMuted` 这种三目 + * 就变成 `string | Resource` 而**编译不过**(`ArkTS Compiler Error`,不是警告)。 + * `fontColor`/`backgroundColor` 本来就收 `ResourceColor`,所以放宽参数类型即可, + * 不需要把系统色抄成字符串——那正是这个文件要避免的事。 + */ @Builder - Chip(text: string, bg: string, fg: string) { + Chip(text: string, bg: ResourceColor, fg: ResourceColor) { Text(text) .fontSize(Theme.fontTiny) .fontColor(fg)