Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_38335589
uni-app
提交
7faa2657
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,发现更多精彩内容 >>
提交
7faa2657
编写于
9月 15, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 移除 mp-kuaishou 部分冗余代码
上级
4e69bd31
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
9 addition
and
329 deletion
+9
-329
src/platforms/mp-kuaishou/runtime/wrapper/app-base-parser.js
src/platforms/mp-kuaishou/runtime/wrapper/app-base-parser.js
+0
-86
src/platforms/mp-kuaishou/runtime/wrapper/app-parser.js
src/platforms/mp-kuaishou/runtime/wrapper/app-parser.js
+3
-11
src/platforms/mp-kuaishou/runtime/wrapper/component-base-parser.js
...orms/mp-kuaishou/runtime/wrapper/component-base-parser.js
+0
-105
src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js
...platforms/mp-kuaishou/runtime/wrapper/component-parser.js
+3
-11
src/platforms/mp-kuaishou/runtime/wrapper/page-base-parser.js
...platforms/mp-kuaishou/runtime/wrapper/page-base-parser.js
+0
-33
src/platforms/mp-kuaishou/runtime/wrapper/page-parser.js
src/platforms/mp-kuaishou/runtime/wrapper/page-parser.js
+3
-11
src/platforms/mp-kuaishou/runtime/wrapper/util.js
src/platforms/mp-kuaishou/runtime/wrapper/util.js
+0
-72
未找到文件。
src/platforms/mp-kuaishou/runtime/wrapper/app-base-parser.js
已删除
100644 → 0
浏览文件 @
4e69bd31
import
Vue
from
'
vue
'
import
{
initHooks
,
initMocks
}
from
'
uni-wrapper/util
'
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
]
export
default
function
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
{
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
}
Vue
.
prototype
.
mpHost
=
__PLATFORM__
Vue
.
mixin
({
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
return
}
this
.
mpType
=
this
.
$options
.
mpType
this
.
$mp
=
{
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
}
this
.
$scope
=
this
.
$options
.
mpInstance
delete
this
.
$options
.
mpType
delete
this
.
$options
.
mpInstance
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
)
initMocks
(
this
,
mocks
)
}
}
})
const
appOptions
=
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
}
this
.
$vm
=
vm
this
.
$vm
.
$mp
=
{
app
:
this
}
this
.
$vm
.
$scope
=
this
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
)
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
)
}
}
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{}
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
]
})
}
initHooks
(
appOptions
,
hooks
)
return
appOptions
}
src/platforms/mp-kuaishou/runtime/wrapper/app-parser.js
浏览文件 @
7faa2657
import
parseBaseApp
from
'
./app-base-parser
'
import
{
mocks
,
initRefs
}
from
'
./util
'
import
parseBaseApp
from
'
../../../mp-weixin/runtime/wrapper/app-parser
'
export
default
function
parseApp
(
vm
)
{
return
parseBaseApp
(
vm
,
{
mocks
,
initRefs
})
}
return
parseBaseApp
(
vm
)
}
src/platforms/mp-kuaishou/runtime/wrapper/component-base-parser.js
已删除
100644 → 0
浏览文件 @
4e69bd31
import
Vue
from
'
vue
'
import
{
initData
,
initSlots
,
initVueIds
,
handleEvent
,
initBehaviors
,
initProperties
,
initVueComponent
}
from
'
uni-wrapper/util
'
import
{
handleLink
,
initBehavior
}
from
'
./util
'
export
default
function
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
}
=
{})
{
const
[
VueComponent
,
vueOptions
]
=
initVueComponent
(
Vue
,
vueComponentOptions
)
const
options
=
{
multipleSlots
:
true
,
addGlobalClass
:
true
}
const
componentOptions
=
{
options
,
data
:
initData
(
vueOptions
,
Vue
.
prototype
),
behaviors
:
initBehaviors
(
vueOptions
,
initBehavior
),
properties
:
initProperties
(
vueOptions
.
props
,
false
,
vueOptions
.
__file
),
lifetimes
:
{
attached
()
{
const
properties
=
this
.
properties
const
options
=
{
mpType
:
isPage
.
call
(
this
)
?
'
page
'
:
'
component
'
,
mpInstance
:
this
,
propsData
:
properties
}
initVueIds
(
properties
.
vueId
,
this
)
// 处理父子关系
initRelation
.
call
(
this
,
{
vuePid
:
this
.
_$vuePid
,
vueOptions
:
options
})
// 初始化 vue 实例
this
.
$vm
=
new
VueComponent
(
options
)
// 处理$slots,$scopedSlots(暂不支持动态变化$slots)
initSlots
(
this
.
$vm
,
properties
.
vueSlots
)
// 触发首次 setData
this
.
$vm
.
$mount
()
},
ready
()
{
// 当组件 props 默认值为 true,初始化时传入 false 会导致 created,ready 触发, 但 attached 不触发
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
this
.
$vm
.
__call_hook
(
'
onReady
'
)
}
else
{
// this.is && console.warn(this.is + ' is not attached')
}
},
detached
()
{
this
.
$vm
.
$destroy
()
}
},
pageLifetimes
:
{
show
(
args
)
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageShow
'
,
args
)
},
hide
()
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageHide
'
)
},
resize
(
size
)
{
this
.
$vm
&&
this
.
$vm
.
__call_hook
(
'
onPageResize
'
,
size
)
}
},
methods
:
{
__l
:
handleLink
,
__e
:
handleEvent
}
}
if
(
Array
.
isArray
(
vueOptions
.
wxsCallMethods
))
{
vueOptions
.
wxsCallMethods
.
forEach
(
callMethod
=>
{
componentOptions
.
methods
[
callMethod
]
=
function
(
args
)
{
return
this
.
$vm
[
callMethod
](
args
)
}
})
}
if
(
isPage
)
{
return
componentOptions
}
return
[
componentOptions
,
VueComponent
]
}
src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js
浏览文件 @
7faa2657
import
parseBaseComponent
from
'
./component-base-parser
'
import
{
isPage
,
initRelation
}
from
'
./util
'
import
parseBaseComponent
from
'
../../../mp-weixin/runtime/wrapper/component-parser
'
export
default
function
parseComponent
(
vueComponentOptions
)
{
return
parseBaseComponent
(
vueComponentOptions
,
{
isPage
,
initRelation
})
}
return
parseBaseComponent
(
vueComponentOptions
)
}
src/platforms/mp-kuaishou/runtime/wrapper/page-base-parser.js
已删除
100644 → 0
浏览文件 @
4e69bd31
import
{
initHooks
,
PAGE_EVENT_HOOKS
}
from
'
uni-wrapper/util
'
import
parseComponent
from
'
uni-platform/runtime/wrapper/component-parser
'
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
'
onUnload
'
]
hooks
.
push
(...
PAGE_EVENT_HOOKS
)
export
default
function
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
{
const
pageOptions
=
parseComponent
(
vuePageOptions
,
{
isPage
,
initRelation
})
initHooks
(
pageOptions
.
methods
,
hooks
,
vuePageOptions
)
pageOptions
.
methods
.
onLoad
=
function
(
args
)
{
this
.
$vm
.
$mp
.
query
=
args
// 兼容 mpvue
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
args
)
}
return
pageOptions
}
src/platforms/mp-kuaishou/runtime/wrapper/page-parser.js
浏览文件 @
7faa2657
import
parseBasePage
from
'
./page-base-parser
'
import
{
isPage
,
initRelation
}
from
'
./util
'
import
parseBasePage
from
'
../../../mp-weixin/runtime/wrapper/page-parser
'
export
default
function
parsePage
(
vuePageOptions
)
{
return
parseBasePage
(
vuePageOptions
,
{
isPage
,
initRelation
})
}
return
parseBasePage
(
vuePageOptions
)
}
src/platforms/mp-kuaishou/runtime/wrapper/util.js
已删除
100644 → 0
浏览文件 @
4e69bd31
/* 快手也使用__wxExparserNodeId__和__wxWebviewId__ */
export
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
]
export
function
findVmByVueId
(
vm
,
vuePid
)
{
const
$children
=
vm
.
$children
// 优先查找直属
let
parentVm
=
$children
.
find
(
childVm
=>
childVm
.
$scope
.
_$vueId
===
vuePid
)
if
(
parentVm
)
{
return
parentVm
}
// 反向递归查找
for
(
let
i
=
$children
.
length
-
1
;
i
>=
0
;
i
--
)
{
parentVm
=
findVmByVueId
(
$children
[
i
],
vuePid
)
if
(
parentVm
)
{
return
parentVm
}
}
}
export
function
initBehavior
(
options
)
{
return
Behavior
(
options
)
}
export
function
isPage
()
{
return
!!
this
.
route
}
export
function
initRelation
(
detail
)
{
this
.
triggerEvent
(
'
__l
'
,
detail
)
}
export
function
initRefs
(
vm
)
{
const
mpInstance
=
vm
.
$scope
Object
.
defineProperty
(
vm
,
'
$refs
'
,
{
get
()
{
const
$refs
=
{}
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
)
components
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
$refs
[
ref
]
=
component
.
$vm
||
component
})
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
forComponents
.
forEach
(
component
=>
{
const
ref
=
component
.
dataset
.
ref
if
(
!
$refs
[
ref
])
{
$refs
[
ref
]
=
[]
}
$refs
[
ref
].
push
(
component
.
$vm
||
component
)
})
return
$refs
}
})
}
export
function
handleLink
(
event
)
{
const
{
vuePid
,
vueOptions
}
=
event
.
detail
||
event
.
value
// detail 是微信,value 是百度(dipatch)
let
parentVm
if
(
vuePid
)
{
parentVm
=
findVmByVueId
(
this
.
$vm
,
vuePid
)
}
if
(
!
parentVm
)
{
parentVm
=
this
.
$vm
}
vueOptions
.
parent
=
parentVm
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录