Skip to content

feat(servicemenu): 简介支持两行折行,减少不必要省略 - #1319

Open
zzd1314 wants to merge 13 commits into
FloatTech:masterfrom
zzd1314:feat/servicemenu-brief-wrap
Open

feat(servicemenu): 简介支持两行折行,减少不必要省略#1319
zzd1314 wants to merge 13 commits into
FloatTech:masterfrom
zzd1314:feat/servicemenu-brief-wrap

Conversation

@zzd1314

@zzd1314 zzd1314 commented Sep 9, 2026

Copy link
Copy Markdown

变更说明

新增 wrapByWidth 函数,按像素宽度把插件简介折成最多两行,解决部分长简介过早省略的问题。

核心改动

  • 新增 wrapByWidth 函数(~50 行)
    • rune 安全 + 二分断行
    • ASCII 单词不从中间断开
    • 末行仍放不下时以省略号截断
  • 简介渲染:单行 -> 最多两行
    • 单行简介垂直居中于简介区
    • 两行简介分别在 y=80 和 y=106
  • 简介字号:22px -> 20px
  • 名称基线:55 -> 50px

关联 PR

本 PR 是 #1318 的后续。

验证

  • go build ./... 已通过
  • go vet ./plugin/servicemenu 已通过

- servicemenu: 封装 loadFont 检查字体加载错误、检查 cmd.Run 错误、
  SetTheme 补注释、删除未用参数、简化 clamp 闭包、gocritic assignOp
- aifalse: fmt.Errorf 改用 pkg/errors(forbidigo)、切片预分配(prealloc)、
  gpTs 改名 gpTS(stylecheck)、gpustate 去掉恒为 nil 的 error 返回(unparam)、
  lhm_autosetup 补齐错误检查与未用参数
- abineundo: syscall.Syscall 升级 SyscallN(SA1019)、消除 else-return(revive)
- hardware_other: 占位函数未用参数改 _
新增 wrapByWidth 函数,按像素宽度把简介折成最多两行:
- ASCII 单词不从中间断开
- 折满两行仍放不下时,末行末尾省略号截断
- 单行简介垂直居中于简介区

同时微调简介字号 22 → 20px(两行布局在 332px 卡宽内更舒展),
名称基线 55 → 50px 为两行简介让位。

本 PR 聚焦简介排版,布局和徽章尺寸在 PR 1318 中调整。
wrapByWidth 引入后 iconD 已在 const 块前声明,下方 const iconD = 28.0
造成 redeclared 错误,golangci-lint typecheck 失败。

CI: golangci-lint ✓ runmain(macos) ✓ (cancelled 依赖 lint 通过)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片资源要和本体解耦,禁止在主仓库中堆放二进制文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants