From 8e9b0894baaf410bf20195ec6e7e411f8bbb24e3 Mon Sep 17 00:00:00 2001 From: Ap_Tx <3045929398@qq.com> Date: Sun, 13 Sep 2026 18:25:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=B8=80=E4=BA=9B=E6=98=BE?= =?UTF-8?q?=E7=A4=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ui/Breadcrumbs.vue | 11 ++++++- tools/icon_work/chk_alpha.py | 13 ++++++++ tools/icon_work/fix_bc_label.py | 33 +++++++++++++++++++ tools/icon_work/fix_star_png.py | 32 ++++++++++++++++++ tools/icon_work/inspect_star.py | 29 ++++++++++++++++ tools/icon_work/sample_edge.py | 19 +++++++++++ 6 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 tools/icon_work/chk_alpha.py create mode 100644 tools/icon_work/fix_bc_label.py create mode 100644 tools/icon_work/fix_star_png.py create mode 100644 tools/icon_work/inspect_star.py create mode 100644 tools/icon_work/sample_edge.py diff --git a/apps/app-frontend/src/components/ui/Breadcrumbs.vue b/apps/app-frontend/src/components/ui/Breadcrumbs.vue index 542617f..995e421 100644 --- a/apps/app-frontend/src/components/ui/Breadcrumbs.vue +++ b/apps/app-frontend/src/components/ui/Breadcrumbs.vue @@ -225,12 +225,21 @@ const breadcrumbs = computed(() => { function resolveLabel(name: string): string { return resolveBreadcrumbLabel( name, - (key) => breadcrumbData.getName(key), + (key) => breadcrumbData.getName(key) || fallbackDynamicLabel(key), staticLabels, (message) => formatMessage(message), ) } +// 动态面包屑(?Xxx)在页面异步 setName 之前,回退到静态标签,避免图标与文字不同步 +function fallbackDynamicLabel(key: string): string { + const fallback: Record = { + BrowseTitle: 'Discover content', + } + const staticKey = fallback[key] + return staticKey ? formatMessage(staticLabels[staticKey]) : '' +} + function resolveIcon(breadcrumb: Breadcrumb): Component | undefined { if (breadcrumb.iconUrl || breadcrumbData.getIcon(breadcrumb.name.slice(1))) return undefined const dynamicIcons: Record = { diff --git a/tools/icon_work/chk_alpha.py b/tools/icon_work/chk_alpha.py new file mode 100644 index 0000000..04b3fd2 --- /dev/null +++ b/tools/icon_work/chk_alpha.py @@ -0,0 +1,13 @@ +from PIL import Image +im = Image.open(r"C:\Users\28579\Downloads\resources\resources\netherstar.png") +print("模式:", im.mode) +print("尺寸:", im.size) +print("有 alpha:", im.mode in ("RGBA", "LA")) +if im.mode in ("RGBA", "LA"): + a = im.getchannel("A") + print("alpha bbox:", a.getbbox()) + print("alpha 范围:", a.getextrema()) + # 采样角落像素,看是不是白/透明 + w, h = im.size + print("左上角:", im.getpixel((0, 0))) + print("中心:", im.getpixel((w // 2, h // 2))) \ No newline at end of file diff --git a/tools/icon_work/fix_bc_label.py b/tools/icon_work/fix_bc_label.py new file mode 100644 index 0000000..34603fa --- /dev/null +++ b/tools/icon_work/fix_bc_label.py @@ -0,0 +1,33 @@ +p = r"D:\Project\Starlight_Lancher\apps\app-frontend\src\components\ui\Breadcrumbs.vue" +t = open(p, encoding="utf-8").read() + +old = """function resolveLabel(name: string): string { + return resolveBreadcrumbLabel( + name, + (key) => breadcrumbData.getName(key), + staticLabels, + (message) => formatMessage(message), + ) +}""" +new = """function resolveLabel(name: string): string { + return resolveBreadcrumbLabel( + name, + (key) => breadcrumbData.getName(key) || fallbackDynamicLabel(key), + staticLabels, + (message) => formatMessage(message), + ) +} + +// 动态面包屑(?Xxx)在页面异步 setName 之前,回退到静态标签,避免图标与文字不同步 +function fallbackDynamicLabel(key: string): string { + const fallback: Record = { + BrowseTitle: 'Discover content', + } + const staticKey = fallback[key] + return staticKey ? formatMessage(staticLabels[staticKey]) : '' +}""" + +assert old in t, "resolveLabel 找不到" +t = t.replace(old, new, 1) +open(p, "w", encoding="utf-8", newline="\n").write(t) +print("done") \ No newline at end of file diff --git a/tools/icon_work/fix_star_png.py b/tools/icon_work/fix_star_png.py new file mode 100644 index 0000000..9942b70 --- /dev/null +++ b/tools/icon_work/fix_star_png.py @@ -0,0 +1,32 @@ +from PIL import Image +import numpy as np +from scipy import ndimage + +src = r"C:\Users\28579\Downloads\resources\resources\netherstar.png" +dst = r"D:\Project\Starlight_Lancher\apps\app-frontend\public\models\netherstar.png" + +im = Image.open(src).convert("RGBA") +arr = np.array(im, dtype=np.float32) +r, g, b, a = arr[..., 0], arr[..., 1], arr[..., 2], arr[..., 3] + +# 1) 完全不透明像素的位置 +opaque = a >= 254 +# 2) 对每个通道,用最近的不透明像素值填充(距离变换的索引) +# 用一个临时:在 opaque 区域保留原 RGB,其余待填 +h, w = a.shape +# 用 scipy 的 distance_transform_edt 拿到"最近的 opaque 像素索引" +indices = ndimage.distance_transform_edt(~opaque, return_distances=False, return_indices=True) +nearest_rgb = arr[indices[0], indices[1], :3] + +# 3) 半透明区域(a < 254 且 a > 0)的 RGB 换成最近不透明像素颜色 +semi = (a > 0) & (a < 254) +out = arr.copy() +out[semi, 0:3] = nearest_rgb[semi] + +# 4) 可选:收紧极小 alpha(<8 直接透明),减少杂边 +out[a < 8, 3] = 0 + +out_img = Image.fromarray(np.clip(out, 0, 255).astype(np.uint8), "RGBA") +out_img.save(dst) +print("done ->", dst) +print("尺寸:", out_img.size) \ No newline at end of file diff --git a/tools/icon_work/inspect_star.py b/tools/icon_work/inspect_star.py new file mode 100644 index 0000000..40da611 --- /dev/null +++ b/tools/icon_work/inspect_star.py @@ -0,0 +1,29 @@ +from PIL import Image +im = Image.open(r"C:\Users\28579\Downloads\resources\resources\netherstar.png").convert("RGBA") +w, h = im.size +# 找 alpha 从 0 到 255 的过渡带,看这些像素的 RGB +print("=== 半透明白色像素采样 ===") +cnt = 0 +for y in range(0, h, 5): + for x in range(0, w, 5): + r, g, b, a = im.getpixel((x, y)) + if 0 < a < 255 and r > 240 and g > 240 and b > 240: + print(f"({x},{y}) RGBA=({r},{g},{b},{a})") + cnt += 1 + if cnt >= 10: + break + if cnt >= 10: + break +# 对比:全不透明像素的 RGB +print("\n=== 不透明像素采样 ===") +cnt = 0 +for y in range(0, h, 5): + for x in range(0, w, 5): + r, g, b, a = im.getpixel((x, y)) + if a == 255: + print(f"({x},{y}) RGBA=({r},{g},{b},{a})") + cnt += 1 + if cnt >= 5: + break + if cnt >= 5: + break \ No newline at end of file diff --git a/tools/icon_work/sample_edge.py b/tools/icon_work/sample_edge.py new file mode 100644 index 0000000..7a6d8d9 --- /dev/null +++ b/tools/icon_work/sample_edge.py @@ -0,0 +1,19 @@ +from PIL import Image +im = Image.open(r"C:\Users\28579\Downloads\resources\resources\netherstar.png").convert("RGBA") +w, h = im.size +print("尺寸:", (w, h)) +# 采样边缘一圈(alpha 低但 RGB 接近白的像素 = "脏"边缘) +dirty = 0 +total_edge = 0 +for y in range(0, h, 3): + for x in range(0, w, 3): + r, g, b, a = im.getpixel((x, y)) + if 0 < a < 255: + total_edge += 1 + # alpha 半透明,但 RGB 很亮(接近白)—— 这就是"没剔干净"的迹象 + if r > 240 and g > 240 and b > 240: + dirty += 1 +print("半透明像素总数:", total_edge) +print("半透明中 RGB 接近白的(脏边缘):", dirty) +if total_edge: + print("脏边比例: {:.1f}%".format(dirty / total_edge * 100)) \ No newline at end of file