Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
744e3252
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
744e3252
编写于
1月 08, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
7614cfa4
b7153612
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
98 addition
and
25 deletion
+98
-25
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+32
-9
packages/vue-cli-plugin-uni-optimize/index.js
packages/vue-cli-plugin-uni-optimize/index.js
+2
-3
packages/vue-cli-plugin-uni/lib/app-plus/index.js
packages/vue-cli-plugin-uni/lib/app-plus/index.js
+11
-8
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+4
-2
packages/vue-cli-plugin-uni/lib/h5/index.js
packages/vue-cli-plugin-uni/lib/h5/index.js
+3
-0
packages/vue-cli-plugin-uni/lib/mp.js
packages/vue-cli-plugin-uni/lib/mp.js
+3
-0
packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js
packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js
+18
-1
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
...lugin-uni/packages/webpack-uni-app-loader/plugin/index.js
+23
-0
src/platforms/h5/components/system-routes/open-location/index.vue
...forms/h5/components/system-routes/open-location/index.vue
+2
-2
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
744e3252
...
@@ -330,17 +330,37 @@ const autoComponentMap = {}
...
@@ -330,17 +330,37 @@ const autoComponentMap = {}
let
lastUsingAutoImportComponentsJson
=
''
let
lastUsingAutoImportComponentsJson
=
''
process
.
UNI_AUTO_COMPONENTS
=
[]
let
uniAutoImportComponents
=
[]
let
uniAutoImportScanComponents
=
[]
function
initAutoImportScanComponents
()
{
const
componentsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
components
'
)
const
components
=
{}
try
{
fs
.
readdirSync
(
componentsPath
).
forEach
(
name
=>
{
if
(
fs
.
existsSync
(
path
.
resolve
(
componentsPath
,
name
,
name
+
'
.vue
'
)))
{
components
[
`^
${
name
}
$`
]
=
`@/components/
${
name
}
/
${
name
}
.vue`
}
else
if
(
fs
.
existsSync
(
path
.
resolve
(
componentsPath
,
name
,
name
+
'
.nvue
'
)))
{
components
[
`^
${
name
}
$`
]
=
`@/components/
${
name
}
/
${
name
}
.nvue`
}
})
}
catch
(
e
)
{}
uniAutoImportScanComponents
=
parseUsingAutoImportComponents
(
components
)
refreshAutoComponentMap
()
}
function
initAutoImportComponents
(
usingAutoImportComponents
=
{})
{
function
initAutoImportComponents
(
usingAutoImportComponents
=
{})
{
// 目前仅 mp-weixin 内置支持 page-meta 等组件
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
)
{
if
(
!
usingAutoImportComponents
[
'
page-meta
'
])
{
if
(
!
usingAutoImportComponents
[
'
^page-meta$
'
])
{
usingAutoImportComponents
[
'
page-meta
'
]
=
usingAutoImportComponents
[
'
^page-meta$
'
]
=
'
@dcloudio/uni-cli-shared/components/page-meta.vue
'
'
@dcloudio/uni-cli-shared/components/page-meta.vue
'
}
}
if
(
!
usingAutoImportComponents
[
'
navigation-bar
'
])
{
if
(
!
usingAutoImportComponents
[
'
^navigation-bar$
'
])
{
usingAutoImportComponents
[
'
navigation-bar
'
]
=
usingAutoImportComponents
[
'
^navigation-bar$
'
]
=
'
@dcloudio/uni-cli-shared/components/navigation-bar.vue
'
'
@dcloudio/uni-cli-shared/components/navigation-bar.vue
'
}
}
}
}
...
@@ -348,7 +368,7 @@ function initAutoImportComponents (usingAutoImportComponents = {}) {
...
@@ -348,7 +368,7 @@ function initAutoImportComponents (usingAutoImportComponents = {}) {
const
newUsingAutoImportComponentsJson
=
JSON
.
stringify
(
usingAutoImportComponents
)
const
newUsingAutoImportComponentsJson
=
JSON
.
stringify
(
usingAutoImportComponents
)
if
(
newUsingAutoImportComponentsJson
!==
lastUsingAutoImportComponentsJson
)
{
if
(
newUsingAutoImportComponentsJson
!==
lastUsingAutoImportComponentsJson
)
{
lastUsingAutoImportComponentsJson
=
newUsingAutoImportComponentsJson
lastUsingAutoImportComponentsJson
=
newUsingAutoImportComponentsJson
process
.
UNI_AUTO_COMPONENTS
=
parseUsingAutoImportComponents
(
usingAutoImportComponents
)
uniAutoImportComponents
=
parseUsingAutoImportComponents
(
usingAutoImportComponents
)
refreshAutoComponentMap
()
refreshAutoComponentMap
()
}
}
}
}
...
@@ -363,8 +383,10 @@ function refreshAutoComponentMap () {
...
@@ -363,8 +383,10 @@ function refreshAutoComponentMap () {
}
}
function
addAutoComponent
(
name
)
{
function
addAutoComponent
(
name
)
{
const
options
=
process
.
UNI_AUTO_COMPONENTS
let
opt
=
uniAutoImportComponents
.
find
(
opt
=>
opt
.
pattern
.
test
(
name
))
const
opt
=
options
.
find
(
opt
=>
opt
.
pattern
.
test
(
name
))
if
(
!
opt
)
{
opt
=
uniAutoImportScanComponents
.
find
(
opt
=>
opt
.
pattern
.
test
(
name
))
}
if
(
!
opt
)
{
// 不匹配
if
(
!
opt
)
{
// 不匹配
return
(
autoComponentMap
[
name
]
=
true
)
// cache
return
(
autoComponentMap
[
name
]
=
true
)
// cache
}
}
...
@@ -411,6 +433,7 @@ module.exports = {
...
@@ -411,6 +433,7 @@ module.exports = {
pagesJsonJsFileName
,
pagesJsonJsFileName
,
getAutoComponents
,
getAutoComponents
,
initAutoImportComponents
,
initAutoImportComponents
,
initAutoImportScanComponents
,
addPageUsingComponents
,
addPageUsingComponents
,
getUsingComponentsCode
,
getUsingComponentsCode
,
generateUsingComponentsCode
,
generateUsingComponentsCode
,
...
...
packages/vue-cli-plugin-uni-optimize/index.js
浏览文件 @
744e3252
...
@@ -80,11 +80,10 @@ module.exports = (api, options) => {
...
@@ -80,11 +80,10 @@ module.exports = (api, options) => {
webpackConfig
.
module
webpackConfig
.
module
.
rule
(
'
vue
'
)
.
rule
(
'
vue
'
)
.
use
(
'
vue-loader
'
)
.
use
(
'
vue-loader
'
)
.
loader
(
resolve
(
'
packages/vue-loader
'
))
.
tap
(
options
=>
Object
.
assign
(
options
,
{
.
tap
(
options
=>
Object
.
assign
(
options
,
{
isH5TreeShaking
:
true
,
cacheDirectory
:
false
,
cacheDirectory
:
false
,
cacheIdentifier
:
false
,
cacheIdentifier
:
false
compilerOptions
:
require
(
'
@dcloudio/vue-cli-plugin-uni/lib/h5/compiler-options
'
)
}))
}))
.
end
()
.
end
()
.
uses
.
uses
...
...
packages/vue-cli-plugin-uni/lib/app-plus/index.js
浏览文件 @
744e3252
...
@@ -11,6 +11,8 @@ const {
...
@@ -11,6 +11,8 @@ const {
getGlobalUsingComponentsCode
getGlobalUsingComponentsCode
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
WebpackUniAppPlugin
=
require
(
'
../../packages/webpack-uni-app-loader/plugin/index
'
)
const
{
const
{
isUnaryTag
,
isUnaryTag
,
getPartialIdentifier
getPartialIdentifier
...
@@ -172,6 +174,7 @@ const v3 = {
...
@@ -172,6 +174,7 @@ const v3 = {
]
]
},
},
plugins
:
[
plugins
:
[
new
WebpackUniAppPlugin
(),
new
webpack
.
ProvidePlugin
(
getProvides
(
isAppService
))
new
webpack
.
ProvidePlugin
(
getProvides
(
isAppService
))
]
]
}
}
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
744e3252
...
@@ -312,9 +312,11 @@ if (
...
@@ -312,9 +312,11 @@ if (
}
}
const
{
const
{
initAutoImportComponents
initAutoImportComponents
,
initAutoImportScanComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
initAutoImportScanComponents
()
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
initAutoImportComponents
(
pagesJsonObj
.
easycom
)
runByHBuilderX
&&
console
.
log
(
`正在编译中...`
)
runByHBuilderX
&&
console
.
log
(
`正在编译中...`
)
...
...
packages/vue-cli-plugin-uni/lib/h5/index.js
浏览文件 @
744e3252
...
@@ -15,6 +15,8 @@ const modifyVueLoader = require('../vue-loader')
...
@@ -15,6 +15,8 @@ const modifyVueLoader = require('../vue-loader')
const
WebpackHtmlAppendPlugin
=
require
(
'
../../packages/webpack-html-append-plugin
'
)
const
WebpackHtmlAppendPlugin
=
require
(
'
../../packages/webpack-html-append-plugin
'
)
const
WebpackUniAppPlugin
=
require
(
'
../../packages/webpack-uni-app-loader/plugin/index
'
)
function
resolve
(
dir
)
{
function
resolve
(
dir
)
{
return
path
.
resolve
(
__dirname
,
'
../../
'
,
dir
)
return
path
.
resolve
(
__dirname
,
'
../../
'
,
dir
)
}
}
...
@@ -41,6 +43,7 @@ function getProvides () {
...
@@ -41,6 +43,7 @@ function getProvides () {
}
}
const
plugins
=
[
const
plugins
=
[
new
WebpackUniAppPlugin
(),
new
webpack
.
ProvidePlugin
(
getProvides
())
new
webpack
.
ProvidePlugin
(
getProvides
())
]
]
...
...
packages/vue-cli-plugin-uni/lib/mp.js
浏览文件 @
744e3252
...
@@ -8,6 +8,8 @@ const {
...
@@ -8,6 +8,8 @@ const {
getPlatformCssnano
getPlatformCssnano
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
WebpackUniAppPlugin
=
require
(
'
../packages/webpack-uni-app-loader/plugin/index
'
)
const
modifyVueLoader
=
require
(
'
./vue-loader
'
)
const
modifyVueLoader
=
require
(
'
./vue-loader
'
)
const
{
const
{
...
@@ -157,6 +159,7 @@ module.exports = {
...
@@ -157,6 +159,7 @@ module.exports = {
}]
}]
},
},
plugins
:
[
plugins
:
[
new
WebpackUniAppPlugin
(),
createUniMPPlugin
(),
createUniMPPlugin
(),
new
webpack
.
ProvidePlugin
(
getProvides
())
new
webpack
.
ProvidePlugin
(
getProvides
())
]
]
...
...
packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js
浏览文件 @
744e3252
...
@@ -13,7 +13,7 @@ const componentNormalizerPath = require.resolve('./runtime/componentNormalizer')
...
@@ -13,7 +13,7 @@ const componentNormalizerPath = require.resolve('./runtime/componentNormalizer')
const
{
NS
}
=
require
(
'
./plugin
'
)
const
{
NS
}
=
require
(
'
./plugin
'
)
let
errorEmitted
=
false
let
errorEmitted
=
false
let
modules
// h5 平台摇树优化时,需要保留编译器原始modules(因为框架内代码不需要modules,开发者代码需要)
function
loadTemplateCompiler
(
loaderContext
)
{
function
loadTemplateCompiler
(
loaderContext
)
{
try
{
try
{
return
require
(
'
vue-template-compiler
'
)
return
require
(
'
vue-template-compiler
'
)
...
@@ -75,6 +75,23 @@ module.exports = function (source) {
...
@@ -75,6 +75,23 @@ module.exports = function (source) {
isAppNVue
:
options
.
isAppNVue
isAppNVue
:
options
.
isAppNVue
})
})
if
(
options
.
isH5TreeShaking
)
{
// 摇树优化逻辑(框架组件移除样式,禁用 modules)
const
isWin
=
/^win/
.
test
(
process
.
platform
)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
// fixed by xxxxxx
if
(
!
modules
&&
options
.
compilerOptions
&&
options
.
compilerOptions
.
modules
){
modules
=
options
.
compilerOptions
.
modules
}
const
sourcePath
=
normalizePath
(
require
(
'
@dcloudio/uni-h5/path
'
).
src
)
if
(
normalizePath
(
this
.
resourcePath
).
indexOf
(
sourcePath
)
===
0
)
{
descriptor
.
styles
.
length
=
0
options
.
compilerOptions
&&
(
delete
options
.
compilerOptions
.
modules
)
}
else
if
(
options
.
compilerOptions
){
options
.
compilerOptions
.
modules
=
modules
}
}
// if the query has a type field, this is a language block request
// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
// e.g. foo.vue?type=template&id=xxxxx
// and we will return early
// and we will return early
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
0 → 100644
浏览文件 @
744e3252
const
path
=
require
(
'
path
'
)
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
initAutoImportScanComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
class
WebpackUniAppPlugin
{
apply
(
compiler
)
{
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-app-invalid
'
,
(
fileName
,
changeTime
)
=>
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
if
(
fileName
.
indexOf
(
'
.vue
'
)
!==
-
1
||
fileName
.
indexOf
(
'
.nvue
'
)
!==
-
1
)
{
initAutoImportScanComponents
()
}
}
})
}
}
module
.
exports
=
WebpackUniAppPlugin
src/platforms/h5/components/system-routes/open-location/index.vue
浏览文件 @
744e3252
...
@@ -70,7 +70,7 @@ export default {
...
@@ -70,7 +70,7 @@ export default {
},
},
_nav
()
{
_nav
()
{
var
url
=
var
url
=
`https://apis.map.qq.com/uri/v1/routeplan?type=drive&to=
${
encodeURIComponent
(
this
.
name
||
'
目的地
'
)}
&tocoord=
${
this
.
latitude
}
,
${
this
.
longitude
}
&referer=
${
referer
}
`
`https://map.qq.com/nav/drive#routes/page?transport=2&epointy=
${
this
.
latitude
}
&epointx=
${
this
.
longitude
}
&eword=
${
encodeURIComponent
(
this
.
name
||
'
目的地
'
)
}
&referer=
${
referer
}
`
this
.
$refs
.
map
.
src
=
url
this
.
$refs
.
map
.
src
=
url
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录