Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
f985d4df
U
uni-app
项目概览
Velpro187
/
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,发现更多精彩内容 >>
提交
f985d4df
编写于
4月 16, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: make i18n tree-shakeable
上级
45857fef
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
183 addition
and
225 deletion
+183
-225
packages/uni-api/src/helpers/interceptor.ts
packages/uni-api/src/helpers/interceptor.ts
+14
-9
packages/uni-core/src/helpers/getWindowOffset.ts
packages/uni-core/src/helpers/getWindowOffset.ts
+9
-17
packages/uni-core/src/i18n/messages.ts
packages/uni-core/src/i18n/messages.ts
+1
-1
packages/uni-core/src/i18n/useI18n.ts
packages/uni-core/src/i18n/useI18n.ts
+14
-2
packages/uni-core/src/view/bridge/index.ts
packages/uni-core/src/view/bridge/index.ts
+1
-1
packages/uni-core/src/view/plugin/appConfig.ts
packages/uni-core/src/view/plugin/appConfig.ts
+3
-3
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+82
-104
packages/uni-h5/src/framework/plugin/provide/page.ts
packages/uni-h5/src/framework/plugin/provide/page.ts
+28
-24
packages/uni-h5/src/framework/plugin/setup.ts
packages/uni-h5/src/framework/plugin/setup.ts
+0
-4
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+4
-9
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+4
-9
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+4
-9
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+4
-9
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+4
-9
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+4
-9
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+1
-1
packages/uni-shared/dist/uni-shared.esm.js
packages/uni-shared/dist/uni-shared.esm.js
+2
-2
packages/uni-shared/src/query.ts
packages/uni-shared/src/query.ts
+2
-2
packages/vite-plugin-uni/src/utils/define.ts
packages/vite-plugin-uni/src/utils/define.ts
+1
-0
scripts/i18n.js
scripts/i18n.js
+1
-1
未找到文件。
packages/uni-api/src/helpers/interceptor.ts
浏览文件 @
f985d4df
import
{
isArray
,
isFunction
,
isPromise
}
from
'
@vue/shared
'
export
enum
HOOKS
{
INVOKE
=
'
invoke
'
,
SUCCESS
=
'
success
'
,
FAIL
=
'
fail
'
,
COMPLETE
=
'
complete
'
,
RETURN_VALUE
=
'
returnValue
'
,
}
const
HOOK_INVOKE
=
'
invoke
'
const
HOOK_SUCCESS
=
'
success
'
const
HOOK_FAIL
=
'
fail
'
const
HOOK_COMPLETE
=
'
complete
'
const
HOOK_RETURN_VALUE
=
'
returnValue
'
export
type
HOOKS
=
|
typeof
HOOK_INVOKE
|
typeof
HOOK_SUCCESS
|
typeof
HOOK_FAIL
|
typeof
HOOK_COMPLETE
|
typeof
HOOK_RETURN_VALUE
export
type
Interceptor
=
{
[
P
in
HOOKS
]?:
Function
}
...
...
@@ -54,8 +59,8 @@ function wrapperOptions(
interceptors
:
Interceptors
,
options
:
Record
<
string
,
any
>
=
{}
)
{
;[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
]
;[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
as
HOOKS
]
if
(
!
isArray
(
hooks
))
{
return
}
...
...
packages/uni-core/src/helpers/getWindowOffset.ts
浏览文件 @
f985d4df
import
safeAreaInsets
from
'
safe-area-insets
'
export
function
getWindowOffset
()
{
if
(
uni
.
canIUse
(
'
css.var
'
))
{
const
style
=
document
.
documentElement
.
style
const
top
=
parseInt
(
style
.
getPropertyValue
(
'
--window-top
'
))
const
bottom
=
parseInt
(
style
.
getPropertyValue
(
'
--window-bottom
'
))
const
left
=
parseInt
(
style
.
getPropertyValue
(
'
--window-left
'
))
const
right
=
parseInt
(
style
.
getPropertyValue
(
'
--window-right
'
))
return
{
top
:
top
?
top
+
safeAreaInsets
.
top
:
0
,
bottom
:
bottom
?
bottom
+
safeAreaInsets
.
bottom
:
0
,
left
:
left
?
left
+
safeAreaInsets
.
left
:
0
,
right
:
right
?
right
+
safeAreaInsets
.
right
:
0
,
}
}
const
style
=
document
.
documentElement
.
style
const
top
=
parseInt
(
style
.
getPropertyValue
(
'
--window-top
'
))
const
bottom
=
parseInt
(
style
.
getPropertyValue
(
'
--window-bottom
'
))
const
left
=
parseInt
(
style
.
getPropertyValue
(
'
--window-left
'
))
const
right
=
parseInt
(
style
.
getPropertyValue
(
'
--window-right
'
))
return
{
top
:
0
,
bottom
:
0
,
left
:
0
,
right
:
0
,
top
:
top
?
top
+
safeAreaInsets
.
top
:
0
,
bottom
:
bottom
?
bottom
+
safeAreaInsets
.
bottom
:
0
,
left
:
left
?
left
+
safeAreaInsets
.
left
:
0
,
right
:
right
?
right
+
safeAreaInsets
.
right
:
0
,
}
}
packages/uni-core/src/i18n/messages.ts
浏览文件 @
f985d4df
...
...
@@ -8,7 +8,7 @@ import {
LOCALE_ZH_HANT
,
}
from
'
@dcloudio/uni-i18n
'
import
{
useI18n
}
from
'
./useI18n
'
const
i18n
=
useI18n
()
const
i18n
=
/*#__PURE__*/
useI18n
()
function
normalizeMessages
(
namespace
:
string
,
messages
:
Record
<
string
,
string
>
...
...
packages/uni-core/src/i18n/useI18n.ts
浏览文件 @
f985d4df
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
const
i18n
=
initVueI18n
()
import
{
BuiltInLocale
,
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
let
i18n
:
ReturnType
<
typeof
initVueI18n
>
export
function
useI18n
()
{
if
(
!
i18n
)
{
let
language
:
BuiltInLocale
if
(
__PLATFORM__
===
'
h5
'
)
{
language
=
navigator
.
language
as
BuiltInLocale
}
else
if
(
__PLATFORM__
===
'
app
'
)
{
// TODO 需替换为新API
language
=
plus
.
os
.
language
as
BuiltInLocale
}
else
{
language
=
uni
.
getSystemInfoSync
().
language
as
BuiltInLocale
}
i18n
=
initVueI18n
(
language
)
}
return
i18n
}
packages/uni-core/src/view/bridge/index.ts
浏览文件 @
f985d4df
import
{
initBridge
}
from
'
../../helpers/bridge
'
export
const
ViewJSBridge
=
initBridge
(
'
view
'
)
export
const
ViewJSBridge
=
/*#__PURE__*/
initBridge
(
'
view
'
)
packages/uni-core/src/view/plugin/appConfig.ts
浏览文件 @
f985d4df
import
{
AppConfig
}
from
'
vue
'
import
{
extend
}
from
'
@vue/shared
'
//
import { extend } from '@vue/shared'
import
*
as
instance
from
'
./componentInstance
'
//
import * as instance from './componentInstance'
import
{
getComponentDescriptor
,
handleWxsEvent
}
from
'
./componentWxs
'
export
function
initAppConfig
(
appConfig
:
AppConfig
)
{
const
globalProperties
=
appConfig
.
globalProperties
extend
(
globalProperties
,
instance
)
//
extend(globalProperties, instance)
if
(
__UNI_FEATURE_WXS__
)
{
globalProperties
.
getComponentDescriptor
=
getComponentDescriptor
Object
.
defineProperty
(
globalProperties
,
'
$ownerInstance
'
,
{
...
...
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
f985d4df
...
...
@@ -2,12 +2,12 @@ import {isFunction, extend, isPlainObject, isString, invokeArrayFns as invokeArr
import
{
injectHook
,
createVNode
,
inject
,
provide
,
reactive
,
computed
,
nextTick
,
getCurrentInstance
,
onBeforeMount
,
onMounted
,
onBeforeActivate
,
onBeforeDeactivate
,
openBlock
,
createBlock
,
mergeProps
,
toDisplayString
,
ref
,
defineComponent
,
resolveComponent
,
toHandlers
,
renderSlot
,
createCommentVNode
,
onBeforeUnmount
,
withModifiers
,
withDirectives
,
vShow
,
vModelDynamic
,
createTextVNode
,
Fragment
,
renderList
,
vModelText
,
watch
,
watchEffect
,
withCtx
,
KeepAlive
,
resolveDynamicComponent
}
from
"
vue
"
;
import
{
passive
,
invokeArrayFns
,
NAVBAR_HEIGHT
,
removeLeadingSlash
,
parseQuery
,
decodedQuery
,
plusReady
,
debounce
,
PRIMARY_COLOR
as
PRIMARY_COLOR$1
,
getLen
,
updateElementStyle
}
from
"
@dcloudio/uni-shared
"
;
import
{
useRoute
,
createRouter
,
createWebHistory
,
createWebHashHistory
,
isNavigationFailure
,
RouterView
}
from
"
vue-router
"
;
function
applyOptions
(
options
,
instance
2
,
publicThis
)
{
function
applyOptions
(
options
,
instance
,
publicThis
)
{
Object
.
keys
(
options
).
forEach
((
name
)
=>
{
if
(
name
.
indexOf
(
"
on
"
)
===
0
)
{
const
hook
=
options
[
name
];
if
(
isFunction
(
hook
))
{
injectHook
(
name
,
hook
.
bind
(
publicThis
),
instance
2
);
injectHook
(
name
,
hook
.
bind
(
publicThis
),
instance
);
}
}
});
...
...
@@ -244,11 +244,18 @@ function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_
}
};
}
const
i18n$1
=
initVueI18n
()
;
let
i18n$1
;
function
useI18n
()
{
if
(
!
i18n$1
)
{
let
language
;
{
language
=
navigator
.
language
;
}
i18n$1
=
initVueI18n
(
language
);
}
return
i18n$1
;
}
const
i18n
=
useI18n
();
const
i18n
=
/* @__PURE__ */
useI18n
();
function
normalizeMessages
(
namespace
,
messages
)
{
return
Object
.
keys
(
messages
).
reduce
((
res
,
name
)
=>
{
res
[
namespace
+
name
]
=
messages
[
name
];
...
...
@@ -334,7 +341,7 @@ function initBridge(namespace) {
}
});
}
const
ViewJSBridge
=
initBridge
(
"
view
"
);
const
ViewJSBridge
=
/* @__PURE__ */
initBridge
(
"
view
"
);
const
LONGPRESS_TIMEOUT
=
350
;
const
LONGPRESS_THRESHOLD
=
10
;
const
passiveOptions$2
=
passive
(
true
);
...
...
@@ -572,24 +579,16 @@ var safeAreaInsets = {
};
var
out
=
safeAreaInsets
;
function
getWindowOffset
()
{
if
(
uni
.
canIUse
(
"
css.var
"
))
{
const
style
=
document
.
documentElement
.
style
;
const
top
=
parseInt
(
style
.
getPropertyValue
(
"
--window-top
"
));
const
bottom
=
parseInt
(
style
.
getPropertyValue
(
"
--window-bottom
"
));
const
left
=
parseInt
(
style
.
getPropertyValue
(
"
--window-left
"
));
const
right
=
parseInt
(
style
.
getPropertyValue
(
"
--window-right
"
));
return
{
top
:
top
?
top
+
out
.
top
:
0
,
bottom
:
bottom
?
bottom
+
out
.
bottom
:
0
,
left
:
left
?
left
+
out
.
left
:
0
,
right
:
right
?
right
+
out
.
right
:
0
};
}
const
style
=
document
.
documentElement
.
style
;
const
top
=
parseInt
(
style
.
getPropertyValue
(
"
--window-top
"
));
const
bottom
=
parseInt
(
style
.
getPropertyValue
(
"
--window-bottom
"
));
const
left
=
parseInt
(
style
.
getPropertyValue
(
"
--window-left
"
));
const
right
=
parseInt
(
style
.
getPropertyValue
(
"
--window-right
"
));
return
{
top
:
0
,
bottom
:
0
,
left
:
0
,
right
:
0
top
:
top
?
top
+
out
.
top
:
0
,
bottom
:
bottom
?
bottom
+
out
.
bottom
:
0
,
left
:
left
?
left
+
out
.
left
:
0
,
right
:
right
?
right
+
out
.
right
:
0
};
}
function
findUniTarget
(
$event
,
$el
)
{
...
...
@@ -683,23 +682,6 @@ function normalizeTouchList(touches) {
}
return
[];
}
function
$trigger
(
name
,
$event
,
detail
)
{
const
target
=
this
.
$el
;
this
.
$emit
(
name
,
normalizeEvent$1
(
name
,
$event
,
detail
,
target
,
target
));
}
function
$handleEvent
(
$event
)
{
if
(
$event
instanceof
Event
)
{
const
target
=
findUniTarget
(
$event
,
this
.
$el
);
return
normalizeEvent$1
(
$event
.
type
,
$event
,
{},
target
||
$event
.
target
,
$event
.
currentTarget
);
}
return
$event
;
}
var
instance
=
/* @__PURE__ */
Object
.
freeze
({
__proto__
:
null
,
[
Symbol
.
toStringTag
]:
"
Module
"
,
$trigger
,
$handleEvent
});
const
CLASS_RE
=
/^
\s
+|
\s
+$/g
;
const
WXS_CLASS_RE
=
/
\s
+/
;
function
getWxsClsArr
(
clsArr
,
classList
,
isAdd
)
{
...
...
@@ -850,18 +832,18 @@ function createComponentDescriptor(vm, isOwnerInstance = true) {
return
vm
.
$el
.
__wxsComponentDescriptor
;
}
}
function
getComponentDescriptor
(
instance
2
,
isOwnerInstance
)
{
return
createComponentDescriptor
(
instance
2
||
this
,
isOwnerInstance
);
function
getComponentDescriptor
(
instance
,
isOwnerInstance
)
{
return
createComponentDescriptor
(
instance
||
this
,
isOwnerInstance
);
}
function
handleWxsEvent
(
$event
)
{
if
(
!
(
$event
instanceof
Event
))
{
return
$event
;
}
const
currentTarget
=
$event
.
currentTarget
;
const
instance
2
=
currentTarget
&&
currentTarget
.
__vue__
&&
getComponentDescriptor
.
call
(
this
,
currentTarget
.
__vue__
,
false
);
const
instance
=
currentTarget
&&
currentTarget
.
__vue__
&&
getComponentDescriptor
.
call
(
this
,
currentTarget
.
__vue__
,
false
);
const
$origEvent
=
$event
;
$event
=
normalizeEvent$1
(
$origEvent
.
type
,
$origEvent
,
{},
findUniTarget
(
$origEvent
,
this
.
$el
)
||
$origEvent
.
target
,
$origEvent
.
currentTarget
);
$event
.
instance
=
instance
2
;
$event
.
instance
=
instance
;
$event
.
preventDefault
=
function
()
{
return
$origEvent
.
preventDefault
();
};
...
...
@@ -871,7 +853,6 @@ function handleWxsEvent($event) {
}
function
initAppConfig$1
(
appConfig
)
{
const
globalProperties
=
appConfig
.
globalProperties
;
extend
(
globalProperties
,
instance
);
if
(
__UNI_FEATURE_WXS__
)
{
globalProperties
.
getComponentDescriptor
=
getComponentDescriptor
;
Object
.
defineProperty
(
globalProperties
,
"
$ownerInstance
"
,
{
...
...
@@ -1029,8 +1010,8 @@ function getRealRoute(fromRoute, toRoute) {
fromRouteArray
.
splice
(
fromRouteArray
.
length
-
i2
-
1
,
i2
+
1
);
return
"
/
"
+
fromRouteArray
.
concat
(
toRouteArray
).
join
(
"
/
"
);
}
function
errorHandler
(
err
,
instance
2
,
info
)
{
if
(
!
instance
2
)
{
function
errorHandler
(
err
,
instance
,
info
)
{
if
(
!
instance
)
{
throw
err
;
}
const
app
=
getApp
();
...
...
@@ -1079,28 +1060,33 @@ function mergePageMeta(pageMeta) {
return
res
;
}
function
normalizePageMeta
(
pageMeta
)
{
const
{
enablePullDownRefresh
,
navigationBar
}
=
pageMeta
;
if
(
enablePullDownRefresh
)
{
const
refreshOptions
=
Object
.
assign
({
support
:
true
,
color
:
"
#2BD009
"
,
style
:
"
circle
"
,
height
:
70
,
range
:
150
,
offset
:
0
},
pageMeta
.
refreshOptions
||
{});
let
offset
=
rpx2px
(
refreshOptions
.
offset
);
const
{
type
}
=
navigationBar
;
if
(
type
!==
"
transparent
"
&&
type
!==
"
none
"
)
{
offset
+=
NAVBAR_HEIGHT
+
out
.
top
;
}
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
);
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
);
pageMeta
.
refreshOptions
=
refreshOptions
;
}
navigationBar
.
backButton
=
pageMeta
.
isQuit
?
false
:
true
;
navigationBar
.
titleColor
=
navigationBar
.
titleColor
||
"
#fff
"
;
navigationBar
.
backgroundColor
=
navigationBar
.
backgroundColor
||
"
#F7F7F7
"
;
if
(
__UNI_FEATURE_PULL_DOWN_REFRESH__
)
{
const
{
enablePullDownRefresh
,
navigationBar
}
=
pageMeta
;
if
(
enablePullDownRefresh
)
{
const
refreshOptions
=
Object
.
assign
({
support
:
true
,
color
:
"
#2BD009
"
,
style
:
"
circle
"
,
height
:
70
,
range
:
150
,
offset
:
0
},
pageMeta
.
refreshOptions
||
{});
let
offset
=
rpx2px
(
refreshOptions
.
offset
);
const
{
type
}
=
navigationBar
;
if
(
type
!==
"
transparent
"
&&
type
!==
"
none
"
)
{
offset
+=
NAVBAR_HEIGHT
+
out
.
top
;
}
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
);
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
);
pageMeta
.
refreshOptions
=
refreshOptions
;
}
}
if
(
__UNI_FEATURE_NAVIGATIONBAR__
)
{
const
{
navigationBar
}
=
pageMeta
;
navigationBar
.
backButton
=
pageMeta
.
isQuit
?
false
:
true
;
navigationBar
.
titleColor
=
navigationBar
.
titleColor
||
"
#fff
"
;
navigationBar
.
backgroundColor
=
navigationBar
.
backgroundColor
||
"
#F7F7F7
"
;
}
if
(
__UNI_FEATURE_PAGES__
&&
history
.
state
)
{
const
type
=
history
.
state
.
__type__
;
if
((
type
===
"
redirectTo
"
||
type
===
"
reLaunch
"
)
&&
getCurrentPages
().
length
===
0
)
{
...
...
@@ -1323,9 +1309,9 @@ function usePageRoute() {
function
wrapperComponentSetup
(
comp
,
{
init
:
init2
,
setup
,
after
})
{
const
oldSetup
=
comp
.
setup
;
comp
.
setup
=
(
props
,
ctx
)
=>
{
const
instance
2
=
getCurrentInstance
();
init2
(
instance
2
.
proxy
);
setup
(
instance
2
);
const
instance
=
getCurrentInstance
();
init2
(
instance
.
proxy
);
setup
(
instance
);
if
(
oldSetup
)
{
return
oldSetup
(
props
,
ctx
);
}
...
...
@@ -1343,29 +1329,29 @@ function setupComponent(comp, options) {
function
setupPage
(
comp
)
{
return
setupComponent
(
comp
,
{
init
:
initPage
,
setup
(
instance
2
)
{
setup
(
instance
)
{
const
route
=
usePageRoute
();
onBeforeMount
(()
=>
{
const
{
onLoad
,
onShow
}
=
instance
2
;
const
{
onLoad
,
onShow
}
=
instance
;
onLoad
&&
invokeArrayFns$1
(
onLoad
,
decodedQuery
(
route
.
query
));
instance
2
.
__isVisible
=
true
;
instance
.
__isVisible
=
true
;
onShow
&&
invokeArrayFns$1
(
onShow
);
});
onMounted
(()
=>
{
const
{
onReady
}
=
instance
2
;
const
{
onReady
}
=
instance
;
onReady
&&
invokeArrayFns$1
(
onReady
);
});
onBeforeActivate
(()
=>
{
if
(
!
instance
2
.
__isVisible
)
{
instance
2
.
__isVisible
=
true
;
const
{
onShow
}
=
instance
2
;
if
(
!
instance
.
__isVisible
)
{
instance
.
__isVisible
=
true
;
const
{
onShow
}
=
instance
;
onShow
&&
invokeArrayFns$1
(
onShow
);
}
});
onBeforeDeactivate
(()
=>
{
if
(
instance
2
.
__isVisible
&&
!
instance2
.
__isUnload
)
{
instance
2
.
__isVisible
=
false
;
const
{
onHide
}
=
instance
2
;
if
(
instance
.
__isVisible
&&
!
instance
.
__isUnload
)
{
instance
.
__isVisible
=
false
;
const
{
onHide
}
=
instance
;
onHide
&&
invokeArrayFns$1
(
onHide
);
}
});
...
...
@@ -1373,13 +1359,12 @@ function setupPage(comp) {
});
}
function
setupApp
(
comp
)
{
useI18n
().
setLocale
(
navigator
.
language
);
return
setupComponent
(
comp
,
{
init
:
initApp
,
setup
(
instance
2
)
{
setup
(
instance
)
{
const
route
=
usePageRoute
();
onBeforeMount
(()
=>
{
const
{
onLaunch
,
onShow
}
=
instance
2
;
const
{
onLaunch
,
onShow
}
=
instance
;
onLaunch
&&
invokeArrayFns$1
(
onLaunch
,
{
path
:
route
.
meta
.
route
,
query
:
decodedQuery
(
route
.
query
),
...
...
@@ -2094,6 +2079,7 @@ var index$4 = /* @__PURE__ */ defineComponent({
hovering
,
binding
}
=
useHover
(
props
);
useI18n
();
function
onClick
()
{
if
(
props
.
disabled
)
{
return
;
...
...
@@ -4260,14 +4246,6 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
}
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS2
)
{
HOOKS2
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS2
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS2
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS2
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS2
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
const
API_ADD_INTERCEPTOR
=
"
addInterceptor
"
;
...
...
@@ -5854,14 +5832,14 @@ function useFormField(nameKey, valueKey) {
if
(
!
uniForm
)
{
return
;
}
const
instance
2
=
getCurrentInstance
();
const
instance
=
getCurrentInstance
();
const
ctx
=
{
submit
()
{
const
proxy
=
instance
2
.
proxy
;
const
proxy
=
instance
.
proxy
;
return
[
proxy
[
nameKey
],
proxy
[
valueKey
]];
},
reset
()
{
instance
2
.
proxy
[
valueKey
]
=
""
;
instance
.
proxy
[
valueKey
]
=
""
;
}
};
uniForm
.
addField
(
ctx
);
...
...
@@ -5969,9 +5947,9 @@ const _sfc_main$g = {
formElem
.
appendChild
(
this
.
$refs
.
input
);
this
.
$refs
.
wrapper
.
appendChild
(
formElem
);
}
const
instance
2
=
getCurrentInstance
();
if
(
instance
2
&&
instance2
.
vnode
.
scopeId
)
{
this
.
$refs
.
placeholder
.
setAttribute
(
instance
2
.
vnode
.
scopeId
,
""
);
const
instance
=
getCurrentInstance
();
if
(
instance
&&
instance
.
vnode
.
scopeId
)
{
this
.
$refs
.
placeholder
.
setAttribute
(
instance
.
vnode
.
scopeId
,
""
);
}
this
.
initKeyboard
(
this
.
$refs
.
input
);
},
...
...
@@ -9654,16 +9632,16 @@ function removeSubscribe(componentId, vm) {
UniViewJSBridge
.
unsubscribe
(
normalizeEvent
(
componentId
,
vm
));
}
function
useSubscribe
(
callback
)
{
const
instance
2
=
getCurrentInstance
().
proxy
;
const
instance
=
getCurrentInstance
().
proxy
;
onMounted
(()
=>
{
addSubscribe
(
instance
2
.
id
,
instance2
,
callback
);
watch
(()
=>
instance
2
.
id
,
(
value
,
oldValue
)
=>
{
addSubscribe
(
value
,
instance
2
,
callback
);
removeSubscribe
(
oldValue
,
instance
2
);
addSubscribe
(
instance
.
id
,
instance
,
callback
);
watch
(()
=>
instance
.
id
,
(
value
,
oldValue
)
=>
{
addSubscribe
(
value
,
instance
,
callback
);
removeSubscribe
(
oldValue
,
instance
);
});
});
onBeforeMount
(()
=>
{
removeSubscribe
(
instance
2
.
id
,
instance2
);
removeSubscribe
(
instance
.
id
,
instance
);
});
}
const
passiveOptions
=
passive
(
false
);
...
...
packages/uni-h5/src/framework/plugin/provide/page.ts
浏览文件 @
f985d4df
...
...
@@ -55,32 +55,36 @@ function mergePageMeta(pageMeta: UniApp.PageRouteMeta) {
}
function
normalizePageMeta
(
pageMeta
:
UniApp
.
PageRouteMeta
)
{
const
{
enablePullDownRefresh
,
navigationBar
}
=
pageMeta
if
(
enablePullDownRefresh
)
{
const
refreshOptions
=
Object
.
assign
(
{
support
:
true
,
color
:
'
#2BD009
'
,
style
:
'
circle
'
,
height
:
70
,
range
:
150
,
offset
:
0
,
},
pageMeta
.
refreshOptions
||
{}
)
let
offset
=
rpx2px
(
refreshOptions
.
offset
)
const
{
type
}
=
navigationBar
if
(
type
!==
'
transparent
'
&&
type
!==
'
none
'
)
{
offset
+=
NAVBAR_HEIGHT
+
safeAreaInsets
.
top
if
(
__UNI_FEATURE_PULL_DOWN_REFRESH__
)
{
const
{
enablePullDownRefresh
,
navigationBar
}
=
pageMeta
if
(
enablePullDownRefresh
)
{
const
refreshOptions
=
Object
.
assign
(
{
support
:
true
,
color
:
'
#2BD009
'
,
style
:
'
circle
'
,
height
:
70
,
range
:
150
,
offset
:
0
,
},
pageMeta
.
refreshOptions
||
{}
)
let
offset
=
rpx2px
(
refreshOptions
.
offset
)
const
{
type
}
=
navigationBar
if
(
type
!==
'
transparent
'
&&
type
!==
'
none
'
)
{
offset
+=
NAVBAR_HEIGHT
+
safeAreaInsets
.
top
}
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
)
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
)
pageMeta
.
refreshOptions
=
refreshOptions
}
refreshOptions
.
height
=
rpx2px
(
refreshOptions
.
height
)
refreshOptions
.
range
=
rpx2px
(
refreshOptions
.
range
)
pageMeta
.
refreshOptions
=
refreshOptions
}
navigationBar
.
backButton
=
pageMeta
.
isQuit
?
false
:
true
navigationBar
.
titleColor
=
navigationBar
.
titleColor
||
'
#fff
'
navigationBar
.
backgroundColor
=
navigationBar
.
backgroundColor
||
'
#F7F7F7
'
if
(
__UNI_FEATURE_NAVIGATIONBAR__
)
{
const
{
navigationBar
}
=
pageMeta
navigationBar
.
backButton
=
pageMeta
.
isQuit
?
false
:
true
navigationBar
.
titleColor
=
navigationBar
.
titleColor
||
'
#fff
'
navigationBar
.
backgroundColor
=
navigationBar
.
backgroundColor
||
'
#F7F7F7
'
}
if
(
__UNI_FEATURE_PAGES__
&&
history
.
state
)
{
// 首页执行了redirectTo
const
type
=
history
.
state
.
__type__
...
...
packages/uni-h5/src/framework/plugin/setup.ts
浏览文件 @
f985d4df
...
...
@@ -12,8 +12,6 @@ import {
onBeforeMount
,
}
from
'
vue
'
import
{
useRoute
}
from
'
vue-router
'
import
{
useI18n
}
from
'
@dcloudio/uni-core
'
import
{
BuiltInLocale
}
from
'
@dcloudio/uni-i18n
'
import
{
parseQuery
,
decodedQuery
}
from
'
@dcloudio/uni-shared
'
import
{
LayoutComponent
}
from
'
../..
'
import
{
initApp
}
from
'
./app
'
...
...
@@ -103,8 +101,6 @@ export function setupPage(comp: any) {
}
export
function
setupApp
(
comp
:
any
)
{
// 根据当前平台语言初始化i18n
useI18n
().
setLocale
(
navigator
.
language
as
BuiltInLocale
)
return
setupComponent
(
comp
,
{
init
:
initApp
,
setup
(
instance
)
{
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
f985d4df
...
...
@@ -245,14 +245,9 @@ const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
return
number
<
0
?
-
result
:
result
;
},
Upx2pxProtocol
);
var
HOOKS
;
(
function
(
HOOKS
)
{
HOOKS
[
"
INVOKE
"
]
=
"
invoke
"
;
HOOKS
[
"
SUCCESS
"
]
=
"
success
"
;
HOOKS
[
"
FAIL
"
]
=
"
fail
"
;
HOOKS
[
"
COMPLETE
"
]
=
"
complete
"
;
HOOKS
[
"
RETURN_VALUE
"
]
=
"
returnValue
"
;
})(
HOOKS
||
(
HOOKS
=
{}));
const
HOOK_SUCCESS
=
'
success
'
;
const
HOOK_FAIL
=
'
fail
'
;
const
HOOK_COMPLETE
=
'
complete
'
;
const
globalInterceptors
=
{};
const
scopedInterceptors
=
{};
function
wrapperHook
(
hook
)
{
...
...
@@ -288,7 +283,7 @@ function queue(hooks, data) {
});
}
function
wrapperOptions
(
interceptors
,
options
=
{})
{
[
HOOK
S
.
SUCCESS
,
HOOKS
.
FAIL
,
HOOKS
.
COMPLETE
].
forEach
((
name
)
=>
{
[
HOOK
_SUCCESS
,
HOOK_FAIL
,
HOOK_
COMPLETE
].
forEach
((
name
)
=>
{
const
hooks
=
interceptors
[
name
];
if
(
!
isArray
(
hooks
))
{
return
;
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
f985d4df
...
...
@@ -187,7 +187,7 @@ function parseQuery(search) {
if
(
key
in
query
)
{
// an extra variable for ts types
let
currentValue
=
query
[
key
];
if
(
!
Array
.
isArray
(
currentValue
))
{
if
(
!
shared
.
isArray
(
currentValue
))
{
currentValue
=
query
[
key
]
=
[
currentValue
];
}
currentValue
.
push
(
value
);
...
...
packages/uni-shared/dist/uni-shared.esm.js
浏览文件 @
f985d4df
import
{
isHTMLTag
,
isSVGTag
,
isPlainObject
}
from
'
@vue/shared
'
;
import
{
isHTMLTag
,
isSVGTag
,
isPlainObject
,
isArray
}
from
'
@vue/shared
'
;
function
passive
(
passive
)
{
return
{
passive
};
...
...
@@ -183,7 +183,7 @@ function parseQuery(search) {
if
(
key
in
query
)
{
// an extra variable for ts types
let
currentValue
=
query
[
key
];
if
(
!
Array
.
isArray
(
currentValue
))
{
if
(
!
isArray
(
currentValue
))
{
currentValue
=
query
[
key
]
=
[
currentValue
];
}
currentValue
.
push
(
value
);
...
...
packages/uni-shared/src/query.ts
浏览文件 @
f985d4df
import
{
isPlainObject
}
from
'
@vue/shared
'
import
{
isPlainObject
,
isArray
}
from
'
@vue/shared
'
const
encode
=
encodeURIComponent
export
function
stringifyQuery
(
obj
?:
Record
<
string
,
any
>
,
encodeStr
=
encode
)
{
...
...
@@ -71,7 +71,7 @@ export function parseQuery(search: string) {
if
(
key
in
query
)
{
// an extra variable for ts types
let
currentValue
=
query
[
key
]
if
(
!
Array
.
isArray
(
currentValue
))
{
if
(
!
isArray
(
currentValue
))
{
currentValue
=
query
[
key
]
=
[
currentValue
]
}
currentValue
.
push
(
value
)
...
...
packages/vite-plugin-uni/src/utils/define.ts
浏览文件 @
f985d4df
...
...
@@ -173,6 +173,7 @@ function resolveManifestFeature(
if
(
options
.
command
===
'
build
'
)
{
// TODO 需要预编译一遍?
features
.
wxs
=
false
features
.
longpress
=
false
}
if
(
manifest
.
h5
&&
...
...
scripts/i18n.js
浏览文件 @
f985d4df
...
...
@@ -50,7 +50,7 @@ import {
LOCALE_ZH_HANT,
} from '@dcloudio/uni-i18n'
import { useI18n } from './useI18n'
const i18n = useI18n()
const i18n =
/*#__PURE__*/
useI18n()
function normalizeMessages(
namespace: string,
messages: Record<string, string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录