Skip to content

Commit 4e91eaf

Browse files
Hieriferhuteng
andauthored
feat(fe,harmony): add tabbar api (#170) (#223)
* feat: add tabbar on harmony * feat(fe): add h5 tabbar * fix(fe): tabbar height * fix: code review issue and compile tabbar icon * fix: code review issue * feat: remove useless comment --------- Co-authored-by: huteng <huteng@echo.tech>
1 parent 29d4ff0 commit 4e91eaf

19 files changed

Lines changed: 1419 additions & 66 deletions

File tree

fe/packages/compiler/src/core/config-compiler.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
import fs from 'node:fs'
22
import {
33
getAppConfigInfo,
4+
getAppId,
45
getAppName,
56
getPageConfigInfo,
67
getTargetPath,
8+
getWorkPath,
79
} from '../env.js'
10+
import { collectAssets } from '../common/utils.js'
11+
12+
/**
13+
* 处理 tabBar.list 中的 iconPath / selectedIconPath。
14+
* 视为相对小程序根目录的资源,复用 collectAssets 拷贝到 main/static/,
15+
* 并把 list 中的路径改写成产物 URL,避免容器侧再做特殊解析。
16+
*
17+
* 注意:会在原 app 配置上原地修改,不影响后续输出(compileConfig 是
18+
* 整个流水线最后才走到的环节,不会被再次读取)。
19+
*/
20+
function processTabBarIcons(app) {
21+
const list = app?.tabBar?.list
22+
if (!Array.isArray(list) || list.length === 0) {
23+
return
24+
}
25+
const workPath = getWorkPath()
26+
const targetPath = getTargetPath()
27+
const appId = getAppId()
28+
29+
for (const item of list) {
30+
// 第二参数 pagePath 留空 → collectAssets 内部 relativePath = '',
31+
// 等价于把 src 当成相对小程序根目录解析,与 app.json 同级
32+
if (item.iconPath) {
33+
item.iconPath = collectAssets(workPath, '', item.iconPath, targetPath, appId)
34+
}
35+
if (item.selectedIconPath) {
36+
item.selectedIconPath = collectAssets(workPath, '', item.selectedIconPath, targetPath, appId)
37+
}
38+
}
39+
}
840

941
/**
1042
*
1143
* 编译项目配置文件 app-config.json
1244
*/
1345
function compileConfig() {
46+
const app = getAppConfigInfo()
47+
48+
// 把 tabBar 图标复制到产物目录并改写 iconPath
49+
processTabBarIcons(app)
50+
1451
const compileResInfo = {
15-
app: getAppConfigInfo(),
52+
app,
1653
modules: getPageConfigInfo(),
1754
projectName: getAppName(),
1855
}

fe/packages/container/src/pages/miniApp/miniApp.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<!-- webview挂载节点 -->
99
<div class="dimina-mini-app__webviews"></div>
1010

11+
<!-- TabBar 底部导航栏 -->
12+
<div class="dimina-mini-app__tabbar" style="display: none;"></div>
13+
1114
<!-- 启动loading页面 -->
1215
<div class="dimina-mini-app__launch-screen">
1316
<div class="dimina-mini-app__launch-screen-content">

0 commit comments

Comments
 (0)