Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
uni-app
提交
29b404ee
U
uni-app
项目概览
Metz
/
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,发现更多精彩内容 >>
提交
29b404ee
编写于
10月 18, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(ext-api): add warning
上级
397f6324
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
13 deletion
+47
-13
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
+9
-6
packages/vue-cli-plugin-uni/lib/configure-webpack.js
packages/vue-cli-plugin-uni/lib/configure-webpack.js
+14
-4
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+24
-3
未找到文件。
packages/uni-cli-shared/lib/uni_modules/uni_modules.js
浏览文件 @
29b404ee
...
@@ -7,7 +7,7 @@ exports.parseInject = exports.parseInjects = exports.parseUniExtApis = void 0;
...
@@ -7,7 +7,7 @@ exports.parseInject = exports.parseInjects = exports.parseUniExtApis = void 0;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
fs_extra_1
=
__importDefault
(
require
(
"
fs-extra
"
));
const
fs_extra_1
=
__importDefault
(
require
(
"
fs-extra
"
));
const
merge_1
=
require
(
"
merge
"
);
const
merge_1
=
require
(
"
merge
"
);
function
parseUniExtApis
()
{
function
parseUniExtApis
(
vite
=
true
)
{
const
uniModulesDir
=
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
);
const
uniModulesDir
=
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
);
if
(
!
fs_extra_1
.
default
.
existsSync
(
uniModulesDir
))
{
if
(
!
fs_extra_1
.
default
.
existsSync
(
uniModulesDir
))
{
return
{};
return
{};
...
@@ -25,7 +25,10 @@ function parseUniExtApis() {
...
@@ -25,7 +25,10 @@ function parseUniExtApis() {
}
}
const
exports
=
(
_b
=
(
_a
=
JSON
.
parse
(
fs_extra_1
.
default
.
readFileSync
(
pkgPath
,
'
utf8
'
)))
===
null
||
_a
===
void
0
?
void
0
:
_a
.
uni_modules
)
===
null
||
_b
===
void
0
?
void
0
:
_b
[
'
uni-ext-api
'
];
const
exports
=
(
_b
=
(
_a
=
JSON
.
parse
(
fs_extra_1
.
default
.
readFileSync
(
pkgPath
,
'
utf8
'
)))
===
null
||
_a
===
void
0
?
void
0
:
_a
.
uni_modules
)
===
null
||
_b
===
void
0
?
void
0
:
_b
[
'
uni-ext-api
'
];
if
(
exports
)
{
if
(
exports
)
{
Object
.
assign
(
injects
,
parseInjects
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
));
Object
.
assign
(
injects
,
parseInjects
(
vite
,
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
+
(
vite
||
!
process
.
env
.
UNI_UTS_PLATFORM
?
''
:
`/utssdk/
${
process
.
env
.
UNI_UTS_PLATFORM
}
/index`
),
exports
));
}
}
});
});
return
injects
;
return
injects
;
...
@@ -52,7 +55,7 @@ exports.parseUniExtApis = parseUniExtApis;
...
@@ -52,7 +55,7 @@ exports.parseUniExtApis = parseUniExtApis;
* @param define
* @param define
* @returns
* @returns
*/
*/
function
parseInjects
(
platform
,
source
,
exports
=
{})
{
function
parseInjects
(
vite
=
true
,
platform
,
source
,
exports
=
{})
{
let
rootDefines
=
{};
let
rootDefines
=
{};
Object
.
keys
(
exports
).
forEach
((
name
)
=>
{
Object
.
keys
(
exports
).
forEach
((
name
)
=>
{
if
(
name
.
startsWith
(
'
uni
'
))
{
if
(
name
.
startsWith
(
'
uni
'
))
{
...
@@ -69,18 +72,18 @@ function parseInjects(platform, source, exports = {}) {
...
@@ -69,18 +72,18 @@ function parseInjects(platform, source, exports = {}) {
}
}
const
injects
=
{};
const
injects
=
{};
for
(
const
key
in
rootDefines
)
{
for
(
const
key
in
rootDefines
)
{
Object
.
assign
(
injects
,
parseInject
(
source
,
'
uni
'
,
rootDefines
[
key
]));
Object
.
assign
(
injects
,
parseInject
(
vite
,
source
,
'
uni
'
,
rootDefines
[
key
]));
}
}
return
injects
;
return
injects
;
}
}
exports
.
parseInjects
=
parseInjects
;
exports
.
parseInjects
=
parseInjects
;
function
parseInject
(
source
,
globalObject
,
define
)
{
function
parseInject
(
vite
=
true
,
source
,
globalObject
,
define
)
{
const
injects
=
{};
const
injects
=
{};
if
(
define
===
false
)
{
if
(
define
===
false
)
{
}
}
else
if
(
typeof
define
===
'
string
'
)
{
else
if
(
typeof
define
===
'
string
'
)
{
// {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
// {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
injects
[
globalObject
+
'
.
'
+
define
]
=
source
;
injects
[
globalObject
+
'
.
'
+
define
]
=
vite
?
source
:
[
source
,
'
default
'
]
;
}
}
else
if
(
Array
.
isArray
(
define
))
{
else
if
(
Array
.
isArray
(
define
))
{
// {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
// {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
...
...
packages/vue-cli-plugin-uni/lib/configure-webpack.js
浏览文件 @
29b404ee
...
@@ -230,10 +230,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
...
@@ -230,10 +230,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
webpackConfig
.
resolve
.
modules
=
webpackConfig
.
resolve
.
modules
.
filter
(
module
=>
module
!==
'
node_modules
'
)
webpackConfig
.
resolve
.
modules
=
webpackConfig
.
resolve
.
modules
.
filter
(
module
=>
module
!==
'
node_modules
'
)
}
}
const
plugins
=
[
const
plugins
=
[]
new
webpack
.
ProvidePlugin
(
require
(
'
@dcloudio/uni-cli-shared/lib/uni_modules/uni_modules
'
)
.
parseUniExtApis
())
]
const
isAppView
=
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
const
isAppView
=
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
vueOptions
.
pluginOptions
&&
vueOptions
.
pluginOptions
&&
...
@@ -245,6 +242,19 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
...
@@ -245,6 +242,19 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
plugins
.
push
(
new
CopyWebpackPlugin
(
CopyWebpackPluginVersion
>
5
?
{
plugins
.
push
(
new
CopyWebpackPlugin
(
CopyWebpackPluginVersion
>
5
?
{
patterns
patterns
}
:
patterns
))
}
:
patterns
))
const
uniExtApis
=
require
(
'
@dcloudio/uni-cli-shared/lib/uni_modules/uni_modules
'
)
.
parseUniExtApis
(
false
)
const
keys
=
Object
.
keys
(
uniExtApis
)
if
(
keys
.
length
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
keys
.
forEach
(
key
=>
{
console
.
warn
(
`[
${
uniExtApis
[
key
][
0
].
split
(
'
/
'
)[
2
]}
]: uts目前仅支持vue3`
)
})
}
else
{
plugins
.
push
(
new
webpack
.
ProvidePlugin
(
uniExtApis
))
}
}
}
}
if
(
!
process
.
env
.
UNI_SUBPACKGE
||
!
process
.
env
.
UNI_MP_PLUGIN
)
{
if
(
!
process
.
env
.
UNI_SUBPACKGE
||
!
process
.
env
.
UNI_MP_PLUGIN
)
{
try
{
try
{
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
29b404ee
...
@@ -148,6 +148,23 @@ if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0
...
@@ -148,6 +148,23 @@ if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0
process
.
env
.
UNI_PLATFORM
=
process
.
env
.
UNI_PLATFORM
||
'
h5
'
process
.
env
.
UNI_PLATFORM
=
process
.
env
.
UNI_PLATFORM
||
'
h5
'
process
.
env
.
VUE_APP_PLATFORM
=
process
.
env
.
UNI_PLATFORM
process
.
env
.
VUE_APP_PLATFORM
=
process
.
env
.
UNI_PLATFORM
process
.
env
.
UNI_OUTPUT_DIR
=
process
.
env
.
UNI_OUTPUT_DIR
||
process
.
env
.
UNI_OUTPUT_DEFAULT_DIR
process
.
env
.
UNI_OUTPUT_DIR
=
process
.
env
.
UNI_OUTPUT_DIR
||
process
.
env
.
UNI_OUTPUT_DEFAULT_DIR
initUtsPlatform
()
function
initUtsPlatform
()
{
if
(
process
.
env
.
UNI_APP_PLATFORM
===
'
android
'
)
{
process
.
env
.
UNI_UTS_PLATFORM
=
'
app-android
'
}
if
(
process
.
env
.
UNI_APP_PLATFORM
===
'
ios
'
)
{
process
.
env
.
UNI_UTS_PLATFORM
=
'
app-ios
'
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
{
process
.
env
.
UNI_UTS_PLATFORM
=
'
web
'
}
else
{
if
(
!
process
.
env
.
UNI_UTS_PLATFORM
)
{
process
.
env
.
UNI_UTS_PLATFORM
=
process
.
env
.
UNI_PLATFORM
}
}
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
process
.
env
.
UNI_OUTPUT_TMP_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
../.tmp/app-plus
'
)
process
.
env
.
UNI_OUTPUT_TMP_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
../.tmp/app-plus
'
)
...
@@ -367,7 +384,9 @@ if (
...
@@ -367,7 +384,9 @@ if (
}
else
{
}
else
{
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
if
(
version
===
'
2
'
)
{
if
(
version
===
'
2
'
)
{
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
}
}
}
}
}
}
...
@@ -379,7 +398,9 @@ if (
...
@@ -379,7 +398,9 @@ if (
}
else
{
}
else
{
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
uniStatLog
(
`已开启 uni统计
${
uniStatistics
.
version
}
.0 版本`
)
if
(
version
===
'
2
'
)
{
if
(
version
===
'
2
'
)
{
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
uniStatLog
(
'
【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097
'
)
}
}
}
}
}
}
...
@@ -569,4 +590,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
...
@@ -569,4 +590,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
module
.
exports
=
{
module
.
exports
=
{
manifestPlatformOptions
:
platformOptions
manifestPlatformOptions
:
platformOptions
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录