Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wychl
uni-app
提交
928629c5
U
uni-app
项目概览
wychl
/
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,发现更多精彩内容 >>
提交
928629c5
编写于
8月 28, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
8ae251ad
5617c587
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
326 addition
and
121 deletion
+326
-121
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+24
-6
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+28
-1
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+2
-1
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+2
-1
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+2
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+3
-1
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
...ni-template-compiler/__tests__/compiler-mp-alipay.spec.js
+45
-38
packages/uni-template-compiler/__tests__/demo.js
packages/uni-template-compiler/__tests__/demo.js
+1
-2
packages/uni-template-compiler/lib/index.js
packages/uni-template-compiler/lib/index.js
+6
-0
packages/uni-template-compiler/lib/module-alipay.js
packages/uni-template-compiler/lib/module-alipay.js
+26
-0
packages/uni-template-compiler/lib/platforms/mp-alipay.js
packages/uni-template-compiler/lib/platforms/mp-alipay.js
+1
-1
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+5
-3
packages/vue-cli-plugin-uni/lib/mp.js
packages/vue-cli-plugin-uni/lib/mp.js
+2
-2
packages/vue-cli-plugin-uni/lib/split-chunks.js
packages/vue-cli-plugin-uni/lib/split-chunks.js
+9
-6
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.js
...-plugin-uni/packages/webpack-custom-block-loader/index.js
+1
-1
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
+22
-6
packages/webpack-uni-mp-loader/lib/plugin/index.js
packages/webpack-uni-mp-loader/lib/plugin/index.js
+22
-6
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+12
-1
packages/webpack-uni-pages-loader/lib/index.js
packages/webpack-uni-pages-loader/lib/index.js
+13
-2
packages/webpack-uni-pages-loader/lib/platforms/mp-alipay.js
packages/webpack-uni-pages-loader/lib/platforms/mp-alipay.js
+9
-1
src/platforms/app-plus/service/api/device/scan-code.js
src/platforms/app-plus/service/api/device/scan-code.js
+14
-17
src/platforms/app-plus/service/api/location/choose-location.js
...latforms/app-plus/service/api/location/choose-location.js
+36
-21
src/platforms/app-plus/service/framework/app.js
src/platforms/app-plus/service/framework/app.js
+12
-1
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
+28
-1
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
928629c5
...
...
@@ -35,8 +35,8 @@ function getPagesJson () {
return
processPagesJson
(
getJson
(
'
pages.json
'
,
true
))
}
function
parsePagesJson
(
content
)
{
return
processPagesJson
(
parseJson
(
content
,
true
))
function
parsePagesJson
(
content
,
loader
)
{
return
processPagesJson
(
parseJson
(
content
,
true
)
,
loader
)
}
function
filterPages
(
pages
=
[],
root
)
{
...
...
@@ -48,7 +48,25 @@ function filterPages (pages = [], root) {
}
}
function
processPagesJson
(
pagesJson
)
{
const
pagesJsonJsFileName
=
'
pages.js
'
function
processPagesJson
(
pagesJson
,
loader
=
{
addDependency
:
function
()
{}
})
{
const
pagesJsonJsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pagesJsonJsFileName
)
if
(
fs
.
existsSync
(
pagesJsonJsPath
))
{
delete
require
.
cache
[
pagesJsonJsPath
]
const
pagesJsonJsFn
=
require
(
pagesJsonJsPath
)
if
(
typeof
pagesJsonJsFn
===
'
function
'
)
{
pagesJson
=
pagesJsonJsFn
(
pagesJson
,
loader
)
if
(
!
pagesJson
)
{
console
.
error
(
`
${
pagesJsonJsFileName
}
必须返回一个 json 对象`
)
}
}
else
{
console
.
error
(
`
${
pagesJsonJsFileName
}
必须导出 function`
)
}
}
let
uniNVueEntryPagePath
if
(
pagesJson
.
pages
&&
pagesJson
.
pages
.
length
)
{
// 如果首页是 nvue
if
(
isNVuePage
(
pagesJson
.
pages
[
0
]))
{
...
...
@@ -86,7 +104,7 @@ function isNVuePage (page, root = '') {
}
function
isValidPage
(
page
,
root
=
''
)
{
if
(
typeof
page
===
'
string
'
)
{
// 不合法的配置
if
(
typeof
page
===
'
string
'
)
{
// 不合法的配置
console
.
warn
(
`
${
page
}
配置错误, 已被忽略, 查看文档: https://uniapp.dcloud.io/collocation/pages?id=pages`
)
return
false
}
...
...
@@ -193,7 +211,6 @@ function parseEntry (pagesJson) {
process
.
UNI_NVUE_ENTRY
=
{}
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
// TODO 考虑 pages.json.js
process
.
UNI_NVUE_ENTRY
[
'
app-config
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json
'
)
process
.
UNI_NVUE_ENTRY
[
'
app-service
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
...
...
@@ -231,5 +248,6 @@ module.exports = {
parsePages
,
parseEntry
,
getPagesJson
,
parsePagesJson
parsePagesJson
,
pagesJsonJsFileName
}
packages/uni-cli-shared/lib/platform.js
浏览文件 @
928629c5
...
...
@@ -238,7 +238,7 @@ const PLATFORMS = {
vue
:
megaloRuntime
,
compiler
:
megaloCompiler
,
megalo
:
'
alipay
'
,
filterTag
:
'
import-
sjs
'
,
filterTag
:
'
sjs
'
,
subPackages
:
true
,
cssVars
:
{
'
--status-bar-height
'
:
'
25px
'
,
...
...
packages/uni-mp-alipay/dist/index.js
浏览文件 @
928629c5
...
...
@@ -1811,7 +1811,7 @@ const handleLink$1 = (function () {
}
})();
function
parseApp
(
vm
)
{
function
parseApp
(
vm
)
{
Object
.
defineProperty
(
Vue
.
prototype
,
'
$slots
'
,
{
get
()
{
return
this
.
$scope
&&
this
.
$scope
.
props
.
$slots
...
...
@@ -1829,6 +1829,33 @@ function parseApp (vm) {
}
});
Vue
.
prototype
.
$onAliGetAuthorize
=
function
onAliGetAuthorize
(
method
,
$event
)
{
my
.
getPhoneNumber
({
success
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
const
response
=
JSON
.
parse
(
res
.
response
).
response
;
if
(
response
.
code
===
'
10000
'
)
{
// success
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
;
$event
.
detail
.
encryptedData
=
res
.
response
;
}
else
{
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
res
.
response
;
}
this
[
method
](
$event
);
},
fail
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
'
;
this
[
method
](
$event
);
}
});
};
Vue
.
prototype
.
$onAliAuthError
=
function
$onAliAuthError
(
method
,
$event
)
{
$event
.
type
=
'
getphonenumber
'
;
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
$event
.
detail
.
errorMessage
;
this
[
method
](
$event
);
};
return
parseBaseApp
(
vm
,
{
mocks
,
initRefs
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
928629c5
...
...
@@ -415,7 +415,8 @@ const todos = [
'
stopBeaconDiscovery
'
,
'
hideShareMenu
'
,
'
onWindowResize
'
,
'
offWindowResize
'
'
offWindowResize
'
,
'
vibrate
'
];
// 存在兼容性的 API 列表
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
928629c5
...
...
@@ -428,7 +428,8 @@ const todos = [
'
checkIsSoterEnrolledInDevice
'
,
'
reportMonitor
'
,
'
getLogManager
'
,
'
reportAnalytics
'
'
reportAnalytics
'
,
'
vibrate
'
];
const
canIUses
=
[
'
scanCode
'
,
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
928629c5
...
...
@@ -451,7 +451,8 @@ const todos = [
'
onWindowResize
'
,
'
offWindowResize
'
,
'
compressImage
'
,
'
createOffscreenCanvas
'
'
createOffscreenCanvas
'
,
'
vibrate
'
];
// 存在兼容性的 API 列表
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
928629c5
...
...
@@ -387,7 +387,9 @@ var previewImage = {
const
protocols
=
{
previewImage
};
const
todos
=
[];
const
todos
=
[
'
vibrate
'
];
const
canIUses
=
[];
const
CALLBACKS
=
[
'
success
'
,
'
fail
'
,
'
cancel
'
,
'
complete
'
];
...
...
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
浏览文件 @
928629c5
...
...
@@ -27,24 +27,24 @@ describe('mp:compiler-mp-alipay', () => {
'
<view><view v-if="show">hello</view><view v-else-if="hide">world</view><view v-else>bye</view></view>
'
,
`<view><block a:if="{{show}}"><view>hello</view></block><block a:else><block a:if="{{hide}}"><view>world</view></block><block a:else><view>bye</view></block></block></view>`
)
})
it
(
'
generate ref
'
,
()
=>
{
assertCodegen
(
'
<component1 ref="c1">text</component1>
'
,
`<component1 vue-id="1" ref="__r" data-ref="c1" onVueInit="__l">text</component1>`
)
assertCodegen
(
'
<component1 :ref="c2">text<text>123213</text></component1>
'
,
`<component1 vue-id="1" ref="__r" data-ref="{{c2}}" onVueInit="__l">text<text>123213</text></component1>`
)
assertCodegen
(
'
<component1 v-for="item in items" ref="c3"></component1>
'
,
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'1-'+__i0__}}" ref="__r" data-ref-in-for="c3" onVueInit="__l"></component1></block>`
)
assertCodegen
(
'
<component1 v-for="item in items" :ref="c4"></component1>
'
,
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'1-'+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" onVueInit="__l"></component1></block>`
)
})
it
(
'
generate ref
'
,
()
=>
{
assertCodegen
(
'
<component1 ref="c1">text</component1>
'
,
`<component1 vue-id="1" ref="__r" data-ref="c1" onVueInit="__l">text</component1>`
)
assertCodegen
(
'
<component1 :ref="c2">text<text>123213</text></component1>
'
,
`<component1 vue-id="1" ref="__r" data-ref="{{c2}}" onVueInit="__l">text<text>123213</text></component1>`
)
assertCodegen
(
'
<component1 v-for="item in items" ref="c3"></component1>
'
,
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'1-'+__i0__}}" ref="__r" data-ref-in-for="c3" onVueInit="__l"></component1></block>`
)
assertCodegen
(
'
<component1 v-for="item in items" :ref="c4"></component1>
'
,
`<block a:for="{{items}}" a:for-item="item" a:for-index="__i0__"><component1 vue-id="{{'1-'+__i0__}}" ref="__r" data-ref-in-for="{{c4}}" onVueInit="__l"></component1></block>`
)
})
it
(
'
generate default slot
'
,
()
=>
{
assertCodegen
(
...
...
@@ -104,6 +104,13 @@ describe('mp:compiler-mp-alipay', () => {
)
})
it
(
'
generate getPhoneNumber
'
,
()
=>
{
assertCodegen
(
'
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
'
,
`<button open-type="getAuthorize" scope="phoneNumber" data-event-opts="{{[['getAuthorize',[['$onAliGetAuthorize',['getPhoneNumber','$event']]]],['error',[['$onAliAuthError',['getPhoneNumber','$event']]]]]}}" onGetAuthorize="__e" onError="__e">获取手机号</button>`
)
})
it
(
'
generate events with v-on directive
'
,
()
=>
{
assertCodegen
(
`<uni-list-item title="标题文字" note="描述信息" show-extra-icon="true" :extra-icon="{color: '#4cd964',size: '22',type: 'spinner'}"></uni-list-item>`
,
...
...
@@ -119,26 +126,26 @@ describe('mp:compiler-mp-alipay', () => {
assertCodegen
(
`<form @submit="formSubmit" @reset="formReset"/>`
,
`<form data-event-opts="{{[['submit',[['formSubmit',['$event']]]]]}}" onSubmit="__e" onReset="formReset"></form>`
)
assertCodegen
(
`<map @callouttap="calloutTap" @controltap="controlTap" @markertap="markerTap" @regionchange="regionChange" @tap="tap"/>`
,
`<map data-event-opts="{{[['tap',[['tap',['$event']]]]]}}" onCalloutTap="calloutTap" onControlTap="controlTap" onMarkerTap="markerTap" onRegionChange="regionChange" onTap="__e"></map>`
)
assertCodegen
(
`<view @transitionend="transitionEnd" @animationstart="animationStart" @animationiteration="animationIteration" @animationend="animationEnd" @firstappear="firstAppear"/>`
,
`<view data-event-opts="{{[['transitionEnd',[['transitionEnd',['$event']]]],['animationStart',[['animationStart',['$event']]]],['animationIteration',[['animationIteration',['$event']]]],['animationEnd',[['animationEnd',['$event']]]],['firstAppear',[['firstAppear',['$event']]]]]}}" onTransitionEnd="__e" onAnimationStart="__e" onAnimationIteration="__e" onAnimationEnd="__e" onFirstAppear="__e"></view>`
)
assertCodegen
(
`<scroll-view @scrolltoupper="scrollToUpper" @scrolltolower="scrollToLower"/>`
,
`<scroll-view data-event-opts="{{[['scrollToUpper',[['scrollToUpper',['$event']]]],['scrollToLower',[['scrollToLower',['$event']]]]]}}" onScrollToUpper="__e" onScrollToLower="__e"></scroll-view>`
)
assertCodegen
(
`<movable-view @changeend="changeEnd"/>`
,
`<movable-view data-event-opts="{{[['changeEnd',[['changeEnd',['$event']]]]]}}" onChangeEnd="__e"></movable-view>`
)
assertCodegen
(
`<map @callouttap="calloutTap" @controltap="controlTap" @markertap="markerTap" @regionchange="regionChange" @tap="tap"/>`
,
`<map data-event-opts="{{[['tap',[['tap',['$event']]]]]}}" onCalloutTap="calloutTap" onControlTap="controlTap" onMarkerTap="markerTap" onRegionChange="regionChange" onTap="__e"></map>`
)
assertCodegen
(
`<view @transitionend="transitionEnd" @animationstart="animationStart" @animationiteration="animationIteration" @animationend="animationEnd" @firstappear="firstAppear"/>`
,
`<view data-event-opts="{{[['transitionEnd',[['transitionEnd',['$event']]]],['animationStart',[['animationStart',['$event']]]],['animationIteration',[['animationIteration',['$event']]]],['animationEnd',[['animationEnd',['$event']]]],['firstAppear',[['firstAppear',['$event']]]]]}}" onTransitionEnd="__e" onAnimationStart="__e" onAnimationIteration="__e" onAnimationEnd="__e" onFirstAppear="__e"></view>`
)
assertCodegen
(
`<scroll-view @scrolltoupper="scrollToUpper" @scrolltolower="scrollToLower"/>`
,
`<scroll-view data-event-opts="{{[['scrollToUpper',[['scrollToUpper',['$event']]]],['scrollToLower',[['scrollToLower',['$event']]]]]}}" onScrollToUpper="__e" onScrollToLower="__e"></scroll-view>`
)
assertCodegen
(
`<movable-view @changeend="changeEnd"/>`
,
`<movable-view data-event-opts="{{[['changeEnd',[['changeEnd',['$event']]]]]}}" onChangeEnd="__e"></movable-view>`
)
})
})
packages/uni-template-compiler/__tests__/demo.js
浏览文件 @
928629c5
const
compiler
=
require
(
'
../lib
'
)
const
res
=
compiler
.
compile
(
`
<
view @/
>
<
button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button
>
`
,
{
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
mp
:
{
...
...
packages/uni-template-compiler/lib/index.js
浏览文件 @
928629c5
...
...
@@ -18,6 +18,8 @@ const generateTemplate = require('./template/generate')
const
compilerModule
=
require
(
'
./module
'
)
const
compilerAlipayModule
=
require
(
'
./module-alipay
'
)
const
generateCodeFrame
=
require
(
'
./codeframe
'
)
module
.
exports
=
{
...
...
@@ -28,6 +30,10 @@ module.exports = {
(
options
.
modules
||
(
options
.
modules
=
[])).
push
(
compilerModule
)
if
(
options
.
mp
.
platform
===
'
mp-alipay
'
)
{
options
.
modules
.
push
(
compilerAlipayModule
)
}
const
res
=
compile
(
source
,
Object
.
assign
(
options
,
{
optimize
:
false
}))
...
...
packages/uni-template-compiler/lib/module-alipay.js
0 → 100644
浏览文件 @
928629c5
module
.
exports
=
{
postTransformNode
(
el
)
{
const
attrsMap
=
el
.
attrsMap
if
(
attrsMap
[
'
open-type
'
]
!==
'
getPhoneNumber
'
)
{
return
}
const
getPhoneNumberValue
=
attrsMap
[
'
@getphonenumber
'
]
||
attrsMap
[
'
v-on:getphonenumber
'
]
if
(
!
getPhoneNumberValue
)
{
return
}
el
.
attrs
.
find
(
attr
=>
attr
.
name
===
'
open-type
'
).
value
=
'
"getAuthorize"
'
el
.
attrs
.
push
({
name
:
'
scope
'
,
value
:
'
"phoneNumber"
'
})
delete
el
.
events
[
'
getphonenumber
'
]
el
.
events
[
'
getAuthorize
'
]
=
{
value
:
'
$onAliGetAuthorize(
\'
'
+
getPhoneNumberValue
+
'
\'
,$event)
'
}
el
.
events
[
'
error
'
]
=
{
value
:
'
$onAliAuthError(
\'
'
+
getPhoneNumberValue
+
'
\'
,$event)
'
}
}
}
packages/uni-template-compiler/lib/platforms/mp-alipay.js
浏览文件 @
928629c5
...
...
@@ -45,7 +45,7 @@ module.exports = {
createFilterTag
(
filterTag
,
{
attrs
})
{
return
`<
${
filterTag
}
name="
${
attrs
.
module
}
" from="
${
attrs
.
src
}
"></
${
filterTag
}
>`
return
`<
import-sjs name="
${
attrs
.
module
}
" from="
${
attrs
.
src
}
"></import-sjs
>`
},
getEventType
(
eventType
)
{
return
EVENTS
[
eventType
]
||
eventType
...
...
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
928629c5
...
...
@@ -91,8 +91,10 @@ const rules = [{
}
},
jsPreprocessorLoader
],
exclude
:
excludeModuleReg
],
exclude
(
modulePath
)
{
return
excludeModuleReg
.
test
(
modulePath
)
&&
modulePath
.
indexOf
(
'
@dcloudio
'
)
===
-
1
}
},
{
test
:
/
\.
nvue
(\?[^
?
]
+
)?
$/
,
...
...
@@ -171,7 +173,7 @@ if (process.env.UNI_USING_NATIVE) {
module
.
exports
=
function
(
entry
)
{
return
{
target
:
'
node
'
,
// 激活 vue-loader 的 isServer 逻辑
mode
:
'
development
'
,
//
process.env.NODE_ENV,
mode
:
process
.
env
.
NODE_ENV
,
devtool
:
process
.
env
.
NODE_ENV
===
'
development
'
?
'
inline-source-map
'
:
false
,
watch
:
process
.
env
.
NODE_ENV
===
'
development
'
,
entry
,
...
...
packages/vue-cli-plugin-uni/lib/mp.js
浏览文件 @
928629c5
...
...
@@ -132,10 +132,10 @@ module.exports = {
resourceQuery
:
[
/lang=wxs/
,
/lang=filter/
,
/lang=
import-
sjs/
,
/lang=sjs/
,
/blockType=wxs/
,
/blockType=filter/
,
/blockType=
import-
sjs/
/blockType=sjs/
],
use
:
[{
loader
:
require
.
resolve
(
...
...
packages/vue-cli-plugin-uni/lib/split-chunks.js
浏览文件 @
928629c5
...
...
@@ -12,6 +12,13 @@ module.exports = function getSplitChunks () {
}
}
}
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
mainPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
main.
'
))
if
(
!
process
.
env
.
UNI_OPT_SUBPACKAGES
)
{
return
{
chunks
(
chunk
)
{
// 防止 node_modules 内 vue 组件被 split
...
...
@@ -27,7 +34,8 @@ module.exports = function getSplitChunks () {
}
if
(
module
.
resource
&&
(
module
.
resource
.
indexOf
(
'
.vue
'
)
!==
-
1
||
module
.
resource
.
indexOf
(
'
.nvue
'
)
!==
-
1
module
.
resource
.
indexOf
(
'
.nvue
'
)
!==
-
1
||
module
.
resource
.
indexOf
(
mainPath
)
===
0
// main.js
))
{
return
false
}
...
...
@@ -40,11 +48,6 @@ module.exports = function getSplitChunks () {
}
}
}
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
mainPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
main.
'
))
function
baseTest
(
module
)
{
if
(
module
.
type
===
'
css/mini-extract
'
)
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.js
浏览文件 @
928629c5
...
...
@@ -48,7 +48,7 @@ module.exports = function(source) {
descriptor
.
customBlocks
=
descriptor
.
customBlocks
.
filter
(
block
=>
{
if
(
block
.
attrs
.
module
||
block
.
attrs
.
module
&&
(
block
.
type
===
FILTER_TAG
||
block
.
attrs
.
lang
===
FILTER_TAG
...
...
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
浏览文件 @
928629c5
...
...
@@ -6,6 +6,10 @@ const {
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
pagesJsonJsFileName
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
generateApp
=
require
(
'
./generate-app
'
)
const
generateJson
=
require
(
'
./generate-json
'
)
const
generateComponent
=
require
(
'
./generate-component
'
)
...
...
@@ -43,7 +47,8 @@ function addSubPackagesRequire (compilation) {
name
.
indexOf
(
root
)
===
0
&&
name
!==
subPackageVendorPath
)
{
const
source
=
`require('
${
normalizePath
(
path
.
relative
(
path
.
dirname
(
name
),
subPackageVendorPath
))}
');`
+
const
source
=
`require('
${
normalizePath
(
path
.
relative
(
path
.
dirname
(
name
),
subPackageVendorPath
))}
');`
+
compilation
.
assets
[
name
].
source
()
compilation
.
assets
[
name
]
=
{
...
...
@@ -82,11 +87,22 @@ class WebpackUniMPPlugin {
})
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-mp-invalid
'
,
(
fileName
,
changeTime
)
=>
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
&&
path
.
basename
(
fileName
)
===
'
pages.json
'
)
{
// 重新解析 entry
try
{
parseEntry
()
}
catch
(
e
)
{
console
.
error
(
e
)
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
// 重新解析 entry
const
basename
=
path
.
basename
(
fileName
)
const
deps
=
process
.
UNI_PAGES_DEPS
||
new
Set
()
if
(
basename
===
'
pages.json
'
||
basename
===
pagesJsonJsFileName
||
deps
.
has
(
normalizePath
(
fileName
))
)
{
try
{
parseEntry
()
}
catch
(
e
)
{
console
.
error
(
e
)
}
}
}
})
...
...
packages/webpack-uni-mp-loader/lib/plugin/index.js
浏览文件 @
928629c5
...
...
@@ -2,9 +2,14 @@ const path = require('path')
const
{
md5
,
parseEntry
parseEntry
,
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
pagesJsonJsFileName
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
getPages
,
getSubPages
,
...
...
@@ -93,11 +98,22 @@ class WebpackUniMPPlugin {
})
compiler
.
hooks
.
invalid
.
tap
(
'
webpack-uni-mp-invalid
'
,
(
fileName
,
changeTime
)
=>
{
if
(
fileName
&&
typeof
fileName
===
'
string
'
&&
path
.
basename
(
fileName
)
===
'
pages.json
'
)
{
// 重新解析 entry
try
{
parseEntry
()
}
catch
(
e
)
{
console
.
error
(
e
)
if
(
fileName
&&
typeof
fileName
===
'
string
'
)
{
// 重新解析 entry
const
basename
=
path
.
basename
(
fileName
)
const
deps
=
process
.
UNI_PAGES_DEPS
||
new
Set
()
if
(
basename
===
'
pages.json
'
||
basename
===
pagesJsonJsFileName
||
deps
.
has
(
normalizePath
(
fileName
))
)
{
try
{
parseEntry
()
}
catch
(
e
)
{
console
.
error
(
e
)
}
}
}
})
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
928629c5
...
...
@@ -14,6 +14,10 @@ const {
updateProjectJson
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
pagesJsonJsFileName
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
parseStyle
=
require
(
'
./util
'
).
parseStyle
// 将开发者手动设置的 usingComponents 调整名称,方便与自动解析到的 usingComponents 做最后合并
...
...
@@ -28,12 +32,19 @@ function renameUsingComponents (jsonObj) {
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
pagesJsonJsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pagesJsonJsFileName
)
const
manifestJsonPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
)
const
manifestJson
=
parseManifestJson
(
fs
.
readFileSync
(
manifestJsonPath
,
'
utf8
'
))
this
.
addDependency
(
pagesJsonJsPath
)
this
.
addDependency
(
manifestJsonPath
)
const
pagesJson
=
parsePagesJson
(
content
)
const
pagesJson
=
parsePagesJson
(
content
,
{
addDependency
:
(
file
)
=>
{
(
process
.
UNI_PAGES_DEPS
||
(
process
.
UNI_PAGES_DEPS
=
new
Set
())).
add
(
normalizePath
(
file
))
this
.
addDependency
(
file
)
}
})
// TODO 与 usingComponents 放在一块读取设置
if
(
manifestJson
.
transformPx
===
false
)
{
process
.
UNI_TRANSFORM_PX
=
false
...
...
packages/webpack-uni-pages-loader/lib/index.js
浏览文件 @
928629c5
...
...
@@ -13,6 +13,10 @@ const {
getPagesJson
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
pagesJsonJsFileName
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
parseStyle
=
require
(
'
./util
'
).
parseStyle
const
emitFileCaches
=
{}
...
...
@@ -25,7 +29,7 @@ function checkEmitFile (filePath, jsonObj, changedEmitFiles) {
}
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
)
{
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
)
{
...
...
@@ -44,11 +48,18 @@ module.exports = function (content) {
this
.
cacheable
&&
this
.
cacheable
()
const
manifestJsonPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
)
const
pagesJsonJsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pagesJsonJsFileName
)
const
manifestJson
=
parseManifestJson
(
fs
.
readFileSync
(
manifestJsonPath
,
'
utf8
'
))
this
.
addDependency
(
manifestJsonPath
)
this
.
addDependency
(
pagesJsonJsPath
)
const
pagesJson
=
parsePagesJson
(
content
)
const
pagesJson
=
parsePagesJson
(
content
,
{
addDependency
:
(
file
)
=>
{
(
process
.
UNI_PAGES_DEPS
||
(
process
.
UNI_PAGES_DEPS
=
new
Set
())).
add
(
normalizePath
(
file
))
this
.
addDependency
(
file
)
}
})
if
(
manifestJson
.
transformPx
===
false
)
{
process
.
UNI_TRANSFORM_PX
=
false
...
...
packages/webpack-uni-pages-loader/lib/platforms/mp-alipay.js
浏览文件 @
928629c5
const
{
parsePages
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
updateAppJsonUsingComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
hasOwn
,
...
...
@@ -59,6 +63,10 @@ module.exports = function (pagesJson, manifestJson) {
})
copyToJson
(
app
,
pagesJson
,
pagesJson2AppJson
)
if
(
app
.
usingComponents
)
{
updateAppJsonUsingComponents
(
app
.
usingComponents
)
}
return
[{
name
:
'
app
'
,
...
...
src/platforms/app-plus/service/api/device/scan-code.js
浏览文件 @
928629c5
...
...
@@ -12,7 +12,8 @@ import {
}
from
'
../../constants
'
import
{
registerPlusMessage
registerPlusMessage
,
consumePlusMessage
}
from
'
../../framework/plus-message
'
export
const
SCAN_ID
=
'
__UNIAPP_SCAN
'
...
...
@@ -97,12 +98,12 @@ export function scanCode ({
barcode
.
scan
(
file
,
(
type
,
code
)
=>
{
if
(
isDark
)
{
plus
.
navigator
.
setStatusBarStyle
(
'
isDark
'
)
}
result
=
{
type
,
code
}
webview
.
close
(
'
auto
'
)
result
=
{
type
,
code
}
},
()
=>
{
plus
.
nativeUI
.
toast
(
'
识别失败
'
)
},
filters
)
...
...
@@ -143,7 +144,7 @@ export function scanCode ({
})
})
webview
.
addEventListener
(
'
close
'
,
()
=>
{
if
(
result
&&
'
code
'
in
result
)
{
if
(
result
)
{
invoke
(
callbackId
,
{
result
:
result
.
code
,
scanType
:
SCAN_MAPS
[
result
.
type
]
||
''
,
...
...
@@ -151,11 +152,12 @@ export function scanCode ({
path
:
''
,
errMsg
:
'
scanCode:ok
'
})
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
scanCode:fail cancel
'
})
}
else
{
invoke
(
callbackId
,
{
errMsg
:
'
scanCode:fail cancel
'
})
}
consumePlusMessage
(
MESSAGE_TYPE
)
})
if
(
isDark
)
{
// 状态栏前景色
plus
.
navigator
.
setStatusBarStyle
(
'
light
'
)
...
...
@@ -170,15 +172,10 @@ export function scanCode ({
}
})
}
// fixed by hxy 注册扫码事件
registerPlusMessage
(
MESSAGE_TYPE
,
function
(
res
)
{
if
(
res
&&
!
res
.
errMsg
)
{
if
(
res
&&
'
code
'
in
res
)
{
result
=
res
}
else
{
const
errMsg
=
res
&&
res
.
errMsg
?
'
'
+
res
.
errMsg
:
''
result
=
{
errMsg
:
'
scanCode:fail
'
+
errMsg
}
}
},
false
)
}
src/platforms/app-plus/service/api/location/choose-location.js
浏览文件 @
928629c5
...
...
@@ -11,10 +11,13 @@ import {
}
from
'
../../constants
'
import
{
registerPlusMessage
registerPlusMessage
,
consumePlusMessage
}
from
'
../../framework/plus-message
'
const
CHOOSE_LOCATION_PATH
=
'
_www/__uniappchooselocation.html
'
const
CHOOSE_LOCATION_PATH
=
'
_www/__uniappchooselocation.html
'
const
MESSAGE_TYPE
=
'
chooseLocation
'
export
function
chooseLocation
(
params
,
callbackId
)
{
const
statusBarStyle
=
plus
.
navigator
.
getStatusBarStyle
()
...
...
@@ -56,27 +59,39 @@ export function chooseLocation (params, callbackId) {
plus
.
navigator
.
setStatusBarStyle
(
'
light
'
)
}
})
}
let
index
=
0
let
onShow
=
function
()
{
index
++
if
(
index
===
2
)
{
webview
.
evalJS
(
`__chooseLocation__(
${
JSON
.
stringify
(
params
)}
)`
)
}
}
webview
.
addEventListener
(
'
loaded
'
,
onShow
)
webview
.
show
(
'
slide-in-bottom
'
,
ANI_DURATION
,
onShow
)
let
result
webview
.
addEventListener
(
'
close
'
,
()
=>
{
if
(
result
)
{
invoke
(
callbackId
,
{
name
:
result
.
poiname
,
address
:
result
.
poiaddress
,
latitude
:
result
.
latlng
.
lat
,
longitude
:
result
.
latlng
.
lng
,
errMsg
:
'
chooseLocation:ok
'
})
}
else
{
consumePlusMessage
(
MESSAGE_TYPE
)
invoke
(
callbackId
,
{
errMsg
:
'
chooseLocation:fail cancel
'
})
}
})
webview
.
show
(
'
slide-in-bottom
'
,
ANI_DURATION
,
()
=>
{
webview
.
evalJS
(
`__chooseLocation__(
${
JSON
.
stringify
(
params
)}
)`
)
})
// fixed by hxy
registerPlusMessage
(
'
chooseLocation
'
,
function
(
res
)
{
if
(
res
&&
!
res
.
errMsg
)
{
invoke
(
callbackId
,
{
name
:
res
.
poiname
,
address
:
res
.
poiaddress
,
latitude
:
res
.
latlng
.
lat
,
longitude
:
res
.
latlng
.
lng
,
errMsg
:
'
chooseLocation:ok
'
})
}
else
{
const
errMsg
=
res
&&
res
.
errMsg
?
'
'
+
res
.
errMsg
:
''
invoke
(
callbackId
,
{
errMsg
:
'
chooseLocation:fail
'
+
errMsg
})
registerPlusMessage
(
MESSAGE_TYPE
,
function
(
res
)
{
if
(
res
&&
'
latlng
'
in
res
)
{
result
=
res
}
},
false
)
}
src/platforms/app-plus/service/framework/app.js
浏览文件 @
928629c5
...
...
@@ -9,7 +9,8 @@ import {
}
from
'
./page
'
import
{
registerPlusMessage
registerPlusMessage
,
consumePlusMessage
}
from
'
./plus-message
'
import
{
...
...
@@ -68,6 +69,16 @@ function initGlobalListeners () {
publish
(
'
onKeyboardHeightChange
'
,
{
height
:
event
.
height
})
})
plus
.
globalEvent
.
addEventListener
(
'
plusMessage
'
,
function
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP[plusMessage]:[
'
+
Date
.
now
()
+
'
]
'
+
JSON
.
stringify
(
e
.
data
))
}
if
(
e
.
data
&&
e
.
data
.
type
)
{
const
type
=
e
.
data
.
type
consumePlusMessage
(
type
,
e
.
data
.
args
||
{})
}
})
}
...
...
src/platforms/mp-alipay/runtime/wrapper/app-parser.js
浏览文件 @
928629c5
...
...
@@ -7,7 +7,7 @@ import {
initRefs
}
from
'
./util
'
export
default
function
parseApp
(
vm
)
{
export
default
function
parseApp
(
vm
)
{
Object
.
defineProperty
(
Vue
.
prototype
,
'
$slots
'
,
{
get
()
{
return
this
.
$scope
&&
this
.
$scope
.
props
.
$slots
...
...
@@ -25,6 +25,33 @@ export default function parseApp (vm) {
}
})
Vue
.
prototype
.
$onAliGetAuthorize
=
function
onAliGetAuthorize
(
method
,
$event
)
{
my
.
getPhoneNumber
({
success
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
const
response
=
JSON
.
parse
(
res
.
response
).
response
if
(
response
.
code
===
'
10000
'
)
{
// success
$event
.
detail
.
errMsg
=
'
getPhoneNumber:ok
'
$event
.
detail
.
encryptedData
=
res
.
response
}
else
{
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
res
.
response
}
this
[
method
](
$event
)
},
fail
:
(
res
)
=>
{
$event
.
type
=
'
getphonenumber
'
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail
'
this
[
method
](
$event
)
}
})
}
Vue
.
prototype
.
$onAliAuthError
=
function
$onAliAuthError
(
method
,
$event
)
{
$event
.
type
=
'
getphonenumber
'
$event
.
detail
.
errMsg
=
'
getPhoneNumber:fail Error:
'
+
$event
.
detail
.
errorMessage
this
[
method
](
$event
)
}
return
parseBaseApp
(
vm
,
{
mocks
,
initRefs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录