Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzb_79
uni-app
提交
d700685c
U
uni-app
项目概览
lzb_79
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d700685c
编写于
4月 21, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add startPullDownRefresh,stopPullDownRefresh
上级
6f01c20f
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
165 addition
and
59 deletion
+165
-59
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+2
-0
packages/uni-api/src/protocols/ui/startPullDownRefresh.ts
packages/uni-api/src/protocols/ui/startPullDownRefresh.ts
+2
-0
packages/uni-api/src/protocols/ui/stopPullDownRefresh.ts
packages/uni-api/src/protocols/ui/stopPullDownRefresh.ts
+2
-0
packages/uni-core/src/service/plugin/appConfig.ts
packages/uni-core/src/service/plugin/appConfig.ts
+1
-1
packages/uni-core/src/service/plugin/index.ts
packages/uni-core/src/service/plugin/index.ts
+17
-1
packages/uni-core/src/service/plugin/subscribe.ts
packages/uni-core/src/service/plugin/subscribe.ts
+4
-0
packages/uni-core/src/view/plugin/componentInstance.ts
packages/uni-core/src/view/plugin/componentInstance.ts
+4
-2
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+54
-27
packages/uni-h5/src/framework/components/page/index.ts
packages/uni-h5/src/framework/components/page/index.ts
+3
-1
packages/uni-h5/src/framework/components/page/page-refresh/index.ts
...ni-h5/src/framework/components/page/page-refresh/index.ts
+12
-14
packages/uni-h5/src/framework/plugin/page.ts
packages/uni-h5/src/framework/plugin/page.ts
+5
-5
packages/uni-h5/src/framework/plugin/provide/page.ts
packages/uni-h5/src/framework/plugin/provide/page.ts
+11
-7
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+2
-0
packages/uni-h5/src/service/api/ui/startPullDownRefresh.ts
packages/uni-h5/src/service/api/ui/startPullDownRefresh.ts
+18
-0
packages/uni-h5/src/service/api/ui/stopPullDownRefresh.ts
packages/uni-h5/src/service/api/ui/stopPullDownRefresh.ts
+18
-0
packages/uni-h5/src/service/bridge/index.ts
packages/uni-h5/src/service/bridge/index.ts
+1
-1
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+9
-0
未找到文件。
packages/uni-api/src/index.ts
浏览文件 @
d700685c
...
...
@@ -49,6 +49,8 @@ export * from './protocols/ui/loadFontFace'
export
*
from
'
./protocols/ui/pageScrollTo
'
export
*
from
'
./protocols/ui/navigationBar
'
export
*
from
'
./protocols/ui/popup
'
export
*
from
'
./protocols/ui/startPullDownRefresh
'
export
*
from
'
./protocols/ui/stopPullDownRefresh
'
export
*
from
'
./protocols/ui/tabBar
'
// helpers
export
{
...
...
packages/uni-api/src/protocols/ui/startPullDownRefresh.ts
0 → 100644
浏览文件 @
d700685c
export
const
API_START_PULL_DOWN_REFRESH
=
'
startPullDownRefresh
'
export
type
API_TYPE_START_PULL_DOWN_REFRESH
=
typeof
uni
.
startPullDownRefresh
packages/uni-api/src/protocols/ui/stopPullDownRefresh.ts
0 → 100644
浏览文件 @
d700685c
export
const
API_STOP_PULL_DOWN_REFRESH
=
'
stopPullDownRefresh
'
export
type
API_TYPE_STOP_PULL_DOWN_REFRESH
=
typeof
uni
.
stopPullDownRefresh
packages/uni-core/src/service/plugin/appConfig.ts
浏览文件 @
d700685c
...
...
@@ -4,8 +4,8 @@ import { extend } from '@vue/shared'
import
*
as
wxInstance
from
'
./componentWx
'
export
function
initAppConfig
(
appConfig
:
AppConfig
)
{
const
globalProperties
=
appConfig
.
globalProperties
if
(
__UNI_FEATURE_WX__
)
{
const
globalProperties
=
appConfig
.
globalProperties
extend
(
globalProperties
,
wxInstance
)
}
}
packages/uni-core/src/service/plugin/index.ts
浏览文件 @
d700685c
...
...
@@ -22,6 +22,14 @@ export function getCurrentPageMeta() {
}
}
export
function
getCurrentPageId
()
{
const
meta
=
getCurrentPageMeta
()
if
(
meta
)
{
return
meta
.
id
}
return
-
1
}
export
function
getCurrentPageVm
()
{
const
page
=
getCurrentPage
()
if
(
page
)
{
...
...
@@ -30,13 +38,14 @@ export function getCurrentPageVm() {
}
export
function
invokeHook
(
name
:
string
,
args
?:
unknown
):
unknown
export
function
invokeHook
(
id
:
number
,
name
:
string
,
args
?:
unknown
):
unknown
export
function
invokeHook
(
vm
:
ComponentPublicInstance
,
name
:
string
,
args
?:
unknown
):
unknown
export
function
invokeHook
(
vm
:
ComponentPublicInstance
|
string
,
vm
:
ComponentPublicInstance
|
string
|
number
,
name
?:
string
|
unknown
,
args
?:
unknown
)
{
...
...
@@ -44,6 +53,13 @@ export function invokeHook(
args
=
name
name
=
vm
vm
=
getCurrentPageVm
()
!
}
else
if
(
typeof
vm
===
'
number
'
)
{
const
page
=
getCurrentPages
().
find
((
page
)
=>
page
.
$page
.
id
===
vm
)
if
(
page
)
{
vm
=
(
page
as
any
).
$vm
as
ComponentPublicInstance
}
else
{
vm
=
getCurrentPageVm
()
as
ComponentPublicInstance
}
}
if
(
!
vm
)
{
return
...
...
packages/uni-core/src/service/plugin/subscribe.ts
0 → 100644
浏览文件 @
d700685c
export
function
initSubscribe
()
{
UniServiceJSBridge
.
on
(
'
onAppEnterForeground
'
,
()
=>
{})
UniServiceJSBridge
.
on
(
'
onAppEnterBackground
'
,
()
=>
{})
}
packages/uni-core/src/view/plugin/componentInstance.ts
浏览文件 @
d700685c
...
...
@@ -10,12 +10,14 @@ export function $normalizeNativeEvent(
this
:
ComponentPublicInstance
,
evt
:
Event
)
{
// TODO 目前内置组件
,也会进入以下处理逻辑,是否有影响?
// TODO 目前内置组件
底层实现,也会进入以下处理逻辑,可能会有影响
const
{
currentTarget
}
=
evt
if
(
!
(
evt
instanceof
Event
)
||
!
(
currentTarget
instanceof
HTMLElement
))
{
return
evt
}
if
(
currentTarget
.
tagName
.
indexOf
(
'
UNI-
'
)
!==
0
)
{
const
{
tagName
}
=
currentTarget
if
(
tagName
.
indexOf
(
'
UNI-
'
)
!==
0
||
tagName
===
'
UNI-PAGE-WRAPPER
'
)
{
// TODO 下拉刷新事件返回原始event,目前硬编码,后续换其他方案解决
return
evt
}
...
...
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
d700685c
...
...
@@ -625,7 +625,8 @@ function $normalizeNativeEvent(evt) {
if
(
!
(
evt
instanceof
Event
)
||
!
(
currentTarget
instanceof
HTMLElement
))
{
return
evt
;
}
if
(
currentTarget
.
tagName
.
indexOf
(
"
UNI-
"
)
!==
0
)
{
const
{
tagName
}
=
currentTarget
;
if
(
tagName
.
indexOf
(
"
UNI-
"
)
!==
0
||
tagName
===
"
UNI-PAGE-WRAPPER
"
)
{
return
evt
;
}
const
res
=
createNativeEvent
(
evt
);
...
...
@@ -914,8 +915,8 @@ var wxInstance = /* @__PURE__ */ Object.freeze({
selectAllComponents
});
function
initAppConfig
(
appConfig
)
{
const
globalProperties
=
appConfig
.
globalProperties
;
if
(
__UNI_FEATURE_WX__
)
{
const
globalProperties
=
appConfig
.
globalProperties
;
extend
(
globalProperties
,
wxInstance
);
}
}
...
...
@@ -935,6 +936,13 @@ function getCurrentPageMeta() {
return
page
.
$page
.
meta
;
}
}
function
getCurrentPageId
()
{
const
meta
=
getCurrentPageMeta
();
if
(
meta
)
{
return
meta
.
id
;
}
return
-
1
;
}
function
getCurrentPageVm
()
{
const
page
=
getCurrentPage
();
if
(
page
)
{
...
...
@@ -946,6 +954,13 @@ function invokeHook(vm, name, args) {
args
=
name
;
name
=
vm
;
vm
=
getCurrentPageVm
();
}
else
if
(
typeof
vm
===
"
number
"
)
{
const
page
=
getCurrentPages
().
find
((
page2
)
=>
page2
.
$page
.
id
===
vm
);
if
(
page
)
{
vm
=
page
.
$vm
;
}
else
{
vm
=
getCurrentPageVm
();
}
}
if
(
!
vm
)
{
return
;
...
...
@@ -1045,23 +1060,23 @@ const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageM
function
usePageMeta
()
{
return
inject
(
pageMetaKey
);
}
function
providePageMeta
()
{
const
pageMeta
=
initPageMeta
();
function
providePageMeta
(
id2
)
{
const
pageMeta
=
initPageMeta
(
id2
);
provide
(
pageMetaKey
,
pageMeta
);
return
pageMeta
;
}
function
initPageMeta
()
{
function
initPageMeta
(
id2
)
{
if
(
__UNI_FEATURE_PAGES__
)
{
return
reactive
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
useRoute
().
meta
)))));
return
reactive
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
id2
,
useRoute
().
meta
)))));
}
return
reactive
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
__uniRoutes
[
0
].
meta
)))));
return
reactive
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
id2
,
__uniRoutes
[
0
].
meta
)))));
}
const
PAGE_META_KEYS
=
[
"
navigationBar
"
,
"
refreshOptions
"
];
function
mergePageMeta
(
pageMeta
)
{
const
res
=
Object
.
assign
({},
__uniConfig
.
globalStyle
,
pageMeta
);
function
mergePageMeta
(
id2
,
pageMeta
)
{
const
res
=
Object
.
assign
({
id
:
id2
},
__uniConfig
.
globalStyle
,
pageMeta
);
PAGE_META_KEYS
.
forEach
((
name
)
=>
{
res
[
name
]
=
Object
.
assign
({},
__uniConfig
.
globalStyle
[
name
]
||
{},
pageMeta
[
name
]
||
{});
});
...
...
@@ -1084,6 +1099,7 @@ function normalizePageMeta(pageMeta) {
if
(
type
!==
"
transparent
"
&&
type
!==
"
none
"
)
{
offset
+=
NAVBAR_HEIGHT
+
out
.
top
;
}
refreshOptions
.
offset
=
offset
;
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
);
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
);
pageMeta
.
refreshOptions
=
refreshOptions
;
...
...
@@ -1190,25 +1206,26 @@ function createPageState(type, __id__) {
};
}
function
initPublicPage
(
route
)
{
const
meta
=
usePageMeta
();
if
(
!
__UNI_FEATURE_PAGES__
)
{
const
{
path
:
path2
,
alias
}
=
__uniRoutes
[
0
];
return
{
id
,
id
:
meta
.
id
,
path
:
path2
,
route
:
alias
.
substr
(
1
),
fullPath
:
path2
,
options
:
{},
meta
:
usePageMeta
()
meta
};
}
const
{
path
}
=
route
;
return
{
id
,
id
:
meta
.
id
,
path
,
route
:
route
.
meta
.
route
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
options
:
{},
meta
:
usePageMeta
()
meta
};
}
function
initPage
(
vm
)
{
...
...
@@ -5096,6 +5113,8 @@ const ShowActionSheetOptions = {
};
const
API_HIDE_TOAST
=
"
hideToast
"
;
const
API_HIDE_LOADING
=
"
hideLoading
"
;
const
API_START_PULL_DOWN_REFRESH
=
"
startPullDownRefresh
"
;
const
API_STOP_PULL_DOWN_REFRESH
=
"
stopPullDownRefresh
"
;
const
IndexProtocol
=
{
index
:
{
type
:
Number
,
...
...
@@ -12350,6 +12369,14 @@ const hideLoading = defineAsyncApi(API_HIDE_LOADING, () => {
});
const
showActionSheet
=
defineAsyncApi
(
API_SHOW_ACTION_SHEET
,
()
=>
{
},
ShowActionSheetProtocol
,
ShowActionSheetOptions
);
const
startPullDownRefresh
=
defineAsyncApi
(
API_START_PULL_DOWN_REFRESH
,
(
_args
,
{
resolve
})
=>
{
UniServiceJSBridge
.
publishHandler
(
"
startPullDownRefresh
"
,
{},
getCurrentPageId
());
resolve
();
});
const
stopPullDownRefresh
=
defineAsyncApi
(
API_STOP_PULL_DOWN_REFRESH
,
(
_args
,
{
resolve
})
=>
{
UniServiceJSBridge
.
publishHandler
(
"
stopPullDownRefresh
"
,
{},
getCurrentPageId
());
resolve
();
});
let
tabBar
;
function
useTabBar
()
{
if
(
!
tabBar
)
{
...
...
@@ -12535,6 +12562,8 @@ var api = /* @__PURE__ */ Object.freeze({
showLoading
,
hideLoading
,
showActionSheet
,
startPullDownRefresh
,
stopPullDownRefresh
,
setTabBarItem
,
setTabBarStyle
,
hideTabBar
,
...
...
@@ -12547,7 +12576,7 @@ var api = /* @__PURE__ */ Object.freeze({
const
uni$1
=
api
;
const
UniServiceJSBridge$1
=
/* @__PURE__ */
extend
(
ServiceJSBridge
,
{
publishHandler
(
event2
,
args
,
pageId
)
{
window
.
UniViewJSBridge
.
subscribeHandler
(
event2
,
args
,
pageId
);
UniViewJSBridge
.
subscribeHandler
(
pageId
+
"
.
"
+
event2
,
args
,
pageId
);
}
});
var
TabBar
=
/* @__PURE__ */
defineComponent
({
...
...
@@ -13333,7 +13362,7 @@ function usePageRefresh(refreshRef) {
refreshControllerElem
=
refreshContainerElem
.
querySelector
(
"
.uni-page-refresh
"
);
refreshControllerElemStyle
=
refreshControllerElem
.
style
;
refreshInnerElemStyle
=
refreshControllerElem
.
querySelector
(
"
.uni-page-refresh-inner
"
).
style
;
Uni
ServiceJSBridge
.
on
(
id2
+
"
.startPullDownRefresh
"
,
()
=>
{
Uni
ViewJSBridge
.
subscribe
(
id2
+
"
.startPullDownRefresh
"
,
()
=>
{
if
(
!
state
)
{
state
=
REFRESHING
;
addClass
();
...
...
@@ -13342,7 +13371,7 @@ function usePageRefresh(refreshRef) {
},
50
);
}
});
Uni
ServiceJSBridge
.
on
(
id2
+
"
.stopPullDownRefresh
"
,
()
=>
{
Uni
ViewJSBridge
.
subscribe
(
id2
+
"
.stopPullDownRefresh
"
,
()
=>
{
if
(
state
===
REFRESHING
)
{
removeClass
();
state
=
RESTORING
;
...
...
@@ -13358,8 +13387,8 @@ function usePageRefresh(refreshRef) {
let
startY
;
let
canRefresh
;
let
state
;
let
distance
;
let
offset
;
let
distance
=
null
;
let
offset
=
null
;
function
toggleClass
(
type
)
{
if
(
!
state
)
{
return
;
...
...
@@ -13399,7 +13428,7 @@ function usePageRefresh(refreshRef) {
canRefresh
=
true
;
}
}
function
onTouchmove
Passive
(
ev
)
{
function
onTouchmove
(
ev
)
{
if
(
!
canRefresh
)
{
return
;
}
...
...
@@ -13414,9 +13443,7 @@ function usePageRefresh(refreshRef) {
if
(
deltaY
<
0
&&
!
state
)
{
return
;
}
if
(
ev
.
cancelable
)
{
ev
.
preventDefault
();
}
if
(
distance
===
null
)
{
offset
=
deltaY
;
state
=
PULLING
;
...
...
@@ -13478,12 +13505,12 @@ function usePageRefresh(refreshRef) {
}
}
function
refreshing
()
{
if
(
refreshControllerElem
)
{
if
(
!
refreshControllerElem
)
{
return
;
}
refreshControllerElemStyle
.
transition
=
"
-webkit-transform 0.2s
"
;
refreshControllerElemStyle
.
transform
=
"
translate3d(-50%,
"
+
height
+
"
px, 0)
"
;
UniServiceJSBridge
.
emit
(
"
onPullDownRefresh
"
,
{},
id2
);
invokeHook
(
id2
,
"
onPullDownRefresh
"
);
}
function
restoring
(
callback
)
{
if
(
!
refreshControllerElem
)
{
...
...
@@ -13503,7 +13530,7 @@ function usePageRefresh(refreshRef) {
}
return
{
onTouchstartPassive
,
onTouchmove
Passive
,
onTouchmove
,
onTouchend
,
onTouchcancel
:
onTouchend
};
...
...
@@ -13531,7 +13558,7 @@ function createPageRefreshTsx(refreshRef, pageMeta) {
var
index
=
defineComponent
({
name
:
"
Page
"
,
setup
(
_props
,
ctx
)
{
const
{
navigationBar
}
=
providePageMeta
();
const
{
navigationBar
}
=
providePageMeta
(
history
.
state
&&
history
.
state
.
__id__
||
1
);
return
()
=>
createVNode
(
"
uni-page
"
,
null
,
__UNI_FEATURE_NAVIGATIONBAR__
&&
navigationBar
.
style
!==
"
custom
"
?
[
createVNode
(
PageHead
),
createPageBodyVNode
(
ctx
)]
:
[
createPageBodyVNode
(
ctx
)]);
}
});
...
...
@@ -13574,4 +13601,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
]);
}
_sfc_main
.
render
=
_sfc_render
;
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$l
as
Audio
,
index$5
as
Button
,
_sfc_main$k
as
Canvas
,
_sfc_main$j
as
Checkbox
,
_sfc_main$i
as
CheckboxGroup
,
_sfc_main$h
as
Editor
,
index$6
as
Form
,
index$4
as
Icon
,
index$3
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
chooseFile
,
chooseImage
,
chooseVideo
,
clearStorage
,
clearStorageSync
,
closeSocket
,
connectSocket
,
createInnerAudioContext
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getFileInfo
,
getImageInfo
,
getLocation
,
getNetworkType
,
getStorage
,
getStorageInfo
,
getStorageInfoSync
,
getStorageSync
,
getSystemInfo
,
getSystemInfoSync
,
getVideoInfo
,
hideKeyboard
,
hideLoading
,
hideNavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
hideToast
,
loadFontFace
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offAccelerometerChange
,
offCompassChange
,
offNetworkStatusChange
,
onAccelerometerChange
,
onCompassChange
,
onNetworkStatusChange
,
onSocketClose
,
onSocketError
,
onSocketMessage
,
onSocketOpen
,
onTabBarMidButtonTap
,
openDocument
,
pageScrollTo
,
index$7
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeStorage
,
removeStorageSync
,
removeTabBarBadge
,
request
,
sendSocketMessage
,
setNavigationBarColor
,
setNavigationBarTitle
,
setStorage
,
setStorageSync
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showActionSheet
,
showLoading
,
showModal
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDot
,
showToast
,
startAccelerometer
,
startCompass
,
st
opAccelerometer
,
stopCompass
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
useCustomEvent
,
usePageRoute
,
useSubscribe
,
vibrateLong
,
vibrateShort
};
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$l
as
Audio
,
index$5
as
Button
,
_sfc_main$k
as
Canvas
,
_sfc_main$j
as
Checkbox
,
_sfc_main$i
as
CheckboxGroup
,
_sfc_main$h
as
Editor
,
index$6
as
Form
,
index$4
as
Icon
,
index$3
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
chooseFile
,
chooseImage
,
chooseVideo
,
clearStorage
,
clearStorageSync
,
closeSocket
,
connectSocket
,
createInnerAudioContext
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getFileInfo
,
getImageInfo
,
getLocation
,
getNetworkType
,
getStorage
,
getStorageInfo
,
getStorageInfoSync
,
getStorageSync
,
getSystemInfo
,
getSystemInfoSync
,
getVideoInfo
,
hideKeyboard
,
hideLoading
,
hideNavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
hideToast
,
loadFontFace
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offAccelerometerChange
,
offCompassChange
,
offNetworkStatusChange
,
onAccelerometerChange
,
onCompassChange
,
onNetworkStatusChange
,
onSocketClose
,
onSocketError
,
onSocketMessage
,
onSocketOpen
,
onTabBarMidButtonTap
,
openDocument
,
pageScrollTo
,
index$7
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeStorage
,
removeStorageSync
,
removeTabBarBadge
,
request
,
sendSocketMessage
,
setNavigationBarColor
,
setNavigationBarTitle
,
setStorage
,
setStorageSync
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showActionSheet
,
showLoading
,
showModal
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDot
,
showToast
,
startAccelerometer
,
startCompass
,
st
artPullDownRefresh
,
stopAccelerometer
,
stopCompass
,
stopPullDownRefresh
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
useCustomEvent
,
usePageRoute
,
useSubscribe
,
vibrateLong
,
vibrateShort
};
packages/uni-h5/src/framework/components/page/index.ts
浏览文件 @
d700685c
...
...
@@ -15,7 +15,9 @@ import { providePageMeta } from '../../plugin/provide'
export
default
defineComponent
({
name
:
'
Page
'
,
setup
(
_props
,
ctx
)
{
const
{
navigationBar
}
=
providePageMeta
()
const
{
navigationBar
}
=
providePageMeta
(
(
history
.
state
&&
history
.
state
.
__id__
)
||
1
)
return
()
=>
createVNode
(
'
uni-page
'
,
...
...
packages/uni-h5/src/framework/components/page/page-refresh/index.ts
浏览文件 @
d700685c
import
{
onMounted
,
Ref
}
from
'
vue
'
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
usePageMeta
}
from
'
../../../plugin/provide
'
function
processDeltaY
(
...
...
@@ -41,8 +42,8 @@ export function usePageRefresh(refreshRef: Ref) {
refreshInnerElemStyle
=
(
refreshControllerElem
.
querySelector
(
'
.uni-page-refresh-inner
'
)
as
HTMLDivElement
).
style
Uni
ServiceJSBridge
.
on
(
id
+
'
.startPullDownRefresh
'
,
()
=>
{
// uni.startPullDownRefresh
Uni
ViewJSBridge
.
subscribe
(
id
+
'
.startPullDownRefresh
'
,
()
=>
{
if
(
!
state
)
{
state
=
REFRESHING
addClass
()
...
...
@@ -51,8 +52,8 @@ export function usePageRefresh(refreshRef: Ref) {
},
50
)
}
})
Uni
ServiceJSBridge
.
on
(
id
+
'
.stopPullDownRefresh
'
,
()
=>
{
// uni.stopPullDownRefresh
Uni
ViewJSBridge
.
subscribe
(
id
+
'
.stopPullDownRefresh
'
,
()
=>
{
if
(
state
===
REFRESHING
)
{
removeClass
()
state
=
RESTORING
...
...
@@ -76,8 +77,8 @@ export function usePageRefresh(refreshRef: Ref) {
|
typeof
RESTORING
|
null
let
distance
:
number
|
null
let
offset
:
number
|
null
let
distance
:
number
|
null
=
null
let
offset
:
number
|
null
=
null
function
toggleClass
(
type
:
'
add
'
|
'
remove
'
)
{
if
(
!
state
)
{
...
...
@@ -124,7 +125,7 @@ export function usePageRefresh(refreshRef: Ref) {
}
}
function
onTouchmove
Passive
(
ev
:
TouchEvent
)
{
function
onTouchmove
(
ev
:
TouchEvent
)
{
if
(
!
canRefresh
)
{
return
}
...
...
@@ -141,9 +142,7 @@ export function usePageRefresh(refreshRef: Ref) {
return
}
if
(
ev
.
cancelable
)
{
ev
.
preventDefault
()
}
if
(
distance
===
null
)
{
offset
=
deltaY
...
...
@@ -222,14 +221,13 @@ export function usePageRefresh(refreshRef: Ref) {
}
function
refreshing
()
{
if
(
refreshControllerElem
)
{
if
(
!
refreshControllerElem
)
{
return
}
refreshControllerElemStyle
.
transition
=
'
-webkit-transform 0.2s
'
refreshControllerElemStyle
.
transform
=
'
translate3d(-50%,
'
+
height
+
'
px, 0)
'
// Service 执行 refresh
UniServiceJSBridge
.
emit
(
'
onPullDownRefresh
'
,
{},
id
)
invokeHook
(
id
,
'
onPullDownRefresh
'
)
}
function
restoring
(
callback
:
Function
)
{
...
...
@@ -259,7 +257,7 @@ export function usePageRefresh(refreshRef: Ref) {
return
{
onTouchstartPassive
,
onTouchmove
Passive
,
onTouchmove
,
onTouchend
,
onTouchcancel
:
onTouchend
,
}
...
...
packages/uni-h5/src/framework/plugin/page.ts
浏览文件 @
d700685c
...
...
@@ -4,7 +4,6 @@ import {
computed
,
ConcreteComponent
,
ComponentPublicInstance
,
ComponentInternalInstance
,
}
from
'
vue
'
import
{
useRoute
,
RouteLocationNormalizedLoaded
}
from
'
vue-router
'
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
...
...
@@ -68,25 +67,26 @@ export function createPageState(type: NavigateType, __id__?: number) {
}
function
initPublicPage
(
route
:
RouteLocationNormalizedLoaded
)
{
const
meta
=
usePageMeta
()
if
(
!
__UNI_FEATURE_PAGES__
)
{
const
{
path
,
alias
}
=
__uniRoutes
[
0
]
return
{
id
,
id
:
meta
.
id
,
path
,
route
:
alias
!
.
substr
(
1
),
fullPath
:
path
,
options
:
{},
meta
:
usePageMeta
()
,
meta
,
}
}
const
{
path
}
=
route
return
{
id
,
id
:
meta
.
id
,
path
:
path
,
route
:
route
.
meta
.
route
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
options
:
{},
// $route.query
meta
:
usePageMeta
()
,
meta
,
}
}
...
...
packages/uni-h5/src/framework/plugin/provide/page.ts
浏览文件 @
d700685c
...
...
@@ -12,19 +12,22 @@ export function usePageMeta() {
return
inject
<
UniApp
.
PageRouteMeta
>
(
pageMetaKey
)
!
}
export
function
providePageMeta
()
{
const
pageMeta
=
initPageMeta
()
export
function
providePageMeta
(
id
:
number
)
{
const
pageMeta
=
initPageMeta
(
id
)
provide
(
pageMetaKey
,
pageMeta
)
return
pageMeta
}
function
initPageMeta
()
{
function
initPageMeta
(
id
:
number
)
{
if
(
__UNI_FEATURE_PAGES__
)
{
return
reactive
<
UniApp
.
PageRouteMeta
>
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
((
useRoute
().
meta
as
unknown
)
as
UniApp
.
PageRouteMeta
)
mergePageMeta
(
id
,
(
useRoute
().
meta
as
unknown
)
as
UniApp
.
PageRouteMeta
)
)
)
)
...
...
@@ -32,7 +35,7 @@ function initPageMeta() {
}
return
reactive
<
UniApp
.
PageRouteMeta
>
(
normalizePageMeta
(
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
__uniRoutes
[
0
].
meta
)))
JSON
.
parse
(
JSON
.
stringify
(
mergePageMeta
(
id
,
__uniRoutes
[
0
].
meta
)))
)
)
}
...
...
@@ -42,8 +45,8 @@ const PAGE_META_KEYS: ['navigationBar', 'refreshOptions'] = [
'
refreshOptions
'
,
]
function
mergePageMeta
(
pageMeta
:
UniApp
.
PageRouteMeta
)
{
const
res
=
Object
.
assign
({},
__uniConfig
.
globalStyle
,
pageMeta
)
function
mergePageMeta
(
id
:
number
,
pageMeta
:
UniApp
.
PageRouteMeta
)
{
const
res
=
Object
.
assign
({
id
},
__uniConfig
.
globalStyle
,
pageMeta
)
PAGE_META_KEYS
.
forEach
((
name
)
=>
{
;(
res
as
any
)[
name
]
=
Object
.
assign
(
{},
...
...
@@ -74,6 +77,7 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
if
(
type
!==
'
transparent
'
&&
type
!==
'
none
'
)
{
offset
+=
NAVBAR_HEIGHT
+
safeAreaInsets
.
top
}
refreshOptions
.
offset
=
offset
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
)
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
)
pageMeta
.
refreshOptions
=
refreshOptions
...
...
packages/uni-h5/src/service/api/index.ts
浏览文件 @
d700685c
...
...
@@ -40,6 +40,8 @@ export * from './ui/loadFontFace'
export
*
from
'
./ui/navigationBar
'
export
*
from
'
./ui/pageScrollTo
'
export
*
from
'
./ui/popup
'
export
*
from
'
./ui/startPullDownRefresh
'
export
*
from
'
./ui/stopPullDownRefresh
'
export
*
from
'
./ui/tabBar
'
export
{
...
...
packages/uni-h5/src/service/api/ui/startPullDownRefresh.ts
0 → 100644
浏览文件 @
d700685c
import
{
API_START_PULL_DOWN_REFRESH
,
API_TYPE_START_PULL_DOWN_REFRESH
,
defineAsyncApi
,
}
from
'
@dcloudio/uni-api
'
import
{
getCurrentPageId
}
from
'
@dcloudio/uni-core
'
export
const
startPullDownRefresh
=
defineAsyncApi
<
API_TYPE_START_PULL_DOWN_REFRESH
>
(
API_START_PULL_DOWN_REFRESH
,
(
_args
,
{
resolve
})
=>
{
UniServiceJSBridge
.
publishHandler
(
'
startPullDownRefresh
'
,
{},
getCurrentPageId
()
)
resolve
()
}
)
packages/uni-h5/src/service/api/ui/stopPullDownRefresh.ts
0 → 100644
浏览文件 @
d700685c
import
{
API_STOP_PULL_DOWN_REFRESH
,
API_TYPE_STOP_PULL_DOWN_REFRESH
,
defineAsyncApi
,
}
from
'
@dcloudio/uni-api
'
import
{
getCurrentPageId
}
from
'
@dcloudio/uni-core
'
export
const
stopPullDownRefresh
=
defineAsyncApi
<
API_TYPE_STOP_PULL_DOWN_REFRESH
>
(
API_STOP_PULL_DOWN_REFRESH
,
(
_args
,
{
resolve
})
=>
{
UniServiceJSBridge
.
publishHandler
(
'
stopPullDownRefresh
'
,
{},
getCurrentPageId
()
)
resolve
()
}
)
packages/uni-h5/src/service/bridge/index.ts
浏览文件 @
d700685c
...
...
@@ -4,6 +4,6 @@ import { ServiceJSBridge } from '@dcloudio/uni-core'
export
const
UniServiceJSBridge
=
/*#__PURE__*/
extend
(
ServiceJSBridge
,
{
publishHandler
(
event
:
string
,
args
:
any
,
pageId
:
number
)
{
window
.
UniViewJSBridge
.
subscribeHandler
(
event
,
args
,
pageId
)
UniViewJSBridge
.
subscribeHandler
(
pageId
+
'
.
'
+
event
,
args
,
pageId
)
},
})
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
d700685c
...
...
@@ -55,6 +55,15 @@ function invokeHook(vm, name, args) {
name
=
vm
;
vm
=
getCurrentPageVm
();
}
else
if
(
typeof
vm
===
'
number
'
)
{
const
page
=
getCurrentPages
().
find
((
page
)
=>
page
.
$page
.
id
===
vm
);
if
(
page
)
{
vm
=
page
.
$vm
;
}
else
{
vm
=
getCurrentPageVm
();
}
}
if
(
!
vm
)
{
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录