mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-24 01:53:01 +08:00
Merge branch 'develop' of github.com:Tencent/tdesign-vue-next-starter into site
This commit is contained in:
commit
81220e78c2
|
@ -1,5 +1,7 @@
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
|
import { RouteMeta } from '@/types/interface';
|
||||||
|
|
||||||
export interface MenuListResult {
|
export interface MenuListResult {
|
||||||
list: Array<RouteItem>;
|
list: Array<RouteItem>;
|
||||||
}
|
}
|
||||||
|
@ -18,15 +20,3 @@ export interface RouteItem {
|
||||||
meta: RouteMeta;
|
meta: RouteMeta;
|
||||||
children?: Array<RouteItem>;
|
children?: Array<RouteItem>;
|
||||||
}
|
}
|
||||||
export interface RouteMeta {
|
|
||||||
title: string;
|
|
||||||
icon?: string;
|
|
||||||
expanded?: boolean;
|
|
||||||
orderNo?: number;
|
|
||||||
hidden?: boolean;
|
|
||||||
hiddenBreadcrumb?: boolean;
|
|
||||||
single?: boolean;
|
|
||||||
keepAlive?: boolean;
|
|
||||||
frameSrc?: string;
|
|
||||||
frameBlank?: boolean;
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import { useLocale } from '@/locales/useLocale';
|
||||||
|
import { RouteMeta } from '@/types/interface';
|
||||||
|
|
||||||
|
const { locale } = useLocale();
|
||||||
|
|
||||||
const crumbs = computed(() => {
|
const crumbs = computed(() => {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -18,14 +23,22 @@ const crumbs = computed(() => {
|
||||||
|
|
||||||
const breadcrumbs = pathArray.reduce((breadcrumbArray, path, idx) => {
|
const breadcrumbs = pathArray.reduce((breadcrumbArray, path, idx) => {
|
||||||
// 如果路由下有hiddenBreadcrumb或当前遍历到参数则隐藏
|
// 如果路由下有hiddenBreadcrumb或当前遍历到参数则隐藏
|
||||||
if (route.matched[idx]?.meta?.hiddenBreadcrumb || Object.values(route.params).includes(path)) {
|
const meta = route.matched[idx]?.meta as RouteMeta;
|
||||||
|
if (meta?.hiddenBreadcrumb || Object.values(route.params).includes(path)) {
|
||||||
return breadcrumbArray;
|
return breadcrumbArray;
|
||||||
}
|
}
|
||||||
|
let title = path;
|
||||||
|
if (meta?.title) {
|
||||||
|
if (typeof meta.title === 'string') {
|
||||||
|
title = meta.title;
|
||||||
|
} else {
|
||||||
|
title = meta.title[locale.value];
|
||||||
|
}
|
||||||
|
}
|
||||||
breadcrumbArray.push({
|
breadcrumbArray.push({
|
||||||
path,
|
path,
|
||||||
to: breadcrumbArray[idx - 1] ? `/${breadcrumbArray[idx - 1].path}/${path}` : `/${path}`,
|
to: breadcrumbArray[idx - 1] ? `/${breadcrumbArray[idx - 1].path}/${path}` : `/${path}`,
|
||||||
title: route.matched[idx]?.meta?.title ?? path,
|
title,
|
||||||
});
|
});
|
||||||
return breadcrumbArray;
|
return breadcrumbArray;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
17
src/types/interface.d.ts
vendored
17
src/types/interface.d.ts
vendored
|
@ -3,9 +3,22 @@ import { LocationQueryRaw, RouteRecordName } from 'vue-router';
|
||||||
|
|
||||||
import STYLE_CONFIG from '@/config/style';
|
import STYLE_CONFIG from '@/config/style';
|
||||||
|
|
||||||
|
export interface RouteMeta {
|
||||||
|
title?: string | Record<string, string>;
|
||||||
|
icon?: string;
|
||||||
|
expanded?: boolean;
|
||||||
|
orderNo?: number;
|
||||||
|
hidden?: boolean;
|
||||||
|
hiddenBreadcrumb?: boolean;
|
||||||
|
single?: boolean;
|
||||||
|
keepAlive?: boolean;
|
||||||
|
frameSrc?: string;
|
||||||
|
frameBlank?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface MenuRoute {
|
export interface MenuRoute {
|
||||||
path: string;
|
path: string;
|
||||||
title?: string;
|
title?: string | Record<string, string>;
|
||||||
name?: string;
|
name?: string;
|
||||||
icon?:
|
icon?:
|
||||||
| string
|
| string
|
||||||
|
@ -14,7 +27,7 @@ export interface MenuRoute {
|
||||||
};
|
};
|
||||||
redirect?: string;
|
redirect?: string;
|
||||||
children: MenuRoute[];
|
children: MenuRoute[];
|
||||||
meta: any;
|
meta: RouteMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ModeType = 'dark' | 'light';
|
export type ModeType = 'dark' | 'light';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import { shallowRef } from 'vue';
|
import { shallowRef } from 'vue';
|
||||||
|
|
||||||
import { RouteItem, RouteMeta } from '@/api/model/permissionModel';
|
import { RouteItem } from '@/api/model/permissionModel';
|
||||||
|
import { RouteMeta } from '@/types/interface';
|
||||||
import {
|
import {
|
||||||
BLANK_LAYOUT,
|
BLANK_LAYOUT,
|
||||||
EXCEPTION_COMPONENT,
|
EXCEPTION_COMPONENT,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user