Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
f3ccbc81
U
uni-app
项目概览
qianlong66
/
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,发现更多精彩内容 >>
提交
f3ccbc81
编写于
6月 30, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
wip(app): uni-app-plus
上级
58d55535
1f094875
变更
31
展开全部
显示空白变更内容
内联
并排
Showing
31 changed file
with
11118 addition
and
9429 deletion
+11118
-9429
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+1
-0
packages/uni-app-plus/__tests__/webviewStyle.spec.ts
packages/uni-app-plus/__tests__/webviewStyle.spec.ts
+1
-1
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+285
-212
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+12
-16
packages/uni-app-plus/src/constants.ts
packages/uni-app-plus/src/constants.ts
+1
-0
packages/uni-app-plus/src/service/framework/app/index.ts
packages/uni-app-plus/src/service/framework/app/index.ts
+1
-1
packages/uni-app-plus/src/service/framework/app/initSubscribeHandlers.ts
...p-plus/src/service/framework/app/initSubscribeHandlers.ts
+0
-1
packages/uni-app-plus/src/service/framework/app/plusMessage.ts
...ges/uni-app-plus/src/service/framework/app/plusMessage.ts
+1
-1
packages/uni-app-plus/src/service/framework/app/subscriber/index.ts
...ni-app-plus/src/service/framework/app/subscriber/index.ts
+15
-0
packages/uni-app-plus/src/service/framework/app/subscriber/onWebviewReady.ts
...us/src/service/framework/app/subscriber/onWebviewReady.ts
+46
-0
packages/uni-app-plus/src/service/framework/constants.ts
packages/uni-app-plus/src/service/framework/constants.ts
+1
-0
packages/uni-app-plus/src/service/framework/page/register.ts
packages/uni-app-plus/src/service/framework/page/register.ts
+1
-1
packages/uni-app-plus/src/service/framework/webview/index.ts
packages/uni-app-plus/src/service/framework/webview/index.ts
+2
-0
packages/uni-app-plus/src/service/framework/webview/nvue.ts
packages/uni-app-plus/src/service/framework/webview/nvue.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/preload.ts
...ges/uni-app-plus/src/service/framework/webview/preload.ts
+37
-0
packages/uni-app-plus/src/service/framework/webview/style/backgroundColor.ts
...us/src/service/framework/webview/style/backgroundColor.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/index.ts
...uni-app-plus/src/service/framework/webview/style/index.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/nvue.ts
.../uni-app-plus/src/service/framework/webview/style/nvue.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/popGesture.ts
...pp-plus/src/service/framework/webview/style/popGesture.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/pullToRefresh.ts
...plus/src/service/framework/webview/style/pullToRefresh.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/titleNView.ts
...pp-plus/src/service/framework/webview/style/titleNView.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/style/utils.ts
...uni-app-plus/src/service/framework/webview/style/utils.ts
+0
-0
packages/uni-app-plus/src/service/framework/webview/utils.ts
packages/uni-app-plus/src/service/framework/webview/utils.ts
+0
-0
packages/uni-app-vue/dist/service.runtime.esm.js
packages/uni-app-vue/dist/service.runtime.esm.js
+10667
-9143
packages/uni-components/src/components/image/index.tsx
packages/uni-components/src/components/image/index.tsx
+4
-4
packages/uni-components/src/components/resize-sensor/index.tsx
...ges/uni-components/src/components/resize-sensor/index.tsx
+3
-3
packages/uni-core/src/helpers/bridge.ts
packages/uni-core/src/helpers/bridge.ts
+5
-5
packages/uni-core/src/service/bridge/index.ts
packages/uni-core/src/service/bridge/index.ts
+8
-6
packages/uni-core/src/view/bridge/index.ts
packages/uni-core/src/view/bridge/index.ts
+1
-1
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+13
-17
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+13
-17
未找到文件。
packages/shims-uni-app.d.ts
浏览文件 @
f3ccbc81
...
...
@@ -55,6 +55,7 @@ declare namespace UniApp {
entryPagePath
?:
string
entryPageQuery
?:
string
realEntryPagePath
?:
string
renderer
?:
'
auto
'
|
'
native
'
}
interface
UniRoute
{
...
...
packages/uni-app-plus/__tests__/webviewStyle.spec.ts
浏览文件 @
f3ccbc81
import
{
parseWebviewStyle
}
from
'
../src/service/framework/
page/
webview/style
'
import
{
parseWebviewStyle
}
from
'
../src/service/framework/webview/style
'
function
initDefaultUniConfig
()
{
return
JSON
.
parse
(
JSON
.
stringify
({
...
...
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
f3ccbc81
...
...
@@ -1295,21 +1295,21 @@ var serviceContext = (function (vue) {
},
};
function
initBridge
(
n
amespace
)
{
function
initBridge
(
subscribeN
amespace
)
{
// TODO vue3 compatibility builds
const
emitter
=
new
E
();
return
extend
(
emitter
,
{
subscribe
(
event
,
callback
)
{
emitter
.
on
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
on
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
unsubscribe
(
event
,
callback
)
{
emitter
.
off
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
off
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
subscribeHandler
(
event
,
args
,
pageId
)
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
`[
${
n
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
console
.
log
(
`[
${
subscribeN
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
}
emitter
.
emit
(
`
${
n
amespace
}
.
${
event
}
`
,
args
,
pageId
);
emitter
.
emit
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
args
,
pageId
);
},
});
}
...
...
@@ -1384,7 +1384,7 @@ var serviceContext = (function (vue) {
return
'
/
'
+
fromRouteArray
.
concat
(
toRouteArray
).
join
(
'
/
'
);
}
const
ServiceJSBridge
=
/*#__PURE__*/
extend
(
initBridge
(
'
service
'
),
{
const
ServiceJSBridge
=
/*#__PURE__*/
extend
(
initBridge
(
'
view
'
/* view 指的是 service 层订阅的是 view 层事件 */
),
{
invokeOnCallback
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
);
},
...
...
@@ -5019,6 +5019,16 @@ var serviceContext = (function (vue) {
}
return
false
;
}
/**
* 注册 view 层通知 service 层事件处理
*/
function
registerPlusMessage
(
type
,
callback
,
keepAlive
=
true
)
{
if
(
callbacks
[
type
])
{
return
console
.
warn
(
`'
${
type
}
' registered: `
+
callbacks
[
type
].
toString
());
}
callback
.
keepAlive
=
!!
keepAlive
;
callbacks
[
type
]
=
callback
;
}
function
backbuttonListener
()
{
uni
.
navigateBack
({
...
...
@@ -5103,6 +5113,274 @@ var serviceContext = (function (vue) {
});
}
const
ON_WEBVIEW_READY
=
'
onWebviewReady
'
;
function
initNVue
(
webviewStyle
,
routeMeta
,
path
)
{
if
(
path
&&
routeMeta
.
isNVue
)
{
webviewStyle
.
uniNView
=
{
path
,
defaultFontSize
:
__uniConfig
.
defaultFontSize
,
viewport
:
__uniConfig
.
viewport
,
};
}
}
const
colorRE
=
/^#
[
a-z0-9
]{6}
$/i
;
function
isColor
(
color
)
{
return
color
&&
(
colorRE
.
test
(
color
)
||
color
===
'
transparent
'
);
}
function
initBackgroundColor
(
webviewStyle
,
routeMeta
)
{
const
{
backgroundColor
}
=
routeMeta
;
if
(
!
backgroundColor
)
{
return
;
}
if
(
!
isColor
(
backgroundColor
))
{
return
;
}
if
(
!
webviewStyle
.
background
)
{
webviewStyle
.
background
=
backgroundColor
;
}
if
(
!
webviewStyle
.
backgroundColorTop
)
{
webviewStyle
.
backgroundColorTop
=
backgroundColor
;
}
}
function
initPopGesture
(
webviewStyle
,
routeMeta
)
{
// 不支持 hide
if
(
webviewStyle
.
popGesture
===
'
hide
'
)
{
delete
webviewStyle
.
popGesture
;
}
// 似乎没用了吧?记得是之前流应用时,需要 appback 的逻辑
if
(
routeMeta
.
isQuit
)
{
webviewStyle
.
popGesture
=
(
plus
.
os
.
name
===
'
iOS
'
?
'
appback
'
:
'
none
'
);
}
}
function
initPullToRefresh
(
webviewStyle
,
routeMeta
)
{
if
(
!
routeMeta
.
enablePullDownRefresh
)
{
return
;
}
webviewStyle
.
pullToRefresh
=
normalizePullToRefreshRpx
(
extend
({},
plus
.
os
.
name
===
'
Android
'
?
defaultAndroidPullToRefresh
:
defaultPullToRefresh
,
routeMeta
.
pullToRefresh
));
}
const
defaultAndroidPullToRefresh
=
{
support
:
true
,
style
:
'
circle
'
};
const
defaultPullToRefresh
=
{
support
:
true
,
style
:
'
default
'
,
height
:
'
50px
'
,
range
:
'
200px
'
,
contentdown
:
{
caption
:
''
,
},
contentover
:
{
caption
:
''
,
},
contentrefresh
:
{
caption
:
''
,
},
};
function
initTitleNView
(
webviewStyle
,
routeMeta
)
{
const
{
navigationBar
}
=
routeMeta
;
if
(
navigationBar
.
style
===
'
custom
'
)
{
return
false
;
}
let
autoBackButton
=
true
;
if
(
routeMeta
.
isQuit
)
{
autoBackButton
=
false
;
}
const
titleNView
=
{
autoBackButton
,
};
Object
.
keys
(
navigationBar
).
forEach
((
name
)
=>
{
const
value
=
navigationBar
[
name
];
if
(
name
===
'
backgroundColor
'
)
{
titleNView
.
backgroundColor
=
isColor
(
value
)
?
value
:
BACKGROUND_COLOR
;
}
else
if
(
name
===
'
titleImage
'
&&
value
)
{
titleNView
.
tags
=
createTitleImageTags
(
value
);
}
else
if
(
name
===
'
buttons
'
&&
isArray
(
value
))
{
titleNView
.
buttons
=
value
.
map
((
button
,
index
)
=>
{
button
.
onclick
=
createTitleNViewBtnClick
(
index
);
return
button
;
});
}
});
webviewStyle
.
titleNView
=
titleNView
;
}
function
createTitleImageTags
(
titleImage
)
{
return
[
{
tag
:
'
img
'
,
src
:
titleImage
,
position
:
{
left
:
'
auto
'
,
top
:
'
auto
'
,
width
:
'
auto
'
,
height
:
'
26px
'
,
},
},
];
}
function
createTitleNViewBtnClick
(
index
)
{
return
function
onClick
(
btn
)
{
btn
.
index
=
index
;
invokeHook
(
'
onNavigationBarButtonTap
'
,
btn
);
};
}
function
parseWebviewStyle
(
id
,
path
,
routeOptions
)
{
const
webviewStyle
=
{
bounce
:
'
vertical
'
,
};
const
routeMeta
=
mergePageMeta
(
id
,
routeOptions
.
meta
);
Object
.
keys
(
routeMeta
).
forEach
((
name
)
=>
{
if
(
WEBVIEW_STYLE_BLACKLIST
.
indexOf
(
name
)
===
-
1
)
{
webviewStyle
[
name
]
=
routeMeta
[
name
];
}
});
initNVue
(
webviewStyle
,
routeMeta
,
path
);
initPopGesture
(
webviewStyle
,
routeMeta
);
initBackgroundColor
(
webviewStyle
,
routeMeta
);
initTitleNView
(
webviewStyle
,
routeMeta
);
initPullToRefresh
(
webviewStyle
,
routeMeta
);
return
webviewStyle
;
}
const
WEBVIEW_STYLE_BLACKLIST
=
[
'
id
'
,
'
route
'
,
'
isNVue
'
,
'
isQuit
'
,
'
isEntry
'
,
'
isTabBar
'
,
'
tabBarIndex
'
,
'
windowTop
'
,
'
topWindow
'
,
'
leftWindow
'
,
'
rightWindow
'
,
'
maxWidth
'
,
'
usingComponents
'
,
'
disableScroll
'
,
'
enablePullDownRefresh
'
,
'
navigationBar
'
,
'
pullToRefresh
'
,
'
onReachBottomDistance
'
,
'
pageOrientation
'
,
'
backgroundColor
'
,
];
let
id
=
2
;
let
preloadWebview$1
;
function
getWebviewId
()
{
return
id
;
}
function
genWebviewId
()
{
return
id
++
;
}
function
getPreloadWebview
()
{
return
preloadWebview$1
;
}
function
encode
(
val
)
{
return
val
;
}
function
initUniPageUrl
(
path
,
query
)
{
const
queryString
=
query
?
stringifyQuery$1
(
query
,
encode
)
:
''
;
return
{
path
:
path
.
substr
(
1
),
query
:
queryString
?
queryString
.
substr
(
1
)
:
queryString
,
};
}
function
createNVueWebview
({
path
,
query
,
routeOptions
,
webviewStyle
,
})
{
const
curWebviewId
=
genWebviewId
();
const
curWebviewStyle
=
parseWebviewStyle
(
curWebviewId
,
path
,
routeOptions
);
curWebviewStyle
.
uniPageUrl
=
initUniPageUrl
(
path
,
query
);
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
[uni-app] createWebview
'
,
curWebviewId
,
path
,
curWebviewStyle
);
}
curWebviewStyle
.
isTab
=
!!
routeOptions
.
meta
.
isTabBar
;
return
plus
.
webview
.
create
(
''
,
String
(
curWebviewId
),
curWebviewStyle
,
extend
({
nvue
:
true
,
},
webviewStyle
));
}
let
preloadWebview
;
function
setPreloadWebview
(
webview
)
{
preloadWebview
=
webview
;
}
const
webviewReadyCallbacks
=
{};
function
consumeWebviewReady
(
pageId
)
{
const
callbacks
=
webviewReadyCallbacks
[
pageId
];
isArray
(
callbacks
)
&&
callbacks
.
forEach
((
callback
)
=>
callback
());
delete
webviewReadyCallbacks
[
pageId
];
}
function
createWebview
(
options
)
{
if
(
options
.
routeOptions
.
meta
.
isNVue
)
{
return
createNVueWebview
(
options
);
}
if
(
getWebviewId
()
===
2
)
{
// 如果首页非 nvue,则直接返回 Launch Webview
return
plus
.
webview
.
getLaunchWebview
();
}
return
getPreloadWebview
();
}
let
isLaunchWebviewReady
=
false
;
// 目前首页双向确定 ready,可能会导致触发两次 onWebviewReady(主要是 Android)
function
onWebviewReady
(
_data
,
pageId
)
{
const
isLaunchWebview
=
pageId
===
'
1
'
;
if
(
isLaunchWebview
&&
isLaunchWebviewReady
)
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
[uni-app] onLaunchWebviewReady.prevent
'
);
}
return
;
}
if
(
isLaunchWebview
)
{
// 首页
isLaunchWebviewReady
=
true
;
setPreloadWebview
(
plus
.
webview
.
getLaunchWebview
());
}
else
if
(
!
preloadWebview
)
{
// preloadWebview 不存在,重新加载一下
setPreloadWebview
(
plus
.
webview
.
getWebviewById
(
pageId
));
}
if
(
preloadWebview
.
id
!==
pageId
)
{
return
console
.
error
(
`webviewReady[
${
preloadWebview
.
id
}
][
${
pageId
}
] not match`
);
}
preloadWebview
.
loaded
=
true
;
// 标记已 ready
consumeWebviewReady
(
pageId
);
if
(
!
isLaunchWebview
)
{
return
;
}
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
;
const
routeOptions
=
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
entryPagePath
);
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 非 nvue 首页,需要主动跳转
const
navigateType
=
routeOptions
.
meta
.
isTabBar
?
'
switchTab
'
:
'
navigateTo
'
;
return
uni
[
navigateType
]({
url
:
entryPagePath
+
(
__uniConfig
.
entryPageQuery
||
''
),
openType
:
'
appLaunch
'
,
});
}
}
function
initSubscribeHandlers
()
{
const
{
subscribe
,
subscribeHandler
}
=
UniServiceJSBridge
;
registerPlusMessage
(
'
subscribeHandler
'
,
(
data
)
=>
{
subscribeHandler
(
data
.
type
,
data
.
data
,
data
.
pageId
);
});
if
(
__uniConfig
.
renderer
!==
'
native
'
)
{
// 非纯原生
subscribe
(
ON_WEBVIEW_READY
,
onWebviewReady
);
}
}
let
appCtx
;
const
defaultApp
=
{
globalData
:
{},
...
...
@@ -5118,6 +5396,7 @@ var serviceContext = (function (vue) {
initEntry
();
initTabBar
();
initGlobalEvent
();
initSubscribeHandlers
();
initAppLaunch
(
appVm
);
// 10s后清理临时文件
setTimeout
(
clearTempFile
,
10000
);
...
...
@@ -5349,212 +5628,6 @@ var serviceContext = (function (vue) {
return
routeOptions
;
}
function
initNVue
(
webviewStyle
,
routeMeta
,
path
)
{
if
(
path
&&
routeMeta
.
isNVue
)
{
webviewStyle
.
uniNView
=
{
path
,
defaultFontSize
:
__uniConfig
.
defaultFontSize
,
viewport
:
__uniConfig
.
viewport
,
};
}
}
const
colorRE
=
/^#
[
a-z0-9
]{6}
$/i
;
function
isColor
(
color
)
{
return
color
&&
(
colorRE
.
test
(
color
)
||
color
===
'
transparent
'
);
}
function
initBackgroundColor
(
webviewStyle
,
routeMeta
)
{
const
{
backgroundColor
}
=
routeMeta
;
if
(
!
backgroundColor
)
{
return
;
}
if
(
!
isColor
(
backgroundColor
))
{
return
;
}
if
(
!
webviewStyle
.
background
)
{
webviewStyle
.
background
=
backgroundColor
;
}
if
(
!
webviewStyle
.
backgroundColorTop
)
{
webviewStyle
.
backgroundColorTop
=
backgroundColor
;
}
}
function
initPopGesture
(
webviewStyle
,
routeMeta
)
{
// 不支持 hide
if
(
webviewStyle
.
popGesture
===
'
hide
'
)
{
delete
webviewStyle
.
popGesture
;
}
// 似乎没用了吧?记得是之前流应用时,需要 appback 的逻辑
if
(
routeMeta
.
isQuit
)
{
webviewStyle
.
popGesture
=
(
plus
.
os
.
name
===
'
iOS
'
?
'
appback
'
:
'
none
'
);
}
}
function
initPullToRefresh
(
webviewStyle
,
routeMeta
)
{
if
(
!
routeMeta
.
enablePullDownRefresh
)
{
return
;
}
webviewStyle
.
pullToRefresh
=
normalizePullToRefreshRpx
(
extend
({},
plus
.
os
.
name
===
'
Android
'
?
defaultAndroidPullToRefresh
:
defaultPullToRefresh
,
routeMeta
.
pullToRefresh
));
}
const
defaultAndroidPullToRefresh
=
{
support
:
true
,
style
:
'
circle
'
};
const
defaultPullToRefresh
=
{
support
:
true
,
style
:
'
default
'
,
height
:
'
50px
'
,
range
:
'
200px
'
,
contentdown
:
{
caption
:
''
,
},
contentover
:
{
caption
:
''
,
},
contentrefresh
:
{
caption
:
''
,
},
};
function
initTitleNView
(
webviewStyle
,
routeMeta
)
{
const
{
navigationBar
}
=
routeMeta
;
if
(
navigationBar
.
style
===
'
custom
'
)
{
return
false
;
}
let
autoBackButton
=
true
;
if
(
routeMeta
.
isQuit
)
{
autoBackButton
=
false
;
}
const
titleNView
=
{
autoBackButton
,
};
Object
.
keys
(
navigationBar
).
forEach
((
name
)
=>
{
const
value
=
navigationBar
[
name
];
if
(
name
===
'
backgroundColor
'
)
{
titleNView
.
backgroundColor
=
isColor
(
value
)
?
value
:
BACKGROUND_COLOR
;
}
else
if
(
name
===
'
titleImage
'
&&
value
)
{
titleNView
.
tags
=
createTitleImageTags
(
value
);
}
else
if
(
name
===
'
buttons
'
&&
isArray
(
value
))
{
titleNView
.
buttons
=
value
.
map
((
button
,
index
)
=>
{
button
.
onclick
=
createTitleNViewBtnClick
(
index
);
return
button
;
});
}
});
webviewStyle
.
titleNView
=
titleNView
;
}
function
createTitleImageTags
(
titleImage
)
{
return
[
{
tag
:
'
img
'
,
src
:
titleImage
,
position
:
{
left
:
'
auto
'
,
top
:
'
auto
'
,
width
:
'
auto
'
,
height
:
'
26px
'
,
},
},
];
}
function
createTitleNViewBtnClick
(
index
)
{
return
function
onClick
(
btn
)
{
btn
.
index
=
index
;
invokeHook
(
'
onNavigationBarButtonTap
'
,
btn
);
};
}
function
parseWebviewStyle
(
id
,
path
,
routeOptions
)
{
const
webviewStyle
=
{
bounce
:
'
vertical
'
,
};
const
routeMeta
=
mergePageMeta
(
id
,
routeOptions
.
meta
);
Object
.
keys
(
routeMeta
).
forEach
((
name
)
=>
{
if
(
WEBVIEW_STYLE_BLACKLIST
.
indexOf
(
name
)
===
-
1
)
{
webviewStyle
[
name
]
=
routeMeta
[
name
];
}
});
initNVue
(
webviewStyle
,
routeMeta
,
path
);
initPopGesture
(
webviewStyle
,
routeMeta
);
initBackgroundColor
(
webviewStyle
,
routeMeta
);
initTitleNView
(
webviewStyle
,
routeMeta
);
initPullToRefresh
(
webviewStyle
,
routeMeta
);
return
webviewStyle
;
}
const
WEBVIEW_STYLE_BLACKLIST
=
[
'
id
'
,
'
route
'
,
'
isNVue
'
,
'
isQuit
'
,
'
isEntry
'
,
'
isTabBar
'
,
'
tabBarIndex
'
,
'
windowTop
'
,
'
topWindow
'
,
'
leftWindow
'
,
'
rightWindow
'
,
'
maxWidth
'
,
'
usingComponents
'
,
'
disableScroll
'
,
'
enablePullDownRefresh
'
,
'
navigationBar
'
,
'
pullToRefresh
'
,
'
onReachBottomDistance
'
,
'
pageOrientation
'
,
'
backgroundColor
'
,
];
let
id
=
2
;
let
preloadWebview
;
function
getWebviewId
()
{
return
id
;
}
function
genWebviewId
()
{
return
id
++
;
}
function
getPreloadWebview
()
{
return
preloadWebview
;
}
function
encode
(
val
)
{
return
val
;
}
function
initUniPageUrl
(
path
,
query
)
{
const
queryString
=
query
?
stringifyQuery$1
(
query
,
encode
)
:
''
;
return
{
path
:
path
.
substr
(
1
),
query
:
queryString
?
queryString
.
substr
(
1
)
:
queryString
,
};
}
function
createNVueWebview
({
path
,
query
,
routeOptions
,
webviewStyle
,
})
{
const
curWebviewId
=
genWebviewId
();
const
curWebviewStyle
=
parseWebviewStyle
(
curWebviewId
,
path
,
routeOptions
);
curWebviewStyle
.
uniPageUrl
=
initUniPageUrl
(
path
,
query
);
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
[uni-app] createWebview
'
,
curWebviewId
,
path
,
curWebviewStyle
);
}
curWebviewStyle
.
isTab
=
!!
routeOptions
.
meta
.
isTabBar
;
return
plus
.
webview
.
create
(
''
,
String
(
curWebviewId
),
curWebviewStyle
,
extend
({
nvue
:
true
,
},
webviewStyle
));
}
function
createWebview
(
options
)
{
if
(
options
.
routeOptions
.
meta
.
isNVue
)
{
return
createNVueWebview
(
options
);
}
if
(
getWebviewId
()
===
2
)
{
// 如果首页非 nvue,则直接返回 Launch Webview
return
plus
.
webview
.
getLaunchWebview
();
}
return
getPreloadWebview
();
}
function
getStatusbarHeight
()
{
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
return
plus
.
navigator
.
isImmersedStatusbar
()
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
f3ccbc81
...
...
@@ -5606,20 +5606,20 @@
return
this
;
}
};
function
initBridge
(
n
amespace
)
{
function
initBridge
(
subscribeN
amespace
)
{
const
emitter
=
new
E
();
return
extend
(
emitter
,
{
subscribe
(
event
,
callback
)
{
emitter
.
on
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
on
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
unsubscribe
(
event
,
callback
)
{
emitter
.
off
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
off
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
subscribeHandler
(
event
,
args
,
pageId
)
{
{
console
.
log
(
`[
${
n
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
console
.
log
(
`[
${
subscribeN
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
}
emitter
.
emit
(
`
${
n
amespace
}
.
${
event
}
`
,
args
,
pageId
);
emitter
.
emit
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
args
,
pageId
);
}
});
}
...
...
@@ -5692,7 +5692,7 @@
fromRouteArray
.
splice
(
fromRouteArray
.
length
-
i
-
1
,
i
+
1
);
return
"
/
"
+
fromRouteArray
.
concat
(
toRouteArray
).
join
(
"
/
"
);
}
/* @__PURE__ */
extend
(
initBridge
(
"
service
"
),
{
/* @__PURE__ */
extend
(
initBridge
(
"
view
"
),
{
invokeOnCallback
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
"
api.
"
+
name
,
res
);
}
...
...
@@ -6147,12 +6147,9 @@
});
watch
(()
=>
extend
({},
size2
),
(
value
)
=>
emit2
(
"
resize
"
,
value
));
return
()
=>
{
const
{
width
,
height
}
=
rootRef
.
value
.
getBoundingClientRect
();
size2
.
width
=
width
;
size2
.
height
=
height
;
const
rootEl
=
rootRef
.
value
;
size2
.
width
=
rootEl
.
offsetWidth
;
size2
.
height
=
rootEl
.
offsetHeight
;
reset2
();
};
}
...
...
@@ -6273,8 +6270,8 @@
}
};
const
FIX_MODES
=
{
widthFix
:
[
"
w
idth
"
,
"
height
"
],
heightFix
:
[
"
h
eight
"
,
"
width
"
]
widthFix
:
[
"
offsetW
idth
"
,
"
height
"
],
heightFix
:
[
"
offsetH
eight
"
,
"
width
"
]
};
const
IMAGE_MODES
=
{
aspectFit
:
[
"
center center
"
,
"
contain
"
],
...
...
@@ -6444,8 +6441,7 @@
return
;
}
const
rootEl
=
rootRef
.
value
;
const
rect
=
rootEl
.
getBoundingClientRect
();
const
value
=
rect
[
names
[
0
]];
const
value
=
rootEl
[
names
[
0
]];
if
(
value
)
{
rootEl
.
style
[
names
[
1
]]
=
fixNumber
(
value
/
ratio
)
+
"
px
"
;
}
...
...
packages/uni-app-plus/src/constants.ts
0 → 100644
浏览文件 @
f3ccbc81
export
const
ON_WEBVIEW_READY
=
'
onWebviewReady
'
packages/uni-app-plus/src/service/framework/app/index.ts
浏览文件 @
f3ccbc81
...
...
@@ -6,7 +6,7 @@ import { initTabBar } from './initTabBar'
import
{
initGlobalEvent
}
from
'
./initGlobalEvent
'
import
{
initAppLaunch
}
from
'
./initAppLaunch
'
import
{
clearTempFile
}
from
'
./clearTempFile
'
import
{
initSubscribeHandlers
}
from
'
./
initSubscribeHandlers
'
import
{
initSubscribeHandlers
}
from
'
./
subscriber
'
let
appCtx
:
ComponentPublicInstance
const
defaultApp
=
{
...
...
packages/uni-app-plus/src/service/framework/app/initSubscribeHandlers.ts
已删除
100644 → 0
浏览文件 @
58d55535
export
function
initSubscribeHandlers
()
{}
packages/uni-app-plus/src/service/framework/app/plusMessage.ts
浏览文件 @
f3ccbc81
...
...
@@ -2,7 +2,7 @@ import { WEB_INVOKE_APPSERVICE } from '@dcloudio/uni-shared'
interface
PlusMessageCallback
{
(
args
:
Record
<
string
,
any
>
):
void
keepAlive
:
boolean
keepAlive
?
:
boolean
}
const
callbacks
:
Record
<
string
,
PlusMessageCallback
>
=
{}
...
...
packages/uni-app-plus/src/service/framework/app/subscriber/index.ts
0 → 100644
浏览文件 @
f3ccbc81
import
{
ON_WEBVIEW_READY
}
from
'
packages/uni-app-plus/src/constants
'
import
{
registerPlusMessage
}
from
'
../plusMessage
'
import
{
onWebviewReady
}
from
'
./onWebviewReady
'
export
function
initSubscribeHandlers
()
{
const
{
subscribe
,
subscribeHandler
}
=
UniServiceJSBridge
registerPlusMessage
(
'
subscribeHandler
'
,
(
data
)
=>
{
subscribeHandler
(
data
.
type
,
data
.
data
,
data
.
pageId
)
})
if
(
__uniConfig
.
renderer
!==
'
native
'
)
{
// 非纯原生
subscribe
(
ON_WEBVIEW_READY
,
onWebviewReady
)
}
}
packages/uni-app-plus/src/service/framework/app/subscriber/onWebviewReady.ts
0 → 100644
浏览文件 @
f3ccbc81
import
{
consumeWebviewReady
,
preloadWebview
,
setPreloadWebview
,
}
from
'
../../webview
'
let
isLaunchWebviewReady
=
false
// 目前首页双向确定 ready,可能会导致触发两次 onWebviewReady(主要是 Android)
export
function
onWebviewReady
(
_data
:
unknown
,
pageId
:
string
)
{
const
isLaunchWebview
=
pageId
===
'
1
'
if
(
isLaunchWebview
&&
isLaunchWebviewReady
)
{
if
(
__DEV__
)
{
console
.
log
(
'
[uni-app] onLaunchWebviewReady.prevent
'
)
}
return
}
if
(
isLaunchWebview
)
{
// 首页
isLaunchWebviewReady
=
true
setPreloadWebview
(
plus
.
webview
.
getLaunchWebview
())
}
else
if
(
!
preloadWebview
)
{
// preloadWebview 不存在,重新加载一下
setPreloadWebview
(
plus
.
webview
.
getWebviewById
(
pageId
))
}
if
(
preloadWebview
.
id
!==
pageId
)
{
return
console
.
error
(
`webviewReady[
${
preloadWebview
.
id
}
][
${
pageId
}
] not match`
)
}
;(
preloadWebview
as
any
).
loaded
=
true
// 标记已 ready
consumeWebviewReady
(
pageId
)
if
(
!
isLaunchWebview
)
{
return
}
const
entryPagePath
=
'
/
'
+
__uniConfig
.
entryPagePath
const
routeOptions
=
__uniRoutes
.
find
(
(
route
)
=>
route
.
path
===
entryPagePath
)
!
if
(
!
routeOptions
.
meta
.
isNVue
)
{
// 非 nvue 首页,需要主动跳转
const
navigateType
=
routeOptions
.
meta
.
isTabBar
?
'
switchTab
'
:
'
navigateTo
'
return
uni
[
navigateType
]({
url
:
entryPagePath
+
(
__uniConfig
.
entryPageQuery
||
''
),
openType
:
'
appLaunch
'
,
}
as
any
)
}
}
packages/uni-app-plus/src/service/framework/constants.ts
0 → 100644
浏览文件 @
f3ccbc81
export
const
VIEW_WEBVIEW_PATH
=
'
_www/__uniappview.html
'
packages/uni-app-plus/src/service/framework/page/register.ts
浏览文件 @
f3ccbc81
...
...
@@ -2,7 +2,7 @@ import { hasOwn } from '@vue/shared'
import
{
NAVBAR_HEIGHT
,
ON_REACH_BOTTOM_DISTANCE
}
from
'
@dcloudio/uni-shared
'
import
{
initEntry
}
from
'
../app/initEntry
'
import
{
initRouteOptions
}
from
'
./initRouteOptions
'
import
{
createWebview
}
from
'
./webview
'
import
{
createWebview
}
from
'
.
.
/webview
'
import
{
createPage
}
from
'
./define
'
import
{
PageNodeOptions
}
from
'
../dom/Page
'
import
{
getStatusbarHeight
}
from
'
../../../helpers/statusBar
'
...
...
packages/uni-app-plus/src/service/framework/
page/
webview/index.ts
→
packages/uni-app-plus/src/service/framework/webview/index.ts
浏览文件 @
f3ccbc81
import
{
createNVueWebview
}
from
'
./nvue
'
import
{
getPreloadWebview
,
getWebviewId
}
from
'
./utils
'
export
*
from
'
./preload
'
export
interface
CreateWebviewOptions
{
path
:
string
query
:
Record
<
string
,
string
>
...
...
packages/uni-app-plus/src/service/framework/
page/
webview/nvue.ts
→
packages/uni-app-plus/src/service/framework/webview/nvue.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/webview/preload.ts
0 → 100644
浏览文件 @
f3ccbc81
import
{
isArray
}
from
'
@vue/shared
'
import
{
VIEW_WEBVIEW_PATH
}
from
'
../constants
'
import
{
genWebviewId
}
from
'
./utils
'
export
let
preloadWebview
:
PlusWebviewWebviewObject
export
function
setPreloadWebview
(
webview
:
PlusWebviewWebviewObject
)
{
preloadWebview
=
webview
}
export
function
createPreloadWebview
()
{
if
(
!
preloadWebview
||
(
preloadWebview
as
any
).
__uniapp_route
)
{
// 不存在,或已被使用
preloadWebview
=
plus
.
webview
.
create
(
VIEW_WEBVIEW_PATH
,
String
(
genWebviewId
())
)
if
(
__DEV__
)
{
console
.
log
(
`[uni-app] preloadWebview[
${
preloadWebview
.
id
}
]`
)
}
}
return
preloadWebview
}
const
webviewReadyCallbacks
:
Record
<
string
,
Function
[]
>
=
{}
export
function
registerWebviewReady
(
pageId
:
string
,
callback
:
Function
)
{
;(
webviewReadyCallbacks
[
pageId
]
||
(
webviewReadyCallbacks
[
pageId
]
=
[])).
push
(
callback
)
}
export
function
consumeWebviewReady
(
pageId
:
string
)
{
const
callbacks
=
webviewReadyCallbacks
[
pageId
]
isArray
(
callbacks
)
&&
callbacks
.
forEach
((
callback
)
=>
callback
())
delete
webviewReadyCallbacks
[
pageId
]
}
packages/uni-app-plus/src/service/framework/
page/
webview/style/backgroundColor.ts
→
packages/uni-app-plus/src/service/framework/webview/style/backgroundColor.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/index.ts
→
packages/uni-app-plus/src/service/framework/webview/style/index.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/nvue.ts
→
packages/uni-app-plus/src/service/framework/webview/style/nvue.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/popGesture.ts
→
packages/uni-app-plus/src/service/framework/webview/style/popGesture.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/pullToRefresh.ts
→
packages/uni-app-plus/src/service/framework/webview/style/pullToRefresh.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/titleNView.ts
→
packages/uni-app-plus/src/service/framework/webview/style/titleNView.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/style/utils.ts
→
packages/uni-app-plus/src/service/framework/webview/style/utils.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-plus/src/service/framework/
page/
webview/utils.ts
→
packages/uni-app-plus/src/service/framework/webview/utils.ts
浏览文件 @
f3ccbc81
文件已移动
packages/uni-app-vue/dist/service.runtime.esm.js
浏览文件 @
f3ccbc81
此差异已折叠。
点击以展开。
packages/uni-components/src/components/image/index.tsx
浏览文件 @
f3ccbc81
...
...
@@ -37,8 +37,8 @@ type ImageState = ReturnType<typeof useImageState>
type
FixSize
=
ReturnType
<
typeof
useImageSize
>
[
'
fixSize
'
]
const
FIX_MODES
=
{
widthFix
:
[
'
w
idth
'
,
'
height
'
],
heightFix
:
[
'
h
eight
'
,
'
width
'
],
widthFix
:
[
'
offsetW
idth
'
,
'
height
'
],
heightFix
:
[
'
offsetH
eight
'
,
'
width
'
],
}
const
IMAGE_MODES
=
{
aspectFit
:
[
'
center center
'
,
'
contain
'
],
...
...
@@ -76,6 +76,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
<
div
style
=
{
modeStyle
}
/>
{
imgSrc
?
<
img
src
=
{
imgSrc
}
draggable
=
{
props
.
draggable
}
/>
:
<
img
/>
}
{
FIX_MODES
[
mode
as
keyof
typeof
FIX_MODES
]
?
(
// @ts-ignore
<
ResizeSensor
onResize
=
{
fixSize
}
/>
)
:
(
<
span
></
span
>
...
...
@@ -209,8 +210,7 @@ function useImageSize(
return
}
const
rootEl
=
rootRef
.
value
!
const
rect
=
rootEl
.
getBoundingClientRect
()
const
value
=
rect
[
names
[
0
]
as
keyof
DOMRect
]
as
number
const
value
=
rootEl
[
names
[
0
]
as
'
offsetWidth
'
|
'
offsetHeight
'
]
if
(
value
)
{
rootEl
.
style
[
names
[
1
]
as
'
height
'
|
'
width
'
]
=
fixNumber
(
value
/
ratio
)
+
'
px
'
...
...
packages/uni-components/src/components/resize-sensor/index.tsx
浏览文件 @
f3ccbc81
...
...
@@ -49,9 +49,9 @@ function useResizeSensorUpdate(
(
value
:
typeof
size
)
=>
emit
(
'
resize
'
,
value
)
)
return
()
=>
{
const
{
width
,
height
}
=
rootRef
.
value
!
.
getBoundingClientRect
()
size
.
width
=
w
idth
size
.
height
=
h
eight
const
rootEl
=
rootRef
.
value
!
size
.
width
=
rootEl
.
offsetW
idth
size
.
height
=
rootEl
.
offsetH
eight
reset
()
}
}
...
...
packages/uni-core/src/helpers/bridge.ts
浏览文件 @
f3ccbc81
...
...
@@ -3,26 +3,26 @@ import { extend } from '@vue/shared'
import
E
from
'
./TinyEmitter
'
export
function
initBridge
(
n
amespace
:
'
service
'
|
'
view
'
subscribeN
amespace
:
'
service
'
|
'
view
'
):
Partial
<
UniApp
.
UniServiceJSBridge
>
{
// TODO vue3 compatibility builds
const
emitter
=
new
E
()
return
extend
(
emitter
,
{
subscribe
(
event
:
string
,
callback
:
Function
):
void
{
emitter
.
on
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
)
emitter
.
on
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
)
},
unsubscribe
(
event
:
string
,
callback
:
Function
):
void
{
emitter
.
off
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
)
emitter
.
off
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
)
},
subscribeHandler
(
event
:
string
,
args
:
unknown
,
pageId
:
number
):
void
{
if
(
__DEV__
)
{
console
.
log
(
`[
${
n
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
`[
${
subscribeN
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
)
}
emitter
.
emit
(
`
${
n
amespace
}
.
${
event
}
`
,
args
,
pageId
)
emitter
.
emit
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
args
,
pageId
)
},
})
}
packages/uni-core/src/service/bridge/index.ts
浏览文件 @
f3ccbc81
import
{
extend
}
from
'
@vue/shared
'
import
{
initBridge
}
from
'
../../helpers/bridge
'
export
const
ServiceJSBridge
=
/*#__PURE__*/
extend
(
initBridge
(
'
service
'
),
{
export
const
ServiceJSBridge
=
/*#__PURE__*/
extend
(
initBridge
(
'
view
'
/* view 指的是 service 层订阅的是 view 层事件 */
),
{
invokeOnCallback
(
name
:
string
,
res
:
unknown
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
},
})
}
)
packages/uni-core/src/view/bridge/index.ts
浏览文件 @
f3ccbc81
import
{
initBridge
}
from
'
../../helpers/bridge
'
export
const
ViewJSBridge
=
/*#__PURE__*/
initBridge
(
'
view
'
)
export
const
ViewJSBridge
=
/*#__PURE__*/
initBridge
(
'
service
'
)
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
f3ccbc81
...
...
@@ -351,24 +351,24 @@ E.prototype = {
return
this
;
}
};
function
initBridge
(
n
amespace
)
{
function
initBridge
(
subscribeN
amespace
)
{
const
emitter
=
new
E
();
return
shared
.
extend
(
emitter
,
{
subscribe
(
event
,
callback
)
{
emitter
.
on
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
on
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
unsubscribe
(
event
,
callback
)
{
emitter
.
off
(
`
${
n
amespace
}
.
${
event
}
`
,
callback
);
emitter
.
off
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
callback
);
},
subscribeHandler
(
event
,
args
,
pageId
)
{
if
(
process
.
env
.
NODE_ENV
!==
"
production
"
)
{
console
.
log
(
`[
${
n
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
console
.
log
(
`[
${
subscribeN
amespace
}
][subscribeHandler][
${
Date
.
now
()}
]:
${
event
}
,
${
JSON
.
stringify
(
args
)}
,
${
pageId
}
`
);
}
emitter
.
emit
(
`
${
n
amespace
}
.
${
event
}
`
,
args
,
pageId
);
emitter
.
emit
(
`
${
subscribeN
amespace
}
.
${
event
}
`
,
args
,
pageId
);
}
});
}
const
ViewJSBridge
=
/* @__PURE__ */
initBridge
(
"
view
"
);
const
ViewJSBridge
=
/* @__PURE__ */
initBridge
(
"
service
"
);
uniShared
.
passive
(
true
);
const
onEventPrevent
=
/* @__PURE__ */
vue
.
withModifiers
(()
=>
{
},
[
"
prevent
"
]);
...
...
@@ -529,7 +529,7 @@ function createNativeEvent(evt) {
}
return
event
;
}
const
ServiceJSBridge
=
/* @__PURE__ */
shared
.
extend
(
initBridge
(
"
service
"
),
{
const
ServiceJSBridge
=
/* @__PURE__ */
shared
.
extend
(
initBridge
(
"
view
"
),
{
invokeOnCallback
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
"
api.
"
+
name
,
res
);
}
...
...
@@ -1573,12 +1573,9 @@ function useResizeSensorUpdate(rootRef, emit2, reset) {
});
vue
.
watch
(()
=>
shared
.
extend
({},
size
),
(
value
)
=>
emit2
(
"
resize
"
,
value
));
return
()
=>
{
const
{
width
,
height
}
=
rootRef
.
value
.
getBoundingClientRect
();
size
.
width
=
width
;
size
.
height
=
height
;
const
rootEl
=
rootRef
.
value
;
size
.
width
=
rootEl
.
offsetWidth
;
size
.
height
=
rootEl
.
offsetHeight
;
reset
();
};
}
...
...
@@ -2605,8 +2602,8 @@ const props$p = {
}
};
const
FIX_MODES
=
{
widthFix
:
[
"
w
idth
"
,
"
height
"
],
heightFix
:
[
"
h
eight
"
,
"
width
"
]
widthFix
:
[
"
offsetW
idth
"
,
"
height
"
],
heightFix
:
[
"
offsetH
eight
"
,
"
width
"
]
};
const
IMAGE_MODES
=
{
aspectFit
:
[
"
center center
"
,
"
contain
"
],
...
...
@@ -2764,8 +2761,7 @@ function useImageSize(rootRef, props2, state) {
return
;
}
const
rootEl
=
rootRef
.
value
;
const
rect
=
rootEl
.
getBoundingClientRect
();
const
value
=
rect
[
names
[
0
]];
const
value
=
rootEl
[
names
[
0
]];
if
(
value
)
{
rootEl
.
style
[
names
[
1
]]
=
fixNumber
(
value
/
ratio
)
+
"
px
"
;
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
f3ccbc81
...
...
@@ -440,24 +440,24 @@ E.prototype = {
return this;
}
};
function initBridge(
n
amespace) {
function initBridge(
subscribeN
amespace) {
const emitter2 = new E();
return extend(emitter2, {
subscribe(event, callback) {
emitter2.on(`${
n
amespace}.${event}`, callback);
emitter2.on(`${
subscribeN
amespace}.${event}`, callback);
},
unsubscribe(event, callback) {
emitter2.off(`${
n
amespace}.${event}`, callback);
emitter2.off(`${
subscribeN
amespace}.${event}`, callback);
},
subscribeHandler(event, args, pageId) {
if (process.env.NODE_ENV !== "production") {
console.log(`[${
n
amespace}][subscribeHandler][${Date.now()}]:${event}, ${JSON.stringify(args)}, ${pageId}`);
console.log(`[${
subscribeN
amespace}][subscribeHandler][${Date.now()}]:${event}, ${JSON.stringify(args)}, ${pageId}`);
}
emitter2.emit(`${
n
amespace}.${event}`, args, pageId);
emitter2.emit(`${
subscribeN
amespace}.${event}`, args, pageId);
}
});
}
const ViewJSBridge = /* @__PURE__ */ initBridge("
view
");
const ViewJSBridge = /* @__PURE__ */ initBridge("
service
");
const LONGPRESS_TIMEOUT = 350;
const LONGPRESS_THRESHOLD = 10;
const passiveOptions$2 = passive(true);
...
...
@@ -1244,7 +1244,7 @@ function initView(app) {
}
initAppConfig$1(app._context.config);
}
const ServiceJSBridge = /* @__PURE__ */ extend(initBridge("
service
"), {
const ServiceJSBridge = /* @__PURE__ */ extend(initBridge("
view
"), {
invokeOnCallback(name, res) {
return UniServiceJSBridge.emit("api." + name, res);
}
...
...
@@ -5780,12 +5780,9 @@ function useResizeSensorUpdate(rootRef, emit2, reset) {
});
watch(() => extend({}, size), (value) => emit2("resize", value));
return () => {
const {
width,
height
} = rootRef.value.getBoundingClientRect();
size.width = width;
size.height = height;
const rootEl = rootRef.value;
size.width = rootEl.offsetWidth;
size.height = rootEl.offsetHeight;
reset();
};
}
...
...
@@ -7539,8 +7536,8 @@ const props$w = {
}
};
const FIX_MODES = {
widthFix: ["
w
idth", "height"],
heightFix: ["
h
eight", "width"]
widthFix: ["
offsetW
idth", "height"],
heightFix: ["
offsetH
eight", "width"]
};
const IMAGE_MODES = {
aspectFit: ["center center", "contain"],
...
...
@@ -7710,8 +7707,7 @@ function useImageSize(rootRef, props2, state2) {
return;
}
const rootEl = rootRef.value;
const rect = rootEl.getBoundingClientRect();
const value = rect[names[0]];
const value = rootEl[names[0]];
if (value) {
rootEl.style[names[1]] = fixNumber(value / ratio) + "px";
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录