Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
db26b9da
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,发现更多精彩内容 >>
提交
db26b9da
编写于
7月 27, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp): vue3
上级
a55489a8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
244 addition
and
153 deletion
+244
-153
packages/uni-cli-shared/lib/preprocess.js
packages/uni-cli-shared/lib/preprocess.js
+8
-1
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+208
-143
packages/vue-cli-plugin-uni/index.js
packages/vue-cli-plugin-uni/index.js
+1
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+14
-4
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+5
-3
packages/webpack-uni-mp-loader/lib/main-new.js
packages/webpack-uni-mp-loader/lib/main-new.js
+4
-0
src/platforms/app-plus/service/publish-handler.js
src/platforms/app-plus/service/publish-handler.js
+4
-1
未找到文件。
packages/uni-cli-shared/lib/preprocess.js
浏览文件 @
db26b9da
...
...
@@ -27,7 +27,14 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {
defaultContext
[
normalize
(
name
)]
=
false
})
defaultContext
.
VUE2
=
true
if
(
process
.
env
.
UNI_USING_VUE3
)
{
defaultContext
.
VUE3
=
true
}
else
{
defaultContext
.
VUE2
=
true
}
// nvue 只支持vue2
nvueContext
.
VUE2
=
true
nvueContext
.
VUE3
=
false
vueContext
[
normalize
(
name
)]
=
true
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
db26b9da
import
{
isSymbol
,
extend
,
isMap
,
isObject
,
toRawType
,
def
,
isArray
,
isString
,
isFunction
,
isPromise
,
toHandlerKey
,
remove
,
EMPTY_OBJ
,
camelize
,
capitalize
,
normalizeClass
,
normalizeStyle
,
isOn
,
NOOP
,
isGloballyWhitelisted
,
isIntegerKey
,
hasOwn
,
hasChanged
,
NO
,
invokeArrayFns
,
makeMap
,
isSet
,
toNumber
,
hyphenate
,
isReservedProp
,
EMPTY_ARR
,
toTypeString
}
from
'
@vue/shared
'
;
import
{
isSymbol
,
extend
,
isMap
,
isObject
,
toRawType
,
def
,
isArray
,
isString
,
isFunction
,
isPromise
,
toHandlerKey
,
remove
,
EMPTY_OBJ
,
camelize
,
capitalize
,
normalizeClass
,
normalizeStyle
,
isOn
,
NOOP
,
isGloballyWhitelisted
,
isIntegerKey
,
hasOwn
,
hasChanged
,
invokeArrayFns
as
invokeArrayFns$1
,
makeMap
,
isSet
,
NO
,
toNumber
,
hyphenate
,
isReservedProp
,
EMPTY_ARR
,
toTypeString
}
from
'
@vue/shared
'
;
export
{
camelize
}
from
'
@vue/shared
'
;
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
const
ON_ERROR
=
'
onError
'
;
const
targetMap
=
new
WeakMap
();
const
effectStack
=
[];
let
activeEffect
;
...
...
@@ -235,7 +244,14 @@ function createGetter(isReadonly = false, shallow = false) {
return
isReadonly
;
}
else
if
(
key
===
"
__v_raw
"
/* RAW */
&&
receiver
===
(
isReadonly
?
readonlyMap
:
reactiveMap
).
get
(
target
))
{
receiver
===
(
isReadonly
?
shallow
?
shallowReadonlyMap
:
readonlyMap
:
shallow
?
shallowReactiveMap
:
reactiveMap
).
get
(
target
))
{
return
target
;
}
const
targetIsArray
=
isArray
(
target
);
...
...
@@ -268,7 +284,7 @@ function createGetter(isReadonly = false, shallow = false) {
return
res
;
};
}
const
set
=
/*#__PURE__*/
createSetter
();
const
set
$1
=
/*#__PURE__*/
createSetter
();
const
shallowSet
=
/*#__PURE__*/
createSetter
(
true
);
function
createSetter
(
shallow
=
false
)
{
return
function
set
(
target
,
key
,
value
,
receiver
)
{
...
...
@@ -318,7 +334,7 @@ function ownKeys(target) {
}
const
mutableHandlers
=
{
get
,
set
,
set
:
set
$1
,
deleteProperty
,
has
,
ownKeys
...
...
@@ -364,7 +380,7 @@ function get$1(target, key, isReadonly = false, isShallow = false) {
}
!
isReadonly
&&
track
(
rawTarget
,
"
get
"
/* GET */
,
rawKey
);
const
{
has
}
=
getProto
(
rawTarget
);
const
wrap
=
is
Readonly
?
toReadonly
:
isShallow
?
toShallow
:
toReactive
;
const
wrap
=
is
Shallow
?
toShallow
:
isReadonly
?
toReadonly
:
toReactive
;
if
(
has
.
call
(
rawTarget
,
key
))
{
return
wrap
(
target
.
get
(
key
));
}
...
...
@@ -400,7 +416,7 @@ function add(value) {
}
return
this
;
}
function
set
$1
(
key
,
value
)
{
function
set
$1
$1
(
key
,
value
)
{
value
=
toRaw
(
value
);
const
target
=
toRaw
(
this
);
const
{
has
,
get
}
=
getProto
(
target
);
...
...
@@ -461,7 +477,7 @@ function createForEach(isReadonly, isShallow) {
const
observed
=
this
;
const
target
=
observed
[
"
__v_raw
"
/* RAW */
];
const
rawTarget
=
toRaw
(
target
);
const
wrap
=
is
Readonly
?
toReadonly
:
isShallow
?
toShallow
:
toReactive
;
const
wrap
=
is
Shallow
?
toShallow
:
isReadonly
?
toReadonly
:
toReactive
;
!
isReadonly
&&
track
(
rawTarget
,
"
iterate
"
/* ITERATE */
,
ITERATE_KEY
);
return
target
.
forEach
((
value
,
key
)
=>
{
// important: make sure the callback is
...
...
@@ -479,7 +495,7 @@ function createIterableMethod(method, isReadonly, isShallow) {
const
isPair
=
method
===
'
entries
'
||
(
method
===
Symbol
.
iterator
&&
targetIsMap
);
const
isKeyOnly
=
method
===
'
keys
'
&&
targetIsMap
;
const
innerIterator
=
target
[
method
](...
args
);
const
wrap
=
is
Readonly
?
toReadonly
:
isShallow
?
toShallow
:
toReactive
;
const
wrap
=
is
Shallow
?
toShallow
:
isReadonly
?
toReadonly
:
toReactive
;
!
isReadonly
&&
track
(
rawTarget
,
"
iterate
"
/* ITERATE */
,
isKeyOnly
?
MAP_KEY_ITERATE_KEY
:
ITERATE_KEY
);
// return a wrapped iterator which returns observed versions of the
...
...
@@ -520,7 +536,7 @@ const mutableInstrumentations = {
},
has
:
has$1
,
add
,
set
:
set
$1
,
set
:
set
$1
$1
,
delete
:
deleteEntry
,
clear
,
forEach
:
createForEach
(
false
,
false
)
...
...
@@ -534,7 +550,7 @@ const shallowInstrumentations = {
},
has
:
has$1
,
add
,
set
:
set
$1
,
set
:
set
$1
$1
,
delete
:
deleteEntry
,
clear
,
forEach
:
createForEach
(
false
,
true
)
...
...
@@ -555,15 +571,34 @@ const readonlyInstrumentations = {
clear
:
createReadonlyMethod
(
"
clear
"
/* CLEAR */
),
forEach
:
createForEach
(
true
,
false
)
};
const
shallowReadonlyInstrumentations
=
{
get
(
key
)
{
return
get
$1
(
this
,
key
,
true
,
true
);
},
get
size
()
{
return
size
(
this
,
true
);
},
has
(
key
)
{
return
has$1
.
call
(
this
,
key
,
true
);
},
add
:
createReadonlyMethod
(
"
add
"
/* ADD */
),
set
:
createReadonlyMethod
(
"
set
"
/* SET */
),
delete
:
createReadonlyMethod
(
"
delete
"
/* DELETE */
),
clear
:
createReadonlyMethod
(
"
clear
"
/* CLEAR */
),
forEach
:
createForEach
(
true
,
true
)
};
const
iteratorMethods
=
[
'
keys
'
,
'
values
'
,
'
entries
'
,
Symbol
.
iterator
];
iteratorMethods
.
forEach
(
method
=>
{
mutableInstrumentations
[
method
]
=
createIterableMethod
(
method
,
false
,
false
);
readonlyInstrumentations
[
method
]
=
createIterableMethod
(
method
,
true
,
false
);
shallowInstrumentations
[
method
]
=
createIterableMethod
(
method
,
false
,
true
);
shallowReadonlyInstrumentations
[
method
]
=
createIterableMethod
(
method
,
true
,
true
);
});
function
createInstrumentationGetter
(
isReadonly
,
shallow
)
{
const
instrumentations
=
shallow
?
shallowInstrumentations
?
isReadonly
?
shallowReadonlyInstrumentations
:
shallowInstrumentations
:
isReadonly
?
readonlyInstrumentations
:
mutableInstrumentations
;
...
...
@@ -591,6 +626,9 @@ const shallowCollectionHandlers = {
const
readonlyCollectionHandlers
=
{
get
:
createInstrumentationGetter
(
true
,
false
)
};
const
shallowReadonlyCollectionHandlers
=
{
get
:
createInstrumentationGetter
(
true
,
true
)
};
function
checkIdentityKeys
(
target
,
has
,
key
)
{
const
rawKey
=
toRaw
(
key
);
if
(
rawKey
!==
key
&&
has
.
call
(
target
,
rawKey
))
{
...
...
@@ -604,7 +642,9 @@ function checkIdentityKeys(target, has, key) {
}
const
reactiveMap
=
new
WeakMap
();
const
shallowReactiveMap
=
new
WeakMap
();
const
readonlyMap
=
new
WeakMap
();
const
shallowReadonlyMap
=
new
WeakMap
();
function
targetTypeMap
(
rawType
)
{
switch
(
rawType
)
{
case
'
Object
'
:
...
...
@@ -629,7 +669,7 @@ function reactive(target) {
if
(
target
&&
target
[
"
__v_isReadonly
"
/* IS_READONLY */
])
{
return
target
;
}
return
createReactiveObject
(
target
,
false
,
mutableHandlers
,
mutableCollectionHandlers
);
return
createReactiveObject
(
target
,
false
,
mutableHandlers
,
mutableCollectionHandlers
,
reactiveMap
);
}
/**
* Return a shallowly-reactive copy of the original object, where only the root
...
...
@@ -637,14 +677,14 @@ function reactive(target) {
* root level).
*/
function
shallowReactive
(
target
)
{
return
createReactiveObject
(
target
,
false
,
shallowReactiveHandlers
,
shallowCollectionHandlers
);
return
createReactiveObject
(
target
,
false
,
shallowReactiveHandlers
,
shallowCollectionHandlers
,
shallowReactiveMap
);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function
readonly
(
target
)
{
return
createReactiveObject
(
target
,
true
,
readonlyHandlers
,
readonlyCollectionHandlers
);
return
createReactiveObject
(
target
,
true
,
readonlyHandlers
,
readonlyCollectionHandlers
,
readonlyMap
);
}
/**
* Returns a reactive-copy of the original object, where only the root level
...
...
@@ -653,9 +693,9 @@ function readonly(target) {
* This is used for creating the props proxy object for stateful components.
*/
function
shallowReadonly
(
target
)
{
return
createReactiveObject
(
target
,
true
,
shallowReadonlyHandlers
,
readonlyCollectionHandlers
);
return
createReactiveObject
(
target
,
true
,
shallowReadonlyHandlers
,
shallowReadonlyCollectionHandlers
,
shallowReadonlyMap
);
}
function
createReactiveObject
(
target
,
isReadonly
,
baseHandlers
,
collectionHandlers
)
{
function
createReactiveObject
(
target
,
isReadonly
,
baseHandlers
,
collectionHandlers
,
proxyMap
)
{
if
(
!
isObject
(
target
))
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
warn
(
`value cannot be made reactive:
${
String
(
target
)}
`
);
...
...
@@ -669,7 +709,6 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
return
target
;
}
// target already has corresponding Proxy
const
proxyMap
=
isReadonly
?
readonlyMap
:
reactiveMap
;
const
existingProxy
=
proxyMap
.
get
(
target
);
if
(
existingProxy
)
{
return
existingProxy
;
...
...
@@ -825,12 +864,14 @@ class ComputedRefImpl {
this
[
"
__v_isReadonly
"
/* IS_READONLY */
]
=
isReadonly
;
}
get
value
()
{
if
(
this
.
_dirty
)
{
this
.
_value
=
this
.
effect
();
this
.
_dirty
=
false
;
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
const
self
=
toRaw
(
this
);
if
(
self
.
_dirty
)
{
self
.
_value
=
this
.
effect
();
self
.
_dirty
=
false
;
}
track
(
toRaw
(
this
)
,
"
get
"
/* GET */
,
'
value
'
);
return
this
.
_value
;
track
(
self
,
"
get
"
/* GET */
,
'
value
'
);
return
self
.
_value
;
}
set
value
(
newValue
)
{
this
.
_setter
(
newValue
);
...
...
@@ -1344,8 +1385,11 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
let
hasExtends
=
false
;
if
(
__VUE_OPTIONS_API__
&&
!
isFunction
(
comp
))
{
const
extendEmits
=
(
raw
)
=>
{
hasExtends
=
true
;
extend
(
normalized
,
normalizeEmitsOptions
(
raw
,
appContext
,
true
));
const
normalizedFromExtend
=
normalizeEmitsOptions
(
raw
,
appContext
,
true
);
if
(
normalizedFromExtend
)
{
hasExtends
=
true
;
extend
(
normalized
,
normalizedFromExtend
);
}
};
if
(
!
asMixin
&&
appContext
.
mixins
.
length
)
{
appContext
.
mixins
.
forEach
(
extendEmits
);
...
...
@@ -1400,10 +1444,11 @@ isSSR = false) {
const
attrs
=
{};
// def(attrs, InternalObjectKey, 1) // fixed by xxxxxx
def
(
attrs
,
'
__vInternal
'
,
1
);
instance
.
propsDefaults
=
Object
.
create
(
null
);
setFullProps
(
instance
,
rawProps
,
props
,
attrs
);
// validation
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
validateProps
(
props
,
instance
);
validateProps
(
rawProps
||
{},
props
,
instance
);
}
if
(
isStateful
)
{
// stateful
...
...
@@ -1460,9 +1505,15 @@ function resolvePropValue(options, props, key, value, instance) {
if
(
hasDefault
&&
value
===
undefined
)
{
const
defaultValue
=
opt
.
default
;
if
(
opt
.
type
!==
Function
&&
isFunction
(
defaultValue
))
{
setCurrentInstance
(
instance
);
value
=
defaultValue
(
props
);
setCurrentInstance
(
null
);
const
{
propsDefaults
}
=
instance
;
if
(
key
in
propsDefaults
)
{
value
=
propsDefaults
[
key
];
}
else
{
setCurrentInstance
(
instance
);
value
=
propsDefaults
[
key
]
=
defaultValue
(
props
);
setCurrentInstance
(
null
);
}
}
else
{
value
=
defaultValue
;
...
...
@@ -1582,14 +1633,14 @@ function getTypeIndex(type, expectedTypes) {
/**
* dev only
*/
function
validateProps
(
props
,
instance
)
{
const
r
aw
Values
=
toRaw
(
props
);
function
validateProps
(
rawProps
,
props
,
instance
)
{
const
r
esolved
Values
=
toRaw
(
props
);
const
options
=
instance
.
propsOptions
[
0
];
for
(
const
key
in
options
)
{
let
opt
=
options
[
key
];
if
(
opt
==
null
)
continue
;
validateProp
(
key
,
r
awValues
[
key
],
opt
,
!
hasOwn
(
rawValues
,
key
));
validateProp
(
key
,
r
esolvedValues
[
key
],
opt
,
!
hasOwn
(
rawProps
,
key
)
&&
!
hasOwn
(
rawProps
,
hyphenate
(
key
)
));
}
}
/**
...
...
@@ -1835,7 +1886,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
if
(
cleanup
)
{
cleanup
();
}
return
callWithErrorHandling
(
source
,
instance
,
3
/* WATCH_CALLBACK */
,
[
onInvalidate
]);
return
callWith
Async
ErrorHandling
(
source
,
instance
,
3
/* WATCH_CALLBACK */
,
[
onInvalidate
]);
};
}
}
...
...
@@ -1848,7 +1899,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
getter
=
()
=>
traverse
(
baseGetter
());
}
let
cleanup
;
cons
t
onInvalidate
=
(
fn
)
=>
{
le
t
onInvalidate
=
(
fn
)
=>
{
cleanup
=
runner
.
options
.
onStop
=
()
=>
{
callWithErrorHandling
(
fn
,
instance
,
4
/* WATCH_CLEANUP */
);
};
...
...
@@ -2062,10 +2113,7 @@ function createAppContext() {
}
let
uid$1
=
0
;
// fixed by xxxxxx
function
createAppAPI
(
// render: RootRenderFunction,
// hydrate?: RootHydrateFunction
)
{
function
createAppAPI
()
{
return
function
createApp
(
rootComponent
,
rootProps
=
null
)
{
if
(
rootProps
!=
null
&&
!
isObject
(
rootProps
))
{
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
warn
(
`root props passed to app.mount() must be an object.`
);
...
...
@@ -2112,7 +2160,7 @@ function createAppAPI(
if
(
__VUE_OPTIONS_API__
)
{
if
(
!
context
.
mixins
.
includes
(
mixin
))
{
context
.
mixins
.
push
(
mixin
);
//
global
mixin with props/emits de-optimizes props/emits
//
window
mixin with props/emits de-optimizes props/emits
// normalization caching.
if
(
mixin
.
props
||
mixin
.
emits
)
{
context
.
deopt
=
true
;
...
...
@@ -2192,17 +2240,12 @@ function resolveDirective(name) {
return
resolveAsset
(
DIRECTIVES
,
name
);
}
// implementation
function
resolveAsset
(
type
,
name
,
warnMissing
=
true
)
{
function
resolveAsset
(
type
,
name
,
warnMissing
=
true
,
maybeSelfReference
=
false
)
{
const
instance
=
currentInstance
;
if
(
instance
)
{
const
Component
=
instance
.
type
;
// self name has highest priority
//
explicit
self name has highest priority
if
(
type
===
COMPONENTS
)
{
// special self referencing call generated by compiler
// inferred from SFC filename
if
(
name
===
`_self`
)
{
return
Component
;
}
const
selfName
=
getComponentName
(
Component
);
if
(
selfName
&&
(
selfName
===
name
||
...
...
@@ -2215,8 +2258,12 @@ function resolveAsset(type, name, warnMissing = true) {
// local registration
// check instance[type] first for components with mixin or extends.
resolve
(
instance
[
type
]
||
Component
[
type
],
name
)
||
//
global
registration
//
window
registration
resolve
(
instance
.
appContext
[
type
],
name
);
if
(
!
res
&&
maybeSelfReference
)
{
// fallback to implicit self-reference
return
Component
;
}
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
warnMissing
&&
!
res
)
{
warn
(
`Failed to resolve
${
type
.
slice
(
0
,
-
1
)}
:
${
name
}
`
);
}
...
...
@@ -2584,8 +2631,8 @@ function createDuplicateChecker() {
}
};
}
let
isInBeforeCreate
=
fals
e
;
function
applyOptions
(
instance
,
options
,
deferredData
=
[],
deferredWatch
=
[],
deferredProvide
=
[],
asMixin
=
false
)
{
let
shouldCacheAccess
=
tru
e
;
function
applyOptions
$1
(
instance
,
options
,
deferredData
=
[],
deferredWatch
=
[],
deferredProvide
=
[],
asMixin
=
false
)
{
const
{
// composition
mixins
,
extends
:
extendsOptions
,
...
...
@@ -2605,15 +2652,15 @@ function applyOptions(instance, options, deferredData = [], deferredWatch = [],
}
// applyOptions is called non-as-mixin once per instance
if
(
!
asMixin
)
{
isInBeforeCreate
=
tru
e
;
shouldCacheAccess
=
fals
e
;
callSyncHook
(
'
beforeCreate
'
,
"
bc
"
/* BEFORE_CREATE */
,
options
,
instance
,
globalMixins
);
isInBeforeCreate
=
fals
e
;
//
global
mixins are applied first
shouldCacheAccess
=
tru
e
;
//
window
mixins are applied first
applyMixins
(
instance
,
globalMixins
,
deferredData
,
deferredWatch
,
deferredProvide
);
}
// extending a base component...
if
(
extendsOptions
)
{
applyOptions
(
instance
,
extendsOptions
,
deferredData
,
deferredWatch
,
deferredProvide
,
true
);
applyOptions
$1
(
instance
,
extendsOptions
,
deferredData
,
deferredWatch
,
deferredProvide
,
true
);
}
// local mixins
if
(
mixins
)
{
...
...
@@ -2858,43 +2905,29 @@ function applyOptions(instance, options, deferredData = [], deferredWatch = [],
}
}
function
callSyncHook
(
name
,
type
,
options
,
instance
,
globalMixins
)
{
callHookFromMixins
(
name
,
type
,
globalMixins
,
instance
);
for
(
let
i
=
0
;
i
<
globalMixins
.
length
;
i
++
)
{
callHookWithMixinAndExtends
(
name
,
type
,
globalMixins
[
i
],
instance
);
}
callHookWithMixinAndExtends
(
name
,
type
,
options
,
instance
);
}
function
callHookWithMixinAndExtends
(
name
,
type
,
options
,
instance
)
{
const
{
extends
:
base
,
mixins
}
=
options
;
const
selfHook
=
options
[
name
];
if
(
base
)
{
callHook
From
Extends
(
name
,
type
,
base
,
instance
);
callHook
WithMixinAnd
Extends
(
name
,
type
,
base
,
instance
);
}
if
(
mixins
)
{
callHookFromMixins
(
name
,
type
,
mixins
,
instance
);
for
(
let
i
=
0
;
i
<
mixins
.
length
;
i
++
)
{
callHookWithMixinAndExtends
(
name
,
type
,
mixins
[
i
],
instance
);
}
}
const
selfHook
=
options
[
name
];
if
(
selfHook
)
{
callWithAsyncErrorHandling
(
selfHook
.
bind
(
instance
.
proxy
),
instance
,
type
);
}
}
function
callHookFromExtends
(
name
,
type
,
base
,
instance
)
{
if
(
base
.
extends
)
{
callHookFromExtends
(
name
,
type
,
base
.
extends
,
instance
);
}
const
baseHook
=
base
[
name
];
if
(
baseHook
)
{
callWithAsyncErrorHandling
(
baseHook
.
bind
(
instance
.
proxy
),
instance
,
type
);
}
}
function
callHookFromMixins
(
name
,
type
,
mixins
,
instance
)
{
for
(
let
i
=
0
;
i
<
mixins
.
length
;
i
++
)
{
const
chainedMixins
=
mixins
[
i
].
mixins
;
if
(
chainedMixins
)
{
callHookFromMixins
(
name
,
type
,
chainedMixins
,
instance
);
}
const
fn
=
mixins
[
i
][
name
];
if
(
fn
)
{
callWithAsyncErrorHandling
(
fn
.
bind
(
instance
.
proxy
),
instance
,
type
);
}
}
}
function
applyMixins
(
instance
,
mixins
,
deferredData
,
deferredWatch
,
deferredProvide
)
{
for
(
let
i
=
0
;
i
<
mixins
.
length
;
i
++
)
{
applyOptions
(
instance
,
mixins
[
i
],
deferredData
,
deferredWatch
,
deferredProvide
,
true
);
applyOptions
$1
(
instance
,
mixins
[
i
],
deferredData
,
deferredWatch
,
deferredProvide
,
true
);
}
}
function
resolveData
(
instance
,
dataFn
,
publicThis
)
{
...
...
@@ -2902,7 +2935,9 @@ function resolveData(instance, dataFn, publicThis) {
warn
(
`The data option must be a function. `
+
`Plain object usage is no longer supported.`
);
}
shouldCacheAccess
=
false
;
const
data
=
dataFn
.
call
(
publicThis
,
publicThis
);
shouldCacheAccess
=
true
;
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
isPromise
(
data
))
{
warn
(
`data() returned a Promise - note data() cannot be async; If you `
+
`intend to perform data fetching before component renders, use `
+
...
...
@@ -3075,7 +3110,7 @@ const PublicInstanceProxyHandlers = {
accessCache
[
key
]
=
3
/* CONTEXT */
;
return
ctx
[
key
];
}
else
if
(
!
__VUE_OPTIONS_API__
||
!
isInBeforeCreate
)
{
else
if
(
!
__VUE_OPTIONS_API__
||
shouldCacheAccess
)
{
accessCache
[
key
]
=
4
/* OTHER */
;
}
}
...
...
@@ -3101,7 +3136,7 @@ const PublicInstanceProxyHandlers = {
return
ctx
[
key
];
}
else
if
(
//
global
properties
//
window
properties
((
globalProperties
=
appContext
.
config
.
globalProperties
),
hasOwn
(
globalProperties
,
key
)))
{
return
globalProperties
[
key
];
...
...
@@ -3213,7 +3248,7 @@ function createRenderContext(instance) {
set
:
NOOP
});
});
// expose
global
properties
// expose
window
properties
const
{
globalProperties
}
=
instance
.
appContext
.
config
;
Object
.
keys
(
globalProperties
).
forEach
(
key
=>
{
Object
.
defineProperty
(
target
,
key
,
{
...
...
@@ -3290,6 +3325,8 @@ function createComponentInstance(vnode, parent, suspense) {
// emit
emit
:
null
,
emitted
:
null
,
// props default value
propsDefaults
:
EMPTY_OBJ
,
// state
ctx
:
EMPTY_OBJ
,
data
:
EMPTY_OBJ
,
...
...
@@ -3401,8 +3438,12 @@ function setupStatefulComponent(instance, isSSR) {
if
(
isPromise
(
setupResult
))
{
if
(
isSSR
)
{
// return the promise so server-renderer can wait on it
return
setupResult
.
then
((
resolvedResult
)
=>
{
handleSetupResult
(
instance
,
resolvedResult
);
return
setupResult
.
then
((
resolvedResult
)
=>
{
handleSetupResult
(
instance
,
resolvedResult
,
isSSR
);
})
.
catch
(
e
=>
{
handleError
(
e
,
instance
,
0
/* SETUP_FUNCTION */
);
});
}
else
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
...
...
@@ -3411,11 +3452,11 @@ function setupStatefulComponent(instance, isSSR) {
}
}
else
{
handleSetupResult
(
instance
,
setupResult
);
handleSetupResult
(
instance
,
setupResult
,
isSSR
);
}
}
else
{
finishComponentSetup
(
instance
);
finishComponentSetup
(
instance
,
isSSR
);
}
}
function
handleSetupResult
(
instance
,
setupResult
,
isSSR
)
{
...
...
@@ -3443,7 +3484,7 @@ function handleSetupResult(instance, setupResult, isSSR) {
else
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
setupResult
!==
undefined
)
{
warn
(
`setup() should return an object. Received:
${
setupResult
===
null
?
'
null
'
:
typeof
setupResult
}
`
);
}
finishComponentSetup
(
instance
);
finishComponentSetup
(
instance
,
isSSR
);
}
function
finishComponentSetup
(
instance
,
isSSR
)
{
const
Component
=
instance
.
type
;
...
...
@@ -3461,12 +3502,13 @@ function finishComponentSetup(instance, isSSR) {
if
(
__VUE_OPTIONS_API__
)
{
currentInstance
=
instance
;
pauseTracking
();
applyOptions
(
instance
,
Component
);
applyOptions
$1
(
instance
,
Component
);
resetTracking
();
currentInstance
=
null
;
}
// warn missing template/render
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
!
Component
.
render
&&
instance
.
render
===
NOOP
)
{
// the runtime compilation of template in SSR is done by server-render
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
)
&&
!
Component
.
render
&&
instance
.
render
===
NOOP
&&
!
isSSR
)
{
/* istanbul ignore if */
if
(
Component
.
template
)
{
warn
(
`Component provided template option but `
+
...
...
@@ -3504,9 +3546,6 @@ function createSetupContext(instance) {
// We use getters in dev in case libs like test-utils overwrite instance
// properties (overwrites should not be done in prod)
return
Object
.
freeze
({
get
props
()
{
return
instance
.
props
;
},
get
attrs
()
{
return
new
Proxy
(
instance
.
attrs
,
attrHandlers
);
},
...
...
@@ -3596,7 +3635,7 @@ function defineEmit() {
}
// Core API ------------------------------------------------------------------
const
version
=
"
3.0.
7
"
;
const
version
=
"
3.0.
9
"
;
// import deepCopy from './deepCopy'
/**
...
...
@@ -3921,8 +3960,8 @@ const prodEffectOptions = {
function
createDevEffectOptions
(
instance
)
{
return
{
scheduler
:
queueJob
,
onTrack
:
instance
.
rtc
?
e
=>
invokeArrayFns
(
instance
.
rtc
,
e
)
:
void
0
,
onTrigger
:
instance
.
rtg
?
e
=>
invokeArrayFns
(
instance
.
rtg
,
e
)
:
void
0
onTrack
:
instance
.
rtc
?
e
=>
invokeArrayFns
$1
(
instance
.
rtc
,
e
)
:
void
0
,
onTrigger
:
instance
.
rtg
?
e
=>
invokeArrayFns
$1
(
instance
.
rtg
,
e
)
:
void
0
};
}
function
setupRenderEffect
(
instance
)
{
...
...
@@ -3938,7 +3977,7 @@ function setupRenderEffect(instance) {
const
{
bu
,
u
}
=
instance
;
// beforeUpdate hook
if
(
bu
)
{
invokeArrayFns
(
bu
);
invokeArrayFns
$1
(
bu
);
}
patch
(
instance
);
// updated hook
...
...
@@ -3952,7 +3991,7 @@ function unmountComponent(instance) {
const
{
bum
,
effects
,
update
,
um
}
=
instance
;
// beforeUnmount hook
if
(
bum
)
{
invokeArrayFns
(
bum
);
invokeArrayFns
$1
(
bum
);
}
if
(
effects
)
{
for
(
let
i
=
0
;
i
<
effects
.
length
;
i
++
)
{
...
...
@@ -4009,7 +4048,15 @@ function createVueApp(rootComponent, rootProps = null) {
return
app
;
}
function
applyOptions$1
(
options
,
instance
,
publicThis
)
{
function
withModifiers
()
{
}
function
createVNode$1
()
{
}
function
applyOptions
(
options
,
instance
,
publicThis
)
{
const
mpType
=
options
.
mpType
||
publicThis
.
$mpType
;
if
(
!
mpType
)
{
// 仅 App,Page 类型支持 on 生命周期
return
;
}
Object
.
keys
(
options
).
forEach
((
name
)
=>
{
if
(
name
.
indexOf
(
'
on
'
)
===
0
)
{
const
hook
=
options
[
name
];
...
...
@@ -4020,7 +4067,7 @@ function applyOptions$1(options, instance, publicThis) {
});
}
function
set
$2
(
target
,
key
,
val
)
{
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
hasHook
(
name
)
{
...
...
@@ -4032,24 +4079,66 @@ function hasHook(name) {
}
function
callHook
(
name
,
args
)
{
const
hooks
=
this
.
$
[
name
];
let
ret
;
if
(
hooks
)
{
for
(
let
i
=
0
;
i
<
hooks
.
length
;
i
++
)
{
ret
=
hooks
[
i
](
args
);
}
}
return
ret
;
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
function
errorHandler
(
err
,
instance
,
info
)
{
if
(
!
instance
)
{
throw
err
;
}
const
app
Instance
=
instance
.
$
.
appContext
.
$appInstance
;
if
(
!
app
Instance
)
{
const
app
=
getApp
()
;
if
(
!
app
||
!
app
.
$vm
)
{
throw
err
;
}
appInstance
.
$callHook
(
'
onError
'
,
err
,
info
);
{
app
.
$vm
.
$callHook
(
ON_ERROR
,
err
,
info
);
}
}
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
)
.
split
(
''
)
.
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
);
})
.
join
(
''
));
}
function
getCurrentUserInfo
()
{
const
token
=
uni
.
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[],
tokenExpired
:
0
,
};
}
let
userInfo
;
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
);
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
return
userInfo
;
}
function
uniIdMixin
(
globalProperties
)
{
globalProperties
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
;
};
globalProperties
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
;
};
globalProperties
.
uniIDTokenValid
=
function
()
{
const
{
tokenExpired
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
();
};
}
function
initApp
(
app
)
{
...
...
@@ -4058,11 +4147,15 @@ function initApp(app) {
appConfig
.
errorHandler
=
errorHandler
;
}
const
globalProperties
=
appConfig
.
globalProperties
;
globalProperties
.
$hasHook
=
hasHook
;
globalProperties
.
$callHook
=
callHook
;
uniIdMixin
(
globalProperties
);
{
// 小程序,待重构,不再挂靠全局
globalProperties
.
$hasHook
=
hasHook
;
globalProperties
.
$callHook
=
callHook
;
}
if
(
__VUE_OPTIONS_API__
)
{
globalProperties
.
$set
=
set
$2
;
globalProperties
.
$applyOptions
=
applyOptions
$1
;
globalProperties
.
$set
=
set
;
globalProperties
.
$applyOptions
=
applyOptions
;
}
}
...
...
@@ -4089,38 +4182,10 @@ var plugin = {
},
};
// @ts-ignore
const
createHook$1
=
(
lifecycle
)
=>
(
hook
,
target
)
=>
// post-create lifecycle registrations are noops during SSR
!
isInSSRComponentSetup
&&
injectHook
(
lifecycle
,
hook
,
target
);
const
onShow
=
/*#__PURE__*/
createHook$1
(
"
onShow
"
/* ON_SHOW */
);
const
onHide
=
/*#__PURE__*/
createHook$1
(
"
onHide
"
/* ON_HIDE */
);
const
onLaunch
=
/*#__PURE__*/
createHook$1
(
"
onLaunch
"
/* ON_LAUCH */
);
const
onError
=
/*#__PURE__*/
createHook$1
(
"
onError
"
/* ON_ERROR */
);
const
onThemeChange
=
/*#__PURE__*/
createHook$1
(
"
onThemeChange
"
/* ON_THEME_CHANGE */
);
const
onPageNotFound
=
/*#__PURE__*/
createHook$1
(
"
onPageNotFound
"
/* ON_PAGE_NOT_FOUND */
);
const
onUnhandledRejection
=
/*#__PURE__*/
createHook$1
(
"
onUnhandledRejection
"
/* ON_UNHANDLE_REJECTION */
);
const
onLoad
=
/*#__PURE__*/
createHook$1
(
"
onLoad
"
/* ON_LOAD */
);
const
onReady
=
/*#__PURE__*/
createHook$1
(
"
onReady
"
/* ON_READY */
);
const
onUnload
=
/*#__PURE__*/
createHook$1
(
"
onUnload
"
/* ON_UNLOAD */
);
const
onResize
=
/*#__PURE__*/
createHook$1
(
"
onResize
"
/* ON_RESIZE */
);
const
onBackPress
=
/*#__PURE__*/
createHook$1
(
"
onBackPress
"
/* ON_BACK_PRESS */
);
const
onPageScroll
=
/*#__PURE__*/
createHook$1
(
"
onPageScroll
"
/* ON_PAGE_SCROLL */
);
const
onTabItemTap
=
/*#__PURE__*/
createHook$1
(
"
onTabItemTap
"
/* ON_TAB_ITEM_TAP */
);
const
onReachBottom
=
/*#__PURE__*/
createHook$1
(
"
onReachBottom
"
/* ON_REACH_BOTTOM */
);
const
onPullDownRefresh
=
/*#__PURE__*/
createHook$1
(
"
onPullDownRefresh
"
/* ON_PULL_DOWN_REFRESH */
);
const
onShareTimeline
=
/*#__PURE__*/
createHook$1
(
"
onShareTimeline
"
/* ON_SHARE_TIMELINE */
);
const
onAddToFavorites
=
/*#__PURE__*/
createHook$1
(
"
onAddToFavorites
"
/* ON_ADD_TO_FAVORITES */
);
const
onShareAppMessage
=
/*#__PURE__*/
createHook$1
(
"
onShareAppMessage
"
/* ON_SHARE_APP_MESSAGE */
);
const
onNavigationBarButtonTap
=
/*#__PURE__*/
createHook$1
(
"
onNavigationBarButtonTap
"
/* ON_NAVIGATION_BAR_BUTTON_TAP */
);
const
onNavigationBarSearchInputChanged
=
/*#__PURE__*/
createHook$1
(
"
onNavigationBarSearchInputChanged
"
/* ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED */
);
const
onNavigationBarSearchInputClicked
=
/*#__PURE__*/
createHook$1
(
"
onNavigationBarSearchInputClicked
"
/* ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED */
);
const
onNavigationBarSearchInputConfirmed
=
/*#__PURE__*/
createHook$1
(
"
onNavigationBarSearchInputConfirmed
"
/* ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED */
);
const
onNavigationBarSearchInputFocusChanged
=
/*#__PURE__*/
createHook$1
(
"
onNavigationBarSearchInputFocusChanged
"
/* ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED */
);
function
createApp
(
rootComponent
,
rootProps
=
null
)
{
rootComponent
&&
(
rootComponent
.
mpType
=
'
app
'
);
return
createVueApp
(
rootComponent
,
rootProps
).
use
(
plugin
);
}
}
const
createSSRApp
=
createApp
;
export
{
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed$1
as
computed
,
createApp
,
create
Hook$1
as
createHook
,
createVueApp
,
customRef
,
defineComponent
,
defineEmit
,
defineProps
,
getCurrentInstance
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
nextTick
,
onActivated
,
onAddToFavorites
,
onBackPress
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onError
,
onErrorCaptured
,
onHide
,
onLaunch
,
onLoad
,
onMounted
,
onNavigationBarButtonTap
,
onNavigationBarSearchInputChanged
,
onNavigationBarSearchInputClicked
,
onNavigationBarSearchInputConfirmed
,
onNavigationBarSearchInputFocusChanged
,
onPageNotFound
,
onPageScroll
,
onPullDownRefresh
,
onReachBottom
,
onReady
,
onRenderTracked
,
onRenderTriggered
,
onResize
,
onShareAppMessage
,
onShareTimeline
,
onShow
,
onTabItemTap
,
onThemeChange
,
onUnhandledRejection
,
onUnload
,
onUnmounted
,
onUpdated
,
provide
,
reactive
,
readonly
,
ref
,
resolveDirective
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
version
,
warn
,
watch
,
watchEffect
,
withDirective
s
};
export
{
callWithAsyncErrorHandling
,
callWithErrorHandling
,
computed$1
as
computed
,
createApp
,
create
SSRApp
,
createVNode$1
as
createVNode
,
createVueApp
,
customRef
,
defineComponent
,
defineEmit
,
defineProps
,
getCurrentInstance
,
inject
,
injectHook
,
isInSSRComponentSetup
,
isProxy
,
isReactive
,
isReadonly
,
isRef
,
logError
,
markRaw
,
nextTick
,
onActivated
,
onBeforeMount
,
onBeforeUnmount
,
onBeforeUpdate
,
onDeactivated
,
onErrorCaptured
,
onMounted
,
onRenderTracked
,
onRenderTriggered
,
onUnmounted
,
onUpdated
,
provide
,
reactive
,
readonly
,
ref
,
resolveDirective
,
shallowReactive
,
shallowReadonly
,
shallowRef
,
toRaw
,
toRef
,
toRefs
,
triggerRef
,
unref
,
version
,
warn
,
watch
,
watchEffect
,
withDirectives
,
withModifier
s
};
packages/vue-cli-plugin-uni/index.js
浏览文件 @
db26b9da
...
...
@@ -87,5 +87,5 @@ const args = require('minimist')(process.argv.slice(2))
module
.
exports
.
defaultModes
=
{
'
uni-serve
'
:
args
.
mode
||
'
development
'
,
'
uni-build
'
:
args
.
mode
||
process
.
env
.
NODE_ENV
'
uni-build
'
:
args
.
mode
||
process
.
env
.
NODE_ENV
}
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
db26b9da
...
...
@@ -16,11 +16,20 @@ if (process.env.UNI_INPUT_DIR && process.env.UNI_INPUT_DIR.indexOf('./') === 0)
process
.
env
.
UNI_INPUT_DIR
=
path
.
resolve
(
process
.
cwd
(),
process
.
env
.
UNI_INPUT_DIR
)
}
process
.
env
.
UNI_INPUT_DIR
=
process
.
env
.
UNI_INPUT_DIR
||
path
.
resolve
(
process
.
cwd
(),
defaultInputDir
)
const
manifestJsonObj
=
require
(
'
@dcloudio/uni-cli-shared/lib/manifest
'
).
getManifestJson
()
// 小程序 vue3 标记
if
(
process
.
env
.
UNI_PLATFORM
.
indexOf
(
'
mp-
'
)
===
0
)
{
if
(
manifestJsonObj
.
vueVersion
===
'
3
'
||
manifestJsonObj
.
vueVersion
===
3
)
{
process
.
env
.
UNI_USING_VUE3
=
true
process
.
env
.
UNI_USING_VUE3_OPTIONS_API
=
true
}
}
// 初始化全局插件对象
global
.
uniPlugin
=
require
(
'
@dcloudio/uni-cli-shared/lib/plugin
'
).
init
()
global
.
uniPlugin
=
require
(
'
@dcloudio/uni-cli-shared/lib/plugin
'
).
init
()
const
manifestJsonObj
=
require
(
'
@dcloudio/uni-cli-shared/lib/manifest
'
).
getManifestJson
()
const
platformOptions
=
manifestJsonObj
[
process
.
env
.
UNI_SUB_PLATFORM
||
process
.
env
.
UNI_PLATFORM
]
||
{}
// 插件校验环境
global
.
uniPlugin
.
validate
.
forEach
(
validate
=>
{
...
...
@@ -263,7 +272,8 @@ if (platformOptions.usingComponents === true) {
// 兼容历史配置 betterScopedSlots
const
modes
=
[
'
legacy
'
,
'
auto
'
,
'
augmented
'
]
const
scopedSlotsCompiler
=
!
platformOptions
.
scopedSlotsCompiler
&&
platformOptions
.
betterScopedSlots
?
modes
[
2
]
:
platformOptions
.
scopedSlotsCompiler
const
scopedSlotsCompiler
=
!
platformOptions
.
scopedSlotsCompiler
&&
platformOptions
.
betterScopedSlots
?
modes
[
2
]
:
platformOptions
.
scopedSlotsCompiler
process
.
env
.
SCOPED_SLOTS_COMPILER
=
modes
.
includes
(
scopedSlotsCompiler
)
?
scopedSlotsCompiler
:
modes
[
1
]
// 快手小程序抽象组件编译报错,如未指定 legacy 固定为 augmented 模式
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-kuaishou
'
&&
process
.
env
.
SCOPED_SLOTS_COMPILER
!==
modes
[
0
])
{
...
...
@@ -465,4 +475,4 @@ runByHBuilderX && console.log('正在编译中...')
module
.
exports
=
{
manifestPlatformOptions
:
platformOptions
}
}
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
db26b9da
...
...
@@ -128,7 +128,8 @@ class PreprocessAssetsPlugin {
function
initSubpackageConfig
(
webpackConfig
,
vueOptions
)
{
if
(
process
.
env
.
UNI_OUTPUT_DEFAULT_DIR
===
process
.
env
.
UNI_OUTPUT_DIR
)
{
// 未自定义output
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
))
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
))
}
vueOptions
.
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
webpackConfig
.
output
.
path
(
process
.
env
.
UNI_OUTPUT_DIR
)
...
...
@@ -175,7 +176,8 @@ module.exports = {
const
UNI_MP_PLUGIN_MAIN
=
process
.
env
.
UNI_MP_PLUGIN_MAIN
if
(
UNI_MP_PLUGIN_MAIN
)
{
process
.
UNI_ENTRY
[
UNI_MP_PLUGIN_MAIN
.
split
(
'
.
'
)[
0
]]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
UNI_MP_PLUGIN_MAIN
)
process
.
UNI_ENTRY
[
UNI_MP_PLUGIN_MAIN
.
split
(
'
.
'
)[
0
]]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
UNI_MP_PLUGIN_MAIN
)
}
}
...
...
@@ -295,4 +297,4 @@ module.exports = {
webpackConfig
.
plugins
.
delete
(
'
preload
'
)
webpackConfig
.
plugins
.
delete
(
'
prefetch
'
)
}
}
}
packages/webpack-uni-mp-loader/lib/main-new.js
浏览文件 @
db26b9da
...
...
@@ -77,6 +77,10 @@ createPage(Page)
type
:
jsPreprocessOptions
.
type
})
if
(
process
.
env
.
UNI_USING_VUE3
)
{
content
=
content
+
'
;createApp().app.mount(
\'
#app
\'
);
'
}
const
resourcePath
=
'
app
'
const
{
...
...
src/platforms/app-plus/service/publish-handler.js
浏览文件 @
db26b9da
export
function
publishHandler
(
eventType
,
args
,
pageIds
)
{
export
function
publishHandler
(
eventType
,
args
,
pageIds
)
{
args
=
JSON
.
stringify
(
args
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`UNIAPP[publishHandler]:[
${
+
new
Date
()}
]`
,
eventType
,
args
,
pageIds
)
...
...
@@ -8,6 +8,9 @@ export function publishHandler (eventType, args, pageIds) {
}
const
evalJSCode
=
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("
${
eventType
}
",
${
args
}
,__PAGE_ID__)`
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`UNIAPP[publishHandler]:[
${
+
new
Date
()}
]`
,
'
length
'
,
evalJSCode
.
length
)
}
pageIds
.
forEach
(
id
=>
{
const
webview
=
plus
.
webview
.
getWebviewById
(
String
(
id
))
webview
&&
webview
.
evalJS
(
evalJSCode
.
replace
(
'
__PAGE_ID__
'
,
id
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录