Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
2d6bcba5
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d6bcba5
编写于
1月 13, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): add --subpackage
上级
e932de17
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
247 addition
and
189 deletion
+247
-189
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+19
-12
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+43
-6
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+29
-15
packages/uni-mp-kuaishou/dist/index.js
packages/uni-mp-kuaishou/dist/index.js
+19
-12
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+19
-12
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+19
-12
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+19
-12
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+19
-12
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+43
-70
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
...es/webpack-uni-mp-loader/lib/plugin/generate-component.js
+2
-10
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
+2
-4
src/platforms/mp-weixin/runtime/index.js
src/platforms/mp-weixin/runtime/index.js
+12
-10
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -625,16 +625,19 @@ function initHook (name, options) {
...
@@ -625,16 +625,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
class
EventChannel
{
class
EventChannel
{
constructor
(
id
,
events
)
{
constructor
(
id
,
events
)
{
...
@@ -1213,7 +1216,7 @@ function handleEvent (event) {
...
@@ -1213,7 +1216,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1221,9 +1224,13 @@ function handleEvent (event) {
...
@@ -1221,9 +1224,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/uni-mp-alipay/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -1857,7 +1857,7 @@ function handleEvent (event) {
...
@@ -1857,7 +1857,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1865,9 +1865,13 @@ function handleEvent (event) {
...
@@ -1865,9 +1865,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
@@ -2152,6 +2156,36 @@ function handleRef (ref) {
...
@@ -2152,6 +2156,36 @@ function handleRef (ref) {
if
(
!
ref
)
{
if
(
!
ref
)
{
return
return
}
}
if
(
ref
.
props
[
'
data-com-type
'
]
===
'
wx
'
)
{
const
eventProps
=
{};
let
refProps
=
ref
.
props
;
// 初始化支付宝小程序组件事件
Object
.
keys
(
refProps
).
forEach
(
key
=>
{
const
handler
=
refProps
[
key
];
const
res
=
key
.
match
(
/^on
([
A-Z
])(\S
*
)
/
);
if
(
res
&&
typeof
handler
===
'
function
'
&&
handler
.
name
===
'
bound handleEvent
'
)
{
const
event
=
res
&&
(
res
[
1
].
toLowerCase
()
+
res
[
2
]);
refProps
[
key
]
=
eventProps
[
key
]
=
function
()
{
const
props
=
Object
.
assign
({},
refProps
);
props
[
key
]
=
handler
;
// 由于支付宝事件可能包含多个参数,不使用微信小程序事件格式
delete
props
[
'
data-com-type
'
];
triggerEvent
.
bind
({
props
})(
event
,
{
__args__
:
[...
arguments
]
});
};
}
});
// 处理 props 重写
Object
.
defineProperty
(
ref
,
'
props
'
,
{
get
()
{
return
refProps
},
set
(
value
)
{
refProps
=
Object
.
assign
(
value
,
eventProps
);
}
});
}
const
refName
=
ref
.
props
[
'
data-ref
'
];
const
refName
=
ref
.
props
[
'
data-ref
'
];
const
refInForName
=
ref
.
props
[
'
data-ref-in-for
'
];
const
refInForName
=
ref
.
props
[
'
data-ref-in-for
'
];
if
(
refName
)
{
if
(
refName
)
{
...
@@ -2162,18 +2196,20 @@ function handleRef (ref) {
...
@@ -2162,18 +2196,20 @@ function handleRef (ref) {
}
}
function
triggerEvent
(
type
,
detail
,
options
)
{
function
triggerEvent
(
type
,
detail
,
options
)
{
const
handler
=
this
.
props
[
customize
(
'
on-
'
+
type
)];
const
handler
=
this
.
props
&&
this
.
props
[
customize
(
'
on-
'
+
type
)];
if
(
!
handler
)
{
if
(
!
handler
)
{
return
return
}
}
const
eventOpts
=
this
.
props
[
'
data-event-opts
'
];
const
eventOpts
=
this
.
props
[
'
data-event-opts
'
];
const
eventParams
=
this
.
props
[
'
data-event-params
'
];
const
eventParams
=
this
.
props
[
'
data-event-params
'
];
const
comType
=
this
.
props
[
'
data-com-type
'
];
const
target
=
{
const
target
=
{
dataset
:
{
dataset
:
{
eventOpts
,
eventOpts
,
eventParams
eventParams
,
comType
}
}
};
};
...
@@ -2405,7 +2441,8 @@ function parsePage (vuePageOptions) {
...
@@ -2405,7 +2441,8 @@ function parsePage (vuePageOptions) {
},
},
__r
:
handleRef
,
__r
:
handleRef
,
__e
:
handleEvent
,
__e
:
handleEvent
,
__l
:
handleLink$1
__l
:
handleLink$1
,
triggerEvent
};
};
initHooks
(
pageOptions
,
hooks$1
,
vuePageOptions
);
initHooks
(
pageOptions
,
hooks$1
,
vuePageOptions
);
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -976,16 +976,19 @@ function initHook (name, options) {
...
@@ -976,16 +976,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1522,7 +1525,7 @@ function handleEvent (event) {
...
@@ -1522,7 +1525,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1530,9 +1533,13 @@ function handleEvent (event) {
...
@@ -1530,9 +1533,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
@@ -1891,10 +1898,17 @@ function parseComponent (vueOptions) {
...
@@ -1891,10 +1898,17 @@ function parseComponent (vueOptions) {
// 关于百度小程序生命周期的说明(组件作为页面时):
// 关于百度小程序生命周期的说明(组件作为页面时):
// lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady
// lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady
// 这里在强制将onShow挪到onLoad之后触发,另外一处修改在page-parser.js
// 这里在强制将onShow挪到onLoad之后触发,另外一处修改在page-parser.js
const
oldAttached
=
componentOptions
.
lifetimes
.
attached
;
let
oldAttached
=
componentOptions
.
lifetimes
.
attached
;
// 百度小程序基础库 3.260 以上支持页面 onInit 生命周期,提前创建 vm 实例
componentOptions
.
lifetimes
.
onInit
=
function
onInit
(
query
)
{
oldAttached
.
call
(
this
);
oldAttached
=
noop
;
this
.
pageinstance
.
$vm
=
this
.
$vm
;
this
.
$vm
.
__call_hook
(
'
onInit
'
,
query
);
};
componentOptions
.
lifetimes
.
attached
=
function
attached
()
{
componentOptions
.
lifetimes
.
attached
=
function
attached
()
{
oldAttached
.
call
(
this
);
oldAttached
.
call
(
this
);
if
(
isPage
.
call
(
this
))
{
// 百度 onLoad 在 attached 之前触发
if
(
isPage
.
call
(
this
))
{
// 百度 onLoad 在 attached 之前触发
(基础库小于 3.70)
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this
.
pageinstance
.
$vm
=
this
.
$vm
;
this
.
pageinstance
.
$vm
=
this
.
$vm
;
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
...
@@ -1994,7 +2008,7 @@ function parsePage (vuePageOptions) {
...
@@ -1994,7 +2008,7 @@ function parsePage (vuePageOptions) {
};
};
pageOptions
.
methods
.
onLoad
=
function
onLoad
(
query
)
{
pageOptions
.
methods
.
onLoad
=
function
onLoad
(
query
)
{
// 百度 onLoad 在 attached 之前触发,先存储 args, 在 attached 里边触发 onLoad
// 百度 onLoad 在 attached 之前触发
(基础库小于 3.70)
,先存储 args, 在 attached 里边触发 onLoad
if
(
this
.
$vm
)
{
if
(
this
.
$vm
)
{
const
copyQuery
=
Object
.
assign
({},
query
);
const
copyQuery
=
Object
.
assign
({},
query
);
delete
copyQuery
.
__id__
;
delete
copyQuery
.
__id__
;
...
...
packages/uni-mp-kuaishou/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -754,16 +754,19 @@ function initHook (name, options) {
...
@@ -754,16 +754,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1274,7 +1277,7 @@ function handleEvent (event) {
...
@@ -1274,7 +1277,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1282,9 +1285,13 @@ function handleEvent (event) {
...
@@ -1282,9 +1285,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -915,16 +915,19 @@ function initHook (name, options) {
...
@@ -915,16 +915,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1435,7 +1438,7 @@ function handleEvent (event) {
...
@@ -1435,7 +1438,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1443,9 +1446,13 @@ function handleEvent (event) {
...
@@ -1443,9 +1446,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -1007,16 +1007,19 @@ function initHook (name, options) {
...
@@ -1007,16 +1007,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1527,7 +1530,7 @@ function handleEvent (event) {
...
@@ -1527,7 +1530,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1535,9 +1538,13 @@ function handleEvent (event) {
...
@@ -1535,9 +1538,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -676,16 +676,19 @@ function initHook (name, options) {
...
@@ -676,16 +676,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1196,7 +1199,7 @@ function handleEvent (event) {
...
@@ -1196,7 +1199,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1204,9 +1207,13 @@ function handleEvent (event) {
...
@@ -1204,9 +1207,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
2d6bcba5
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
2d6bcba5
此差异已折叠。
点击以展开。
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
2d6bcba5
...
@@ -764,16 +764,19 @@ function initHook (name, options) {
...
@@ -764,16 +764,19 @@ function initHook (name, options) {
};
};
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
;
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
return
MPPage
(
options
)
};
Page
.
after
=
MPPage
.
after
;
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
);
initHook
(
'
created
'
,
options
);
return
MPPage
(
options
)
return
MPComponent
(
options
)
};
};
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
);
return
MPComponent
(
options
)
};
const
PAGE_EVENT_HOOKS
=
[
const
PAGE_EVENT_HOOKS
=
[
'
onPullDownRefresh
'
,
'
onPullDownRefresh
'
,
...
@@ -1284,7 +1287,7 @@ function handleEvent (event) {
...
@@ -1284,7 +1287,7 @@ function handleEvent (event) {
}
}
handler
.
once
=
true
;
handler
.
once
=
true
;
}
}
cons
t
params
=
processEventArgs
(
le
t
params
=
processEventArgs
(
this
.
$vm
,
this
.
$vm
,
event
,
event
,
eventArray
[
1
],
eventArray
[
1
],
...
@@ -1292,9 +1295,13 @@ function handleEvent (event) {
...
@@ -1292,9 +1295,13 @@ function handleEvent (event) {
isCustom
,
isCustom
,
methodName
methodName
);
);
params
=
Array
.
isArray
(
params
)
?
params
:
[];
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
// eslint-disable-next-line no-sparse-arrays
if
(
/=
\s
*
\S
+
\.
eventParams
\s
*
\|\|\s
*
\S
+
\[[
'"
]
event-params
[
'"
]\]
/
.
test
(
handler
.
toString
()))
{
ret
.
push
(
handler
.
apply
(
handlerCtx
,
(
Array
.
isArray
(
params
)
?
params
:
[]).
concat
([,
,
,
,
,
,
,
,
,
,
event
])));
// eslint-disable-next-line no-sparse-arrays
params
=
params
.
concat
([,
,
,
,
,
,
,
,
,
,
event
]);
}
ret
.
push
(
handler
.
apply
(
handlerCtx
,
params
));
}
}
});
});
}
}
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
2d6bcba5
...
@@ -4,15 +4,13 @@ const webpack = require('webpack')
...
@@ -4,15 +4,13 @@ const webpack = require('webpack')
const
{
const
{
parseEntry
,
parseEntry
,
getMainEntry
,
getMainEntry
,
normalizePath
,
//
normalizePath,
getPlatformExts
,
getPlatformExts
,
getPlatformCssnano
getPlatformCssnano
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
WebpackUniAppPlugin
=
require
(
'
../../packages/webpack-uni-app-loader/plugin/index
'
)
const
WebpackUniAppPlugin
=
require
(
'
../../packages/webpack-uni-app-loader/plugin/index
'
)
const
CustomModuleIdsPlugin
=
require
(
'
../../packages/webpack-custom-module-ids-plugin/index
'
)
const
modifyVueLoader
=
require
(
'
../vue-loader
'
)
const
modifyVueLoader
=
require
(
'
../vue-loader
'
)
const
{
const
{
...
@@ -66,86 +64,67 @@ function getProvides () {
...
@@ -66,86 +64,67 @@ function getProvides () {
return
provides
return
provides
}
}
function
processWxss
(
name
,
assets
)
{
const
dirname
=
path
.
dirname
(
name
)
const
mainWxssCode
=
`@import "
${
path
.
relative
(
dirname
,
'
common/main.wxss
'
)}
";`
const
code
=
`
${
mainWxssCode
}
`
+
assets
[
name
].
source
().
toString
()
assets
[
name
]
=
{
size
()
{
return
Buffer
.
byteLength
(
code
,
'
utf8
'
)
},
source
()
{
return
code
}
}
}
function
procssJs
(
name
,
assets
,
hasVendor
)
{
const
dirname
=
path
.
dirname
(
name
)
const
runtimeJsCode
=
`require('
${
path
.
relative
(
dirname
,
'
common/runtime.js
'
)}
');`
const
vendorJsCode
=
hasVendor
?
`require('
${
path
.
relative
(
dirname
,
'
common/vendor.js
'
)}
');`
:
''
const
mainJsCode
=
`require('
${
path
.
relative
(
dirname
,
'
common/main.js
'
)}
');`
const
code
=
`
${
runtimeJsCode
}${
vendorJsCode
}${
mainJsCode
}
`
+
assets
[
name
].
source
().
toString
()
assets
[
name
]
=
{
size
()
{
return
Buffer
.
byteLength
(
code
,
'
utf8
'
)
},
source
()
{
return
code
}
}
}
class
PreprocessAssetsPlugin
{
class
PreprocessAssetsPlugin
{
apply
(
compiler
)
{
apply
(
compiler
)
{
compiler
.
hooks
.
emit
.
tap
(
'
PreprocessAssetsPlugin
'
,
compilation
=>
{
compiler
.
hooks
.
emit
.
tap
(
'
PreprocessAssetsPlugin
'
,
compilation
=>
{
const
assets
=
compilation
.
assets
const
assets
=
compilation
.
assets
const
hasMainWxss
=
assets
[
'
common/main.wxss
'
]
const
hasVendor
=
assets
[
'
common/vendor.js
'
]
const
hasVendor
=
assets
[
'
common/vendor.js
'
]
Object
.
keys
(
assets
).
forEach
(
name
=>
{
Object
.
keys
(
assets
).
forEach
(
name
=>
{
const
extname
=
path
.
extname
(
name
)
if
(
extname
!==
'
.js
'
)
{
return
}
if
(
name
.
startsWith
(
'
common
'
))
{
if
(
name
.
startsWith
(
'
common
'
))
{
return
return
}
}
const
dirname
=
path
.
dirname
(
name
)
const
extname
=
path
.
extname
(
name
)
const
runtimeJsCode
=
`require('
${
path
.
relative
(
dirname
,
'
common/runtime.js
'
)}
');`
if
(
extname
===
'
.wxss
'
&&
hasMainWxss
&&
process
.
UNI_ENTRY
[
name
.
replace
(
extname
,
''
)])
{
const
vendorJsCode
=
hasVendor
?
`require('
${
path
.
relative
(
dirname
,
'
common/vendor.js
'
)}
');`
:
''
processWxss
(
name
,
assets
)
const
code
=
`
${
runtimeJsCode
}${
vendorJsCode
}
`
+
assets
[
name
].
source
().
toString
()
}
else
if
(
extname
===
'
.js
'
)
{
assets
[
name
]
=
{
procssJs
(
name
,
assets
,
hasVendor
)
size
()
{
return
Buffer
.
byteLength
(
code
,
'
utf8
'
)
},
source
()
{
return
code
}
}
}
})
})
delete
assets
[
'
common/main.js
'
]
//
delete assets['common/main.js']
delete
assets
[
'
app.js
'
]
delete
assets
[
'
app.js
'
]
delete
assets
[
'
app.json
'
]
delete
assets
[
'
app.json
'
]
delete
assets
[
'
app.wxss
'
]
delete
assets
[
'
app.wxss
'
]
delete
assets
[
'
project.config.json
'
]
delete
assets
[
'
project.config.json
'
]
console
.
log
(
Object
.
keys
(
assets
))
})
})
}
}
}
}
function
initSubpackageConfig
(
webpackConfig
,
vueOptions
)
{
function
initSubpackageConfig
(
webpackConfig
,
vueOptions
)
{
webpackConfig
.
node
.
set
(
'
global
'
,
false
)
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
process
.
env
.
UNI_SUBPACKGE
)
webpackConfig
.
plugins
.
delete
(
'
hash-module-ids
'
)
vueOptions
.
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
// 与子包共享的模块
webpackConfig
.
output
.
path
(
process
.
env
.
UNI_OUTPUT_DIR
)
const
sharedModules
=
{
webpackConfig
.
output
.
jsonpFunction
(
'
webpackJsonp_
'
+
process
.
env
.
UNI_SUBPACKGE
)
'
uni-mp-weixin/dist/index.js
'
:
'
uniWeixin
'
,
'
mp-vue/dist/mp.runtime.esm.js
'
:
'
uniVue
'
}
const
sharedModulePaths
=
Object
.
keys
(
sharedModules
)
webpackConfig
.
plugin
(
'
custom-hash-module-ids
'
)
.
use
(
CustomModuleIdsPlugin
,
[{
prefix
:
process
.
env
.
UNI_SUBPACKGE
,
custom
(
libIdent
)
{
if
(
!
libIdent
)
{
return
}
const
normalizedLibIdent
=
normalizePath
(
libIdent
)
const
name
=
sharedModulePaths
.
find
(
p
=>
normalizedLibIdent
.
endsWith
(
p
))
if
(
name
)
{
return
sharedModules
[
name
]
}
}
}])
if
(
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
// 非主包
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
process
.
env
.
UNI_SUBPACKGE
)
vueOptions
.
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
webpackConfig
.
output
.
path
(
process
.
env
.
UNI_OUTPUT_DIR
)
webpackConfig
.
output
.
jsonpFunction
(
'
webpackJsonp_
'
+
process
.
env
.
UNI_SUBPACKGE
)
webpackConfig
.
externals
([
function
(
context
,
request
,
callback
)
{
if
(
request
===
'
vue
'
)
{
return
callback
(
null
,
'
root global["webpackMain"]["uniVue"]
'
)
}
const
normalizedRequest
=
normalizePath
(
request
)
const
name
=
sharedModulePaths
.
find
(
p
=>
normalizedRequest
.
endsWith
(
p
))
if
(
name
)
{
return
callback
(
null
,
`root global["webpackMain"]["
${
sharedModules
[
name
]}
"]`
)
}
callback
()
}
])
}
}
}
module
.
exports
=
{
module
.
exports
=
{
...
@@ -169,13 +148,7 @@ module.exports = {
...
@@ -169,13 +148,7 @@ module.exports = {
const
statCode
=
process
.
env
.
UNI_USING_STAT
?
'
import
\'
@dcloudio/uni-stat
\'
;
'
:
''
const
statCode
=
process
.
env
.
UNI_USING_STAT
?
'
import
\'
@dcloudio/uni-stat
\'
;
'
:
''
let
beforeCode
=
'
import
\'
uni-pages
\'
;
'
const
beforeCode
=
'
import
\'
uni-pages
\'
;
'
if
(
process
.
env
.
UNI_SUBPACKGE
===
'
main
'
)
{
const
uniPath
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
).
getMPRuntimePath
()
beforeCode
+=
`import uniVue from 'vue';import * as uniWeixin from '
${
uniPath
}
';global['webpackMain']={uniVue,uniWeixin};`
}
const
plugins
=
[
const
plugins
=
[
new
WebpackUniAppPlugin
(),
new
WebpackUniAppPlugin
(),
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
浏览文件 @
2d6bcba5
...
@@ -69,9 +69,7 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
...
@@ -69,9 +69,7 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
const
modules
=
compilation
.
modules
const
modules
=
compilation
.
modules
const
concatenatedModules
=
modules
.
filter
(
module
=>
module
.
modules
)
const
concatenatedModules
=
modules
.
filter
(
module
=>
module
.
modules
)
const
uniModule
=
!
process
.
env
.
UNI_SUBPACKAGE
&&
modules
.
find
(
module
=>
module
.
resource
&&
normalizePath
(
module
.
resource
)
===
const
uniModuleId
=
modules
.
find
(
module
=>
module
.
resource
&&
normalizePath
(
module
.
resource
)
===
uniPath
).
id
uniPath
)
const
uniModuleId
=
uniModule
&&
uniModule
.
id
const
styleImports
=
{}
const
styleImports
=
{}
const
fixSlots
=
{}
const
fixSlots
=
{}
...
@@ -109,19 +107,13 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
...
@@ -109,19 +107,13 @@ module.exports = function generateComponent (compilation, jsonpFunction = 'webpa
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
beforeCode
=
'
;my.defineComponent || (my.defineComponent = Component);
'
beforeCode
=
'
;my.defineComponent || (my.defineComponent = Component);
'
}
}
let
requireCode
=
`__webpack_require__('
${
uniModuleId
}
')['createComponent'](__webpack_require__(
${
JSON
.
stringify
(
moduleId
)}
))`
if
(
process
.
env
.
UNI_SUBPACKGE
)
{
requireCode
=
`global['webpackMain']['uniWeixin']['createComponent'](__webpack_require__(
${
JSON
.
stringify
(
moduleId
)}
))`
}
const
source
=
beforeCode
+
origSource
+
const
source
=
beforeCode
+
origSource
+
`
`
;(
${
globalVar
}
["
${
jsonpFunction
}
"] =
${
globalVar
}
["
${
jsonpFunction
}
"] || []).push([
;(
${
globalVar
}
["
${
jsonpFunction
}
"] =
${
globalVar
}
["
${
jsonpFunction
}
"] || []).push([
'
${
chunkName
}
',
'
${
chunkName
}
',
{
{
'
${
chunkName
}
':(function(module, exports, __webpack_require__){
'
${
chunkName
}
':(function(module, exports, __webpack_require__){
${
requireCode
}
__webpack_require__('
${
uniModuleId
}
')['createComponent'](__webpack_require__(
${
JSON
.
stringify
(
moduleId
)}
))
})
})
},
},
[['
${
chunkName
}
']]
[['
${
chunkName
}
']]
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
浏览文件 @
2d6bcba5
...
@@ -179,10 +179,8 @@ module.exports = function generateJson (compilation) {
...
@@ -179,10 +179,8 @@ module.exports = function generateJson (compilation) {
delete
jsonObj
.
navigationBarShadow
delete
jsonObj
.
navigationBarShadow
}
}
if
(
process
.
env
.
UNI_SUBPACKGE
&&
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
if
(
process
.
env
.
UNI_SUBPACKGE
&&
jsonObj
.
usingComponents
)
{
if
(
jsonObj
.
usingComponents
)
{
jsonObj
.
usingComponents
=
normalizeUsingComponents
(
name
,
jsonObj
.
usingComponents
)
jsonObj
.
usingComponents
=
normalizeUsingComponents
(
name
,
jsonObj
.
usingComponents
)
}
}
}
const
source
=
JSON
.
stringify
(
jsonObj
,
null
,
2
)
const
source
=
JSON
.
stringify
(
jsonObj
,
null
,
2
)
...
...
src/platforms/mp-weixin/runtime/index.js
浏览文件 @
2d6bcba5
...
@@ -37,14 +37,16 @@ function initHook (name, options) {
...
@@ -37,14 +37,16 @@ function initHook (name, options) {
}
}
}
}
}
}
if
(
!
MPPage
.
__$wrappered
)
{
MPPage
.
__$wrappered
=
true
Page
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
)
return
MPPage
(
options
)
}
Page
.
after
=
MPPage
.
after
Page
=
function
(
options
=
{})
{
Component
=
function
(
options
=
{})
{
initHook
(
'
onLoad
'
,
options
)
initHook
(
'
created
'
,
options
)
return
MPPage
(
options
)
return
MPComponent
(
options
)
}
}
Page
.
after
=
MPPage
.
after
}
Component
=
function
(
options
=
{})
{
initHook
(
'
created
'
,
options
)
return
MPComponent
(
options
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录