diff --git a/vue/src/assets/styles/index.scss b/vue/src/assets/styles/index.scss
index a573051..2dbf271 100644
--- a/vue/src/assets/styles/index.scss
+++ b/vue/src/assets/styles/index.scss
@@ -2,7 +2,6 @@
@import "~element-ui/packages/theme-chalk/src/index";
@import "transition";
@import "element-ui";
-@import "sidebar";
@import "nprogress";
body {
diff --git a/vue/src/assets/styles/sidebar.scss b/vue/src/assets/styles/sidebar.scss
index b8658ee..4d7b054 100644
--- a/vue/src/assets/styles/sidebar.scss
+++ b/vue/src/assets/styles/sidebar.scss
@@ -9,6 +9,14 @@ $iconSize: 17px;
overflow: hidden;
flex-shrink: 0;
transition: all .3s;
+ top: 0;
+ bottom: 0;
+ z-index: 10;
+
+ //移动端时为fixed
+ &.mobile {
+ position: fixed;
+ }
//折叠设置
&.collapse-sidebar {
diff --git a/vue/src/layout/components/Navbar/components/Breadcrumb.vue b/vue/src/layout/components/Navbar/components/Breadcrumb.vue
index f70c706..284bc9d 100644
--- a/vue/src/layout/components/Navbar/components/Breadcrumb.vue
+++ b/vue/src/layout/components/Navbar/components/Breadcrumb.vue
@@ -37,7 +37,6 @@
.app-breadcrumb.el-breadcrumb {
display: inline-block;
line-height: 50px;
- margin-left: 15px;
.no-redirect {
color: $--color-gray;
diff --git a/vue/src/layout/components/Navbar/components/Hamburger.vue b/vue/src/layout/components/Navbar/components/Hamburger.vue
new file mode 100644
index 0000000..f3d10c4
--- /dev/null
+++ b/vue/src/layout/components/Navbar/components/Hamburger.vue
@@ -0,0 +1,53 @@
+
+
+
diff --git a/vue/src/layout/components/Navbar/components/SettingDrawer.vue b/vue/src/layout/components/Navbar/components/SettingDrawer.vue
index f070412..5433b0a 100644
--- a/vue/src/layout/components/Navbar/components/SettingDrawer.vue
+++ b/vue/src/layout/components/Navbar/components/SettingDrawer.vue
@@ -39,83 +39,30 @@
diff --git a/vue/src/layout/components/Navbar/index.vue b/vue/src/layout/components/Navbar/index.vue
index 5fb8c6f..0b8a6cb 100644
--- a/vue/src/layout/components/Navbar/index.vue
+++ b/vue/src/layout/components/Navbar/index.vue
@@ -1,5 +1,7 @@
+
+
diff --git a/vue/src/layout/index.vue b/vue/src/layout/index.vue
index b7fc563..3e5e706 100644
--- a/vue/src/layout/index.vue
+++ b/vue/src/layout/index.vue
@@ -5,6 +5,12 @@
+
+
@@ -13,15 +19,21 @@
import VMain from './components/Main'
import VHeader from './components/Header'
import VSidebar from './components/Sidebar'
+ import ResizeHandler from './mixin/ResizeHandler'
import {isEmpty} from "@/utils"
export default {
name: 'Layout',
+ mixins: [ResizeHandler],
components: {VMain, VSidebar, VHeader},
computed: {
...mapState('app', {
+ device: state => state.device,
hasHeader: state => state.hasHeader
}),
+ ...mapState('setting', {
+ sidebarCollapse: state => state.sidebarCollapse
+ }),
...mapState('socket', {
online: state => state.online
}),
@@ -30,6 +42,9 @@
}),
showOfflineTip() {
return !this.online && this.isLogin
+ },
+ showSidebarMask() {
+ return !this.sidebarCollapse && this.device === 'mobile'
}
},
watch: {
@@ -46,11 +61,21 @@
height: 100%;
width: 100%;
flex-direction: row;
- }
- .main-container {
- overflow: hidden;
- position: relative;
- flex-direction: column;
+ .drawer-bg {
+ background: #000;
+ opacity: 0.3;
+ width: 100%;
+ top: 0;
+ height: 100%;
+ position: absolute;
+ z-index: 9;
+ }
+
+ .main-container {
+ overflow: hidden;
+ position: relative;
+ flex-direction: column;
+ }
}
diff --git a/vue/src/layout/mixin/ResizeHandler.js b/vue/src/layout/mixin/ResizeHandler.js
new file mode 100644
index 0000000..bae37d1
--- /dev/null
+++ b/vue/src/layout/mixin/ResizeHandler.js
@@ -0,0 +1,25 @@
+const {body} = document
+const WIDTH = 768
+
+export default {
+ methods: {
+ $_isMobile() {
+ const rect = body.getBoundingClientRect()
+ return rect.width - 1 < WIDTH
+ },
+ $_resizeHandler() {
+ if (!document.hidden) {
+ const isMobile = this.$_isMobile()
+ this.$store.commit('app/device', isMobile ? 'mobile' : 'pc')
+ isMobile && this.$store.commit('setting/sidebarCollapse', true)
+ }
+ }
+ },
+ mounted() {
+ window.addEventListener('resize', this.$_resizeHandler)
+ this.$_resizeHandler()
+ },
+ beforeDestroy() {
+ window.removeEventListener('resize', this.$_resizeHandler)
+ }
+}
diff --git a/vue/src/store/modules/app.js b/vue/src/store/modules/app.js
index 7883bd9..1ba0576 100644
--- a/vue/src/store/modules/app.js
+++ b/vue/src/store/modules/app.js
@@ -4,6 +4,7 @@ import {createMutations} from "@/utils"
const localSettings = getLocalPersonalSettings()
const state = {
+ //区分pc和移动端(mobile)
device: 'pc',
//登陆页背景动画
loginPageBackgroundAnimation: 'firework',
diff --git a/vue/src/store/modules/setting.js b/vue/src/store/modules/setting.js
index 46d5db8..371689a 100644
--- a/vue/src/store/modules/setting.js
+++ b/vue/src/store/modules/setting.js
@@ -7,6 +7,16 @@ import {getLocalPersonalSettings, setLocalPersonalSettings} from "@/utils/localS
const localSettings = getLocalPersonalSettings()
+function createMutations(state) {
+ return Object.keys(state).reduce((mutations, key) => {
+ mutations[key] = (ref, data) => {
+ ref[key] = data
+ setLocalPersonalSettings(ref)
+ }
+ return mutations
+ }, {})
+}
+
const state = {
//是否显示logo
showLogo: true,
@@ -31,16 +41,22 @@ Object.keys(state).forEach(key => {
if (!isEmpty(localSettings[key])) state[key] = localSettings[key]
})
-const mutations = createMutations(state)
-
-function createMutations(state) {
- return Object.keys(state).reduce((mutations, key) => {
- mutations[key] = (ref, data) => {
- ref[key] = data
- setLocalPersonalSettings(ref)
+const mutations = {
+ ...createMutations(state),
+ sidebarCollapse(state, v) {
+ if (v && state.sidebarAutoHidden) {
+ state.sidebarAutoHidden = false
}
- return mutations
- }, {})
+ state.sidebarCollapse = v
+ setLocalPersonalSettings(state)
+ },
+ sidebarAutoHidden(state, v) {
+ if (v && state.sidebarCollapse) {
+ state.sidebarCollapse = false
+ }
+ state.sidebarAutoHidden = v
+ setLocalPersonalSettings(state)
+ }
}
export default {