Browse Source

navbar-sidebar-页面整体样式修改

dev
xuhuajiao 3 years ago
parent
commit
4e391b8f1d
  1. BIN
      src/assets/images/logo-x.png
  2. BIN
      src/assets/images/logo.png
  3. BIN
      src/assets/images/menu_bg_02.png
  4. 1
      src/assets/styles/sidebar.scss
  5. 6
      src/assets/styles/variables.scss
  6. 24
      src/layout/components/AppMain.vue
  7. 181
      src/layout/components/Navbar.vue
  8. 17
      src/layout/components/Sidebar/Logo.vue
  9. 23
      src/layout/components/Sidebar/index.vue
  10. 94
      src/layout/index.vue
  11. 92
      src/views/home.vue

BIN
src/assets/images/logo-x.png

After

Width: 121  |  Height: 23  |  Size: 2.3 KiB

BIN
src/assets/images/logo.png

Before

Width: 128  |  Height: 128  |  Size: 8.1 KiB

BIN
src/assets/images/menu_bg_02.png

After

Width: 264  |  Height: 188  |  Size: 5.0 KiB

1
src/assets/styles/sidebar.scss

@ -11,6 +11,7 @@
transition: width 0.28s; transition: width 0.28s;
width: $sideBarWidth !important; width: $sideBarWidth !important;
background-color: $menuBg; background-color: $menuBg;
background: url(../images/menu_bg_02.png) no-repeat left bottom #fff;
height: 100%; height: 100%;
position: fixed; position: fixed;
font-size: 0; font-size: 0;

6
src/assets/styles/variables.scss

