Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tomleePHP
uni-app
提交
81b293e1
U
uni-app
项目概览
tomleePHP
/
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,发现更多精彩内容 >>
提交
81b293e1
编写于
12月 10, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'v3' of github.com:dcloudio/uni-app into v3
上级
b788411b
2c3a64db
变更
20
展开全部
显示空白变更内容
内联
并排
Showing
20 changed file
with
2013 addition
and
50 deletion
+2013
-50
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+23
-0
packages/uni-app-plus/dist/view.css
packages/uni-app-plus/dist/view.css
+1864
-1
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+1
-1
packages/uni-migration/__tests__/demo.js
packages/uni-migration/__tests__/demo.js
+2
-2
packages/uni-migration/__tests__/wxml.spec.js
packages/uni-migration/__tests__/wxml.spec.js
+9
-3
packages/uni-migration/lib/mp-weixin/index.js
packages/uni-migration/lib/mp-weixin/index.js
+5
-1
packages/uni-migration/lib/mp-weixin/patch.js
packages/uni-migration/lib/mp-weixin/patch.js
+21
-2
packages/uni-migration/lib/mp-weixin/transform/file-transformer.js
...uni-migration/lib/mp-weixin/transform/file-transformer.js
+6
-4
packages/uni-migration/lib/mp-weixin/transform/json-transformer.js
...uni-migration/lib/mp-weixin/transform/json-transformer.js
+2
-1
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/generate.js
...ixin/transform/template-transformer/transform/generate.js
+7
-3
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/index.js
...-weixin/transform/template-transformer/transform/index.js
+3
-5
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
...ixin/transform/template-transformer/transform/traverse.js
+1
-1
packages/uni-migration/lib/validate.js
packages/uni-migration/lib/validate.js
+3
-5
packages/uni-mp-weixin/dist/mp.js
packages/uni-mp-weixin/dist/mp.js
+13
-8
packages/uni-template-compiler/__tests__/demo.js
packages/uni-template-compiler/__tests__/demo.js
+10
-2
packages/uni-template-compiler/lib/app/util.js
packages/uni-template-compiler/lib/app/util.js
+4
-1
src/core/runtime/mp/polyfill/methods.js
src/core/runtime/mp/polyfill/methods.js
+12
-3
src/core/runtime/mp/polyfill/state/properties.js
src/core/runtime/mp/polyfill/state/properties.js
+4
-4
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
...platforms/app-plus/service/framework/plugins/vdom-sync.js
+23
-0
src/platforms/app-plus/view/framework/plugins/data.js
src/platforms/app-plus/view/framework/plugins/data.js
+0
-3
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
81b293e1
...
...
@@ -12088,7 +12088,30 @@ var serviceContext = (function () {
// }
}
// TODO 临时通过序列化,反序列化传递dataset,后续可以全部保留在service,不做传递
function
parseDataset$1
(
dataset
)
{
const
ret
=
Object
.
create
(
null
);
Object
.
keys
(
dataset
).
forEach
(
name
=>
{
try
{
ret
[
name
]
=
JSON
.
parse
(
dataset
[
name
]);
}
catch
(
e
)
{}
});
return
ret
}
function
parseTargets
(
event
)
{
const
targetDataset
=
event
.
target
&&
event
.
target
.
dataset
;
if
(
targetDataset
)
{
event
.
target
.
dataset
=
parseDataset$1
(
targetDataset
);
}
const
currentTargetDataset
=
event
.
currentTarget
&&
event
.
currentTarget
.
dataset
;
if
(
currentTargetDataset
)
{
event
.
currentTarget
.
dataset
=
parseDataset$1
(
currentTargetDataset
);
}
}
function
wrapperEvent
(
event
)
{
parseTargets
(
event
);
event
.
preventDefault
=
noop
;
event
.
stopPropagation
=
noop
;
event
.
mp
=
event
;
...
...
packages/uni-app-plus/dist/view.css
浏览文件 @
81b293e1
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
81b293e1
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-migration/__tests__/demo.js
浏览文件 @
81b293e1
...
...
@@ -7,13 +7,13 @@ migrate('/Users/fxy/Downloads/wa-vantui_1.1')
// const {
// parse
// } = require('mustache')
// console.log(parse(
'{{ { enter: 300, leave: 1000 } }}'
))
// console.log(parse(
"van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}"
))
// const {
// transformTemplate
// } = require('../lib/mp-weixin/transform/template-transformer')
// console.log(transformTemplate(
// `<view
wx:for="{{ columns }}" wx:for-item="item1" wx:key="item1"/
>`, {
// `<view
class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}"></view
>`, {
// filename: 'index'
// }
// ))
packages/uni-migration/__tests__/wxml.spec.js
浏览文件 @
81b293e1
...
...
@@ -12,10 +12,16 @@ describe('wxml:compiler', () => {
`<view @touchstart="startDrag" @touchmove.stop="catchMove ? 'noop' : ''"></view>`
)
})
it
(
'
generate class
'
,
()
=>
{
assertCodegen
(
`<view class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}"></view>`
,
`<view :class="'van-notice-bar__content '+(!scrollable && !wrapable ? 'van-ellipsis' : '')"></view>`
)
})
it
(
'
generate v-if
'
,
()
=>
{
assertCodegen
(
'
<block wx:if="{{ !loading }}" loading loading-text="">{{ item.name }}</block>
'
,
`<block v-if="
!loading
" loading loading-text>{{ item.name }}</block>`
`<block v-if="
(!loading)
" loading loading-text>{{ item.name }}</block>`
)
})
it
(
'
generate v-for
'
,
()
=>
{
...
...
@@ -35,7 +41,7 @@ describe('wxml:compiler', () => {
it
(
'
generate root element
'
,
()
=>
{
assertCodegen
(
'
<view></view><view></view>
'
,
`<
view><view></view><view></view></view
>`
`<
uni-shadow-root><view></view><view></view></uni-shadow-root
>`
)
assertCodegen
(
...
...
@@ -47,7 +53,7 @@ describe('wxml:compiler', () => {
assertCodegen
(
'
<slot></slot>
'
,
`<
view><slot></slot></view
>`
`<
uni-shadow-root><slot></slot></uni-shadow-root
>`
)
})
})
packages/uni-migration/lib/mp-weixin/index.js
浏览文件 @
81b293e1
const
patch
=
require
(
'
./patch
'
)
module
.
exports
=
{
options
:
{
extname
:
{
template
:
'
.wxml
'
,
style
:
'
.wxss
'
},
shouldWrapper
(
filepath
)
{
return
patch
.
wrapper
(
filepath
)
}
},
transform
:
require
(
'
./transform
'
),
patch
:
require
(
'
./patch
'
)
patch
}
packages/uni-migration/lib/mp-weixin/patch.js
浏览文件 @
81b293e1
...
...
@@ -49,7 +49,26 @@ function patchVue(file) {
}
}
const
VANT_WRAPPERS
=
[
function
test
(
filepath
)
{
return
filepath
.
indexOf
(
'
/cell/index
'
)
!==
-
1
},
function
test
(
filepath
)
{
return
filepath
.
indexOf
(
'
/sticky/index
'
)
!==
-
1
}
]
const
PATCH_WRAPPERS
=
[
...
VANT_WRAPPERS
]
function
patchWrapper
(
filepath
)
{
filepath
=
normalizePath
(
filepath
)
return
!!
PATCH_WRAPPERS
.
find
(
test
=>
test
(
filepath
))
}
module
.
exports
=
{
vue
:
patchVue
,
asset
:
patchAsset
asset
:
patchAsset
,
wrapper
:
patchWrapper
}
packages/uni-migration/lib/mp-weixin/transform/file-transformer.js
浏览文件 @
81b293e1
...
...
@@ -25,11 +25,13 @@ module.exports = function transformFile(input, options) {
filepath
+
templateExtname
]
const
[
jsCode
]
=
transformJsonFile
(
filepath
+
'
.json
'
,
deps
)
const
[
jsCode
,
isComponent
]
=
transformJsonFile
(
filepath
+
'
.json
'
,
deps
)
const
[
templateCode
,
wxsCode
=
''
,
wxsFiles
=
[]]
=
transformTemplateFile
(
filepath
+
templateExtname
,
{
filename
:
path
.
basename
(
filepath
)
})
options
.
isComponent
=
isComponent
options
.
filepath
=
filepath
options
.
filename
=
path
.
basename
(
filepath
)
const
[
templateCode
,
wxsCode
=
''
,
wxsFiles
=
[]]
=
transformTemplateFile
(
filepath
+
templateExtname
,
options
)
const
styleCode
=
transformStyleFile
(
filepath
+
styleExtname
,
options
,
deps
)
||
''
const
scriptCode
=
transformScriptFile
(
filepath
+
'
.js
'
,
jsCode
,
options
,
deps
)
...
...
packages/uni-migration/lib/mp-weixin/transform/json-transformer.js
浏览文件 @
81b293e1
...
...
@@ -7,6 +7,7 @@ const {
function
transformJson
(
content
)
{
const
{
component
,
usingComponents
}
=
JSON
.
parse
(
content
)
if
(
!
usingComponents
)
{
...
...
@@ -22,7 +23,7 @@ function transformJson(content) {
return
[
`
${
importCode
.
join
(
'
\n
'
)}
global['__wxVueOptions'] = {components:{
${
componentsCode
.
join
(
'
,
'
)}
}}
`
]
`
,
component
]
}
module
.
exports
=
{
...
...
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/generate.js
浏览文件 @
81b293e1
...
...
@@ -57,7 +57,10 @@ function genWxs(wxs, state) {
return
[
wxsCode
.
join
(
''
).
trim
(),
wxsFiles
]
}
function
shouldWrapper
(
node
)
{
function
shouldWrapper
(
node
,
state
)
{
if
(
state
.
shouldWrapper
(
state
.
filepath
))
{
return
true
}
node
.
children
=
node
.
children
.
filter
(
child
=>
{
// remove \n
if
(
child
.
type
===
'
text
'
&&
!
child
.
data
.
trim
())
{
return
false
...
...
@@ -75,8 +78,9 @@ function shouldWrapper(node) {
}
module
.
exports
=
function
generate
(
node
,
state
)
{
if
(
shouldWrapper
(
node
))
{
return
[
`<view>
${
genChildren
(
node
).
trim
()}
</view>`
,
...
genWxs
(
state
.
wxs
,
state
)]
// [`<uni-shadow-root>${genChildren(node).trim()}</uni-shadow-root>`, ...genWxs(state.wxs, state)]
if
(
shouldWrapper
(
node
,
state
))
{
return
[
`<uni-shadow-root>
${
genChildren
(
node
).
trim
()}
</uni-shadow-root>`
,
...
genWxs
(
state
.
wxs
,
state
)]
}
return
[
genChildren
(
node
).
trim
(),
...
genWxs
(
state
.
wxs
,
state
)]
}
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/index.js
浏览文件 @
81b293e1
...
...
@@ -2,9 +2,7 @@ const traverse = require('./traverse')
const
generate
=
require
(
'
./generate
'
)
module
.
exports
=
function
transform
(
ast
,
options
)
{
const
state
=
{
wxs
:
[],
filename
:
options
.
filename
}
return
generate
(
traverse
(
ast
,
state
),
state
)
options
.
wxs
=
[]
options
.
shouldWrapper
=
options
.
shouldWrapper
||
function
noop
()
{}
return
generate
(
traverse
(
ast
,
options
),
options
)
}
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
浏览文件 @
81b293e1
...
...
@@ -34,7 +34,7 @@ function parseMustache(expr, identifier = false) {
}
return
`'
${
token
[
1
]}
'`
}
else
if
(
token
[
0
]
===
'
!
'
)
{
// {{ !loading }}
return
`
!
${
token
[
1
]}
`
return
`
(!
${
token
[
1
]}
)
`
}
else
if
(
token
[
0
]
===
'
name
'
)
{
if
(
isIdentifier
)
{
return
token
[
1
]
...
...
packages/uni-migration/lib/validate.js
浏览文件 @
81b293e1
...
...
@@ -2,7 +2,7 @@ const fs = require('fs')
const
path
=
require
(
'
path
'
)
const
migraters
=
{
'
mp-weixin
'
:
require
(
'
./mp-weixin
'
)
.
options
'
mp-weixin
'
:
require
(
'
./mp-weixin
'
)
}
module
.
exports
=
function
validate
(
input
,
out
,
options
)
{
...
...
@@ -10,9 +10,7 @@ module.exports = function validate(input, out, options) {
if
(
!
fs
.
existsSync
(
input
))
{
return
console
.
error
(
`错误: '
${
input
}
' 不存在`
)
}
const
platformOptions
=
migraters
[
options
.
platform
]
options
.
extname
=
platformOptions
.
extname
Object
.
assign
(
options
,
migraters
[
options
.
platform
].
options
)
const
templateExtname
=
options
.
extname
.
template
const
stat
=
fs
.
lstatSync
(
input
)
...
...
packages/uni-mp-weixin/dist/mp.js
浏览文件 @
81b293e1
...
...
@@ -532,11 +532,11 @@ const PROP_DEFAULT_VALUES = {
null
:
null
};
const
PROP_DEFAULT_KEY
S
=
Object
.
keys
(
PROP_DEFAULT_VALUES
);
const
PROP_DEFAULT_KEY
_RE
=
Object
.
keys
(
PROP_DEFAULT_VALUES
).
map
(
type
=>
new
RegExp
(
type
)
);
function
getDefaultVal
(
t
ype
)
{
return
PROP_DEFAULT_KEY
S
.
filter
(
type
=>
new
RegExp
(
type
).
test
(
type
+
''
))
function
getDefaultVal
(
propT
ype
)
{
return
PROP_DEFAULT_KEY
_RE
.
filter
(
regex
=>
regex
.
test
(
String
(
propType
)
))
.
map
(
type
=>
PROP_DEFAULT_VALUES
[
type
])[
0
]
}
...
...
@@ -547,7 +547,7 @@ function getPropertyVal (options) {
}
return
getDefaultVal
(
options
.
type
)
}
return
getDefaultVal
()
return
getDefaultVal
(
options
)
}
function
getType
(
propOptions
)
{
...
...
@@ -672,11 +672,16 @@ function initMethods (vm) {
const
target
=
{
dataset
:
vm
.
$el
.
dataset
};
oldEmit
.
call
(
vm
,
eventName
,
{
const
event
=
{
target
,
currentTarget
:
target
,
detail
});
detail
,
preventDefault
:
noop
,
stopPropagation
:
noop
};
oldEmit
.
call
(
vm
,
eventName
,
event
);
};
// 主要是Vant 自己封装了 $emit,放到 methods 中会触发 Vue 的警告,索性,框架直接重写该方法
vm
.
$emit
=
(...
args
)
=>
{
...
...
packages/uni-template-compiler/__tests__/demo.js
浏览文件 @
81b293e1
const
compiler
=
require
(
'
../lib
'
)
const
res
=
compiler
.
compile
(
`
<view data-a="1" :data-b="b"></view>
<view>
<view v-for="(item, index) in dataList" :key="item.id">
<view v-if="dataType === 2">
</view>
<view v-else>
{{ item.text }}
</view>
</view>
</view>
`
,
{
miniprogram
:
true
,
resourcePath
:
'
/User/fxy/Documents/test.wxml
'
,
...
...
packages/uni-template-compiler/lib/app/util.js
浏览文件 @
81b293e1
...
...
@@ -60,6 +60,9 @@ function updateEleId (el, it, state) {
child
.
forId
=
`
${
child
.
forId
}
+'-'+
${
it
}
`
}
})
el
.
ifConditions
&&
el
.
ifConditions
.
forEach
((
con
,
index
)
=>
{
index
!==
0
&&
updateEleId
(
con
.
block
,
it
,
state
)
})
}
function
getBindingAttr
(
el
,
name
)
{
...
...
src/core/runtime/mp/polyfill/methods.js
浏览文件 @
81b293e1
import
{
noop
}
from
'
uni-shared
'
import
{
updateProperties
}
from
'
./state/properties
'
...
...
@@ -8,11 +12,16 @@ export function initMethods (vm) {
const
target
=
{
dataset
:
vm
.
$el
.
dataset
}
oldEmit
.
call
(
vm
,
eventName
,
{
const
event
=
{
target
,
currentTarget
:
target
,
detail
})
detail
,
preventDefault
:
noop
,
stopPropagation
:
noop
}
oldEmit
.
call
(
vm
,
eventName
,
event
)
}
// 主要是Vant 自己封装了 $emit,放到 methods 中会触发 Vue 的警告,索性,框架直接重写该方法
vm
.
$emit
=
(...
args
)
=>
{
...
...
src/core/runtime/mp/polyfill/state/properties.js
浏览文件 @
81b293e1
...
...
@@ -12,11 +12,11 @@ const PROP_DEFAULT_VALUES = {
null
:
null
}
const
PROP_DEFAULT_KEY
S
=
Object
.
keys
(
PROP_DEFAULT_VALUES
)
const
PROP_DEFAULT_KEY
_RE
=
Object
.
keys
(
PROP_DEFAULT_VALUES
).
map
(
type
=>
new
RegExp
(
type
)
)
function
getDefaultVal
(
t
ype
)
{
return
PROP_DEFAULT_KEY
S
.
filter
(
type
=>
new
RegExp
(
type
).
test
(
type
+
''
))
function
getDefaultVal
(
propT
ype
)
{
return
PROP_DEFAULT_KEY
_RE
.
filter
(
regex
=>
regex
.
test
(
String
(
propType
)
))
.
map
(
type
=>
PROP_DEFAULT_VALUES
[
type
])[
0
]
}
...
...
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
浏览文件 @
81b293e1
...
...
@@ -27,7 +27,30 @@ import {
import
parseComponentCreateOptions
from
'
./parse-component-create-options
'
// TODO 临时通过序列化,反序列化传递dataset,后续可以全部保留在service,不做传递
function
parseDataset
(
dataset
)
{
const
ret
=
Object
.
create
(
null
)
Object
.
keys
(
dataset
).
forEach
(
name
=>
{
try
{
ret
[
name
]
=
JSON
.
parse
(
dataset
[
name
])
}
catch
(
e
)
{}
})
return
ret
}
function
parseTargets
(
event
)
{
const
targetDataset
=
event
.
target
&&
event
.
target
.
dataset
if
(
targetDataset
)
{
event
.
target
.
dataset
=
parseDataset
(
targetDataset
)
}
const
currentTargetDataset
=
event
.
currentTarget
&&
event
.
currentTarget
.
dataset
if
(
currentTargetDataset
)
{
event
.
currentTarget
.
dataset
=
parseDataset
(
currentTargetDataset
)
}
}
function
wrapperEvent
(
event
)
{
parseTargets
(
event
)
event
.
preventDefault
=
noop
event
.
stopPropagation
=
noop
event
.
mp
=
event
...
...
src/platforms/app-plus/view/framework/plugins/data.js
浏览文件 @
81b293e1
...
...
@@ -103,9 +103,6 @@ function vdSync ({
function
getData
(
id
,
name
)
{
try
{
if
(
name
.
indexOf
(
'
a-data-
'
)
===
0
)
{
// TODO 临时方案序列化,反序列化dataset,后续应该将dataset保留在service层
return
JSON
.
parse
(
this
.
$r
[
id
][
name
])
}
return
this
.
$r
[
id
][
name
]
}
catch
(
e
)
{
console
.
error
(
this
.
$options
.
__file
+
`:[
${
this
.
_$id
}
]$r[
${
id
}
][
${
name
}
] is undefined`
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录