mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-04-06 03:57:54 +08:00
feat(components): 增加头部的操作按钮
BREAKING CHANGE: 黑暗模式、全屏、通知、设置、github、用户中心
This commit is contained in:
parent
bb9e741375
commit
04cea2907d
@ -5,23 +5,46 @@
|
|||||||
<Menu />
|
<Menu />
|
||||||
</n-layout-sider>
|
</n-layout-sider>
|
||||||
<n-layout class="h-full bg-hex-f3f4f6" :native-scrollbar="false">
|
<n-layout class="h-full bg-hex-f3f4f6" :native-scrollbar="false">
|
||||||
<n-layout-header bordered class="h-60px flex-y-center">
|
<n-layout-header bordered class="h-60px flex-y-center justify-between">
|
||||||
|
<div class="flex-y-center h-full">
|
||||||
<CollapaseButton />
|
<CollapaseButton />
|
||||||
<Breadcrumb />
|
<Breadcrumb />
|
||||||
|
</div>
|
||||||
|
<div class="flex-y-center h-full">
|
||||||
|
<Github />
|
||||||
|
<FullScreen />
|
||||||
|
<DarkMode />
|
||||||
|
<Notices />
|
||||||
|
<Setting />
|
||||||
|
<UserCenter />
|
||||||
|
</div>
|
||||||
</n-layout-header>
|
</n-layout-header>
|
||||||
<div class="p-16px">
|
<div class="p-16px">
|
||||||
<n-layout-content>
|
<n-layout-content>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</n-layout-content>
|
</n-layout-content>
|
||||||
</div>
|
</div>
|
||||||
<n-layout-footer position="absolute" class="text-center op-80 bg-transparent">Ench admin</n-layout-footer>
|
<n-layout-footer position="absolute" class="text-center op-80 bg-transparent">
|
||||||
|
{{ appStore.title }}
|
||||||
|
</n-layout-footer>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useApp } from '@/store';
|
import { useApp } from '@/store';
|
||||||
import { Breadcrumb, CollapaseButton, Menu, Logo } from '../components';
|
import {
|
||||||
|
Breadcrumb,
|
||||||
|
CollapaseButton,
|
||||||
|
Menu,
|
||||||
|
Logo,
|
||||||
|
FullScreen,
|
||||||
|
DarkMode,
|
||||||
|
Setting,
|
||||||
|
Github,
|
||||||
|
Notices,
|
||||||
|
UserCenter,
|
||||||
|
} from '../components';
|
||||||
|
|
||||||
const appStore = useApp();
|
const appStore = useApp();
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-breadcrumb>
|
<n-breadcrumb class="px-5">
|
||||||
<n-breadcrumb-item class="align-middle">
|
<n-breadcrumb-item class="align-middle">
|
||||||
<e-icon icon="icon-park-outline:home-two" />
|
<e-icon icon="icon-park-outline:home-two" />
|
||||||
首页
|
首页
|
||||||
@ -14,7 +14,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { Icon } from '@iconify/vue';
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const routes = computed(() => {
|
const routes = computed(() => {
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-2 flex-center cursor-pointer"
|
class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer"
|
||||||
@click="appStore.switchCollapse()"
|
@click="appStore.toggleCollapse()"
|
||||||
>
|
>
|
||||||
<e-icon v-show="appStore.collapsed" icon="icon-park-outline:menu-unfold" />
|
<e-icon v-show="appStore.collapsed" icon="icon-park-outline:menu-unfold" />
|
||||||
<e-icon v-show="!appStore.collapsed" icon="icon-park-outline:menu-fold" />
|
<e-icon v-show="!appStore.collapsed" icon="icon-park-outline:menu-fold" />
|
21
src/layouts/components/header/DarkMode.vue
Normal file
21
src/layouts/components/header/DarkMode.vue
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<template>
|
||||||
|
<n-tooltip placement="bottom" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<div
|
||||||
|
class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer"
|
||||||
|
@click="appStore.toggleDarkMode()"
|
||||||
|
>
|
||||||
|
<e-icon v-show="appStore.darkMode" icon="icon-park-outline:moon" />
|
||||||
|
<e-icon v-show="!appStore.darkMode" icon="icon-park-outline:sun" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span>切换主题模式</span>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useApp } from '@/store';
|
||||||
|
const appStore = useApp();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
21
src/layouts/components/header/FullScreen.vue
Normal file
21
src/layouts/components/header/FullScreen.vue
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<template>
|
||||||
|
<n-tooltip placement="bottom" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<div
|
||||||
|
class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer"
|
||||||
|
@click="appStore.toggleFullScreen()"
|
||||||
|
>
|
||||||
|
<e-icon v-show="appStore.fullScreen" icon="icon-park-outline:off-screen-two" />
|
||||||
|
<e-icon v-show="!appStore.fullScreen" icon="icon-park-outline:full-screen-two" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span>全屏</span>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useApp } from '@/store';
|
||||||
|
const appStore = useApp();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
18
src/layouts/components/header/Github.vue
Normal file
18
src/layouts/components/header/Github.vue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<n-tooltip placement="bottom" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<div class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer" @click="toMyGithub">
|
||||||
|
<e-icon icon="icon-park-outline:github" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span>Github</span>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const toMyGithub = () => {
|
||||||
|
window.open('https://github.com/chen-see');
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
18
src/layouts/components/header/Notices.vue
Normal file
18
src/layouts/components/header/Notices.vue
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<n-tooltip placement="bottom" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<div class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer" @click="openNotice">
|
||||||
|
<e-icon icon="icon-park-outline:remind" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span>消息通知</span>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const openNotice = () => {
|
||||||
|
console.log('消息通知');
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
26
src/layouts/components/header/Setting.vue
Normal file
26
src/layouts/components/header/Setting.vue
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<n-tooltip placement="bottom" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<div class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer" @click="openSetting">
|
||||||
|
<e-icon icon="icon-park-outline:setting-two" />
|
||||||
|
<n-drawer v-model:show="drawerActive" :width="400">
|
||||||
|
<n-drawer-content title="系统设置">这是系统设置,但是暂时还没有内容</n-drawer-content>
|
||||||
|
</n-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<span>设置</span>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
// import { useApp } from '@/store';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
// const appStore = useApp();
|
||||||
|
|
||||||
|
const drawerActive = ref(false);
|
||||||
|
const openSetting = () => {
|
||||||
|
drawerActive.value = !drawerActive.value;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
37
src/layouts/components/header/UserCenter.vue
Normal file
37
src/layouts/components/header/UserCenter.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<n-dropdown trigger="hover" :options="options" @select="handleSelect">
|
||||||
|
<div class="hover:bg-hex-F3F4F6 hover:shadow-inner h-full px-4 flex-center cursor-pointer">Admin chen</div>
|
||||||
|
</n-dropdown>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Icon } from '@iconify/vue';
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
function renderIcon(icon: string) {
|
||||||
|
return () => h(Icon, { icon });
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
label: '个人中心',
|
||||||
|
key: 'personal center',
|
||||||
|
icon: renderIcon('icon-park-outline:grinning-face'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
key: 'd1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '退出登录',
|
||||||
|
key: 'login out',
|
||||||
|
icon: renderIcon('icon-park-outline:logout'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const handleSelect = (key: string | number) => {
|
||||||
|
console.log('%c [key]-32', 'font-size:13px; background:pink; color:#bf2c9f;', key);
|
||||||
|
// message.info(String(key));
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
@ -1,6 +1,15 @@
|
|||||||
import Breadcrumb from './Breadcrumb.vue';
|
/* 侧边栏组件 */
|
||||||
import CollapaseButton from './CollapaseButton.vue';
|
import Logo from './sider/Logo.vue';
|
||||||
import Logo from './Logo.vue';
|
import Menu from './sider/Menu.vue';
|
||||||
import Menu from './Menu.vue';
|
|
||||||
|
|
||||||
export { Breadcrumb, CollapaseButton, Menu, Logo };
|
/* 头部栏组件 */
|
||||||
|
import Breadcrumb from './header/Breadcrumb.vue';
|
||||||
|
import CollapaseButton from './header/CollapaseButton.vue';
|
||||||
|
import FullScreen from './header/FullScreen.vue';
|
||||||
|
import DarkMode from './header/DarkMode.vue';
|
||||||
|
import Setting from './header/Setting.vue';
|
||||||
|
import Github from './header/Github.vue';
|
||||||
|
import Notices from './header/Notices.vue';
|
||||||
|
import UserCenter from './header/UserCenter.vue';
|
||||||
|
|
||||||
|
export { Breadcrumb, CollapaseButton, Menu, Logo, FullScreen, DarkMode, Setting, Github, Notices, UserCenter };
|
||||||
|
@ -23,7 +23,7 @@ function renderIcon(icon: string) {
|
|||||||
return () => h(Icon, { icon });
|
return () => h(Icon, { icon });
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClickMenu = (key: string, _item: MenuOption) => {
|
const handleClickMenu = (key: string) => {
|
||||||
router.push(key);
|
router.push(key);
|
||||||
};
|
};
|
||||||
const menuOptions: MenuOption[] = [
|
const menuOptions: MenuOption[] = [
|
@ -4,12 +4,29 @@ export const useApp = defineStore('app-store', {
|
|||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
|
fullScreen: false,
|
||||||
|
darkMode: false,
|
||||||
title: import.meta.env.VITE_APP_TITLE,
|
title: import.meta.env.VITE_APP_TITLE,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
switchCollapse() {
|
/* 切换侧边栏收缩 */
|
||||||
|
toggleCollapse() {
|
||||||
this.collapsed = !this.collapsed;
|
this.collapsed = !this.collapsed;
|
||||||
},
|
},
|
||||||
|
/* 切换全屏 */
|
||||||
|
toggleFullScreen() {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
this.fullScreen = true;
|
||||||
|
document.documentElement.requestFullscreen();
|
||||||
|
} else if (document.exitFullscreen) {
|
||||||
|
this.fullScreen = false;
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/* 切换主题 亮/深色 */
|
||||||
|
toggleDarkMode() {
|
||||||
|
this.darkMode = !this.darkMode;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user