@ -13,13 +13,13 @@ $menuText:#bfcbd9;
$menuActiveText:#409EFF; $menuActiveText:#409EFF;
$subMenuActiveText:#f4f4f5; $subMenuActiveText:#f4f4f5;
$menuBg:#304156;
$menuBg:#fff;
$menuHover:#263445; $menuHover:#263445;
$subMenuBg:#1f2d3d;
$subMenuBg:#fff;
$subMenuHover:#001528; $subMenuHover:#001528;
$sideBarWidth: 205px;
$sideBarWidth: 264px;
:export { :export {

24
src/layout/components/AppMain.vue

@ -7,8 +7,11 @@
</transition> </transition>
<div v-if="$store.state.settings.showFooter" id="el-main-footer"> <div v-if="$store.state.settings.showFooter" id="el-main-footer">
<span v-html="$store.state.settings.footerTxt" /> <span v-html="$store.state.settings.footerTxt" />
<span> </span>
<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">{{ $store.state.settings.caseNumber }}</a>
<span></span>
<a
href="https://beian.miit.gov.cn/#/Integrated/index"
target="_blank"
>{{ $store.state.settings.caseNumber }}</a>
</div> </div>
</section> </section>
</template> </template>
@ -30,25 +33,14 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.app-main { .app-main {
/* 50= navbar 50 */ /* 50= navbar 50 */
min-height: calc(100vh - 50px);
min-height: calc(100vh - 64px);
width: 100%; width: 100%;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
.fixed-header+.app-main {
padding-top: 50px;
}
.hasTagsView {
.app-main {
min-height: calc(100vh - 84px);
}
.fixed-header+.app-main {
padding-top: 84px;
}
.fixed-header + .app-main {
padding-top: 64px;
} }
</style> </style>

181
src/layout/components/Navbar.vue

@ -1,82 +1,22 @@
<template> <template>
<div class="navbar"> <div class="navbar">
<hamburger
id="hamburger-container"
:is-active="sidebar.opened"
class="hamburger-container"
@toggleClick="toggleSideBar"
/>
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
<!-- 顶部菜单 start--> <!-- 顶部菜单 start-->
<div class="navmenu">
<template>
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
active-text-color="#409EFF"
@select="handleSelect"
>
<!-- <el-menu-item index="1">系统管理</el-menu-item> -->
<!-- <el-submenu index="2">
<template slot="title">瀑布墙管理</template>
<el-menu-item index="2-1">子菜单</el-menu-item>
<el-submenu index="2-4">
<template slot="title">选项4</template>
<el-menu-item index="2-4-1">选项1</el-menu-item>
<el-menu-item index="2-4-2">选项2</el-menu-item>
<el-menu-item index="2-4-3">选项3</el-menu-item>
</el-submenu>
</el-submenu>
<el-menu-item index="3">竖屏管理</el-menu-item>
<el-menu-item index="4" disabled>AI阅行管理</el-menu-item> -->
</el-menu>
</template>
</div>
<div class="navmenu">武汉图书馆</div>
<!-- 顶部菜单 end--> <!-- 顶部菜单 end-->
<div class="right-menu"> <div class="right-menu">
<template v-if="device !== 'mobile'">
<search id="header-search" class="right-menu-item" />
<el-tooltip content="项目文档" effect="dark" placement="bottom">
<Doc class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip content="全屏缩放" effect="dark" placement="bottom">
<screenfull id="screenfull" class="right-menu-item hover-effect" />
</el-tooltip>
<el-tooltip content="布局设置" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip>
</template>
<el-dropdown
class="avatar-container right-menu-item hover-effect"
trigger="click"
>
<div class="current_date">2022-02-25 星期五</div>
<el-dropdown class="avatar-container right-menu-item" trigger="click">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<img
:src="
user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar
"
class="user-avatar"
/>
<!-- <p>{{user.phone}}</p> -->
<p class="user_phone">13476289682</p>
<i class="el-icon-caret-bottom" /> <i class="el-icon-caret-bottom" />
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<span style="display:block;" @click="show = true">
<el-dropdown-item>
布局设置
</el-dropdown-item>
</span>
<router-link to="/user/center"> <router-link to="/user/center">
<el-dropdown-item>
个人中心
</el-dropdown-item>
<el-dropdown-item>个人中心</el-dropdown-item>
</router-link> </router-link>
<span style="display:block;" @click="open"> <span style="display:block;" @click="open">
<el-dropdown-item divided>
退出登录
</el-dropdown-item>
<el-dropdown-item divided>退出登录</el-dropdown-item>
</span> </span>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -86,49 +26,19 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Doc from '@/components/Doc'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import Avatar from '@/assets/images/avatar.png' import Avatar from '@/assets/images/avatar.png'
export default { export default {
components: {
Breadcrumb,
Hamburger,
Screenfull,
SizeSelect,
Search,
Doc
},
components: {},
data() { data() {
return { return {
Avatar: Avatar,
dialogVisible: false,
activeIndex: '1',
activeIndex2: '1'
Avatar: Avatar
} }
}, },
computed: { computed: {
...mapGetters(['sidebar', 'device', 'user', 'baseApi']),
show: {
get() {
return this.$store.state.settings.showSettings
},
set(val) {
this.$store.dispatch('settings/changeSetting', {
key: 'showSettings',
value: val
})
}
}
...mapGetters(['user'])
}, },
methods: { methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
open() { open() {
this.$confirm('确定注销并退出系统吗?', '提示', { this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -138,9 +48,6 @@ export default {
this.logout() this.logout()
}) })
}, },
handleSelect(key, keyPath) {
console.log(key, keyPath)
},
logout() { logout() {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.reload() location.reload()
@ -152,79 +59,51 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.navbar { .navbar {
height: 60px;
display: flex;
justify-content: space-between;
height: 64px;
line-height: 64px;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
background: #fff; background: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
.navmenu { .navmenu {
float: left;
}
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
.breadcrumb-container {
float: left;
}
.errLog-container {
display: inline-block;
vertical-align: top;
flex: 1;
font-size: 18px;
font-weight: bold;
padding-left: 32px;
} }
.right-menu { .right-menu {
float: right;
display: flex;
height: 100%; height: 100%;
line-height: 50px;
line-height: 64px;
font-size: 14px;
color: #333333;
&:focus { &:focus {
outline: none; outline: none;
} }
.current_date {
display: block;
margin-right: 72px;
}
.right-menu-item { .right-menu-item {
display: inline-block; display: inline-block;
padding: 0 8px; padding: 0 8px;
height: 100%; height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom; vertical-align: text-bottom;
&.hover-effect {
cursor: pointer;
transition: background 0.3s;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
} }
.avatar-container { .avatar-container {
margin-right: 30px;
margin-right: 68px;
.avatar-wrapper { .avatar-wrapper {
margin-top: 5px;
position: relative; position: relative;
.user-avatar {
.user_phone {
margin: 0;
cursor: pointer; cursor: pointer;
width: 40px;
height: 40px;
border-radius: 10px;
} }
.el-icon-caret-bottom { .el-icon-caret-bottom {
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;

17
src/layout/components/Sidebar/Logo.vue

@ -3,18 +3,16 @@
<transition name="sidebarLogoFade"> <transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/"> <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo"> <img v-if="logo" :src="logo" class="sidebar-logo">
<h1 v-else class="sidebar-title">{{ title }} </h1>
</router-link> </router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/"> <router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo"> <img v-if="logo" :src="logo" class="sidebar-logo">
<h1 class="sidebar-title">{{ title }} </h1>
</router-link> </router-link>
</transition> </transition>
</div> </div>
</template> </template>
<script> <script>
import Logo from '@/assets/images/logo.png'
import Logo from '@/assets/images/logo-x.png'
export default { export default {
name: 'SidebarLogo', name: 'SidebarLogo',
props: { props: {
@ -45,20 +43,19 @@ export default {
.sidebar-logo-container { .sidebar-logo-container {
position: relative; position: relative;
width: 100%; width: 100%;
height: 50px;
line-height: 50px;
height: 64px;
line-height: 64px;
text-align: center; text-align: center;
overflow: hidden; overflow: hidden;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
& .sidebar-logo-link { & .sidebar-logo-link {
height: 100%; height: 100%;
width: 100%; width: 100%;
& .sidebar-logo { & .sidebar-logo {
width: 32px;
height: 32px;
width: 121px;
height: 23px;
vertical-align: middle; vertical-align: middle;
margin-right: 6px;
} }
& .sidebar-title { & .sidebar-title {
@ -66,7 +63,7 @@ export default {
margin: 0; margin: 0;
color: #fff; color: #fff;
font-weight: 600; font-weight: 600;
line-height: 50px;
line-height: 64px;
font-size: 14px; font-size: 14px;
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif; font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
vertical-align: middle; vertical-align: middle;

23
src/layout/components/Sidebar/index.vue

@ -2,9 +2,22 @@
<div :class="{ 'has-logo': showLogo }"> <div :class="{ 'has-logo': showLogo }">
<logo v-if="showLogo" :collapse="isCollapse" /> <logo v-if="showLogo" :collapse="isCollapse" />
<el-scrollbar wrap-class="scrollbar-wrapper"> <el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu :default-active="activeMenu" :collapse="isCollapse" :background-color="variables.menuBg" :text-color="variables.menuText" :unique-opened="$store.state.settings.uniqueOpened"
:active-text-color="variables.menuActiveText" :collapse-transition="false" mode="vertical">
<sidebar-item v-for="route in sidebarRouters" :key="route.path" :item="route" :base-path="route.path" />
<el-menu
:default-active="activeMenu"
:collapse="isCollapse"
:background-color="variables.menuBg"
:text-color="variables.menuText"
:unique-opened="$store.state.settings.uniqueOpened"
:active-text-color="variables.menuActiveText"
:collapse-transition="false"
mode="vertical"
>
<sidebar-item
v-for="route in sidebarRouters"
:key="route.path"
:item="route"
:base-path="route.path"
/>
</el-menu> </el-menu>
</el-scrollbar> </el-scrollbar>
</div> </div>
@ -37,7 +50,7 @@ export default {
}, },
isCollapse() { isCollapse() {
return !this.sidebar.opened return !this.sidebar.opened
},
},
}
}
} }
</script> </script>

94
src/layout/index.vue

@ -1,28 +1,29 @@
<template> <template>
<div :class="classObj" class="app-wrapper"> <div :class="classObj" class="app-wrapper">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<div
v-if="device === 'mobile' && sidebar.opened"
class="drawer-bg"
@click="handleClickOutside"
/>
<sidebar class="sidebar-container" /> <sidebar class="sidebar-container" />
<div :class="{hasTagsView:needTagsView}" class="main-container">
<div :class="{'fixed-header':fixedHeader}">
<div class="main-container">
<div :class="{ 'fixed-header': fixedHeader }">
<navbar /> <navbar />
<tags-view v-if="needTagsView" />
<!-- <tags-view v-if="needTagsView" /> -->
</div> </div>
<app-main /> <app-main />
<right-panel v-if="showSettings"> <right-panel v-if="showSettings">
<settings /> <settings />
</right-panel> </right-panel>
</div> </div>
<!-- 防止刷新后主题丢失 -->
<Theme v-show="false" ref="theme" />
</div> </div>
</template> </template>
<script> <script>
import RightPanel from '@/components/RightPanel' import RightPanel from '@/components/RightPanel'
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
import { AppMain, Navbar, Settings, Sidebar } from './components'
import ResizeMixin from './mixin/ResizeHandler' import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import Theme from '@/components/ThemePicker'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
export default { export default {
name: 'Layout', name: 'Layout',
@ -31,10 +32,7 @@ export default {
Navbar, Navbar,
RightPanel, RightPanel,
Settings, Settings,
Sidebar,
TagsView,
Theme
Sidebar
}, },
mixins: [ResizeMixin], mixins: [ResizeMixin],
computed: { computed: {
@ -42,7 +40,7 @@ export default {
sidebar: state => state.app.sidebar, sidebar: state => state.app.sidebar,
device: state => state.app.device, device: state => state.app.device,
showSettings: state => state.settings.showSettings, showSettings: state => state.settings.showSettings,
needTagsView: state => state.settings.tagsView,
// needTagsView: state => state.settings.tagsView,
fixedHeader: state => state.settings.fixedHeader fixedHeader: state => state.settings.fixedHeader
}), }),
classObj() { classObj() {
@ -72,46 +70,46 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "~@/assets/styles/mixin.scss";
@import "~@/assets/styles/variables.scss";
.app-wrapper {
@include clearfix;
position: relative;
height: 100%;
width: 100%;
&.mobile.openSidebar {
position: fixed;
top: 0;
}
}
@import "~@/assets/styles/mixin.scss";
@import "~@/assets/styles/variables.scss";
.drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
top: 0;
height: 100%;
position: absolute;
z-index: 999;
}
.app-wrapper {
@include clearfix;
position: relative;
height: 100%;
width: 100%;
.fixed-header {
&.mobile.openSidebar {
position: fixed; position: fixed;
top: 0; top: 0;
right: 0;
z-index: 9;
width: calc(100% - #{$sideBarWidth});
transition: width 0.28s;
padding: 0;
} }
}
.hideSidebar .fixed-header {
width: calc(100% - 54px)
}
.drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
top: 0;
height: 100%;
position: absolute;
z-index: 999;
}
.mobile .fixed-header {
width: 100%;
}
.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
width: calc(100% - #{$sideBarWidth});
transition: width 0.28s;
padding: 0;
}
.hideSidebar .fixed-header {
width: calc(100% - 54px);
}
.mobile .fixed-header {
width: 100%;
}
</style> </style>

92
src/views/home.vue

@ -1,107 +1,27 @@
<template> <template>
<div class="dashboard-container"> <div class="dashboard-container">
<div class="dashboard-editor-container">
<github-corner class="github-corner" />
<panel-group @handleSetLineChartData="handleSetLineChartData" />
<el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
<line-chart :chart-data="lineChartData" />
</el-row>
<el-row :gutter="32">
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<radar-chart />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<pie-chart />
</div>
</el-col>
<el-col :xs="24" :sm="24" :lg="8">
<div class="chart-wrapper">
<bar-chart />
</div>
</el-col>
</el-row>
</div>
<div class="dashboard-editor-container"></div>
</div> </div>
</template> </template>
<script> <script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import RadarChart from '@/components/Echarts/RadarChart'
import PieChart from '@/components/Echarts/PieChart'
import BarChart from '@/components/Echarts/BarChart'
const lineChartData = {
newVisitis: {
expectedData: [100, 120, 161, 134, 105, 160, 165],
actualData: [120, 82, 91, 154, 162, 140, 145]
},
messages: {
expectedData: [200, 192, 120, 144, 160, 130, 140],
actualData: [180, 160, 151, 106, 145, 150, 130]
},
purchases: {
expectedData: [80, 100, 121, 104, 105, 90, 100],
actualData: [120, 90, 100, 138, 142, 130, 130]
},
shoppings: {
expectedData: [130, 140, 141, 142, 145, 150, 160],
actualData: [120, 82, 91, 154, 162, 140, 130]
}
}
export default { export default {
name: 'Dashboard', name: 'Dashboard',
components: { components: {
GithubCorner,
PanelGroup,
LineChart,
RadarChart,
PieChart,
BarChart
}, },
data() { data() {
return { return {
lineChartData: lineChartData.newVisitis
} }
}, },
methods: { methods: {
handleSetLineChartData(type) {
this.lineChartData = lineChartData[type]
}
} }
} }
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
padding: 32px;
background-color: rgb(240, 242, 245);
position: relative;
.github-corner {
position: absolute;
top: 0;
border: 0;
right: 0;
}
.chart-wrapper {
background: #fff;
padding: 16px 16px 0;
margin-bottom: 32px;
}
}
@media (max-width:1024px) {
.chart-wrapper {
padding: 8px;
}
}
.dashboard-editor-container {
padding: 32px;
background-color: #f5f5f5;
position: relative;
}
</style> </style>
Loading…
Cancel
Save