Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
ed13794b
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed13794b
编写于
12月 03, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp): support build plugin
上级
43c94c49
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
415 addition
and
178 deletion
+415
-178
package.json
package.json
+1
-1
packages/shims-node.d.ts
packages/shims-node.d.ts
+1
-0
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+6
-0
packages/uni-cli-shared/src/env/define.ts
packages/uni-cli-shared/src/env/define.ts
+1
-0
packages/uni-cli-shared/src/messages/index.ts
packages/uni-cli-shared/src/messages/index.ts
+1
-0
packages/uni-cli-shared/src/mp/constants.ts
packages/uni-cli-shared/src/mp/constants.ts
+1
-0
packages/uni-cli-shared/src/mp/index.ts
packages/uni-cli-shared/src/mp/index.ts
+1
-0
packages/uni-cli-shared/src/mp/plugin.ts
packages/uni-cli-shared/src/mp/plugin.ts
+12
-0
packages/uni-mp-alipay/dist/uni.compiler.js
packages/uni-mp-alipay/dist/uni.compiler.js
+2
-0
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+26
-16
packages/uni-mp-alipay/src/compiler/options.ts
packages/uni-mp-alipay/src/compiler/options.ts
+3
-0
packages/uni-mp-alipay/src/runtime/index.ts
packages/uni-mp-alipay/src/runtime/index.ts
+7
-1
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+17
-15
packages/uni-mp-core/src/index.ts
packages/uni-mp-core/src/index.ts
+1
-0
packages/uni-mp-core/src/runtime/app.ts
packages/uni-mp-core/src/runtime/app.ts
+23
-17
packages/uni-mp-core/src/runtime/plugin.ts
packages/uni-mp-core/src/runtime/plugin.ts
+8
-0
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
+17
-15
packages/uni-mp-lark/dist/uni.mp.esm.js
packages/uni-mp-lark/dist/uni.mp.esm.js
+17
-15
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+26
-16
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+17
-15
packages/uni-mp-vite/src/index.ts
packages/uni-mp-vite/src/index.ts
+5
-1
packages/uni-mp-vite/src/plugin/build.ts
packages/uni-mp-vite/src/plugin/build.ts
+48
-2
packages/uni-mp-vite/src/plugin/index.ts
packages/uni-mp-vite/src/plugin/index.ts
+12
-2
packages/uni-mp-vite/src/plugins/pagesJson.ts
packages/uni-mp-vite/src/plugins/pagesJson.ts
+1
-1
packages/uni-mp-vite/src/plugins/plugin.ts
packages/uni-mp-vite/src/plugins/plugin.ts
+65
-0
packages/uni-mp-vite/src/plugins/subpackage.ts
packages/uni-mp-vite/src/plugins/subpackage.ts
+30
-24
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+5
-3
packages/uni-mp-vue/src/plugin.ts
packages/uni-mp-vue/src/plugin.ts
+3
-1
packages/uni-mp-weixin/dist/uni.compiler.js
packages/uni-mp-weixin/dist/uni.compiler.js
+2
-0
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+26
-16
packages/uni-mp-weixin/src/compiler/options.ts
packages/uni-mp-weixin/src/compiler/options.ts
+3
-0
packages/uni-mp-weixin/src/runtime/index.ts
packages/uni-mp-weixin/src/runtime/index.ts
+3
-0
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+17
-15
packages/vite-plugin-uni/src/cli/index.ts
packages/vite-plugin-uni/src/cli/index.ts
+2
-0
packages/vite-plugin-uni/src/cli/utils.ts
packages/vite-plugin-uni/src/cli/utils.ts
+5
-2
未找到文件。
package.json
浏览文件 @
ed13794b
...
...
@@ -9,7 +9,7 @@
"build"
:
"node scripts/build.js"
,
"build:h5"
:
"node scripts/build.js uni-app uni-cli-shared uni-h5 uni-i18n uni-stat uni-shared uni-h5-vite vite-plugin-uni"
,
"build:app"
:
"node scripts/build.js uni-app-plus uni-app-vite uni-app-vue uni-cli-nvue"
,
"build:mp"
:
"node scripts/build.js uni-mp-vue uni-mp-
alipay uni-mp-baidu uni-mp-qq uni-mp-toutiao uni-mp-weixin uni-mp-kuaishou
uni-quickapp-webview"
,
"build:mp"
:
"node scripts/build.js uni-mp-vue uni-mp-
vite uni-mp-alipay uni-mp-baidu uni-mp-kuaishou uni-mp-lark uni-mp-qq uni-mp-toutiao uni-mp-weixin
uni-quickapp-webview"
,
"size"
:
"npm run build size-check"
,
"lint"
:
"eslint packages/*/src/**/*.ts"
,
"format"
:
"prettier --write --parser typescript
\"
packages/**/*.ts?(x)
\"
"
,
...
...
packages/shims-node.d.ts
浏览文件 @
ed13794b
...
...
@@ -11,6 +11,7 @@ declare namespace NodeJS {
UNI_OUTPUT_DIR
:
string
UNI_CLI_CONTEXT
:
string
UNI_SUBPACKAGE
?:
string
UNI_MP_PLUGIN
?:
'
true
'
UNI_COMPILER_VERSION
:
string
UNI_COMPILER_VERSION_TYPE
:
'
a
'
|
'
r
'
UNI_HBUILDERX_PLUGINS
:
string
...
...
packages/shims-uni-app.d.ts
浏览文件 @
ed13794b
...
...
@@ -235,6 +235,12 @@ declare namespace UniApp {
interface
PagesJson
{
pages
:
PagesJsonPageOptions
[]
preloadRule
?:
{
[
page
:
string
]:
{
network
?:
'
all
'
|
'
wifi
'
packages
:
string
[]
}
}
subpackages
?:
PagesJsonSubpackagesOptions
[]
subPackages
?:
PagesJsonSubpackagesOptions
[]
globalStyle
:
PagesJsonPageStyle
...
...
packages/uni-cli-shared/src/env/define.ts
浏览文件 @
ed13794b
...
...
@@ -13,6 +13,7 @@ export function initDefine(stringifyBoolean: boolean = false) {
'
process.env.UNI_APP_ID
'
:
JSON
.
stringify
(
manifestJson
.
appid
||
''
),
'
process.env.UNI_APP_NAME
'
:
JSON
.
stringify
(
manifestJson
.
name
||
''
),
'
process.env.UNI_PLATFORM
'
:
JSON
.
stringify
(
process
.
env
.
UNI_PLATFORM
),
'
process.env.UNI_MP_PLUGIN
'
:
JSON
.
stringify
(
process
.
env
.
UNI_MP_PLUGIN
),
'
process.env.UNI_SUBPACKAGE
'
:
JSON
.
stringify
(
process
.
env
.
UNI_SUBPACKAGE
),
'
process.env.UNI_COMPILER_VERSION
'
:
JSON
.
stringify
(
process
.
env
.
UNI_COMPILER_VERSION
...
...
packages/uni-cli-shared/src/messages/index.ts
浏览文件 @
ed13794b
...
...
@@ -21,4 +21,5 @@ export const M = {
'
mp.component.args[0]
'
:
'
{0}的第一个参数必须为静态字符串
'
,
'
mp.component.args[1]
'
:
'
{0}需要两个参数
'
,
'
mp.360.unsupported
'
:
'
vue3暂不支持360小程序
'
,
'
file.notfound
'
:
'
{file} 文件不存在
'
,
}
packages/uni-cli-shared/src/mp/constants.ts
浏览文件 @
ed13794b
...
...
@@ -2,3 +2,4 @@ export const COMPONENT_ON_LINK = 'onVI'
export
const
COMPONENT_BIND_LINK
=
'
__l
'
export
const
COMPONENT_CUSTOM_HIDDEN
=
'
data-c-h
'
export
const
COMPONENT_CUSTOM_HIDDEN_BIND
=
'
bind:-
'
+
COMPONENT_CUSTOM_HIDDEN
export
const
MP_PLUGIN_JSON_NAME
=
'
plugin.json
'
packages/uni-cli-shared/src/mp/index.ts
浏览文件 @
ed13794b
...
...
@@ -3,4 +3,5 @@ export * from './event'
export
*
from
'
./style
'
export
*
from
'
./template
'
export
*
from
'
./constants
'
export
{
copyMiniProgramPluginJson
}
from
'
./plugin
'
export
{
transformVueComponentImports
}
from
'
./transformImports
'
packages/uni-cli-shared/src/mp/plugin.ts
0 → 100644
浏览文件 @
ed13794b
import
{
UniViteCopyPluginTarget
}
from
'
../vite/plugins/copy
'
import
{
parseJson
}
from
'
../json/json
'
export
const
copyMiniProgramPluginJson
:
UniViteCopyPluginTarget
=
{
src
:
[
'
plugin.json
'
],
get
dest
()
{
return
process
.
env
.
UNI_OUTPUT_DIR
},
transform
(
source
)
{
return
JSON
.
stringify
(
parseJson
(
source
.
toString
(),
true
),
null
,
2
)
},
}
packages/uni-mp-alipay/dist/uni.compiler.js
浏览文件 @
ed13794b
...
...
@@ -170,6 +170,7 @@ const options = {
},
copyOptions
:
{
assets
:
[
'
mycomponents
'
],
targets
:
process
.
env
.
UNI_MP_PLUGIN
?
[
uniCliShared
.
copyMiniProgramPluginJson
]
:
[],
},
},
global
:
'
my
'
,
...
...
@@ -203,6 +204,7 @@ const options = {
app
:
{
darkmode
:
false
,
subpackages
:
true
,
plugins
:
true
,
},
project
:
{
filename
:
projectConfigFilename
,
...
...
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -362,23 +362,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
my
.
onAppShow
)
{
my
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
my
.
onAppHide
)
{
my
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
my
.
getLaunchOptionsSync
&&
my
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
my
.
onAppShow
)
{
my
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
my
.
onAppHide
)
{
my
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
my
.
getLaunchOptionsSync
&&
my
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
my
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -617,6 +619,12 @@ function $destroyComponent(instance) {
return
$destroyComponentFn
(
instance
);
}
function
initCreatePluginApp
(
parseAppOptions
)
{
return
function
createApp
(
vm
)
{
initAppLifecycle
(
parseApp
(
vm
,
parseAppOptions
),
vm
);
};
}
function
onAliAuthError
(
method
,
$event
)
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
...
...
@@ -1055,11 +1063,13 @@ function initCreateComponent() {
const
createApp
=
initCreateApp
(
parseAppOptions
);
const
createPage
=
initCreatePage
();
const
createComponent
=
initCreateComponent
();
const
createPluginApp
=
initCreatePluginApp
(
parseAppOptions
);
const
createSubpackageApp
=
initCreateSubpackageApp
(
parseAppOptions
);
my
.
EventChannel
=
EventChannel
;
my
.
createApp
=
createApp
;
my
.
createPage
=
createPage
;
my
.
createComponent
=
createComponent
;
my
.
createPluginApp
=
createPluginApp
;
my
.
createSubpackageApp
=
createSubpackageApp
;
export
{
createApp
,
createComponent
,
createPage
,
createSubpackageApp
};
export
{
createApp
,
createComponent
,
createPage
,
create
PluginApp
,
create
SubpackageApp
};
packages/uni-mp-alipay/src/compiler/options.ts
浏览文件 @
ed13794b
...
...
@@ -2,6 +2,7 @@ import path from 'path'
import
{
CompilerOptions
,
NodeTypes
}
from
'
@vue/compiler-core
'
import
{
COMPONENT_ON_LINK
,
copyMiniProgramPluginJson
,
createTransformComponentLink
,
MiniProgramCompilerOptions
,
transformMatchMedia
,
...
...
@@ -61,6 +62,7 @@ export const options: UniMiniProgramPluginOptions = {
},
copyOptions
:
{
assets
:
[
'
mycomponents
'
],
targets
:
process
.
env
.
UNI_MP_PLUGIN
?
[
copyMiniProgramPluginJson
]
:
[],
},
},
global
:
'
my
'
,
...
...
@@ -94,6 +96,7 @@ export const options: UniMiniProgramPluginOptions = {
app
:
{
darkmode
:
false
,
subpackages
:
true
,
plugins
:
true
,
},
project
:
{
filename
:
projectConfigFilename
,
...
...
packages/uni-mp-alipay/src/runtime/index.ts
浏览文件 @
ed13794b
import
{
EventChannel
}
from
'
@dcloudio/uni-shared
'
import
{
initCreateApp
,
initCreateSubpackageApp
}
from
'
@dcloudio/uni-mp-core
'
import
{
initCreateApp
,
initCreatePluginApp
,
initCreateSubpackageApp
,
}
from
'
@dcloudio/uni-mp-core
'
import
*
as
parseAppOptions
from
'
./parseAppOptions
'
...
...
@@ -9,9 +13,11 @@ import { initCreateComponent } from './createComponent'
export
const
createApp
=
initCreateApp
(
parseAppOptions
)
export
const
createPage
=
initCreatePage
()
export
const
createComponent
=
initCreateComponent
()
export
const
createPluginApp
=
initCreatePluginApp
(
parseAppOptions
)
export
const
createSubpackageApp
=
initCreateSubpackageApp
(
parseAppOptions
)
;(
my
as
any
).
EventChannel
=
EventChannel
;(
my
as
any
).
createApp
=
createApp
;(
my
as
any
).
createPage
=
createPage
;(
my
as
any
).
createComponent
=
createComponent
;(
my
as
any
).
createPluginApp
=
createPluginApp
;(
my
as
any
).
createSubpackageApp
=
createSubpackageApp
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -421,23 +421,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
swan
.
onAppShow
)
{
swan
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
swan
.
onAppHide
)
{
swan
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
swan
.
getLaunchOptionsSync
&&
swan
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
swan
.
onAppShow
)
{
swan
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
swan
.
onAppHide
)
{
swan
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
swan
.
getLaunchOptionsSync
&&
swan
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
swan
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
packages/uni-mp-core/src/index.ts
浏览文件 @
ed13794b
...
...
@@ -10,6 +10,7 @@ declare module '@vue/runtime-core' {
export
{
initCreateApp
,
initCreateSubpackageApp
}
from
'
./runtime/app
'
export
{
initCreatePage
}
from
'
./runtime/page
'
export
{
initCreateComponent
}
from
'
./runtime/component
'
export
{
initCreatePluginApp
}
from
'
./runtime/plugin
'
export
{
initUni
}
from
'
./api/index
'
export
{
initGetProvider
}
from
'
./api/shims
'
...
...
packages/uni-mp-core/src/runtime/app.ts
浏览文件 @
ed13794b
...
...
@@ -42,7 +42,7 @@ export interface ParseAppOptions {
parse
:
(
appOptions
:
MiniProgramAppOptions
)
=>
void
}
function
parseApp
(
export
function
parseApp
(
instance
:
ComponentPublicInstance
,
parseAppOptions
?:
ParseAppOptions
)
{
...
...
@@ -121,22 +121,28 @@ export function initCreateSubpackageApp(parseAppOptions?: ParseAppOptions) {
app
[
name
]
=
appOptions
[
name
]
}
})
if
(
isFunction
(
appOptions
.
onShow
)
&&
__GLOBAL__
.
onAppShow
)
{
__GLOBAL__
.
onAppShow
((
args
:
unknown
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
)
})
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
__GLOBAL__
.
onAppHide
)
{
__GLOBAL__
.
onAppHide
((
args
:
unknown
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
)
})
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
__GLOBAL__
.
getLaunchOptionsSync
&&
__GLOBAL__
.
getLaunchOptionsSync
()
vm
.
$callHook
(
'
onLaunch
'
,
args
)
}
return
App
(
appOptions
)
initAppLifecycle
(
appOptions
,
vm
)
}
}
export
function
initAppLifecycle
(
appOptions
:
MiniProgramAppOptions
,
vm
:
ComponentPublicInstance
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
__GLOBAL__
.
onAppShow
)
{
__GLOBAL__
.
onAppShow
((
args
:
unknown
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
)
})
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
__GLOBAL__
.
onAppHide
)
{
__GLOBAL__
.
onAppHide
((
args
:
unknown
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
)
})
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
__GLOBAL__
.
getLaunchOptionsSync
&&
__GLOBAL__
.
getLaunchOptionsSync
()
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{})
}
}
...
...
packages/uni-mp-core/src/runtime/plugin.ts
0 → 100644
浏览文件 @
ed13794b
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
initAppLifecycle
,
parseApp
,
ParseAppOptions
}
from
'
./app
'
export
function
initCreatePluginApp
(
parseAppOptions
?:
ParseAppOptions
)
{
return
function
createApp
(
vm
:
ComponentPublicInstance
)
{
initAppLifecycle
(
parseApp
(
vm
,
parseAppOptions
),
vm
)
}
}
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -416,23 +416,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
ks
.
onAppShow
)
{
ks
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
ks
.
onAppHide
)
{
ks
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
ks
.
getLaunchOptionsSync
&&
ks
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
ks
.
onAppShow
)
{
ks
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
ks
.
onAppHide
)
{
ks
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
ks
.
getLaunchOptionsSync
&&
ks
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
ks
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
packages/uni-mp-lark/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -415,23 +415,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -412,23 +412,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
qq
.
onAppShow
)
{
qq
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
qq
.
onAppHide
)
{
qq
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
qq
.
getLaunchOptionsSync
&&
qq
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
qq
.
onAppShow
)
{
qq
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
qq
.
onAppHide
)
{
qq
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
qq
.
getLaunchOptionsSync
&&
qq
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
qq
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -804,6 +806,12 @@ function initCreatePage(parseOptions) {
};
}
function
initCreatePluginApp
(
parseAppOptions
)
{
return
function
createApp
(
vm
)
{
initAppLifecycle
(
parseApp
(
vm
,
parseAppOptions
),
vm
);
};
}
const
MPPage
=
Page
;
const
MPComponent
=
Component
;
const
customizeRE
=
/:/g
;
...
...
@@ -919,10 +927,12 @@ var parseOptions = /*#__PURE__*/Object.freeze({
const
createApp
=
initCreateApp
();
const
createPage
=
initCreatePage
(
parseOptions
);
const
createComponent
=
initCreateComponent
(
parseOptions
);
const
createPluginApp
=
initCreatePluginApp
();
const
createSubpackageApp
=
initCreateSubpackageApp
();
wx
.
createApp
=
global
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createPluginApp
=
createPluginApp
;
wx
.
createSubpackageApp
=
createSubpackageApp
;
qq
.
EventChannel
=
EventChannel$1
;
...
...
@@ -931,4 +941,4 @@ qq.createPage = createPage;
qq
.
createComponent
=
createComponent
;
qq
.
createSubpackageApp
=
createSubpackageApp
;
export
{
createApp
,
createComponent
,
createPage
,
createSubpackageApp
};
export
{
createApp
,
createComponent
,
createPage
,
create
PluginApp
,
create
SubpackageApp
};
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -415,23 +415,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
tt
.
onAppShow
)
{
tt
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
tt
.
onAppHide
)
{
tt
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
tt
.
getLaunchOptionsSync
&&
tt
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
tt
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
packages/uni-mp-vite/src/index.ts
浏览文件 @
ed13794b
...
...
@@ -11,13 +11,16 @@ import { uniEntryPlugin } from './plugins/entry'
import
{
uniRenderjsPlugin
}
from
'
./plugins/renderjs
'
import
{
uniSubpackagePlugin
}
from
'
./plugins/subpackage
'
import
{
uniMiniProgramPluginPlugin
}
from
'
./plugins/plugin
'
export
{
UniMiniProgramPluginOptions
}
from
'
./plugin
'
export
default
(
options
:
UniMiniProgramPluginOptions
)
=>
{
if
(
!
options
.
app
.
subpackages
)
{
delete
process
.
env
.
UNI_SUBPACKAGE
}
if
(
!
options
.
app
.
plugins
)
{
delete
process
.
env
.
UNI_MP_PLUGIN
}
return
[
(
options
:
{
vueOptions
?:
{
script
?:
Partial
<
SFCScriptCompileOptions
>
}
...
...
@@ -36,5 +39,6 @@ export default (options: UniMiniProgramPluginOptions) => {
return
uniUsingComponentsPlugin
(
options
.
vueOptions
?.
script
)
},
...(
process
.
env
.
UNI_SUBPACKAGE
?
[
uniSubpackagePlugin
(
options
)]
:
[]),
...(
process
.
env
.
UNI_MP_PLUGIN
?
[
uniMiniProgramPluginPlugin
(
options
)]
:
[]),
]
}
packages/uni-mp-vite/src/plugin/build.ts
浏览文件 @
ed13794b
import
fs
from
'
fs
'
import
path
from
'
path
'
import
debug
from
'
debug
'
import
{
UserConfig
}
from
'
vite
'
import
{
BuildOptions
,
UserConfig
}
from
'
vite
'
import
{
emptyDir
,
...
...
@@ -12,6 +12,8 @@ import {
resolveMainPathOnce
,
normalizeMiniProgramFilename
,
isCSSRequest
,
parseManifestJsonOnce
,
M
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
GetManualChunk
,
GetModuleInfo
,
Plugin
,
PreRenderedChunk
}
from
'
rollup
'
import
{
...
...
@@ -24,12 +26,20 @@ import {
const
debugChunk
=
debug
(
'
vite:uni:chunk
'
)
export
function
buildOptions
():
UserConfig
[
'
build
'
]
{
const
platform
=
process
.
env
.
UNI_PLATFORM
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
// 开始编译时,清空输出目录
if
(
fs
.
existsSync
(
outputDir
))
{
emptyDir
(
outputDir
)
}
return
createBuildOptions
(
inputDir
,
platform
)
}
export
function
createBuildOptions
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
):
BuildOptions
{
return
{
// sourcemap: 'inline', // TODO
// target: ['chrome53'], // 由小程序自己启用 es6 编译
...
...
@@ -41,8 +51,14 @@ export function buildOptions(): UserConfig['build'] {
formats
:
[
'
cjs
'
],
},
rollupOptions
:
{
input
:
parseRollupInput
(
inputDir
,
platform
),
output
:
{
entryFileNames
:
'
app.js
'
,
entryFileNames
(
chunk
)
{
if
(
chunk
.
name
===
'
main
'
)
{
return
'
app.js
'
}
return
chunk
.
name
+
'
.js
'
},
format
:
'
cjs
'
,
manualChunks
:
createMoveToVendorChunkFn
(),
chunkFileNames
:
createChunkFileNames
(
inputDir
),
...
...
@@ -53,6 +69,29 @@ export function buildOptions(): UserConfig['build'] {
}
}
function
parseRollupInput
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
const
inputOptions
:
Record
<
string
,
string
>
=
{
app
:
resolveMainPathOnce
(
inputDir
),
}
if
(
process
.
env
.
UNI_MP_PLUGIN
)
{
return
inputOptions
}
const
manifestJson
=
parseManifestJsonOnce
(
inputDir
)
const
plugins
=
manifestJson
[
platform
]?.
plugins
||
{}
Object
.
keys
(
plugins
).
forEach
((
name
)
=>
{
const
pluginExport
=
plugins
[
name
].
export
if
(
!
pluginExport
)
{
return
}
const
pluginExportFile
=
path
.
resolve
(
inputDir
,
pluginExport
)
if
(
!
fs
.
existsSync
(
pluginExportFile
))
{
notFound
(
pluginExportFile
)
}
inputOptions
[
removeExt
(
pluginExport
)]
=
pluginExportFile
})
return
inputOptions
}
function
isVueJs
(
id
:
string
)
{
return
id
.
includes
(
'
plugin-vue:export-helper
'
)
}
...
...
@@ -163,3 +202,10 @@ function dynamicImportPolyfill(): Plugin {
},
}
}
export
function
notFound
(
filename
:
string
):
never
{
console
.
log
()
console
.
error
(
M
[
'
file.notfound
'
].
replace
(
'
{file}
'
,
filename
))
console
.
log
()
process
.
exit
(
0
)
}
packages/uni-mp-vite/src/plugin/index.ts
浏览文件 @
ed13794b
...
...
@@ -43,8 +43,18 @@ export interface UniMiniProgramPluginOptions {
)
=>
void
}
app
:
{
darkmode
:
boolean
subpackages
:
boolean
/**
* 是否支持darkmode
*/
darkmode
?:
boolean
/**
* 是否支持subpackages
*/
subpackages
?:
boolean
/**
* 是否支持发行插件
*/
plugins
?:
boolean
}
project
?:
{
filename
:
string
...
...
packages/uni-mp-vite/src/plugins/pagesJson.ts
浏览文件 @
ed13794b
...
...
@@ -54,7 +54,7 @@ export function uniPagesJsonPlugin(
options
.
app
.
darkmode
&&
fs
.
existsSync
(
path
.
resolve
(
inputDir
,
'
theme.json
'
)),
networkTimeout
:
manifestJson
.
networkTimeout
,
subpackages
:
options
.
app
.
subpackages
,
subpackages
:
!!
options
.
app
.
subpackages
,
...
options
.
json
,
}
)
...
...
packages/uni-mp-vite/src/plugins/plugin.ts
0 → 100644
浏览文件 @
ed13794b
import
fs
from
'
fs
'
import
path
from
'
path
'
import
type
{
Plugin
}
from
'
vite
'
import
type
{
RollupOptions
}
from
'
rollup
'
import
{
MP_PLUGIN_JSON_NAME
,
parseJson
,
removeExt
,
resolveMainPathOnce
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
../plugin
'
import
{
createNonAppGenerateBundle
}
from
'
./subpackage
'
import
{
extend
}
from
'
@vue/shared
'
import
{
notFound
}
from
'
../plugin/build
'
export
function
uniMiniProgramPluginPlugin
({
style
:
{
extname
},
}:
UniMiniProgramPluginOptions
):
Plugin
{
const
entry
=
initPluginEntry
()
const
rollupOptions
:
RollupOptions
=
{}
if
(
entry
)
{
rollupOptions
.
input
=
extend
(
{
app
:
resolveMainPathOnce
(
process
.
env
.
UNI_INPUT_DIR
),
},
entry
)
}
return
{
name
:
'
vite:uni-mp-plugin
'
,
enforce
:
'
post
'
,
config
()
{
return
{
build
:
{
rollupOptions
,
},
}
},
generateBundle
:
createNonAppGenerateBundle
(
extname
),
}
}
function
initPluginEntry
():
Record
<
string
,
string
>
|
void
{
const
pluginJsonFilename
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
MP_PLUGIN_JSON_NAME
)
if
(
!
fs
.
existsSync
(
pluginJsonFilename
))
{
notFound
(
pluginJsonFilename
)
}
const
pluginJson
=
parseJson
(
fs
.
readFileSync
(
pluginJsonFilename
,
'
utf8
'
),
true
)
if
(
!
pluginJson
.
main
)
{
return
}
const
mainFilename
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pluginJson
.
main
)
if
(
!
fs
.
existsSync
(
mainFilename
))
{
notFound
(
mainFilename
)
}
return
{
[
removeExt
(
pluginJson
.
main
)]:
mainFilename
,
}
}
packages/uni-mp-vite/src/plugins/subpackage.ts
浏览文件 @
ed13794b
import
{
OutputAsset
,
OutputChunk
}
from
'
rollup
'
import
{
OutputAsset
,
OutputChunk
,
OutputPluginHooks
}
from
'
rollup
'
import
type
{
Plugin
}
from
'
vite
'
import
{
isMiniProgramPageFile
,
relativeFile
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
../plugin
'
...
...
@@ -9,28 +9,34 @@ export function uniSubpackagePlugin({
return
{
name
:
'
vite:uni-mp-subpackage
'
,
enforce
:
'
post
'
,
generateBundle
(
_
,
bundle
)
{
;[
'
project.config.json
'
,
'
app.json
'
].
forEach
((
name
)
=>
{
delete
bundle
[
name
]
})
const
appJsFile
=
'
app.js
'
const
appCssFile
=
'
app
'
+
extname
Object
.
keys
(
bundle
).
forEach
((
name
)
=>
{
if
(
!
isMiniProgramPageFile
(
name
))
{
return
}
// 仅页面级 wxss 需要补充 app.wxss
if
(
name
.
endsWith
(
extname
))
{
const
cssFile
=
bundle
[
name
]
as
OutputAsset
cssFile
.
source
=
`@import "
${
relativeFile
(
name
,
appCssFile
)}
";\n`
+
cssFile
.
source
.
toString
()
}
else
if
(
name
.
endsWith
(
'
.js
'
))
{
const
jsFile
=
bundle
[
name
]
as
OutputChunk
jsFile
.
code
=
`require('
${
relativeFile
(
name
,
appJsFile
)}
');\n`
+
jsFile
.
code
}
})
},
generateBundle
:
createNonAppGenerateBundle
(
extname
),
}
}
export
function
createNonAppGenerateBundle
(
extname
:
string
):
OutputPluginHooks
[
'
generateBundle
'
]
{
return
function
generateBundle
(
_
,
bundle
)
{
;[
'
project.config.json
'
,
'
app.json
'
].
forEach
((
name
)
=>
{
delete
bundle
[
name
]
})
const
appJsFile
=
'
app.js
'
const
appCssFile
=
'
app
'
+
extname
Object
.
keys
(
bundle
).
forEach
((
name
)
=>
{
if
(
!
isMiniProgramPageFile
(
name
))
{
return
}
// 仅页面级 wxss 需要补充 app.wxss
if
(
name
.
endsWith
(
extname
))
{
const
cssFile
=
bundle
[
name
]
as
OutputAsset
cssFile
.
source
=
`@import "
${
relativeFile
(
name
,
appCssFile
)}
";\n`
+
cssFile
.
source
.
toString
()
}
else
if
(
name
.
endsWith
(
'
.js
'
))
{
const
jsFile
=
bundle
[
name
]
as
OutputChunk
jsFile
.
code
=
`require('
${
relativeFile
(
name
,
appJsFile
)}
');\n`
+
jsFile
.
code
}
})
}
}
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
ed13794b
...
...
@@ -4995,9 +4995,11 @@ var plugin = {
},
};
function
getCreateApp
()
{
const
method
=
process
.
env
.
UNI_SUBPACKAGE
?
'
createSubpackageApp
'
:
'
createApp
'
;
const
method
=
process
.
env
.
UNI_MP_PLUGIN
?
'
createPluginApp
'
:
process
.
env
.
UNI_SUBPACKAGE
?
'
createSubpackageApp
'
:
'
createApp
'
;
if
(
typeof
global
!==
'
undefined
'
)
{
return
global
[
method
];
}
...
...
packages/uni-mp-vue/src/plugin.ts
浏览文件 @
ed13794b
...
...
@@ -29,7 +29,9 @@ export default {
}
function
getCreateApp
()
{
const
method
=
process
.
env
.
UNI_SUBPACKAGE
const
method
=
process
.
env
.
UNI_MP_PLUGIN
?
'
createPluginApp
'
:
process
.
env
.
UNI_SUBPACKAGE
?
'
createSubpackageApp
'
:
'
createApp
'
if
(
typeof
global
!==
'
undefined
'
)
{
...
...
packages/uni-mp-weixin/dist/uni.compiler.js
浏览文件 @
ed13794b
...
...
@@ -91,6 +91,7 @@ const options = {
copyOptions
:
{
assets
:
[
'
wxcomponents
'
],
targets
:
[
...(
process
.
env
.
UNI_MP_PLUGIN
?
[
uniCliShared
.
copyMiniProgramPluginJson
]
:
[]),
{
src
:
[
'
theme.json
'
,
...
...
@@ -111,6 +112,7 @@ const options = {
app
:
{
darkmode
:
true
,
subpackages
:
true
,
plugins
:
true
,
},
project
:
{
filename
:
projectConfigFilename
,
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -284,23 +284,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
@@ -670,6 +672,12 @@ function initCreatePage(parseOptions) {
};
}
function
initCreatePluginApp
(
parseAppOptions
)
{
return
function
createApp
(
vm
)
{
initAppLifecycle
(
parseApp
(
vm
,
parseAppOptions
),
vm
);
};
}
const
ON_READY
=
'
onReady
'
;
const
MPPage
=
Page
;
...
...
@@ -787,10 +795,12 @@ var parseOptions = /*#__PURE__*/Object.freeze({
const
createApp
=
initCreateApp
();
const
createPage
=
initCreatePage
(
parseOptions
);
const
createComponent
=
initCreateComponent
(
parseOptions
);
const
createPluginApp
=
initCreatePluginApp
();
const
createSubpackageApp
=
initCreateSubpackageApp
();
wx
.
createApp
=
global
.
createApp
=
createApp
;
wx
.
createPage
=
createPage
;
wx
.
createComponent
=
createComponent
;
wx
.
createPluginApp
=
createPluginApp
;
wx
.
createSubpackageApp
=
createSubpackageApp
;
export
{
createApp
,
createComponent
,
createPage
,
createSubpackageApp
};
export
{
createApp
,
createComponent
,
createPage
,
create
PluginApp
,
create
SubpackageApp
};
packages/uni-mp-weixin/src/compiler/options.ts
浏览文件 @
ed13794b
...
...
@@ -2,6 +2,7 @@ import path from 'path'
import
type
{
CompilerOptions
}
from
'
@vue/compiler-core
'
import
{
COMPONENT_CUSTOM_HIDDEN
,
copyMiniProgramPluginJson
,
MiniProgramCompilerOptions
,
transformComponentLink
,
transformRef
,
...
...
@@ -46,6 +47,7 @@ export const options: UniMiniProgramPluginOptions = {
copyOptions
:
{
assets
:
[
'
wxcomponents
'
],
targets
:
[
...(
process
.
env
.
UNI_MP_PLUGIN
?
[
copyMiniProgramPluginJson
]
:
[]),
{
src
:
[
'
theme.json
'
,
...
...
@@ -66,6 +68,7 @@ export const options: UniMiniProgramPluginOptions = {
app
:
{
darkmode
:
true
,
subpackages
:
true
,
plugins
:
true
,
},
project
:
{
filename
:
projectConfigFilename
,
...
...
packages/uni-mp-weixin/src/runtime/index.ts
浏览文件 @
ed13794b
...
...
@@ -2,6 +2,7 @@ import {
initCreateApp
,
initCreatePage
,
initCreateComponent
,
initCreatePluginApp
,
initCreateSubpackageApp
,
}
from
'
@dcloudio/uni-mp-core
'
...
...
@@ -12,8 +13,10 @@ import * as parseOptions from './parseOptions'
export
const
createApp
=
initCreateApp
()
export
const
createPage
=
initCreatePage
(
parseOptions
)
export
const
createComponent
=
initCreateComponent
(
parseOptions
)
export
const
createPluginApp
=
initCreatePluginApp
()
export
const
createSubpackageApp
=
initCreateSubpackageApp
()
;(
wx
as
any
).
createApp
=
(
global
as
any
).
createApp
=
createApp
;(
wx
as
any
).
createPage
=
createPage
;(
wx
as
any
).
createComponent
=
createComponent
;(
wx
as
any
).
createPluginApp
=
createPluginApp
;(
wx
as
any
).
createSubpackageApp
=
createSubpackageApp
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
ed13794b
...
...
@@ -412,23 +412,25 @@ function initCreateSubpackageApp(parseAppOptions) {
app
[
name
]
=
appOptions
[
name
];
}
});
if
(
isFunction
(
appOptions
.
onShow
)
&&
qa
.
onAppShow
)
{
qa
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
qa
.
onAppHide
)
{
qa
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
qa
.
getLaunchOptionsSync
&&
qa
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
);
}
return
App
(
appOptions
);
initAppLifecycle
(
appOptions
,
vm
);
};
}
function
initAppLifecycle
(
appOptions
,
vm
)
{
if
(
isFunction
(
appOptions
.
onShow
)
&&
qa
.
onAppShow
)
{
qa
.
onAppShow
((
args
)
=>
{
vm
.
$callHook
(
'
onShow
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onHide
)
&&
qa
.
onAppHide
)
{
qa
.
onAppHide
((
args
)
=>
{
vm
.
$callHook
(
'
onHide
'
,
args
);
});
}
if
(
isFunction
(
appOptions
.
onLaunch
))
{
const
args
=
qa
.
getLaunchOptionsSync
&&
qa
.
getLaunchOptionsSync
();
vm
.
$callHook
(
'
onLaunch
'
,
args
||
{});
}
}
function
initLocale
(
appVm
)
{
const
locale
=
ref
(
qa
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
Object
.
defineProperty
(
appVm
,
'
$locale
'
,
{
...
...
packages/vite-plugin-uni/src/cli/index.ts
浏览文件 @
ed13794b
...
...
@@ -26,6 +26,7 @@ export interface CliOptions {
autoHost
?:
string
autoPort
?:
number
subpackage
?:
string
plugin
?:
boolean
}
cli
...
...
@@ -43,6 +44,7 @@ cli
.
option
(
'
--autoHost [autoHost]
'
,
`[string] specify automator hostname`
)
.
option
(
'
--autoPort [autoPort]
'
,
`[number] specify automator port`
)
.
option
(
'
--subpackage [subpackage]
'
,
`[string] specify subpackage to build`
)
.
option
(
'
--plugin
'
,
`[boolean] build plugin`
)
cli
.
command
(
''
)
...
...
packages/vite-plugin-uni/src/cli/utils.ts
浏览文件 @
ed13794b
...
...
@@ -47,6 +47,9 @@ export function initEnv(type: 'dev' | 'build', options: CliOptions) {
console
.
error
(
M
[
'
mp.360.unsupported
'
])
process
.
exit
(
0
)
}
if
(
options
.
plugin
)
{
process
.
env
.
UNI_MP_PLUGIN
=
'
true
'
}
if
(
type
===
'
dev
'
)
{
process
.
env
.
NODE_ENV
=
'
development
'
}
else
if
(
type
===
'
build
'
)
{
...
...
@@ -137,8 +140,8 @@ export function initEnv(type: 'dev' | 'build', options: CliOptions) {
}
function
initAutomator
({
autoHost
,
autoPort
}:
CliOptions
)
{
// 发行分包也不需要自动化测试
if
(
!
autoPort
||
process
.
env
.
UNI_SUBPACKAGE
)
{
// 发行分包
,插件
也不需要自动化测试
if
(
!
autoPort
||
process
.
env
.
UNI_SUBPACKAGE
||
process
.
env
.
UNI_MP_PLUGIN
)
{
return
}
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录