ke: 鸿蒙 UI 整改:emoji→AmIcon 图标、宽屏侧栏、Md 第三方库、通知可配置项
- common/Icons.ets(生成器产出):43 枚与 WebUI icons.tsx 同几何的 Path 图标 - NavItems.ts:icon(emoji) → iconKey,与 WebUI 导航同图标 - 全页面 emoji 清除(空态改单行灰字,按钮/头像/刷新等换 AmIcon) - MailDetailPage 接入 @luvi/lv-markdown-in(第三方,替代手写解析器) - WideSidebar + MainPage isWide(≥768vp):宽屏侧栏 60vp 图标轨、藏底部条、onAreaChange 断点 - 通知=可配置项(默认关):PushService.isEnabled/setEnabled + reportToken 最前 gate (关=不取token/不弹权限/不打网关)+ SettingsPage Toggle + 服务端通道状态提示 - EntryAbility.onCreate 解析 want:冷启点通知也能路由(原来只有 onNewWant) - 判据:harmony-widescreen(4) + harmony-push-optin(4) 新增;harmony-nav 同步 iconKey/条件 padding
This commit is contained in:
80
client/harmony/entry/src/main/ets/pages/WideSidebar.ets
Normal file
80
client/harmony/entry/src/main/ets/pages/WideSidebar.ets
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 宽屏侧栏图标轨 —— **一比一复刻 WebUI 的 `Sidebar.tsx`**。
|
||||
*
|
||||
* WebUI 的 `Sidebar`(60px 宽)是一列图标按钮:
|
||||
* · 品牌标(顶部)
|
||||
* · 通信 / 日历 / 联系人(中部)
|
||||
* · 设置(底部)
|
||||
* 选中态:文字/图标变色 + 品牌浅底(`nav-active-bg`),**不加背景块、不加指示条**
|
||||
* (用户 2026-09-14:「同时底部导航栏选中对应的文字和图标变色即可」)。
|
||||
*
|
||||
* 鸿蒙这一侧原先**完全没有宽屏布局**(只有底部导航条),所以这个文件同时承担
|
||||
* "宽屏入口"的角色。判据 `harmony-widescreen.test.mjs` 会检查:
|
||||
* · 60vp 宽(与 WebUI 的 60px 一致)
|
||||
* · 三项导航 + 设置按钮
|
||||
* · 选中态只换颜色(与底部导航同一套纪律)
|
||||
*/
|
||||
|
||||
import { Theme } from '../common/Theme';
|
||||
import { AmIcon } from '../common/Icons';
|
||||
import { NAV_ITEMS, NavItem } from '../model/NavItems';
|
||||
|
||||
/** 侧栏宽度(vp)。WebUI 的 `Sidebar` 用 `w-[60px]` */
|
||||
export const SIDEBAR_WIDTH: number = 60;
|
||||
|
||||
@Component
|
||||
export struct WideSidebar {
|
||||
/** 当前选中的导航下标 */
|
||||
@Prop currentIndex: number = 0;
|
||||
/** 选中回调 */
|
||||
onSelect: (index: number) => void = (): void => {};
|
||||
/** 设置回调 */
|
||||
onSettings: () => void = (): void => {};
|
||||
|
||||
@Builder
|
||||
NavItemBuilder(key: string, label: string, iconKey: string, index: number) {
|
||||
Column() {
|
||||
AmIcon({
|
||||
iconName: iconKey,
|
||||
iconSize: 22,
|
||||
iconColor: this.currentIndex === index ? Theme.navFgActive : Theme.navFg
|
||||
})
|
||||
Text(label)
|
||||
.fontSize(Theme.fontTiny)
|
||||
.fontColor(this.currentIndex === index ? Theme.navFgActive : Theme.navFg)
|
||||
.margin({ top: 2 })
|
||||
}
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.onClick(() => { this.onSelect(index); })
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 品牌标
|
||||
AmIcon({ iconName: 'brandMark', iconSize: 26, iconColor: Theme.accent })
|
||||
.margin({ bottom: 16 })
|
||||
|
||||
// 导航项
|
||||
ForEach(NAV_ITEMS, (item: NavItem, index: number) => {
|
||||
this.NavItemBuilder(item.key, item.label, item.iconKey, index)
|
||||
}, (item: NavItem) => item.key)
|
||||
|
||||
Blank()
|
||||
|
||||
// 设置
|
||||
Column() {
|
||||
AmIcon({ iconName: 'person', iconSize: 22, iconColor: Theme.navFg })
|
||||
Text('我的').fontSize(Theme.fontTiny).fontColor(Theme.navFg).margin({ top: 2 })
|
||||
}
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.onClick(() => { this.onSettings(); })
|
||||
}
|
||||
.width(SIDEBAR_WIDTH)
|
||||
.height('100%')
|
||||
.padding({ top: 12, bottom: 12 })
|
||||
.backgroundColor(Theme.surface)
|
||||
.borderRadius(Theme.radiusCard)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user