提交 d1b4900b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor: 移除 tabBar 页面历史菜单

上级 50395311
......@@ -11,21 +11,6 @@
<u-link :href="'https://uniapp.dcloud.io/uni-app-x/api/'" :text="'https://uniapp.dcloud.io/uni-app-x/api/'"
:inWhiteList="true"></u-link>
</view>
<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(page)">
<text class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</template>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :title="menuItem!.name"
class="item">
......@@ -64,564 +49,14 @@
import { generateMenu } from './generateMenu.uts'
import { MenuItem } from './generateMenu.uts'
const menu = generateMenu('pages/API')
type Page = {
name : string
url : string
enable ?: boolean
api ?: Array<string>
}
type ListItem = {
id : string
name : string
pages : Page[]
url ?: string
enable ?: boolean
}
export default {
data() {
return {
menu: menu as (MenuItem | null)[],
list: [
{
id: 'global',
name: '全局',
pages: [
{
name: 'getApp',
url: 'get-app',
},
{
name: 'getCurrentPages',
url: 'get-current-pages',
}
] as Page[],
},
{
id: 'base',
name: '基础',
pages: [
{
name: '事件总线event-bus',
url: 'event-bus',
api: ["$on", "$once", "$off", "$emit"]
},
{
name: '拦截器',
url: 'interceptor',
api: ["addInterceptor", "removeInterceptor"]
},
{
name: '获取启动参数',
url: 'get-launch-options-sync',
},
// #ifndef WEB
{
name: 'env环境变量',
url: 'env'
},
// #endif
// #ifdef APP-ANDROID
{
name: '退出应用',
url: 'exit',
}
// #endif
] as Page[],
},
{
id: 'page',
name: '页面和路由',
pages: [
{
name: '页面跳转',
url: 'navigator',
api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"]
},
{
name: '设置导航条标题',
url: 'set-navigation-bar-title',
},
{
name: '设置导航条颜色',
url: 'set-navigation-bar-color',
},
{
name: '设置页面容器背景色',
url: 'set-page-backgroundColorContent',
},
{
name: '设置TabBar',
url: 'set-tabbar',
api: ["showTabBar", "hideTabBar", "showTabBarRedDot", "hideTabBarRedDot", "setTabBarBadge", "removeTabBarBadge", "setTabBarStyle", "setTabBarItem"]
},
{
name: '页面下拉刷新',
url: 'pull-down-refresh',
api: ["stopPullDownRefresh"]
},
{
name: '将页面滚动到指定位置',
url: 'page-scroll-to',
},
] as Page[],
},
{
id: 'ui',
name: '界面',
pages: [
// {
// name: "创建动画",
// url: "animation",
// enable: false
// },
// {
// name: "创建绘画",
// url: "canvas",
// enable: true
// },
// {
// name: "节点布局交互状态",
// url: "intersection-observer",
// enable: false
// },
{
name: 'element元素',
url: 'get-element-by-id',
api: ["getElementById"],
},
// #ifdef APP
{
name: 'element draw',
url: 'element-draw',
api: ["Element.getDrawableContext"]
}, {
name: 'element截图',
url: 'element-takesnapshot',
api: ["Element.takeSnapshot"]
},
// #endif
{
name: 'element大小变化监听',
url: 'resize-observer'
},
{
name: 'node节点',
url: 'nodes-info',
api: ["createSelectorQuery"]
},
{
name: '动态加载字体',
url: 'load-font-face',
},
{
name: 'rpx2px',
url: 'rpx2px'
},
{
name: 'actionSheet操作菜单',
url: 'action-sheet',
},
{
name: 'showModal模态弹窗',
url: 'modal',
api: ["showModal"]
},
{
name: 'showLoading等待框',
url: 'loading',
},
{
name: 'showToast轻提示框',
url: 'toast',
api: ["showToast"]
}
// #ifdef APP
, {
name: '主题切换',
url: 'theme-change',
api: ["setAppTheme", "onOsThemeChange", "offOsThemeChange", "onAppThemeChange", "offAppThemeChange"]
}
// #endif
] as Page[],
},
{
id: 'network',
name: '网络',
pages: [
{
name: '发起请求request',
url: 'request',
},
{
name: '上传文件',
url: 'upload-file',
},
{
name: '下载文件',
url: 'download-file',
},
{
name: '获取设备网络状态',
url: 'get-network-type',
},
{
name: 'socketTask',
url: 'websocket-socketTask',
api: [""] //它不是uni.的api
},
{
name: '全局websocket',
url: 'websocket-global',
api: ["connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"]
},
] as Page[],
},
{
id: 'device',
name: '设备',
pages: [
{
name: '获取系统信息',
url: 'get-system-info',
},
{
name: '获取设备信息',
url: 'get-device-info',
},
{
name: '获取窗口信息',
url: 'get-window-info',
},
{
name: '获取APP基础信息',
url: 'get-app-base-info',
},
// #ifdef APP
{
name: '获取APP授权设置',
url: 'get-app-authorize-setting',
},
{
name: '获取系统设置',
url: 'get-system-setting',
},
// #endif
{
name: '电量',
url: 'get-battery-info',
},
// #ifdef APP-ANDROID
{
name: '安装Apk',
url: 'install-apk'
},
// #endif
// #ifdef WEB
{
name: "打电话",
url: "make-phone-call",
},
{
name: "剪贴板",
url: "clipboard",
},
{
name: "监听罗盘数据",
url: "on-compass-change",
},
// #endif
/*
{
name: "震动",
url: "vibrate",
},
{
name: "添加手机联系人",
url: "add-phone-contact",
},
{
name: "扫码",
url: "scan-code",
},
{
name: "屏幕亮度",
url: "brightness",
},
{
name: "蓝牙",
url: "bluetooth",
},
{
name: "生物认证",
url: "soter",
},
{
name: "iBeacon",
url: "ibeacon",
},
{
name: "监听加速度传感器",
url: "on-accelerometer-change",
},
{
name: "监听距离传感器",
url: "/platforms/app-plus/proximity/proximity",
},
{
name: "监听方向传感器",
url: "/platforms/app-plus/orientation/orientation",
}, */
] as Page[],
},
{
id: 'media',
name: '媒体',
pages: [
{
name: "拍摄图片或从相册中选择图片",
url: 'choose-image'
},
{
name: '图片预览',
url: 'preview-image',
api: ["previewImage", "closePreviewImage"]
},
// #ifdef APP
{
name: "保存图片到相册",
url: 'save-image-to-photos-album'
},
// #endif
{
name: "获取图片信息",
url: 'get-image-info'
},
// #ifdef APP
{
name: "压缩图片",
url: 'compress-image'
},
// #endif
{
name: "拍摄视频或从相册中选择视频",
url: 'choose-video'
},
// #ifdef APP
{
name: "保存视频到相册",
url: 'save-video-to-photos-album'
},
// #endif
{
name: "获取视频信息",
url: 'get-video-info'
},
// #ifdef APP
{
name: "压缩视频",
url: 'compress-video'
},
// #endif
// #ifdef WEB
{
name: "音频",
url: "inner-audio",
},
// #endif
/*
{
name: "背景音频",
url: "background-audio",
},
{
name: "录音",
url: "rec",
},
{
name: "文件",
url: "file",
},
*/
] as Page[],
},
{
id: 'location',
name: '位置',
pages: [
{
name: '获取当前位置',
url: 'get-location',
},
// #ifdef WEB
{
name: "使用地图查看位置",
url: "open-location",
},
{
name: "使用地图选择位置",
url: "choose-location",
},
// #endif
/*
{
name: "地图搜索",
url: "map-search",
}, */
] as Page[],
},
{
id: 'storage',
name: '数据存储',
pages: [
{
name: 'storage(key-value存储)',
url: 'storage',
api: ["getStorageInfo", "getStorageInfoSync", "getStorage", "getStorageSync", "setStorage", "setStorageSync", "removeStorage", "removeStorageSync", "clearStorage", "clearStorageSync"]
}
] as Page[],
},
// #ifdef APP
{
id: 'file',
name: '文件',
pages: [
{
name: 'fileSystemManager文件管理',
url: 'get-file-system-manager'
}
] as Page[],
},
// #endif
{
id: 'unicloud',
name: 'uniCloud',
pages: [
{
name: '云函数',
url: 'unicloud-call-function',
},
{
name: '云对象',
url: 'unicloud-import-object',
},
{
name: '云存储',
url: 'unicloud-file-api',
},
{
name: 'clientDB',
url: 'unicloud-database',
},
] as Page[],
},
// #ifdef APP
{
id: 'login',
name: '登录与认证',
pages: [
{
name: '一键登录',
url: 'get-univerify-manager',
},
{
name: '实人认证',
url: 'facial-recognition-verify',
}
] as Page[],
},
{
id: 'ad',
name: '广告',
pages: [
{
name: '激励视频广告',
url: 'rewarded-video-ad',
}
/* {
id: "full-screen-video-ad",
url: "full-screen-video-ad",
name: "全屏视频广告",
enable: false,
pages: [] as Page[]
}, */
] as Page[],
},
// #endif
{
id: "payment",
name: "支付",
pages: [
// #ifndef WEB
{
name: "简易支付示例",
url: "request-payment",
},
// #endif
{
name: "uni-pay支付示例",
url: "request-payment-uni-pay",
}
] as Page[],
},
// #ifdef APP-ANDROID
{
id: 'permission-listener',
name: '权限申请监听',
pages: [
{
name: '权限申请监听',
url: 'create-request-permission-listener',
}
] as Page[]
},
// #endif
/*
{
id: "share",
name: "分享",
pages: [
{
name: "分享",
url: "share",
},
] as Page[],
},
*/
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
onLoad() {
// console.log("API page onLoad")
},
onShow() {
// console.log("API page onShow")
},
onHide() {
// console.log("API page onHide")
},
methods: {
goDetailPage(e : Page) {
if (e.enable == false) {
uni.showToast({
title: '暂不支持',
icon: 'none',
})
return
}
if (e.url === 'set-tabbar') {
this.showPop()
return;
}
const url =
e.url.indexOf('platform') > -1 ? e.url : `/pages/API/${e.url}/${e.url}`
uni.navigateTo({
url,
})
},
goPage(url : string) {
if (url == '/set-tab-bar') {
this.showPop()
......
......@@ -11,20 +11,6 @@
<u-link :href="'https://uniapp.dcloud.io/uni-app-x/css/'" :text="'https://uniapp.dcloud.io/uni-app-x/css/'"
:inWhiteList="true"></u-link>
</view>
<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(page)">
<text class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</template>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :title="menuItem!.name"
class="item">
......@@ -58,375 +44,14 @@
import { generateMenu } from './generateMenu.uts'
import { MenuItem } from './generateMenu.uts'
const menu = generateMenu('pages/CSS')
type Page = {
name : string
enable ?: boolean
url ?: string
}
type ListItem = {
id : string
name : string
pages : Page[]
url ?: string
enable ?: boolean
}
export default {
data() {
return {
menu: menu as (MenuItem | null)[],
list: [
{
id: 'background',
name: 'background',
pages: [
{
name: 'background-color',
url: '/pages/CSS/background/background-color',
},
{
name: 'background-image',
url: '/pages/CSS/background/background-image',
},
] as Page[],
},
{
id: 'border',
name: 'border',
pages: [
{
name: 'border',
url: '/pages/CSS/border/border',
},
{
name: 'border-width',
url: '/pages/CSS/border/border-width',
},
{
name: 'border-style',
url: '/pages/CSS/border/border-style',
},
{
name: 'border-color',
url: '/pages/CSS/border/border-color',
},
{
name: 'border-radius',
url: '/pages/CSS/border/border-radius',
},
{
name: 'border-top',
url: '/pages/CSS/border/border-top',
},
{
name: 'border-bottom',
url: '/pages/CSS/border/border-bottom',
},
{
name: 'border-left',
url: '/pages/CSS/border/border-left',
},
{
name: 'border-right',
url: '/pages/CSS/border/border-right',
},
{
name: 'border属性复合示例',
url: '/pages/CSS/border/complex-border/complex-border',
},
{
name: 'border动态修改样式',
url: '/pages/CSS/border/dynamic-border'
},
] as Page[],
},
{
id: 'box-shadow',
name: 'box-shadow',
pages: [
{
name: 'box-shadow',
url: '/pages/CSS/box-shadow/box-shadow',
},
] as Page[],
},
{
id: 'display',
name: 'display',
pages: [
{
name: 'flex',
url: '/pages/CSS/display/flex',
},
{
name: 'none',
url: '/pages/CSS/display/none',
}
] as Page[],
},
{
id: 'flex',
name: 'flex',
pages: [
{
name: 'align-content',
url: '/pages/CSS/flex/align-content',
},
{
name: 'align-items',
url: '/pages/CSS/flex/align-items',
},
{
name: 'flex-basis',
url: '/pages/CSS/flex/flex-basis',
},
{
name: 'flex-direction',
url: '/pages/CSS/flex/flex-direction',
},
{
name: 'flex-flow',
url: '/pages/CSS/flex/flex-flow',
},
{
name: 'flex-grow',
url: '/pages/CSS/flex/flex-grow',
},
{
name: 'flex-shrink',
url: '/pages/CSS/flex/flex-shrink',
},
{
name: 'flex',
url: '/pages/CSS/flex/flex',
},
{
name: 'justify-content',
url: '/pages/CSS/flex/justify-content',
},
] as Page[],
},
{
id: 'layout',
name: 'layout',
pages: [
{
name: 'height',
url: '/pages/CSS/layout/height',
},
{
name: 'max-height',
url: '/pages/CSS/layout/max-height',
},
{
name: 'max-width',
url: '/pages/CSS/layout/max-width',
},
{
name: 'min-height',
url: '/pages/CSS/layout/min-height',
},
{
name: 'min-width',
url: '/pages/CSS/layout/min-width',
},
{
name: 'position',
url: '/pages/CSS/layout/position',
},
{
name: 'width',
url: '/pages/CSS/layout/width',
},
{
name: 'z-index',
url: '/pages/CSS/layout/z-index',
},
{
name: 'visibility',
url: '/pages/CSS/layout/visibility',
},
] as Page[],
},
{
id: 'margin',
name: 'margin',
pages: [
{
name: 'margin-bottom',
url: '/pages/CSS/margin/margin-bottom',
},
{
name: 'margin-left',
url: '/pages/CSS/margin/margin-left',
},
{
name: 'margin-right',
url: '/pages/CSS/margin/margin-right',
},
{
name: 'margin-top',
url: '/pages/CSS/margin/margin-top',
},
{
name: 'margin',
url: '/pages/CSS/margin/margin',
},
] as Page[],
},
{
id: 'padding',
name: 'padding',
pages: [
{
name: 'padding-bottom',
url: '/pages/CSS/padding/padding-bottom',
},
{
name: 'padding-left',
url: '/pages/CSS/padding/padding-left',
},
{
name: 'padding-right',
url: '/pages/CSS/padding/padding-right',
},
{
name: 'padding-top',
url: '/pages/CSS/padding/padding-top',
},
{
name: 'padding',
url: '/pages/CSS/padding/padding',
},
] as Page[],
},
{
id: 'overflow',
name: 'overflow',
pages: [
{
name: 'overflow',
url: '/pages/CSS/overflow/overflow',
},
{
name: 'overflow-visible-event',
url: '/pages/CSS/overflow/overflow-visible-event'
}
] as Page[],
},
{
id: 'text',
name: 'text',
pages: [
{
name: 'color',
url: '/pages/CSS/text/color',
},
{
name: 'font-family',
url: '/pages/CSS/text/font-family',
},
{
name: 'font-size',
url: '/pages/CSS/text/font-size',
},
{
name: 'font-style',
url: '/pages/CSS/text/font-style',
},
{
name: 'font-weight',
url: '/pages/CSS/text/font-weight',
},
{
name: 'letter-spacing',
url: '/pages/CSS/text/letter-spacing',
},
{
name: 'line-height',
url: '/pages/CSS/text/line-height',
},
{
name: 'text-align',
url: '/pages/CSS/text/text-align',
},
{
name: 'text-overflow',
url: '/pages/CSS/text/text-overflow',
},
{
name: 'text-decoration-line',
url: '/pages/CSS/text/text-decoration-line',
},
] as Page[],
},
{
id: 'transform',
name: 'transform',
pages: [
{
name: 'translate',
url: '/pages/CSS/transform/translate',
},
{
name: 'scale',
url: '/pages/CSS/transform/scale',
},
{
name: 'rotate',
url: '/pages/CSS/transform/rotate',
},
] as Page[],
},
{
id: 'transition',
name: 'transition',
pages: [
{
name: 'transition',
url: '/pages/CSS/transition/transition',
},
] as Page[],
},
{
id: 'pointer-events',
name: 'pointer-events',
pages: [
{
name: 'pointer-events',
url: '/pages/CSS/pointer-events/pointer-events',
},
] as Page[],
},
{
id: 'variable',
name: 'variable',
pages: [
{
name: 'variable',
url: '/pages/CSS/variable/variable',
},
] as Page[],
}
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
goDetailPage(e : Page) {
if (e.enable == false) {
uni.showToast({
icon: 'none',
title: '暂不支持',
})
return
}
const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}`
uni.navigateTo({
url,
})
},
goPage(url : string) {
uni.navigateTo({ url })
},
......
......@@ -12,27 +12,12 @@
:text="'https://uniapp.dcloud.io/uni-app-x/component/'" :inWhiteList="true"></u-link>
</view>
<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(page)">
<text class="uni-navigate-text"
:class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
</template>
</uni-collapse>
<text>---------------</text>
<uni-collapse>
<uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :title="menuItem!.name"
class="item">
<uni-collapse-item v-for="menuItem in menu" :key="menuItem!.id" :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}`)">
@click="goPage(`/${page!.path}`)">
<text class="uni-navigate-text">{{
page!.style["navigationBarTitleText"]
}}</text>
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
<uni-collapse style="width: 100%" v-for="childMenu in menuItem!.children" :key="childMenu!.id">
......@@ -41,7 +26,7 @@
:key="childPage!.path" @click="goPage(`/${childPage!.path}`)">
<text class="uni-navigate-text">{{
childPage!.style["navigationBarTitleText"]
}}</text>
}}</text>
<image :src="arrowRightIcon" class="uni-icon-size"></image>
</view>
</uni-collapse-item>
......@@ -66,268 +51,15 @@
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
// #endif
type Page = {
name : string
enable ?: boolean
url ?: string.PageURIString
}
type ListItem = {
id : string
name : string
pages : Page[]
url ?: string
enable ?: boolean
}
export default {
data() {
return {
menu: menu as (MenuItem | null)[],
list: [
{
id: 'view',
name: '视图容器',
pages: [
{
name: 'view',
},
{
name: 'scroll-view',
},
{
name: 'swiper',
},
// #ifdef WEB
{
name: 'movable-view'
},
{
name: 'cover-view'
},
// #endif
{
name: 'list-view',
},
{
name: 'sticky-header',
},
{
name: 'sticky-section',
},
// #ifdef APP
{
name: 'nested-scroll-header',
},
{
name: 'nested-scroll-body',
},
// #endif
] as Page[],
},
{
id: 'content',
name: '基础内容',
pages: [
{
name: 'text',
},
{
name: 'rich-text',
enable: true,
},
{
name: 'progress',
},
] as Page[],
},
{
id: 'form',
name: '表单组件',
pages: [
{
name: 'button',
},
{
name: 'checkbox',
},
{
name: 'form',
},
{
name: 'input',
},
// #ifdef WEB
{
name: 'editor',
},
{
name: 'label',
},
{
name: 'picker',
},
// #endif
{
name: 'picker-view',
},
{
name: 'radio',
},
{
name: 'slider',
},
{
name: 'slider-100',
},
{
name: 'switch',
},
{
name: 'textarea',
},
] as Page[],
},
{
id: 'nav',
name: '导航',
pages: [{
name: 'navigator',
enable: true
}] as Page[],
},
{
id: 'media',
name: '媒体组件',
pages: [
{
name: 'image',
enable: true,
},
{
name: 'video',
enable: true,
},
/* {
name: 'animation-view',
enable: false,
}, */
] as Page[],
},
// #ifdef WEB
{
id: 'map',
name: '地图',
pages: [
{
name: 'map',
}
] as Page[]
},
// #endif
// #ifdef APP || WEB
{
id: 'canvas',
name: '画布',
pages: [
{
name: 'canvas',
url: '/pages/component/canvas/canvas',
},
{
name: 'ball',
url: '/pages/component/canvas/canvas/ball',
}
] as Page[]
},
// #endif
{
id: 'web-view',
name: '网页',
pages: [
{
name: '网络网页',
enable: true,
url: '/pages/component/web-view/web-view',
},
{
name: '本地网页',
enable: true,
url: '/pages/component/web-view-local/web-view-local',
},
] as Page[],
},
{
id: 'unicloud-db',
name: 'unicloud-db',
pages: [
{
name: '联系人',
enable: true,
url: '/pages/component/unicloud-db-contacts/list'
},
{
name: 'mixinDatacom',
enable: true,
url: '/pages/component/mixin-datacom/mixin-datacom'
}
] as Page[],
},
/*
{
id: 'ad',
url: 'ad',
name: 'AD组件',
enable: false,
pages: [] as Page[]
}
*/
{
id: 'general-attr-event',
name: '通用属性和事件',
pages: [
{
name: '通用属性',
url: '/pages/component/public-properties/public-properties',
enable: true,
},
{
name: '通用事件',
url: '/pages/component/public-events/public-events',
enable: true,
},
{
name: 'touch事件',
url: '/pages/component/public-events/touch-events',
enable: true,
},
{
name: 'Transition事件',
url: '/pages/component/public-events/transition-events',
enable: true,
},
] as Page[],
}
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png' as string.ImageURIString,
arrowDownIcon: '/static/icons/arrow-down.png' as string.ImageURIString,
arrowRightIcon: '/static/icons/arrow-right.png' as string.ImageURIString,
pageHiden: false
}
},
methods: {
goDetailPage(e : Page) {
if (e.enable == false) {
uni.showToast({
title: '暂不支持',
icon: 'none'
})
return
}
const url =
e.url != null ? e.url! : `/pages/component/${e.name}/${e.name}`
uni.navigateTo({
url,
})
},
goPage(url : string) {
uni.navigateTo({ url })
},
......@@ -349,15 +81,10 @@
checkUpdate(this.$refs['upgradePopup'] as UniUpgradeCenterAppComponentPublicInstance)
// #endif
},
onLoad() {
// console.log("component page onLoad")
},
onShow() {
// console.log("component page onShow")
this.pageHiden = false
},
onHide() {
// console.log("component page onHide")
this.pageHiden = true
},
beforeUnmount() {
......
import { pages } from '@/target-pages.json'
type PageGroup = {
id: string,
name: string,
index: number | null
id : string,
name : string,
index : number | null
}
type Page = {
path: string,
style: UTSJSONObject,
group?: PageGroup[] | null
path : string,
style : UTSJSONObject,
group ?: PageGroup[] | null
}
export type MenuItem = {
id: string,
name: string,
index: number,
children: (MenuItem | null)[],
pages: (Page | null)[]
id : string,
name : string,
index : number,
children : (MenuItem | null)[],
pages : (Page | null)[]
}
export function generateMenu(tabBarType: string): (MenuItem | null)[] {
let res: (MenuItem | null)[] = []
export function generateMenu(tabBarType : string) : (MenuItem | null)[] {
let res : (MenuItem | null)[] = []
const tabBarPages = JSON.parse<Page[]>(JSON.stringify(pages))!.filter((page: Page): boolean => page.path.startsWith(tabBarType) && hasPageGroup(page.group))
const tabBarPages = JSON.parse<Page[]>(JSON.stringify(pages))!.filter((page : Page) : boolean => page.path.startsWith(tabBarType) && hasPageGroup(page.group))
tabBarPages.forEach(page => {
let menuItemArr: (MenuItem | null)[] = res
let currentMenu: MenuItem | null = null
let menuItemArr : (MenuItem | null)[] = res
let currentMenu : MenuItem | null = null
const lastGroup = page.group![page.group!.length - 1]
let hasPageGroup = false
if (page.path.endsWith(camelToDash(lastGroup.name)) && page.group!.length > 1) {
......@@ -61,10 +61,10 @@ export function generateMenu(tabBarType: string): (MenuItem | null)[] {
fillPageArrayWithNull(currentMenu!.pages, pageIndex)
if (currentMenu!.pages[pageIndex] == null) {
currentMenu!.pages[pageIndex] = page
}else{
currentMenu!.pages.push(page)
} else {
currentMenu!.pages.push(page)
}
} else {
} else {
currentMenu!.pages.push(page)
}
})
......@@ -72,7 +72,7 @@ export function generateMenu(tabBarType: string): (MenuItem | null)[] {
return removeNullItem(res)
}
function hasPageGroup(value: PageGroup[] | null): boolean {
function hasPageGroup(value : PageGroup[] | null) : boolean {
// #ifdef APP-ANDROID
return value !== null
// #endif
......@@ -81,7 +81,7 @@ function hasPageGroup(value: PageGroup[] | null): boolean {
// #endif
}
function isNumber(value: number | null): boolean {
function isNumber(value : number | null) : boolean {
// #ifdef APP-ANDROID
return value !== null
// #endif
......@@ -90,41 +90,41 @@ function isNumber(value: number | null): boolean {
// #endif
}
function camelToDash(camelStr: string): string {
function camelToDash(camelStr : string) : string {
return camelStr.replace(/([A-Z])/g, '-$1').toLowerCase()
}
function fillMenuArrayWithNull(arr: (MenuItem | null)[], index: number): void {
function fillMenuArrayWithNull(arr : (MenuItem | null)[], index : number) : void {
const len = arr.length
for (let i = 0;i <= index - (len - 1);i++) {
for (let i = 0; i <= index - (len - 1); i++) {
arr.push(null)
}
}
function fillPageArrayWithNull(arr: (Page | null)[], index: number): void {
function fillPageArrayWithNull(arr : (Page | null)[], index : number) : void {
const len = arr.length
for (let i = 0;i <= index - (len - 1);i++) {
for (let i = 0; i <= index - (len - 1); i++) {
arr.push(null)
}
}
function removeNullItem(arr: (MenuItem | null)[]): (MenuItem | null)[] {
const res = arr.filter((item: MenuItem | null): boolean => item !== null)
function removeNullItem(arr : (MenuItem | null)[]) : (MenuItem | null)[] {
const res = arr.filter((item : MenuItem | null) : boolean => item !== null)
res.forEach(menuItem => {
addSetTabBarPage(menuItem!)
// #ifdef APP-ANDROID
menuItem.children = removeNullItem(menuItem.children)
menuItem.pages = menuItem.pages.filter((item: Page | null): boolean => item !== null)
menuItem.pages = menuItem.pages.filter((item : Page | null) : boolean => item !== null)
// #endif
// #ifndef APP-ANDROID
menuItem!.children = removeNullItem(menuItem!.children)
menuItem!.pages = menuItem!.pages.filter((item: Page | null): boolean => item !== null)
menuItem!.pages = menuItem!.pages.filter((item : Page | null) : boolean => item !== null)
// #endif
})
return res
}
function addSetTabBarPage(menuItem: MenuItem) {
function addSetTabBarPage(menuItem : MenuItem) {
const { id, name } = menuItem
if (id == 'page' && name == '页面和路由') {
menuItem.pages.push({
......@@ -134,4 +134,4 @@ function addSetTabBarPage(menuItem: MenuItem) {
}
} as Page)
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册