feat(projects): 添加multiTab标签页
This commit is contained in:
parent
789855a378
commit
eec0b36f59
@ -93,7 +93,6 @@ soybean-admin
|
|||||||
│ └── views //页面
|
│ └── views //页面
|
||||||
│ ├── dashboard
|
│ ├── dashboard
|
||||||
│ └── system
|
│ └── system
|
||||||
├── tree.md
|
|
||||||
├── tsconfig.json //TS配置
|
├── tsconfig.json //TS配置
|
||||||
├── vite.config.ts //vite配置
|
├── vite.config.ts //vite配置
|
||||||
├── windi.config.ts //windicss框架配置
|
├── windi.config.ts //windicss框架配置
|
||||||
|
@ -21,6 +21,10 @@ export interface ThemeSettings {
|
|||||||
crumbsStyle: CrumbsStyle;
|
crumbsStyle: CrumbsStyle;
|
||||||
/** 页面样式 */
|
/** 页面样式 */
|
||||||
pageStyle: PageStyle;
|
pageStyle: PageStyle;
|
||||||
|
/** 固定头部和多标签 */
|
||||||
|
fixedHeaderAndTab: boolean;
|
||||||
|
/** 显示重载按钮 */
|
||||||
|
showReload: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OtherColor {
|
interface OtherColor {
|
||||||
@ -50,10 +54,6 @@ interface HeaderStyle {
|
|||||||
height: number;
|
height: number;
|
||||||
/** 背景颜色 */
|
/** 背景颜色 */
|
||||||
bgColor: string;
|
bgColor: string;
|
||||||
/** 固定顶部 */
|
|
||||||
fixed: boolean;
|
|
||||||
/** 显示重载按钮 */
|
|
||||||
showReload: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MenuStyle {
|
interface MenuStyle {
|
||||||
@ -70,6 +70,8 @@ interface MenuStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface MultiTabStyle {
|
interface MultiTabStyle {
|
||||||
|
/** 多标签高度 */
|
||||||
|
height: number;
|
||||||
/** 多标签可见 */
|
/** 多标签可见 */
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
/** 背景颜色 */
|
/** 背景颜色 */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<header v-if="fixedHeader && theme.navStyle.mode !== 'horizontal-mix'" class="w-full header-height"></header>
|
<header v-if="fixedHeaderAndTab && theme.navStyle.mode !== 'horizontal-mix'" class="header-height w-full"></header>
|
||||||
<n-layout-header :inverted="headerInverted" :position="position" :style="{ zIndex }">
|
<n-layout-header :inverted="headerInverted" :position="position" :style="{ zIndex }">
|
||||||
<div class="global-header header-height flex-y-center w-full">
|
<div class="global-header header-height flex-y-center w-full">
|
||||||
<div v-if="!theme.isVerticalNav" class="menu-width h-full">
|
<div v-if="!theme.isVerticalNav" class="menu-width h-full">
|
||||||
@ -38,8 +38,8 @@ const theme = useThemeStore();
|
|||||||
const inverted = computed(() => {
|
const inverted = computed(() => {
|
||||||
return theme.navStyle.theme !== 'light';
|
return theme.navStyle.theme !== 'light';
|
||||||
});
|
});
|
||||||
const fixedHeader = computed(() => theme.headerStyle.fixed || theme.navStyle.mode === 'horizontal-mix');
|
const fixedHeaderAndTab = computed(() => theme.fixedHeaderAndTab || theme.navStyle.mode === 'horizontal-mix');
|
||||||
const position = computed(() => (fixedHeader.value ? 'absolute' : 'static'));
|
const position = computed(() => (fixedHeaderAndTab.value ? 'absolute' : 'static'));
|
||||||
const headerInverted = computed(() => {
|
const headerInverted = computed(() => {
|
||||||
return theme.navStyle.theme !== 'dark' ? inverted.value : !inverted.value;
|
return theme.navStyle.theme !== 'dark' ? inverted.value : !inverted.value;
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,50 @@
|
|||||||
<template>
|
<template>
|
||||||
<div></div>
|
<div v-if="fixedHeaderAndTab && theme.navStyle.mode !== 'horizontal-mix'" class="multi-tab-height w-full"></div>
|
||||||
|
<div
|
||||||
|
class="multi-tab-height flex-y-center w-full px-10px"
|
||||||
|
:class="{ 'multi-tab-top absolute': fixedHeaderAndTab, 'bg-[#f5f7f9]': !theme.darkMode }"
|
||||||
|
:style="{ zIndex }"
|
||||||
|
>
|
||||||
|
<n-space :align="'center'">
|
||||||
|
<n-tag>爱在西元前</n-tag>
|
||||||
|
<n-tag type="success">不该</n-tag>
|
||||||
|
<n-tag type="warning">超人不会飞</n-tag>
|
||||||
|
<n-tag type="error">手写的从前</n-tag>
|
||||||
|
<n-tag type="info">哪里都是你</n-tag>
|
||||||
|
<n-gradient-text size="24">这是MultiTab组件</n-gradient-text>
|
||||||
|
</n-space>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup></script>
|
<script lang="ts" setup>
|
||||||
<style scoped></style>
|
import { computed } from 'vue';
|
||||||
|
import { NSpace, NTag, NGradientText } from 'naive-ui';
|
||||||
|
import { useThemeStore } from '@/store';
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
zIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const theme = useThemeStore();
|
||||||
|
|
||||||
|
const fixedHeaderAndTab = computed(() => theme.fixedHeaderAndTab || theme.navStyle.mode === 'horizontal-mix');
|
||||||
|
const multiTabHeight = computed(() => {
|
||||||
|
const { height } = theme.multiTabStyle;
|
||||||
|
return `${height}px`;
|
||||||
|
});
|
||||||
|
const headerHeight = computed(() => {
|
||||||
|
const { height } = theme.headerStyle;
|
||||||
|
return `${height}px`;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.multi-tab-height {
|
||||||
|
height: v-bind(multiTabHeight);
|
||||||
|
}
|
||||||
|
.multi-tab-top {
|
||||||
|
top: v-bind(headerHeight);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<setting-menu-item label="分割菜单">
|
<setting-menu-item label="分割菜单">
|
||||||
<n-switch :value="theme.menuStyle.splitMenu" @update:value="handleSplitMenu" />
|
<n-switch :value="theme.menuStyle.splitMenu" @update:value="handleSplitMenu" />
|
||||||
</setting-menu-item>
|
</setting-menu-item>
|
||||||
<setting-menu-item label="固定头部">
|
<setting-menu-item label="固定头部和多标签">
|
||||||
<n-switch :value="splitMenu" :disabled="disabledSplitMenu" @update:value="handleFixedHeader" />
|
<n-switch :value="splitMenu" :disabled="disabledSplitMenu" @update:value="handleFixedHeaderAndTab" />
|
||||||
</setting-menu-item>
|
</setting-menu-item>
|
||||||
<setting-menu-item label="头部高度">
|
<setting-menu-item label="头部高度">
|
||||||
<n-input-number
|
<n-input-number
|
||||||
@ -16,6 +16,15 @@
|
|||||||
@update:value="handleHeaderHeight"
|
@update:value="handleHeaderHeight"
|
||||||
/>
|
/>
|
||||||
</setting-menu-item>
|
</setting-menu-item>
|
||||||
|
<setting-menu-item label="多标签高度">
|
||||||
|
<n-input-number
|
||||||
|
class="w-120px"
|
||||||
|
size="small"
|
||||||
|
:value="theme.multiTabStyle.height"
|
||||||
|
:step="1"
|
||||||
|
@update:value="handleMultiTabHeight"
|
||||||
|
/>
|
||||||
|
</setting-menu-item>
|
||||||
<setting-menu-item label="菜单展开宽度">
|
<setting-menu-item label="菜单展开宽度">
|
||||||
<n-input-number
|
<n-input-number
|
||||||
class="w-120px"
|
class="w-120px"
|
||||||
@ -46,10 +55,17 @@ import { useThemeStore } from '@/store';
|
|||||||
import { SettingMenuItem } from '../common';
|
import { SettingMenuItem } from '../common';
|
||||||
|
|
||||||
const theme = useThemeStore();
|
const theme = useThemeStore();
|
||||||
const { handleSplitMenu, handleFixedHeader, handleHeaderHeight, handleMenuWidth, handleMixMenuWidth } = useThemeStore();
|
const {
|
||||||
|
handleSplitMenu,
|
||||||
|
handleFixedHeaderAndTab,
|
||||||
|
handleHeaderHeight,
|
||||||
|
handleMultiTabHeight,
|
||||||
|
handleMenuWidth,
|
||||||
|
handleMixMenuWidth
|
||||||
|
} = useThemeStore();
|
||||||
|
|
||||||
const disabledSplitMenu = computed(() => theme.navStyle.mode === 'horizontal-mix');
|
const disabledSplitMenu = computed(() => theme.navStyle.mode === 'horizontal-mix');
|
||||||
const splitMenu = computed(() => theme.headerStyle.fixed || disabledSplitMenu.value);
|
const splitMenu = computed(() => theme.fixedHeaderAndTab || disabledSplitMenu.value);
|
||||||
const disabledMenuWidth = computed(() => {
|
const disabledMenuWidth = computed(() => {
|
||||||
const { mode } = theme.navStyle;
|
const { mode } = theme.navStyle;
|
||||||
return mode !== 'vertical' && mode !== 'horizontal-mix';
|
return mode !== 'vertical' && mode !== 'horizontal-mix';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import GlobalSider from './GlobalSider/index.vue';
|
import GlobalSider from './GlobalSider/index.vue';
|
||||||
import GlobalHeader from './GlobalHeader/index.vue';
|
import GlobalHeader from './GlobalHeader/index.vue';
|
||||||
|
import GlobalTab from './GlobalTab/index.vue';
|
||||||
import GlobalFooter from './GlobalFooter/index.vue';
|
import GlobalFooter from './GlobalFooter/index.vue';
|
||||||
import SettingDrawer from './SettingDrawer/index.vue';
|
import SettingDrawer from './SettingDrawer/index.vue';
|
||||||
|
|
||||||
export { GlobalSider, GlobalHeader, GlobalFooter, SettingDrawer };
|
export { GlobalSider, GlobalHeader, GlobalTab, GlobalFooter, SettingDrawer };
|
||||||
|
@ -10,8 +10,14 @@
|
|||||||
:class="[{ 'content-padding': isHorizontalMix }, fullPage ? 'h-full' : 'min-h-100vh']"
|
:class="[{ 'content-padding': isHorizontalMix }, fullPage ? 'h-full' : 'min-h-100vh']"
|
||||||
>
|
>
|
||||||
<global-header v-if="!isHorizontalMix" :z-index="1" />
|
<global-header v-if="!isHorizontalMix" :z-index="1" />
|
||||||
|
<global-tab :z-index="1" />
|
||||||
<n-layout-content class="flex-auto" :class="{ 'bg-[#f5f7f9]': !theme.darkMode }">
|
<n-layout-content class="flex-auto" :class="{ 'bg-[#f5f7f9]': !theme.darkMode }">
|
||||||
<router-view />
|
<router-view v-slot="{ Component }">
|
||||||
|
<keep-alive v-if="keepAlive">
|
||||||
|
<component :is="Component" />
|
||||||
|
</keep-alive>
|
||||||
|
<component :is="Component" v-else />
|
||||||
|
</router-view>
|
||||||
</n-layout-content>
|
</n-layout-content>
|
||||||
<global-footer />
|
<global-footer />
|
||||||
</div>
|
</div>
|
||||||
@ -27,17 +33,24 @@ import { useRoute } from 'vue-router';
|
|||||||
import { NLayout, NScrollbar, NLayoutContent } from 'naive-ui';
|
import { NLayout, NScrollbar, NLayoutContent } from 'naive-ui';
|
||||||
import { useThemeStore } from '@/store';
|
import { useThemeStore } from '@/store';
|
||||||
import { useScrollBehavior } from '@/hooks';
|
import { useScrollBehavior } from '@/hooks';
|
||||||
import { GlobalSider, GlobalHeader, GlobalFooter, SettingDrawer } from './components';
|
import { GlobalSider, GlobalHeader, GlobalTab, GlobalFooter, SettingDrawer } from './components';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const theme = useThemeStore();
|
const theme = useThemeStore();
|
||||||
const { scrollbar, resetScrollWatcher } = useScrollBehavior();
|
const { scrollbar, resetScrollWatcher } = useScrollBehavior();
|
||||||
|
|
||||||
const isHorizontalMix = computed(() => theme.navStyle.mode === 'horizontal-mix');
|
const isHorizontalMix = computed(() => theme.navStyle.mode === 'horizontal-mix');
|
||||||
const headerHeight = computed(() => {
|
const headerAndMultiTabHeight = computed(() => {
|
||||||
const { height } = theme.headerStyle;
|
const {
|
||||||
return `${height}px`;
|
headerStyle: { height: hHeight },
|
||||||
|
multiTabStyle: { height: mHeight }
|
||||||
|
} = theme;
|
||||||
|
return `${hHeight + mHeight}px`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 缓存页面 */
|
||||||
|
const keepAlive = computed(() => Boolean(route.meta?.keepAlive));
|
||||||
|
|
||||||
/** 100%视高 */
|
/** 100%视高 */
|
||||||
const fullPage = computed(() => Boolean(route.meta?.fullPage));
|
const fullPage = computed(() => Boolean(route.meta?.fullPage));
|
||||||
|
|
||||||
@ -49,9 +62,9 @@ resetScrollWatcher();
|
|||||||
z-index: 11;
|
z-index: 11;
|
||||||
}
|
}
|
||||||
.sider-margin {
|
.sider-margin {
|
||||||
margin-top: v-bind(headerHeight);
|
margin-top: v-bind(headerAndMultiTabHeight);
|
||||||
}
|
}
|
||||||
.content-padding {
|
.content-padding {
|
||||||
padding-top: v-bind(headerHeight);
|
padding-top: v-bind(headerAndMultiTabHeight);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-scrollbar ref="scrollbar" class="h-full" :x-scrollable="true" :content-class="fullPage ? 'h-full' : ''">
|
<n-scrollbar ref="scrollbar" class="h-full" :x-scrollable="true" :content-class="fullPage ? 'h-full' : ''">
|
||||||
<div class="inline-block w-full" :class="[fullPage ? 'h-full' : 'min-h-100vh']">
|
<div class="inline-block w-full" :class="[fullPage ? 'h-full' : 'min-h-100vh']">
|
||||||
<router-view />
|
<router-view v-slot="{ Component }">
|
||||||
|
<keep-alive v-if="keepAlive">
|
||||||
|
<component :is="Component" />
|
||||||
|
</keep-alive>
|
||||||
|
<component :is="Component" v-else />
|
||||||
|
</router-view>
|
||||||
</div>
|
</div>
|
||||||
</n-scrollbar>
|
</n-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
@ -15,6 +20,9 @@ import { useScrollBehavior } from '@/hooks';
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { scrollbar, resetScrollWatcher } = useScrollBehavior();
|
const { scrollbar, resetScrollWatcher } = useScrollBehavior();
|
||||||
|
|
||||||
|
/** 缓存页面 */
|
||||||
|
const keepAlive = computed(() => Boolean(route.meta?.keepAlive));
|
||||||
|
|
||||||
/** 100%视高 */
|
/** 100%视高 */
|
||||||
const fullPage = computed(() => Boolean(route.meta?.fullPage));
|
const fullPage = computed(() => Boolean(route.meta?.fullPage));
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ export const customRoutes: CustomRoute[] = [
|
|||||||
redirect: { name: RouteNameMap.get('dashboard-analysis') },
|
redirect: { name: RouteNameMap.get('dashboard-analysis') },
|
||||||
meta: {
|
meta: {
|
||||||
title: EnumRouteTitle.dashboard,
|
title: EnumRouteTitle.dashboard,
|
||||||
|
keepAlive: true,
|
||||||
icon: Dashboard
|
icon: Dashboard
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
@ -45,11 +45,10 @@ const themeSettings: ThemeSettings = {
|
|||||||
},
|
},
|
||||||
headerStyle: {
|
headerStyle: {
|
||||||
height: 64,
|
height: 64,
|
||||||
bgColor: '#fff',
|
bgColor: '#fff'
|
||||||
fixed: true,
|
|
||||||
showReload: true
|
|
||||||
},
|
},
|
||||||
multiTabStyle: {
|
multiTabStyle: {
|
||||||
|
height: 48,
|
||||||
visible: true,
|
visible: true,
|
||||||
bgColor: '#fff'
|
bgColor: '#fff'
|
||||||
},
|
},
|
||||||
@ -68,7 +67,9 @@ const themeSettings: ThemeSettings = {
|
|||||||
{ value: 'fade-bottom', label: EnumAnimate['fade-bottom'] },
|
{ value: 'fade-bottom', label: EnumAnimate['fade-bottom'] },
|
||||||
{ value: 'fade-scale', label: EnumAnimate['fade-scale'] }
|
{ value: 'fade-scale', label: EnumAnimate['fade-scale'] }
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
fixedHeaderAndTab: true,
|
||||||
|
showReload: true
|
||||||
};
|
};
|
||||||
|
|
||||||
export default themeSettings;
|
export default themeSettings;
|
||||||
|
@ -47,8 +47,10 @@ const appStore = defineStore({
|
|||||||
toggleMenu() {
|
toggleMenu() {
|
||||||
this.menu.collapsed = !this.menu.collapsed;
|
this.menu.collapsed = !this.menu.collapsed;
|
||||||
},
|
},
|
||||||
/** 初始化多tab的数据 */
|
/** 添加多tab的数据 */
|
||||||
initMultiTab() {},
|
addMultiTab(route: RouteLocationNormalizedLoaded) {
|
||||||
|
this.multiTab.routes.push(route);
|
||||||
|
},
|
||||||
/** 打开配置抽屉 */
|
/** 打开配置抽屉 */
|
||||||
openSettingDrawer() {
|
openSettingDrawer() {
|
||||||
this.settingDrawer.visible = true;
|
this.settingDrawer.visible = true;
|
||||||
|
@ -85,15 +85,17 @@ const themeStore = defineStore({
|
|||||||
this.menuStyle.mixWidth = width;
|
this.menuStyle.mixWidth = width;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 更改头部的高度(不包含tab标签) */
|
/** 更改头部的高度 */
|
||||||
handleHeaderHeight(height: number | null) {
|
handleHeaderHeight(height: number | null) {
|
||||||
if (height !== null) {
|
if (height !== null) {
|
||||||
this.headerStyle.height = height;
|
this.headerStyle.height = height;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 固定头部 */
|
/** 更改Tab标签的高度 */
|
||||||
handleFixedHeader(isFixed: boolean) {
|
handleMultiTabHeight(height: number | null) {
|
||||||
this.headerStyle.fixed = isFixed;
|
if (height !== null) {
|
||||||
|
this.multiTabStyle.height = height;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 设置多标签的显示 */
|
/** 设置多标签的显示 */
|
||||||
handleMultiTabVisible(visible: boolean) {
|
handleMultiTabVisible(visible: boolean) {
|
||||||
@ -116,6 +118,10 @@ const themeStore = defineStore({
|
|||||||
if (this.pageStyle.animate) {
|
if (this.pageStyle.animate) {
|
||||||
this.pageStyle.animateType = animateType;
|
this.pageStyle.animateType = animateType;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/** 固定头部 */
|
||||||
|
handleFixedHeaderAndTab(isFixed: boolean) {
|
||||||
|
this.fixedHeaderAndTab = isFixed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="p-10px">
|
<div class="px-10px">
|
||||||
<data-card :loading="loading" />
|
<data-card :loading="loading" />
|
||||||
<nav-card :loading="loading" />
|
<nav-card :loading="loading" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="p-10px">
|
<div class="px-10px">
|
||||||
<div class="flex-y-center flex-col h-500px bg-white">
|
<div class="flex-y-center flex-col h-500px bg-white">
|
||||||
<n-gradient-text type="primary" size="32">工作台</n-gradient-text>
|
<n-gradient-text type="primary" size="32">工作台</n-gradient-text>
|
||||||
<n-space>
|
<n-space>
|
||||||
|
Loading…
Reference in New Issue
Block a user