Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_38335589
uni-app
提交
6e2e7815
U
uni-app
项目概览
weixin_38335589
/
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,发现更多精彩内容 >>
提交
6e2e7815
编写于
8月 20, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): support match-media
上级
03cc15dd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
27 deletion
+50
-27
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+21
-9
packages/uni-template-compiler/lib/util.js
packages/uni-template-compiler/lib/util.js
+11
-3
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
...es/webpack-uni-mp-loader/lib/plugin/generate-component.js
+6
-5
packages/webpack-uni-mp-loader/lib/script-new.js
packages/webpack-uni-mp-loader/lib/script-new.js
+7
-6
packages/webpack-uni-mp-loader/lib/template.js
packages/webpack-uni-mp-loader/lib/template.js
+5
-4
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
6e2e7815
...
...
@@ -111,7 +111,7 @@ function isNVuePage (page, root = '') {
}
function
isValidPage
(
page
,
root
=
''
)
{
if
(
typeof
page
===
'
string
'
||
!
page
.
path
)
{
// 不合法的配置
if
(
typeof
page
===
'
string
'
||
!
page
.
path
)
{
// 不合法的配置
console
.
warn
(
'
pages.json 页面配置错误, 已被忽略, 查看文档: https://uniapp.dcloud.io/collocation/pages?id=pages
'
)
return
false
}
...
...
@@ -392,14 +392,13 @@ function initAutoImportComponents (easycom = {}) {
}
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
!
usingAutoImportComponents
[
'
^page-meta$
'
])
{
usingAutoImportComponents
[
'
^page-meta$
'
]
=
'
@dcloudio/uni-cli-shared/components/page-meta.vue
'
}
if
(
!
usingAutoImportComponents
[
'
^navigation-bar$
'
])
{
usingAutoImportComponents
[
'
^navigation-bar$
'
]
=
'
@dcloudio/uni-cli-shared/components/navigation-bar.vue
'
}
BUILT_IN_COMPONENTS
.
forEach
(
name
=>
{
const
easycomName
=
`^
${
name
}
$`
if
(
!
usingAutoImportComponents
[
easycomName
])
{
usingAutoImportComponents
[
easycomName
]
=
'
@dcloudio/uni-cli-shared/components/
'
+
name
+
'
.vue
'
}
})
}
const
newUsingAutoImportComponentsJson
=
JSON
.
stringify
(
usingAutoImportComponents
)
...
...
@@ -463,7 +462,20 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
}
return
autoImportComponents
}
const
BUILT_IN_COMPONENTS
=
[
'
page-meta
'
,
'
navigation-bar
'
,
'
match-media
'
]
function
isBuiltInComponent
(
name
)
{
return
BUILT_IN_COMPONENTS
.
includes
(
name
)
}
function
isBuiltInComponentPath
(
modulePath
)
{
return
!!
BUILT_IN_COMPONENTS
.
find
(
name
=>
modulePath
.
includes
(
name
))
}
module
.
exports
=
{
isBuiltInComponent
,
isBuiltInComponentPath
,
getMainEntry
,
getNVueMainEntry
,
parsePages
,
...
...
packages/uni-template-compiler/lib/util.js
浏览文件 @
6e2e7815
...
...
@@ -181,6 +181,10 @@ function hasOwn (obj, key) {
const
tags
=
require
(
'
@dcloudio/uni-cli-shared/lib/tags
'
)
const
{
isBuiltInComponent
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
getTagName
}
=
require
(
'
./h5
'
)
...
...
@@ -196,7 +200,7 @@ function isComponent (tagName) {
}
// mp-weixin 底层支持 page-meta,navigation-bar
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
)
{
if
(
tagName
===
'
page-meta
'
||
tagName
===
'
navigation-bar
'
)
{
if
(
isBuiltInComponent
(
tagName
)
)
{
return
false
}
}
...
...
@@ -219,7 +223,11 @@ function makeMap (str, expectsLowerCase) {
* @param {*} node
*/
function
isSimpleObjectExpression
(
node
)
{
return
t
.
isObjectExpression
(
node
)
&&
!
node
.
properties
.
find
(({
key
,
value
})
=>
!
t
.
isIdentifier
(
key
)
||
!
(
t
.
isIdentifier
(
value
)
||
t
.
isStringLiteral
(
value
)
||
t
.
isBooleanLiteral
(
value
)
||
t
.
isNumericLiteral
(
value
)
||
t
.
isNullLiteral
(
value
)))
return
t
.
isObjectExpression
(
node
)
&&
!
node
.
properties
.
find
(({
key
,
value
})
=>
!
t
.
isIdentifier
(
key
)
||
!
(
t
.
isIdentifier
(
value
)
||
t
.
isStringLiteral
(
value
)
||
t
.
isBooleanLiteral
(
value
)
||
t
.
isNumericLiteral
(
value
)
||
t
.
isNullLiteral
(
value
)))
}
module
.
exports
=
{
...
...
@@ -253,4 +261,4 @@ module.exports = {
processMemberExpression
,
getForIndexIdentifier
,
isSimpleObjectExpression
}
}
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
浏览文件 @
6e2e7815
...
...
@@ -10,6 +10,10 @@ const {
getJsonFile
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
isBuiltInComponentPath
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
restoreNodeModules
}
=
require
(
'
../shared
'
)
...
...
@@ -88,10 +92,7 @@ module.exports = function generateComponent (compilation) {
if
(
/^win/
.
test
(
process
.
platform
)
&&
modulePath
.
includes
(
'
@dcloudio
'
)
&&
(
modulePath
.
includes
(
'
page-meta
'
)
||
modulePath
.
includes
(
'
navigation-bar
'
)
)
isBuiltInComponentPath
(
modulePath
)
)
{
resource
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_CLI_CONTEXT
,
modulePath
))
}
...
...
@@ -233,4 +234,4 @@ function removeUnusedComponent (name) {
fs
.
renameSync
(
path
.
join
(
process
.
env
.
UNI_OUTPUT_DIR
,
name
+
'
.json
'
),
path
.
join
(
process
.
env
.
UNI_OUTPUT_DIR
,
name
+
'
.bak.json
'
))
}
catch
(
e
)
{}
}
}
packages/webpack-uni-mp-loader/lib/script-new.js
浏览文件 @
6e2e7815
...
...
@@ -12,7 +12,11 @@ const {
const
{
getBabelParserOptions
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
const
{
isBuiltInComponentPath
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
updateUsingComponents
...
...
@@ -61,11 +65,8 @@ module.exports = function (content, map) {
if
(
// windows 上 page-meta, navigation-bar 可能在不同盘上
/^win/
.
test
(
process
.
platform
)
&&
path
.
isAbsolute
(
resourcePath
)
&&
(
resourcePath
.
indexOf
(
'
page-meta
'
)
!==
-
1
||
resourcePath
.
indexOf
(
'
navigation-bar
'
)
!==
-
1
)
path
.
isAbsolute
(
resourcePath
)
&&
isBuiltInComponentPath
(
resourcePath
)
)
{
resourcePath
=
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_CLI_CONTEXT
,
resourcePath
))
}
...
...
packages/webpack-uni-mp-loader/lib/template.js
浏览文件 @
6e2e7815
...
...
@@ -19,6 +19,10 @@ const {
updateUsingGlobalComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
isBuiltInComponentPath
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
getPlatformFilterTag
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
...
...
@@ -49,10 +53,7 @@ module.exports = function (content, map) {
if
(
// windows 上 page-meta, navigation-bar 可能在不同盘上
/^win/
.
test
(
process
.
platform
)
&&
path
.
isAbsolute
(
resourcePath
)
&&
(
resourcePath
.
indexOf
(
'
page-meta
'
)
!==
-
1
||
resourcePath
.
indexOf
(
'
navigation-bar
'
)
!==
-
1
)
isBuiltInComponentPath
(
resourcePath
)
)
{
resourcePath
=
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_CLI_CONTEXT
,
resourcePath
))
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录