Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
65d74e8b
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65d74e8b
编写于
4月 22, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add onNavigationBarButtonTap
上级
84d20e77
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
26 deletion
+39
-26
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+17
-7
packages/uni-h5/src/framework/components/page/pageHead.tsx
packages/uni-h5/src/framework/components/page/pageHead.tsx
+22
-19
未找到文件。
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
65d74e8b
...
...
@@ -13502,7 +13502,7 @@ var PageHead = /* @__PURE__ */ defineComponent({
clazz
,
style
:
style2
}
=
usePageHead
(
navigationBar
);
const
buttons
=
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__
&&
usePageHeadButtons
(
navigationBar
);
const
buttons
=
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__
&&
usePageHeadButtons
(
pageMeta
);
const
searchInput
=
__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__
&&
navigationBar
.
searchInput
&&
usePageHeadSearchInput
(
pageMeta
);
__UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__
&&
navigationBar
.
type
===
"
transparent
"
&&
usePageHeadTransparent
(
headRef
,
pageMeta
);
return
()
=>
{
...
...
@@ -13544,6 +13544,7 @@ function createBackButtonTsx(pageMeta) {
}
function
createButtonsTsx
(
btns
)
{
return
btns
.
map
(({
onClick
,
btnClass
,
btnStyle
,
btnText
,
...
...
@@ -13555,12 +13556,13 @@ function createButtonsTsx(btns) {
key
:
index2
,
class
:
btnClass
,
style
:
btnStyle
,
onClick
,
"
badge-text
"
:
badgeText
},
[
btnIconPath
?
createSvgIconVNode
(
btnIconPath
,
iconStyle
.
color
,
iconStyle
.
fontSize
)
:
createVNode
(
"
i
"
,
{
class
:
"
uni-btn-icon
"
,
style
:
iconStyle
,
innerHTML
:
btnText
},
null
,
12
,
[
"
innerHTML
"
])],
14
,
[
"
badge-text
"
]);
},
null
,
12
,
[
"
innerHTML
"
])],
14
,
[
"
onClick
"
,
"
badge-text
"
]);
});
}
function
createPageHeadBdTsx
(
navigationBar
,
searchInput
)
{
...
...
@@ -13696,7 +13698,10 @@ function usePageHead(navigationBar) {
style
:
style2
};
}
function
usePageHeadButtons
(
navigationBar
)
{
function
usePageHeadButtons
({
id
:
id2
,
navigationBar
})
{
const
left
=
[];
const
right
=
[];
const
{
...
...
@@ -13708,7 +13713,7 @@ function usePageHeadButtons(navigationBar) {
}
=
navigationBar
;
const
isTransparent
=
type
===
"
transparent
"
;
const
fonts
=
Object
.
create
(
null
);
buttons
.
forEach
((
btn
)
=>
{
buttons
.
forEach
((
btn
,
index2
)
=>
{
if
(
btn
.
fontSrc
&&
!
btn
.
fontFamily
)
{
const
fontSrc
=
getRealPath
(
btn
.
fontSrc
);
let
fontFamily
=
fonts
[
fontSrc
];
...
...
@@ -13719,7 +13724,7 @@ function usePageHeadButtons(navigationBar) {
}
btn
.
fontFamily
=
fontFamily
;
}
const
pageHeadBtn
=
usePageHeadButton
(
btn
,
isTransparent
);
const
pageHeadBtn
=
usePageHeadButton
(
id2
,
index2
,
btn
,
isTransparent
);
if
(
btn
.
float
===
"
left
"
)
{
left
.
push
(
pageHeadBtn
);
}
else
{
...
...
@@ -13732,7 +13737,7 @@ function usePageHeadButtons(navigationBar) {
right
};
}
function
usePageHeadButton
(
btn
,
isTransparent
)
{
function
usePageHeadButton
(
pageId
,
index2
,
btn
,
isTransparent
)
{
const
iconStyle
=
{
color
:
btn
.
color
,
fontSize
:
btn
.
fontSize
,
...
...
@@ -13754,7 +13759,12 @@ function usePageHeadButton(btn, isTransparent) {
btnText
:
btn
.
fontSrc
&&
btn
.
fontFamily
?
btn
.
text
.
replace
(
"
\\
u
"
,
"
&#x
"
)
:
btn
.
text
,
btnIconPath
:
ICON_PATHS
[
btn
.
type
],
badgeText
:
btn
.
badgeText
,
iconStyle
iconStyle
,
onClick
()
{
invokeHook
(
pageId
,
"
onNavigationBarButtonTap
"
,
extend
({
index
:
index2
},
btn
));
}
};
}
function
usePageHeadSearchInput
({
...
...
packages/uni-h5/src/framework/components/page/pageHead.tsx
浏览文件 @
65d74e8b
import
{
computed
,
defineComponent
,
ref
}
from
'
vue
'
import
{
isArray
}
from
'
@vue/shared
'
import
{
extend
,
isArray
}
from
'
@vue/shared
'
import
{
Input
}
from
'
@dcloudio/uni-components
'
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
import
{
...
...
@@ -45,7 +45,7 @@ export default /*#__PURE__*/ defineComponent({
const
{
clazz
,
style
}
=
usePageHead
(
navigationBar
)
const
buttons
=
(
__UNI_FEATURE_NAVIGATIONBAR_BUTTONS__
&&
usePageHeadButtons
(
navigationBar
))
as
PageHeadButtons
usePageHeadButtons
(
pageMeta
))
as
PageHeadButtons
const
searchInput
=
(
__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__
&&
navigationBar
.
searchInput
&&
...
...
@@ -112,7 +112,15 @@ function createBackButtonTsx(pageMeta: UniApp.PageRouteMeta) {
function
createButtonsTsx
(
btns
:
PageHeadButton
[])
{
return
btns
.
map
(
(
{
btnClass
,
btnStyle
,
btnText
,
btnIconPath
,
badgeText
,
iconStyle
},
{
onClick
,
btnClass
,
btnStyle
,
btnText
,
btnIconPath
,
badgeText
,
iconStyle
,
},
index
)
=>
{
return
(
...
...
@@ -120,6 +128,7 @@ function createButtonsTsx(btns: PageHeadButton[]) {
key
=
{
index
}
class
=
{
btnClass
}
style
=
{
btnStyle
}
onClick
=
{
onClick
}
badge
-
text
=
{
badgeText
}
>
{
btnIconPath
?
(
...
...
@@ -283,21 +292,10 @@ function usePageHead(navigationBar: UniApp.PageNavigationBar) {
}
}
interface
PageHeadButton
{
btnClass
:
UniApp
.
ClassObj
btnStyle
:
UniApp
.
StyleObj
btnText
:
string
btnIconPath
?:
string
badgeText
?:
string
iconStyle
:
UniApp
.
StyleObj
}
type
PageHeadButton
=
ReturnType
<
typeof
usePageHeadButton
>
type
PageHeadButtons
=
ReturnType
<
typeof
usePageHeadButtons
>
interface
PageHeadButtons
{
left
:
PageHeadButton
[]
right
:
PageHeadButton
[]
}
function
usePageHeadButtons
(
navigationBar
:
UniApp
.
PageNavigationBar
)
{
function
usePageHeadButtons
({
id
,
navigationBar
}:
UniApp
.
PageRouteMeta
)
{
const
left
:
PageHeadButton
[]
=
[]
const
right
:
PageHeadButton
[]
=
[]
const
{
buttons
}
=
navigationBar
...
...
@@ -305,7 +303,7 @@ function usePageHeadButtons(navigationBar: UniApp.PageNavigationBar) {
const
{
type
}
=
navigationBar
const
isTransparent
=
type
===
'
transparent
'
const
fonts
=
Object
.
create
(
null
)
buttons
.
forEach
((
btn
)
=>
{
buttons
.
forEach
((
btn
,
index
)
=>
{
if
(
btn
.
fontSrc
&&
!
btn
.
fontFamily
)
{
const
fontSrc
=
getRealPath
(
btn
.
fontSrc
)
let
fontFamily
=
fonts
[
fontSrc
]
...
...
@@ -319,7 +317,7 @@ function usePageHeadButtons(navigationBar: UniApp.PageNavigationBar) {
}
btn
.
fontFamily
=
fontFamily
}
const
pageHeadBtn
=
usePageHeadButton
(
btn
,
isTransparent
)
const
pageHeadBtn
=
usePageHeadButton
(
id
,
index
,
btn
,
isTransparent
)
if
(
btn
.
float
===
'
left
'
)
{
left
.
push
(
pageHeadBtn
)
}
else
{
...
...
@@ -331,6 +329,8 @@ function usePageHeadButtons(navigationBar: UniApp.PageNavigationBar) {
}
function
usePageHeadButton
(
pageId
:
number
,
index
:
number
,
btn
:
UniApp
.
PageNavigationBarButton
,
isTransparent
:
boolean
)
{
...
...
@@ -358,6 +358,9 @@ function usePageHeadButton(
btnIconPath
:
ICON_PATHS
[
btn
.
type
],
badgeText
:
btn
.
badgeText
,
iconStyle
,
onClick
()
{
invokeHook
(
pageId
,
'
onNavigationBarButtonTap
'
,
extend
({
index
},
btn
))
},
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录