Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
e737540a
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,发现更多精彩内容 >>
提交
e737540a
编写于
3月 25, 2021
作者:
D
DCloud_LXH
提交者:
qiang
3月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-weixin): 支持微信小程序插件
上级
fae0c2f6
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
430 addition
and
394 deletion
+430
-394
packages/vue-cli-plugin-uni/commands/build.js
packages/vue-cli-plugin-uni/commands/build.js
+7
-2
packages/vue-cli-plugin-uni/lib/configure-webpack.js
packages/vue-cli-plugin-uni/lib/configure-webpack.js
+1
-1
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+6
-4
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
...vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
+376
-376
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
+1
-1
src/core/runtime/index.js
src/core/runtime/index.js
+8
-5
src/core/runtime/wrapper/create-plugin.js
src/core/runtime/wrapper/create-plugin.js
+26
-0
src/platforms/mp-weixin/runtime/index.js
src/platforms/mp-weixin/runtime/index.js
+2
-2
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
+3
-3
未找到文件。
packages/vue-cli-plugin-uni/commands/build.js
浏览文件 @
e737540a
...
...
@@ -28,7 +28,8 @@ module.exports = (api, options) => {
'
--minimize
'
:
'
Tell webpack to minimize the bundle using the TerserPlugin.
'
,
'
--auto-host
'
:
'
specify automator host
'
,
'
--auto-port
'
:
'
specify automator port
'
,
'
--subpackage
'
:
'
specify subpackage
'
'
--subpackage
'
:
'
specify subpackage
'
,
'
--plugin
'
:
'
specify plugin
'
}
},
async
(
args
)
=>
{
for
(
const
key
in
defaults
)
{
...
...
@@ -42,6 +43,10 @@ module.exports = (api, options) => {
process
.
env
.
UNI_SUBPACKGE
=
args
.
subpackage
}
if
(
args
.
plugin
&&
platforms
.
includes
(
process
.
env
.
UNI_PLATFORM
))
{
process
.
env
.
UNI_MP_PLUGIN
=
args
.
plugin
}
require
(
'
./util
'
).
initAutomator
(
args
)
args
.
entry
=
args
.
entry
||
args
.
_
[
0
]
...
...
@@ -190,4 +195,4 @@ async function build (args, api, options) {
module
.
exports
.
defaultModes
=
{
'
uni-build
'
:
process
.
env
.
NODE_ENV
}
}
packages/vue-cli-plugin-uni/lib/configure-webpack.js
浏览文件 @
e737540a
...
...
@@ -197,7 +197,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
if
(
!
isAppView
)
{
// app-plus view不需要copy
plugins
.
push
(
new
CopyWebpackPlugin
(
getCopyWebpackPluginOptions
(
manifestPlatformOptions
,
vueOptions
)))
}
if
(
!
process
.
env
.
UNI_SUBPACKGE
)
{
if
(
!
process
.
env
.
UNI_SUBPACKGE
||
!
process
.
env
.
UNI_MP_PLUGIN
)
{
try
{
const
automatorJson
=
require
.
resolve
(
'
@dcloudio/uni-automator/dist/automator.json
'
)
plugins
.
push
(
new
CopyWebpackPlugin
([{
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
e737540a
...
...
@@ -38,6 +38,8 @@ function getProvides () {
if
(
process
.
env
.
UNI_USING_COMPONENTS
)
{
if
(
process
.
env
.
UNI_SUBPACKGE
)
{
provides
.
createApp
=
[
uniPath
,
'
createSubpackageApp
'
]
}
else
if
(
process
.
env
.
UNI_MP_PLUGIN
)
{
provides
.
createApp
=
[
uniPath
,
'
createPlugin
'
]
}
else
{
provides
.
createApp
=
[
uniPath
,
'
createApp
'
]
}
...
...
@@ -126,11 +128,11 @@ 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_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
)
webpackConfig
.
output
.
jsonpFunction
(
'
webpackJsonp_
'
+
process
.
env
.
UNI_SUBPACKGE
)
webpackConfig
.
output
.
jsonpFunction
(
'
webpackJsonp_
'
+
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
)
}
module
.
exports
=
{
...
...
@@ -162,7 +164,7 @@ module.exports = {
new
webpack
.
ProvidePlugin
(
getProvides
())
]
if
(
process
.
env
.
UNI_SUBPACKGE
&&
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
if
(
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
&&
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
plugins
.
push
(
new
PreprocessAssetsPlugin
())
}
...
...
@@ -272,7 +274,7 @@ module.exports = {
}))
}
if
(
process
.
env
.
UNI_SUBPACKGE
)
{
if
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
{
initSubpackageConfig
(
webpackConfig
,
vueOptions
)
}
...
...
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
浏览文件 @
e737540a
此差异已折叠。
点击以展开。
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
浏览文件 @
e737540a
...
...
@@ -184,7 +184,7 @@ module.exports = function generateJson (compilation) {
delete
jsonObj
.
navigationBarShadow
}
if
(
process
.
env
.
UNI_SUBPACKGE
&&
jsonObj
.
usingComponents
)
{
if
(
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
&&
jsonObj
.
usingComponents
)
{
jsonObj
.
usingComponents
=
normalizeUsingComponents
(
name
,
jsonObj
.
usingComponents
)
}
const
source
=
JSON
.
stringify
(
jsonObj
,
null
,
2
)
...
...
src/core/runtime/index.js
浏览文件 @
e737540a
...
...
@@ -26,8 +26,9 @@ import {
import
createApp
from
'
./wrapper/create-app
'
import
createPage
from
'
./wrapper/create-page
'
import
createComponent
from
'
./wrapper/create-component
'
import
createComponent
from
'
./wrapper/create-component
'
import
createSubpackageApp
from
'
./wrapper/create-subpackage-app
'
import
createPlugin
from
'
./wrapper/create-plugin
'
todos
.
forEach
(
todoApi
=>
{
protocols
[
todoApi
]
=
false
...
...
@@ -115,13 +116,15 @@ if (__PLATFORM__ === 'app-plus') {
__GLOBAL__
.
createApp
=
createApp
__GLOBAL__
.
createPage
=
createPage
__GLOBAL__
.
createComponent
=
createComponent
__GLOBAL__
.
createSubpackageApp
=
createSubpackageApp
__GLOBAL__
.
createSubpackageApp
=
createSubpackageApp
__GLOBAL__
.
createPlugin
=
createPlugin
export
{
createApp
,
createPage
,
createComponent
,
createSubpackageApp
createComponent
,
createSubpackageApp
,
createPlugin
}
export
default
uni
export
default
uni
src/core/runtime/wrapper/create-plugin.js
0 → 100644
浏览文件 @
e737540a
import
'
uni-platform/runtime/index
'
import
{
isFn
}
from
'
uni-shared
'
import
parseApp
from
'
uni-platform/runtime/wrapper/app-parser
'
export
default
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
)
if
(
isFn
(
appOptions
.
onShow
)
&&
__GLOBAL__
.
onAppShow
)
{
__GLOBAL__
.
onAppShow
((...
args
)
=>
{
appOptions
.
onShow
.
apply
(
vm
,
args
)
})
}
if
(
isFn
(
appOptions
.
onHide
)
&&
__GLOBAL__
.
onAppHide
)
{
__GLOBAL__
.
onAppHide
((...
args
)
=>
{
appOptions
.
onHide
.
apply
(
vm
,
args
)
})
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
__GLOBAL__
.
getLaunchOptionsSync
&&
__GLOBAL__
.
getLaunchOptionsSync
()
appOptions
.
onLaunch
.
call
(
vm
,
args
)
}
return
vm
}
src/platforms/mp-weixin/runtime/index.js
浏览文件 @
e737540a
...
...
@@ -14,7 +14,7 @@ const customize = cached((str) => {
function
initTriggerEvent
(
mpInstance
)
{
if
(
__PLATFORM__
===
'
mp-weixin
'
||
__PLATFORM__
===
'
app-plus
'
)
{
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
if
(
!
wx
.
canIUse
||
!
wx
.
canIUse
(
'
nextTick
'
))
{
return
}
}
...
...
@@ -49,4 +49,4 @@ if (!MPPage.__$wrappered) {
initHook
(
'
created
'
,
options
)
return
MPComponent
(
options
)
}
}
}
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
浏览文件 @
e737540a
...
...
@@ -69,7 +69,7 @@ export default function parseBaseApp (vm, {
delete
this
.
$options
.
mpType
delete
this
.
$options
.
mpInstance
if
(
this
.
mpType
===
'
page
'
)
{
// hack vue-i18n
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
()
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
...
...
@@ -88,7 +88,7 @@ export default function parseBaseApp (vm, {
return
}
if
(
__PLATFORM__
===
'
mp-weixin
'
||
__PLATFORM__
===
'
mp-qq
'
)
{
if
(
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
)
}
}
...
...
@@ -123,4 +123,4 @@ export default function parseBaseApp (vm, {
initHooks
(
appOptions
,
hooks
)
return
appOptions
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录