优化代码
This commit is contained in:
10
src/boot.js
Normal file
10
src/boot.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import * as AIcons from '@ant-design/icons-vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
install(app) {
|
||||||
|
|
||||||
|
for (let icon in AIcons) {
|
||||||
|
app.component(`${icon}`, AIcons[icon])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="userbar">
|
<div class="userbar">
|
||||||
|
<a-tooltip title="全屏">
|
||||||
|
<a-button type="text" @click="toggleFullscreen" class="action-btn">
|
||||||
|
<FullscreenOutlined v-if="!isFullscreen" />
|
||||||
|
<FullscreenExitOutlined v-else />
|
||||||
|
</a-button>
|
||||||
|
</a-tooltip>
|
||||||
|
|
||||||
|
<a-tooltip title="布局设置">
|
||||||
|
<a-button type="text" @click="showSetting = true" class="action-btn">
|
||||||
|
<SettingOutlined />
|
||||||
|
</a-button>
|
||||||
|
</a-tooltip>
|
||||||
|
|
||||||
<a-dropdown :trigger="['click']">
|
<a-dropdown :trigger="['click']">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<a-avatar :size="32" :src="userStore.user?.avatar || ''">
|
<a-avatar :size="32" :src="userStore.user?.avatar || ''">
|
||||||
@@ -27,19 +40,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
|
|
||||||
<a-tooltip title="全屏">
|
|
||||||
<a-button type="text" @click="toggleFullscreen" class="action-btn">
|
|
||||||
<FullscreenOutlined v-if="!isFullscreen" />
|
|
||||||
<FullscreenExitOutlined v-else />
|
|
||||||
</a-button>
|
|
||||||
</a-tooltip>
|
|
||||||
|
|
||||||
<a-tooltip title="布局设置">
|
|
||||||
<a-button type="text" @click="showSetting = true" class="action-btn">
|
|
||||||
<SettingOutlined />
|
|
||||||
</a-button>
|
|
||||||
</a-tooltip>
|
|
||||||
|
|
||||||
<!-- 布局设置抽屉 -->
|
<!-- 布局设置抽屉 -->
|
||||||
<a-drawer v-model:open="showSetting" title="布局设置" placement="right" :width="280">
|
<a-drawer v-model:open="showSetting" title="布局设置" placement="right" :width="280">
|
||||||
<div class="setting-content">
|
<div class="setting-content">
|
||||||
@@ -185,7 +185,7 @@ const changeThemeColor = (color) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 4px 12px;
|
padding: 0 12px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<a-layout class="main-layout">
|
<a-layout class="main-layout">
|
||||||
<a-layout-header class="app-header">
|
<a-layout-header class="app-header">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
<a-button type="text" :icon="sidebarCollapsed ? 'menu-unfold' : 'menu-fold'"
|
<a-button type="text" :icon="sidebarCollapsed ? h(MenuUnfoldOutlined) : h(MenuFoldOutlined)"
|
||||||
@click="toggleSidebar" class="collapse-btn" />
|
@click="toggleSidebar" class="collapse-btn" />
|
||||||
<breadcrumb />
|
<breadcrumb />
|
||||||
</div>
|
</div>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<a-layout class="main-layout">
|
<a-layout class="main-layout">
|
||||||
<a-layout-header class="app-header">
|
<a-layout-header class="app-header">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
<a-button type="text" :icon="sidebarCollapsed ? 'menu-unfold' : 'menu-fold'"
|
<a-button type="text" :icon="sidebarCollapsed ? h(MenuUnfoldOutlined) : h(MenuFoldOutlined)"
|
||||||
@click="toggleSidebar" class="collapse-btn" />
|
@click="toggleSidebar" class="collapse-btn" />
|
||||||
<breadcrumb />
|
<breadcrumb />
|
||||||
</div>
|
</div>
|
||||||
@@ -85,9 +85,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, h } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useLayoutStore } from '@/stores/modules/layout'
|
import { useLayoutStore } from '@/stores/modules/layout'
|
||||||
|
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
import userbar from './components/userbar.vue'
|
import userbar from './components/userbar.vue'
|
||||||
import breadcrumb from './components/breadcrumb.vue'
|
import breadcrumb from './components/breadcrumb.vue'
|
||||||
@@ -143,6 +144,7 @@ const handleCollapse = (collapsed) => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
||||||
|
height: 60px;
|
||||||
z-index: 9;
|
z-index: 9;
|
||||||
|
|
||||||
.header-left {
|
.header-left {
|
||||||
@@ -152,7 +154,7 @@ const handleCollapse = (collapsed) => {
|
|||||||
|
|
||||||
.collapse-btn {
|
.collapse-btn {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding: 4px 8px;
|
padding: 0 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,7 +193,7 @@ const handleCollapse = (collapsed) => {
|
|||||||
|
|
||||||
.menu-sidebar {
|
.menu-sidebar {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
|
box-shadow: 1px 0 6px rgba(0, 0, 0, 0.1);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +206,6 @@ const handleCollapse = (collapsed) => {
|
|||||||
|
|
||||||
.app-header {
|
.app-header {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
height: 50px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-main {
|
.app-main {
|
||||||
@@ -216,7 +217,7 @@ const handleCollapse = (collapsed) => {
|
|||||||
&.layout-menu {
|
&.layout-menu {
|
||||||
.full-menu-sidebar {
|
.full-menu-sidebar {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
|
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.1);
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
|
||||||
.logo-box-full {
|
.logo-box-full {
|
||||||
@@ -251,7 +252,6 @@ const handleCollapse = (collapsed) => {
|
|||||||
|
|
||||||
.app-header {
|
.app-header {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
height: 50px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-main {
|
.app-main {
|
||||||
@@ -265,7 +265,6 @@ const handleCollapse = (collapsed) => {
|
|||||||
|
|
||||||
.top-header {
|
.top-header {
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
height: 60px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import App from './App.vue'
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import pinia from './stores'
|
import pinia from './stores'
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
|
import boot from './boot'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
@@ -13,5 +14,6 @@ app.use(Antd)
|
|||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
app.use(boot)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
<h1 class="page-title">欢迎回来,管理员!</h1>
|
<h1 class="page-title">欢迎回来,管理员!</h1>
|
||||||
|
|
||||||
<div class="dashboard-cards">
|
<div class="dashboard-cards">
|
||||||
<div class="stat-card">
|
<div class="stat-card">
|
||||||
<div class="stat-icon">👥</div>
|
<div class="stat-icon">👥</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user