Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
e5ea67c4
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
367
Star
3
Fork
8
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e5ea67c4
编写于
1月 03, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 拆分组合式 & 选项式 API tabBar
上级
84ee5a6b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
158 addition
and
52 deletion
+158
-52
App.uvue
App.uvue
+1
-1
pages.json
pages.json
+45
-31
pages/App.test.js
pages/App.test.js
+1
-1
pages/app-instance/index/index.uvue
pages/app-instance/index/index.uvue
+20
-13
pages/lifecycle/component/component.test.js
pages/lifecycle/component/component.test.js
+1
-1
pages/lifecycle/page/page.test.js
pages/lifecycle/page/page.test.js
+5
-4
pages/lifecycle/page/page.uvue
pages/lifecycle/page/page.uvue
+1
-1
pages/tab-bar/composition-api.uvue
pages/tab-bar/composition-api.uvue
+84
-0
pages/tab-bar/options-api.uvue
pages/tab-bar/options-api.uvue
+0
-0
未找到文件。
App.uvue
浏览文件 @
e5ea67c4
...
...
@@ -55,7 +55,7 @@
},
methods: {
checkLaunchPath() : boolean {
const HOME_PATH = '/pages/
index
'
const HOME_PATH = '/pages/
tab-bar/options-api
'
if (state.appLaunchPath != HOME_PATH) {
return false
}
...
...
pages.json
浏览文件 @
e5ea67c4
{
"pages"
:
[{
"path"
:
"pages/index"
,
"style"
:
{
"navigationBarTitleText"
:
"hello uvue"
}
"pages"
:
[
{
"path"
:
"pages/tab-bar/options-api"
,
"style"
:
{
"navigationBarTitleText"
:
"选项式 API"
}
},
{
"path"
:
"pages/tab-bar/composition-api"
,
"style"
:
{
"navigationBarTitleText"
:
"组合式 API"
}
},
{
"path"
:
"pages/app-instance/index/index"
,
...
...
@@ -267,57 +274,49 @@
{
"path"
:
"pages/state/data/data"
,
"style"
:
{
"navigationBarTitleText"
:
"data"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"data"
}
},
{
"path"
:
"pages/state/methods/methods"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/state/props/props"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/state/computed/computed"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/state/watch/watch"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/rendering/slots/slots"
,
"style"
:
{
"navigationBarTitleText"
:
"slots"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"slots"
}
},
{
"path"
:
"pages/rendering/template/template"
,
"style"
:
{
"navigationBarTitleText"
:
"template"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"template"
}
},
{
"path"
:
"pages/rendering/unrecognized-component/unrecognized-component"
,
"style"
:
{
"navigationBarTitleText"
:
"unrecognized-component"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"unrecognized-component"
}
},
{
...
...
@@ -371,18 +370,31 @@
{
"path"
:
"pages/examples/nested-component-communication/nested-component-communication"
,
"style"
:
{
"navigationBarTitleText"
:
"嵌套组件通信"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"嵌套组件通信"
}
},
{
"path"
:
"pages/examples/set-custom-child-component-root-node-class/set-custom-child-component-root-node-class"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式"
,
"enablePullDownRefresh"
:
false
"navigationBarTitleText"
:
"自定义组件中使用 class 定制另一个自定义组件根节点样式"
}
}
],
],
"tabBar"
:
{
"color"
:
"#7A7E83"
,
"selectedColor"
:
"#007AFF"
,
"borderStyle"
:
"black"
,
"backgroundColor"
:
"#F8F8F8"
,
"list"
:
[{
"pagePath"
:
"pages/tab-bar/options-api"
,
"text"
:
"选项式 API"
},
{
"pagePath"
:
"pages/tab-bar/composition-api"
,
"text"
:
"组合式 API"
}
]
},
"globalStyle"
:
{
"pageOrientation"
:
"portrait"
,
"navigationBarTitleText"
:
"Hello UVUE"
,
...
...
@@ -401,10 +413,12 @@
"condition"
:
{
//模式配置,仅开发期间生效
"current"
:
0
,
//当前激活的模式(list
的索引项)
"list"
:
[{
"name"
:
""
,
//模式名称
"path"
:
""
,
//启动页面,必选
"query"
:
""
//启动参数,在页面的onLoad函数里面得到
}]
"list"
:
[
{
"name"
:
""
,
//模式名称
"path"
:
""
,
//启动页面,必选
"query"
:
""
//启动参数,在页面的onLoad函数里面得到
}
]
}
}
\ No newline at end of file
pages/App.test.js
浏览文件 @
e5ea67c4
describe
(
"
app lanch & show options
"
,
()
=>
{
it
(
"
onLaunch onShow
"
,
async
()
=>
{
const
HOME_PATH
=
"
/pages/index
"
const
HOME_PATH
=
'
/pages/tab-bar/options-api
'
const
page
=
await
program
.
reLaunch
(
HOME_PATH
)
await
page
.
waitFor
(
1000
)
expect
(
await
page
.
callMethod
(
"
checkLaunchPath
"
)).
toBe
(
true
)
...
...
pages/app-instance/index/index.uvue
浏览文件 @
e5ea67c4
...
...
@@ -7,18 +7,25 @@
</view>
</template>
<script lang="uts">
import CompForAppComponent from '@/components/CompForAppComponent.uvue'
// #ifdef APP-ANDROID
import CompForAppUse from '@/components/CompForAppUse.uvue'
// #endif
<script lang="uts">
import { state} from '@/store/index.uts'
import CompForAppComponent from '@/components/CompForAppComponent.uvue'
// #ifdef APP-ANDROID
import CompForAppUse from '@/components/CompForAppUse.uvue'
// #endif
export default {
components: {
CompForAppComponent,
// #ifdef APP-ANDROID
CompForAppUse
// #endif
export default {
components: {
CompForAppComponent,
// #ifdef APP-ANDROID
CompForAppUse
// #endif
},
methods: {
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
}
}
}
</script>
</script>
\ No newline at end of file
pages/lifecycle/component/component.test.js
浏览文件 @
e5ea67c4
const
PAGE_PATH
=
'
/pages/lifecycle/component/component
'
const
HOME_PATH
=
'
/pages/
index
'
const
HOME_PATH
=
'
/pages/
tab-bar/options-api
'
describe
(
'
component-lifecycle
'
,
()
=>
{
let
page
...
...
pages/lifecycle/page/page.test.js
浏览文件 @
e5ea67c4
const
PAGE_PATH
=
'
/pages/lifecycle/page/page
'
const
HOME_PATH
=
'
/pages/index
'
const
PAGE_PATH
=
'
/pages/lifecycle/page/page
'
const
HOME_PATH
=
'
/pages/tab-bar/options-api
'
const
INTER_PAGE_PATH
=
'
/pages/app-instance/index/index
'
let
page
let
lifeCycleNum
...
...
@@ -54,7 +55,7 @@ describe('page-lifecycle', () => {
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onHide
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
HOM
E_PATH
)
page
=
await
program
.
navigateTo
(
INTER_PAG
E_PATH
)
await
page
.
waitFor
(
'
view
'
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
-
10
)
...
...
@@ -64,7 +65,7 @@ describe('page-lifecycle', () => {
expect
(
lifeCycleNum
).
toBe
(
0
)
})
it
(
'
onUnload
'
,
async
()
=>
{
page
=
await
program
.
re
directTo
(
HOME_PATH
)
page
=
await
program
.
re
Launch
(
HOME_PATH
)
await
page
.
waitFor
(
700
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
-
100
)
...
...
pages/lifecycle/page/page.uvue
浏览文件 @
e5ea67c4
...
...
@@ -12,7 +12,7 @@
</template>
<script lang="uts">
import {
State,
state, setLifeCycleNum } from '@/store/index.uts'
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
...
...
pages/tab-bar/composition-api.uvue
0 → 100644
浏览文件 @
e5ea67c4
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="uni-container">
<uni-collapse>
<template v-for="item in list" :key="item.id">
<uni-collapse-item :title="item.name" class="item">
<view class="uni-navigate-item" :hover-class="page.enable == false ? '' : 'is--active'"
v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(item.id, page)">
<text class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
<view class="down_arrow"></view>
</view>
</uni-collapse-item>
</template>
</uni-collapse>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type PageItem = {
name : string
enable ?: boolean
url ?: string
}
type PageList = {
id : string
name : string
open : boolean
pages : PageItem[]
url ?: string
enable ?: boolean
}
export default {
data() {
return {
list: [
] as PageList[],
}
},
methods: {
triggerCollapse(_ : PageList, index : number) {
this.list[index].open = !this.list[index].open
},
goDetailPage(id : string, e : PageItem) {
if (e.enable == false) {
uni.showToast({
icon: 'none',
title: '暂不支持',
})
return
}
const url = e.url!.includes('/') ? e.url : `${e.url}/${e.url}`
uni.navigateTo({
url: `/pages/${id}/${url}`,
})
},
},
}
</script>
<style>
.item {
margin-bottom: 12px;
}
.down_arrow {
width: 8px;
height: 8px;
transform: rotate(45deg);
border-right: 1px #999 solid;
border-bottom: 1px #999 solid;
margin-top: -3px;
transition-property: transform;
transition-duration: 0.2s;
}
</style>
\ No newline at end of file
pages/
index
.uvue
→
pages/
tab-bar/options-api
.uvue
浏览文件 @
e5ea67c4
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录