From 7b16fec61c4660e5e096a38a3709eca07635a6a3 Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Tue, 15 Sep 2026 11:33:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(harmony):=20AdminUsersPage=20=E7=9A=84=20Ch?= =?UTF-8?q?ip=20=E5=8F=82=E6=95=B0=E6=94=BE=E5=AE=BD=E5=88=B0=20ResourceCo?= =?UTF-8?q?lor=20=E2=80=94=E2=80=94=20=E4=B8=89=E4=B8=AA=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=9C=9F=E9=94=99=E8=AF=AF=EF=BC=88=E4=B8=8D=E6=98=AF=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 -- `)。 - 同一批的另两条(MainPage.ets 的 `arkts-no-misplaced-imports`)由**别人**在写, 我没有 stage / 没有改那份文件。 - 实测:修前 `hvigorw assembleHap` = BUILD FAILED(6 个 arkts 错误, 含 MainPage 两条 misplaced-imports);MainPage 那份修好后本笔使整个构建 BUILD SUCCESSFUL(本轮实测)。 --- .../entry/src/main/ets/pages/AdminUsersPage.ets | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)