Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
4c3c76c5
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
4c3c76c5
编写于
10月 18, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(v3): Build complete
上级
f4175f62
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
108 addition
and
1475 deletion
+108
-1475
build/build.js
build/build.js
+2
-2
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+6
-4
packages/uni-app-plus/dist/service.runtime.esm.js
packages/uni-app-plus/dist/service.runtime.esm.js
+1
-1
packages/uni-app-plus/dist/view.css
packages/uni-app-plus/dist/view.css
+1
-1389
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+2
-2
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
...lugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
+60
-40
packages/vue-cli-plugin-uni/lib/app-plus/index.js
packages/vue-cli-plugin-uni/lib/app-plus/index.js
+8
-9
src/platforms/app-plus/service/framework/plugins/data.js
src/platforms/app-plus/service/framework/plugins/data.js
+12
-12
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
...platforms/app-plus/service/framework/plugins/vdom-sync.js
+16
-16
未找到文件。
build/build.js
浏览文件 @
4c3c76c5
...
...
@@ -41,7 +41,7 @@ service.run('build', {
entry
,
clean
:
!
process
.
env
.
UNI_VIEW
,
mode
:
process
.
env
.
NODE_ENV
}).
then
(
function
()
{
}).
then
(
function
()
{
if
(
process
.
env
.
UNI_WATCH
!==
'
true
'
&&
process
.
env
.
UNI_UI
!==
'
true
'
&&
...
...
@@ -62,7 +62,7 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_WATCH === 'false') {
const
packageJsonPath
=
path
.
join
(
packagePath
,
'
package.json
'
)
del
(
path
.
join
(
packagePath
,
'
{lib,src}
'
))
.
then
(()
=>
{
copy
([
path
.
join
(
__dirname
,
'
../{lib,src}/**/*
'
)],
packagePath
,
function
(
err
,
file
)
{
copy
([
path
.
join
(
__dirname
,
'
../{lib,src}/**/*
'
)],
packagePath
,
function
(
err
,
file
)
{
if
(
err
)
{
throw
err
}
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
4c3c76c5
...
...
@@ -3577,10 +3577,12 @@ var serviceContext = (function () {
}
}
const
ANI_SHOW
=
plus
.
os
.
name
===
'
Android
'
&&
parseInt
(
plus
.
os
.
version
)
<
6
?
'
slide-in-right
'
:
'
pop-in
'
;
const
ANI_DURATION
=
300
;
const
ANI_CLOSE
=
'
pop-out
'
;
const
downgrade
=
plus
.
os
.
name
===
'
Android
'
&&
parseInt
(
plus
.
os
.
version
)
<
6
;
const
ANI_SHOW
=
downgrade
?
'
slide-in-right
'
:
'
pop-in
'
;
const
ANI_DURATION
=
300
;
const
ANI_CLOSE
=
downgrade
?
'
slide-out-right
'
:
'
pop-out
'
;
const
TITLEBAR_HEIGHT
=
44
;
...
...
packages/uni-app-plus/dist/service.runtime.esm.js
浏览文件 @
4c3c76c5
...
...
@@ -1952,7 +1952,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
};
}
else
if
(
typeof
setImmediate
!==
'
undefined
'
&&
isNative
(
setImmediate
))
{
// Fallback to setImmediate.
// Tech
i
nically it leverages the (macro) task queue,
// Technically it leverages the (macro) task queue,
// but it is still a better choice than setTimeout.
timerFunc
=
function
()
{
setImmediate
(
flushCallbacks
);
...
...
packages/uni-app-plus/dist/view.css
浏览文件 @
4c3c76c5
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
4c3c76c5
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
浏览文件 @
4c3c76c5
...
...
@@ -5,53 +5,73 @@ const {
log
,
done
}
=
require
(
'
@vue/cli-shared-utils
'
)
let
serviceCompiled
=
true
let
viewCompiled
=
true
class
WebpackAppPlusPlugin
{
apply
(
compiler
)
{
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
process
.
env
.
UNI_USING_V3
)
{
const
isAppService
=
compiler
.
options
.
entry
[
'
app-service
'
]
const
isAppView
=
compiler
.
options
.
entry
[
'
app-view
'
]
compiler
.
hooks
.
beforeCompile
.
tapAsync
(
'
WebpackAppPlusPlugin
'
,
(
params
,
callback
)
=>
{
isAppService
&&
(
serviceCompiled
=
false
)
isAppView
&&
(
viewCompiled
=
false
)
callback
()
})
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
isAppService
&&
(
serviceCompiled
=
true
)
isAppView
&&
(
viewCompiled
=
true
)
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
return
resolve
()
}
if
(
process
.
env
.
UNI_USING_V3
)
{
log
()
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
done
(
`Build complete. Watching for changes...`
)
}
else
{
done
(
`Build complete. `
)
if
(
serviceCompiled
&&
viewCompiled
)
{
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
done
(
`Build complete. Watching for changes...`
)
}
else
{
done
(
`Build complete. `
)
}
}
return
resolve
()
}
const
callback
=
function
()
{
fs
.
copyFileSync
(
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
'
manifest.json
'
),
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
manifest.json
'
))
log
()
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
done
(
`Build complete. Watching for changes...`
)
}
else
{
done
(
`Build complete. `
)
}
resolve
()
}
// Copy manifest.json
const
wxmp
=
require
(
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
weapp-tools/lib
'
))
try
{
wxmp
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
process
.
env
.
UNI_OUTPUT_DIR
,
path
.
basename
(
process
.
env
.
UNI_INPUT_DIR
),
callback
)
}
catch
(
e
)
{
resolve
()
console
.
error
(
e
.
message
)
}
})
})
}
else
{
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
return
resolve
()
}
const
callback
=
function
()
{
fs
.
copyFileSync
(
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
'
manifest.json
'
),
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
manifest.json
'
))
log
()
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
done
(
`Build complete. Watching for changes...`
)
}
else
{
done
(
`Build complete. `
)
}
resolve
()
}
// Copy manifest.json
const
wxmp
=
require
(
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
weapp-tools/lib
'
))
try
{
wxmp
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
process
.
env
.
UNI_OUTPUT_DIR
,
path
.
basename
(
process
.
env
.
UNI_INPUT_DIR
),
callback
)
}
catch
(
e
)
{
resolve
()
console
.
error
(
e
.
message
)
}
})
})
}
)
}
}
}
...
...
packages/vue-cli-plugin-uni/lib/app-plus/index.js
浏览文件 @
4c3c76c5
...
...
@@ -56,6 +56,13 @@ const v3 = {
'
../../packages/webpack-uni-app-loader/view/script
'
)
}]
})
}
const
entry
=
{}
if
(
isAppService
)
{
entry
[
'
app-service
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
else
if
(
isAppView
)
{
entry
[
'
app-view
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
return
{
...
...
@@ -64,15 +71,7 @@ const v3 = {
externals
:
{
vue
:
'
Vue
'
},
entry
()
{
const
entry
=
{}
if
(
isAppService
)
{
entry
[
'
app-service
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
else
if
(
isAppView
)
{
entry
[
'
app-view
'
]
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getMainEntry
())
}
return
entry
},
entry
,
output
:
{
filename
:
'
[name].js
'
,
chunkFilename
:
'
[id].js
'
,
...
...
src/platforms/app-plus/service/framework/plugins/data.js
浏览文件 @
4c3c76c5
...
...
@@ -16,17 +16,17 @@ import {
diff
}
from
'
./diff
'
export
function
initData
(
Vue
)
{
export
function
initData
(
Vue
)
{
Vue
.
prototype
.
_$s
=
setData
Vue
.
prototype
.
_$i
=
setIfData
Vue
.
prototype
.
_$f
=
setForData
Vue
.
prototype
.
_$e
=
setElseIfData
Vue
.
prototype
.
_$setData
=
function
setData
(
type
,
data
)
{
Vue
.
prototype
.
_$setData
=
function
setData
(
type
,
data
)
{
this
.
_$vd
.
push
(
type
,
this
.
_$id
,
data
)
}
Vue
.
prototype
.
_$mounted
=
function
mounted
()
{
Vue
.
prototype
.
_$mounted
=
function
mounted
()
{
if
(
!
this
.
_$vd
)
{
return
}
...
...
@@ -39,7 +39,7 @@ export function initData(Vue) {
}
}
Vue
.
prototype
.
_$updated
=
function
updated
()
{
Vue
.
prototype
.
_$updated
=
function
updated
()
{
if
(
!
this
.
_$vd
)
{
return
}
...
...
@@ -50,13 +50,13 @@ export function initData(Vue) {
}
Object
.
defineProperty
(
Vue
.
prototype
,
'
_$vd
'
,
{
get
()
{
get
()
{
return
this
.
$root
.
_$vdomSync
}
})
Vue
.
mixin
({
beforeCreate
()
{
beforeCreate
()
{
if
(
this
.
$options
.
mpType
)
{
this
.
mpType
=
this
.
$options
.
mpType
}
...
...
@@ -77,7 +77,7 @@ export function initData(Vue) {
this
.
_$newData
=
Object
.
create
(
null
)
}
},
beforeUpdate
()
{
beforeUpdate
()
{
if
(
!
this
.
_$vd
)
{
return
}
...
...
@@ -86,7 +86,7 @@ export function initData(Vue) {
console
.
log
(
`[
${
this
.
_$id
}
] beforeUpdate `
+
Date
.
now
())
this
.
_$newData
=
Object
.
create
(
null
)
},
beforeDestroy
()
{
beforeDestroy
()
{
if
(
!
this
.
_$vd
)
{
return
}
...
...
@@ -96,7 +96,7 @@ export function initData(Vue) {
})
}
function
setData
(
id
,
name
,
value
)
{
function
setData
(
id
,
name
,
value
)
{
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{})
if
(
typeof
name
!==
'
string
'
)
{
...
...
@@ -112,7 +112,7 @@ function setData(id, name, value) {
return
(
diffData
[
name
]
=
value
)
}
function
setForData
(
id
,
value
)
{
function
setForData
(
id
,
value
)
{
const
diffData
=
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{})
const
vForData
=
diffData
[
'
v-for
'
]
||
(
diffData
[
'
v-for
'
]
=
[])
...
...
@@ -133,10 +133,10 @@ function setForData(id, value) {
return
key
}
function
setIfData
(
id
,
value
)
{
function
setIfData
(
id
,
value
)
{
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
'
v-if
'
]
=
value
)
}
function
setElseIfData
(
id
,
value
)
{
function
setElseIfData
(
id
,
value
)
{
return
((
this
.
_$newData
[
id
]
||
(
this
.
_$newData
[
id
]
=
{}))[
'
v-else-if
'
]
=
value
)
}
src/platforms/app-plus/service/framework/plugins/vdom-sync.js
浏览文件 @
4c3c76c5
...
...
@@ -12,12 +12,12 @@ import {
registerWebviewUIEvent
}
from
'
../subscribe-handlers
'
function
noop
()
{}
function
noop
()
{}
const
callbacks
=
[]
// 数据同步 callback
export
class
VDomSync
{
constructor
(
pageId
,
pagePath
)
{
constructor
(
pageId
,
pagePath
)
{
this
.
pageId
=
pageId
this
.
pagePath
=
pagePath
this
.
batchData
=
[]
...
...
@@ -29,7 +29,7 @@ export class VDomSync {
this
.
_init
()
}
_init
()
{
_init
()
{
UniServiceJSBridge
.
subscribe
(
VD_SYNC_CALLBACK
,
()
=>
{
const
copies
=
callbacks
.
slice
(
0
)
callbacks
.
length
=
0
...
...
@@ -56,43 +56,43 @@ export class VDomSync {
})
}
addMountedVm
(
vm
)
{
addMountedVm
(
vm
)
{
vm
.
_$mounted
()
// 触发vd数据同步
this
.
addCallback
(
function
mounted
()
{
this
.
addCallback
(
function
mounted
()
{
vm
.
__call_hook
(
'
mounted
'
)
})
}
addUpdatedVm
(
vm
)
{
addUpdatedVm
(
vm
)
{
vm
.
_$updated
()
// 触发vd数据同步
this
.
addCallback
(
function
mounted
()
{
this
.
addCallback
(
function
mounted
()
{
vm
.
__call_hook
(
'
updated
'
)
})
}
addCallback
(
callback
)
{
addCallback
(
callback
)
{
isFn
(
callback
)
&&
callbacks
.
push
(
callback
)
}
getVm
(
id
)
{
getVm
(
id
)
{
return
this
.
vms
[
id
]
}
addVm
(
vm
)
{
addVm
(
vm
)
{
this
.
vms
[
vm
.
_$id
]
=
vm
}
removeVm
(
vm
)
{
removeVm
(
vm
)
{
delete
this
.
vms
[
vm
.
_$id
]
}
addEvent
(
cid
,
nid
,
name
,
handler
)
{
addEvent
(
cid
,
nid
,
name
,
handler
)
{
const
cHandlers
=
this
.
handlers
[
cid
]
||
(
this
.
handlers
[
cid
]
=
Object
.
create
(
null
))
const
nHandlers
=
cHandlers
[
nid
]
||
(
cHandlers
[
nid
]
=
Object
.
create
(
null
));
(
nHandlers
[
name
]
||
(
nHandlers
[
name
]
=
[])).
push
(
handler
)
}
removeEvent
(
cid
,
nid
,
name
,
handler
)
{
removeEvent
(
cid
,
nid
,
name
,
handler
)
{
const
cHandlers
=
this
.
handlers
[
cid
]
||
(
this
.
handlers
[
cid
]
=
Object
.
create
(
null
))
const
nHandlers
=
cHandlers
[
nid
]
||
(
cHandlers
[
nid
]
=
Object
.
create
(
null
))
const
eHandlers
=
nHandlers
[
name
]
...
...
@@ -104,11 +104,11 @@ export class VDomSync {
}
}
push
(
type
,
nodeId
,
data
)
{
push
(
type
,
nodeId
,
data
)
{
this
.
batchData
.
push
([
type
,
[
nodeId
,
data
]])
}
flush
()
{
flush
()
{
if
(
!
this
.
initialized
)
{
this
.
initialized
=
true
this
.
batchData
.
push
([
PAGE_CREATED
,
[
this
.
pageId
,
this
.
pagePath
]])
...
...
@@ -124,7 +124,7 @@ export class VDomSync {
}
}
destroy
()
{
destroy
()
{
this
.
batchData
.
length
=
0
this
.
vms
=
Object
.
create
(
null
)
this
.
initialized
=
false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录