fix(harmony): AdminUsersPage 的 Chip 参数放宽到 ResourceColor —— 三个编译期错误(不是警告)
`Chip(text: string, bg: string, fg: string)` 收不下 `Theme.surfaceMuted` /
`Theme.textSubtle`(它们是 `$r('sys.color.*')` ⇒ `Resource`)。于是
`user.role === 'admin' ? Theme.chipNeutralBg : Theme.surfaceMuted` 这类三目
在三处报:
Argument of type 'string | Resource' is not assignable to parameter of type 'string'
Argument of type 'Resource' is not assignable to parameter of type 'string'
(AdminUsersPage.ets:353 / 357 / 368)
`fontColor` / `backgroundColor` 本来就收 `ResourceColor`,所以放宽参数类型即可 ——
不必把系统语义色抄成字符串(那正是 Theme.ets 文件头要避免的事)。
归属与复核(2026-09-15):
- 这三条在 `474cada` / `b806a05` / `7f4fa26` 上**一直红着**,是**提交树里**的错误,
不是任何人的在飞改动。复核方式:`git show 7f4fa26:…/AdminUsersPage.ets | grep -n 'Chip(text'`
⇒ `bg: string`;该文件自 `474cada` 起未被改过(`git log -- <file>`)。
- 同一批的另两条(MainPage.ets 的 `arkts-no-misplaced-imports`)由**别人**在写,
我没有 stage / 没有改那份文件。
- 实测:修前 `hvigorw assembleHap` = BUILD FAILED(6 个 arkts 错误,
含 MainPage 两条 misplaced-imports);MainPage 那份修好后本笔使整个构建
BUILD SUCCESSFUL(本轮实测)。
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user