Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
34e27b2c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
34e27b2c
编写于
7月 01, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: 通过 json 文件生成部分 tabBar 页面目录
上级
22d5663f
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
2945 addition
and
117 deletion
+2945
-117
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+131
-46
pages/tabBar/CSS.uvue
pages/tabBar/CSS.uvue
+106
-20
pages/tabBar/component.uvue
pages/tabBar/component.uvue
+136
-51
target-pages.json
target-pages.json
+2572
-0
未找到文件。
pages/tabBar/API.uvue
浏览文件 @
34e27b2c
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1;
background-color: #f8f8f8;
" enable-back-to-top="true">
<scroll-view style="flex: 1;
background-color: #f8f8f8
" enable-back-to-top="true">
<!-- #endif -->
<!-- #endif -->
<view class="uni-container">
<view class="uni-container">
<view class="uni-header-logo">
<view class="uni-header-logo">
...
@@ -24,6 +24,32 @@
...
@@ -24,6 +24,32 @@
</uni-collapse-item>
</uni-collapse-item>
</template>
</template>
</uni-collapse>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<template v-for="menuItem in menu" :key="menuItem.id">
<uni-collapse-item :title="menuItem.name" class="item">
<view v-for="page in menuItem.pages" :key="page.path" class="uni-navigate-item" hover-class="is--active"
@click="goPage(`/${page.path}`)">
<text class="uni-navigate-text">{{
page.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
<uni-collapse style="width: 100%" v-for="childMenu in menuItem.children" :key="childMenu.id">
<uni-collapse-item :title="childMenu.name" class="item" style="margin-bottom: 0">
<view class="uni-navigate-item" hover-class="is--active" v-for="childPage in childMenu.pages"
:key="childPage.path" @click="goPage(`/${childPage.path}`)">
<text class="uni-navigate-text">{{
childPage.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</uni-collapse>
</uni-collapse-item>
</template>
</uni-collapse>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
@@ -36,6 +62,61 @@
...
@@ -36,6 +62,61 @@
</template>
</template>
<script lang="uts">
<script lang="uts">
import { pages } from '@/target-pages.json'
type PagesJsonPageGroup = {
id : string,
name : string
}
type PagesJsonPage = {
path : string,
style : UTSJSONObject,
group ?: PagesJsonPageGroup[] | null
}
type MenuItem = {
id : string,
name : string,
children : MenuItem[],
pages : PagesJsonPage[]
}
const menu : MenuItem[] = []
const menuKeyMap = new Map<string, number>()
// #ifdef APP-ANDROID
const apiPages = JSON.parse<PagesJsonPage[]>(JSON.stringify(pages))!.filter((page : PagesJsonPage) : boolean => page.path.startsWith('pages/API') && page.group !== null)
// #endif
// #ifdef WEB || APP-IOS
const apiPages = (pages as unknown as PagesJsonPage[]).filter(page => page.path.startsWith('pages/API') && page.group)
// #endif
apiPages.forEach(page => {
let currentArr : MenuItem[] = menu
let currentMenu : MenuItem | null = null
if (page.group !== null) {
page.group!.forEach((item, index) => {
const { id, name } = item
const ids = id.split('.')
const _id = ids[ids.length - 1]
if (!menuKeyMap.has(id)) {
menuKeyMap.set(id, currentArr.length)
currentArr.push({
id: _id,
name,
children: [] as MenuItem[],
pages: [] as PagesJsonPage[]
} as MenuItem)
}
currentMenu = currentArr[menuKeyMap.get(id)!]
if (index < page.group!.length - 1) {
currentArr = currentArr[menuKeyMap.get(id)!].children as MenuItem[]
}
})
}
if (currentMenu !== null) {
(currentMenu as MenuItem).pages.push(page)
}
})
console.log('menu', menu)
type Page = {
type Page = {
name : string
name : string
url : string
url : string
...
@@ -52,6 +133,7 @@
...
@@ -52,6 +133,7 @@
export default {
export default {
data() {
data() {
return {
return {
menu: menu as MenuItem[],
list: [
list: [
{
{
id: 'global',
id: 'global',
...
@@ -208,10 +290,10 @@
...
@@ -208,10 +290,10 @@
api: ["showToast"]
api: ["showToast"]
}
}
// #ifdef APP
// #ifdef APP
,
{
,
{
name: '主题切换',
name: '主题切换',
url: 'theme-change',
url: 'theme-change',
api: ["setAppTheme",
"onOsThemeChange","offOsThemeChange","onAppThemeChange","offAppThemeChange"]
api: ["setAppTheme",
"onOsThemeChange", "offOsThemeChange", "onAppThemeChange", "offAppThemeChange"]
}
}
// #endif
// #endif
] as Page[],
] as Page[],
...
@@ -593,6 +675,9 @@
...
@@ -593,6 +675,9 @@
url,
url,
})
})
},
},
goPage(url : string) {
uni.navigateTo({ url })
},
showPop: function () {
showPop: function () {
(this.$refs["pop"] as UniElement).style.setProperty("display", "flex")
(this.$refs["pop"] as UniElement).style.setProperty("display", "flex")
},
},
...
...
pages/tabBar/CSS.uvue
浏览文件 @
34e27b2c
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1;
background-color: #f8f8f8;
" enable-back-to-top="true">
<scroll-view style="flex: 1;
background-color: #f8f8f8
" enable-back-to-top="true">
<!-- #endif -->
<!-- #endif -->
<view class="uni-container">
<view class="uni-container">
<view class="uni-header-logo">
<view class="uni-header-logo">
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<uni-collapse>
<uni-collapse>
<template v-for="item in list" :key="item.id">
<template v-for="item in list" :key="item.id">
<uni-collapse-item :title="item.name" class="item">
<uni-collapse-item :title="item.name" class="item">
<view class="uni-navigate-item" :hover-class="page.enable == false
?'':
'is--active'"
<view class="uni-navigate-item" :hover-class="page.enable == false
? '' :
'is--active'"
v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
<text class="uni-navigate-text"
<text class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
...
@@ -23,6 +23,32 @@
...
@@ -23,6 +23,32 @@
</uni-collapse-item>
</uni-collapse-item>
</template>
</template>
</uni-collapse>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<template v-for="menuItem in menu" :key="menuItem.id">
<uni-collapse-item :title="menuItem.name" class="item">
<view v-for="page in menuItem.pages" :key="page.path" class="uni-navigate-item" hover-class="is--active"
@click="goPage(`/${page.path}`)">
<text class="uni-navigate-text">{{
page.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
<uni-collapse style="width: 100%" v-for="childMenu in menuItem.children" :key="childMenu.id">
<uni-collapse-item :title="childMenu.name" class="item" style="margin-bottom: 0">
<view class="uni-navigate-item" hover-class="is--active" v-for="childPage in childMenu.pages"
:key="childPage.path" @click="goPage(`/${childPage.path}`)">
<text class="uni-navigate-text">{{
childPage.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</uni-collapse>
</uni-collapse-item>
</template>
</uni-collapse>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
@@ -30,6 +56,62 @@
...
@@ -30,6 +56,62 @@
</template>
</template>
<script lang="uts">
<script lang="uts">
import { pages } from '@/target-pages.json'
type PagesJsonPageGroup = {
id : string,
name : string
}
type PagesJsonPage = {
path : string,
style : UTSJSONObject,
group ?: PagesJsonPageGroup[] | null
}
type MenuItem = {
id : string,
name : string,
children : MenuItem[],
pages : PagesJsonPage[]
}
const menu : MenuItem[] = []
const menuKeyMap = new Map<string, number>()
// #ifdef APP-ANDROID
const cssPages = JSON.parse<PagesJsonPage[]>(JSON.stringify(pages))!.filter((page : PagesJsonPage) : boolean => page.path.startsWith('pages/CSS') && page.group !== null)
// #endif
// #ifdef WEB || APP-IOS
const cssPages = (pages as unknown as PagesJsonPage[]).filter(page => page.path.startsWith('pages/CSS') && page.group)
// #endif
cssPages.forEach(page => {
let currentArr : MenuItem[] = menu
let currentMenu : MenuItem | null = null
if (page.group !== null) {
page.group!.forEach((item, index) => {
const { id, name } = item
const ids = id.split('.')
const _id = ids[ids.length - 1]
if (!menuKeyMap.has(id)) {
menuKeyMap.set(id, currentArr.length)
currentArr.push({
id: _id,
name,
children: [] as MenuItem[],
pages: [] as PagesJsonPage[]
} as MenuItem)
}
currentMenu = currentArr[menuKeyMap.get(id)!]
if (index < page.group!.length - 1) {
currentArr = currentArr[menuKeyMap.get(id)!].children as MenuItem[]
}
})
}
if (currentMenu !== null) {
(currentMenu as MenuItem).pages.push(page)
}
})
console.log('menu', menu)
type Page = {
type Page = {
name : string
name : string
enable ?: boolean
enable ?: boolean
...
@@ -45,6 +127,7 @@
...
@@ -45,6 +127,7 @@
export default {
export default {
data() {
data() {
return {
return {
menu: menu as MenuItem[],
list: [
list: [
{
{
id: 'background',
id: 'background',
...
@@ -398,6 +481,9 @@
...
@@ -398,6 +481,9 @@
url,
url,
})
})
},
},
goPage(url : string) {
uni.navigateTo({ url })
},
},
},
}
}
</script>
</script>
...
...
pages/tabBar/component.uvue
浏览文件 @
34e27b2c
<template>
<template>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1; background-color: #f8f8f8
;
" enable-back-to-top="true">
<scroll-view style="flex: 1; background-color: #f8f8f8" enable-back-to-top="true">
<!-- #endif -->
<!-- #endif -->
<view class="uni-container">
<view class="uni-container">
<view class="uni-header-logo">
<view class="uni-header-logo">
...
@@ -24,6 +24,32 @@
...
@@ -24,6 +24,32 @@
</template>
</template>
</uni-collapse>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<template v-for="menuItem in menu" :key="menuItem.id">
<uni-collapse-item :title="menuItem.name" class="item">
<view v-for="page in menuItem.pages" :key="page.path" class="uni-navigate-item" hover-class="is--active"
@click="goPage(`/${page.path}`)">
<text class="uni-navigate-text">{{
page.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
<uni-collapse style="width: 100%" v-for="childMenu in menuItem.children" :key="childMenu.id">
<uni-collapse-item :title="childMenu.name" class="item" style="margin-bottom: 0">
<view class="uni-navigate-item" hover-class="is--active" v-for="childPage in childMenu.pages"
:key="childPage.path" @click="goPage(`/${childPage.path}`)">
<text class="uni-navigate-text">{{
childPage.style["navigationBarTitleText"]
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</uni-collapse>
</uni-collapse-item>
</template>
</uni-collapse>
<!-- #ifdef UNI-APP-X && APP -->
<!-- #ifdef UNI-APP-X && APP -->
<uni-upgrade-center-app ref="upgradePopup" @show="upgradePopupShow" @close="upgradePopupClose" />
<uni-upgrade-center-app ref="upgradePopup" @show="upgradePopupShow" @close="upgradePopupClose" />
<!-- #endif -->
<!-- #endif -->
...
@@ -34,6 +60,61 @@
...
@@ -34,6 +60,61 @@
</template>
</template>
<script lang="uts">
<script lang="uts">
import { pages } from '@/target-pages.json'
type PagesJsonPageGroup = {
id : string,
name : string
}
type PagesJsonPage = {
path : string,
style : UTSJSONObject,
group ?: PagesJsonPageGroup[] | null
}
type MenuItem = {
id : string,
name : string,
children : MenuItem[],
pages : PagesJsonPage[]
}
const menu : MenuItem[] = []
const menuKeyMap = new Map<string, number>()
// #ifdef APP-ANDROID
const componentPages = JSON.parse<PagesJsonPage[]>(JSON.stringify(pages))!.filter((page : PagesJsonPage) : boolean => page.path.startsWith('pages/component') && page.group !== null)
// #endif
// #ifdef WEB || APP-IOS
const componentPages = (pages as unknown as PagesJsonPage[]).filter(page => page.path.startsWith('pages/component') && page.group)
// #endif
componentPages.forEach(page => {
let currentArr : MenuItem[] = menu
let currentMenu : MenuItem | null = null
if (page.group !== null) {
page.group!.forEach((item, index) => {
const { id, name } = item
const ids = id.split('.')
const _id = ids[ids.length - 1]
if (!menuKeyMap.has(id)) {
menuKeyMap.set(id, currentArr.length)
currentArr.push({
id: _id,
name,
children: [] as MenuItem[],
pages: [] as PagesJsonPage[]
} as MenuItem)
}
currentMenu = currentArr[menuKeyMap.get(id)!]
if (index < page.group!.length - 1) {
currentArr = currentArr[menuKeyMap.get(id)!].children as MenuItem[]
}
})
}
if (currentMenu !== null) {
(currentMenu as MenuItem).pages.push(page)
}
})
console.log('menu', menu)
// #ifdef UNI-APP-X && APP
// #ifdef UNI-APP-X && APP
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
// #endif
// #endif
...
@@ -53,6 +134,7 @@
...
@@ -53,6 +134,7 @@
export default {
export default {
data() {
data() {
return {
return {
menu: menu as MenuItem[],
list: [
list: [
{
{
id: 'view',
id: 'view',
...
@@ -257,22 +339,22 @@
...
@@ -257,22 +339,22 @@
pages: [
pages: [
{
{
name: '通用属性',
name: '通用属性',
url: '/pages/component/
general-attribute/general-attribute
',
url: '/pages/component/
public-properties/public-properties
',
enable: true,
enable: true,
},
},
{
{
name: '通用事件',
name: '通用事件',
url: '/pages/component/
general-event/general-event
',
url: '/pages/component/
public-events/public-events
',
enable: true,
enable: true,
},
},
{
{
name: 'touch事件',
name: 'touch事件',
url: '/pages/component/
general-event/touch-event
',
url: '/pages/component/
public-events/touch-events
',
enable: true,
enable: true,
},
},
{
{
name: 'Transition事件',
name: 'Transition事件',
url: '/pages/component/
general-event/transition-event
',
url: '/pages/component/
public-events/transition-events
',
enable: true,
enable: true,
},
},
] as Page[],
] as Page[],
...
@@ -298,9 +380,12 @@
...
@@ -298,9 +380,12 @@
uni.navigateTo({
uni.navigateTo({
url,
url,
})
})
}
},
goPage(url : string) {
uni.navigateTo({ url })
},
// #ifdef UNI-APP-X && APP
// #ifdef UNI-APP-X && APP
,
upgradePopupShow() {
upgradePopupShow() {
console.log('upgradePopup show');
console.log('upgradePopup show');
if (!this.pageHiden) {
if (!this.pageHiden) {
uni.hideTabBar()?.catch(_ => { })
uni.hideTabBar()?.catch(_ => { })
...
...
target-pages.json
0 → 100644
浏览文件 @
34e27b2c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录