From 6622218409bdb6d1cbf85be33367b7630f84029e Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期一, 28 八月 2023 10:03:15 +0800
Subject: [PATCH] modified: src/layout/components/Navbar.vue modified: src/layout/index.vue modified: src/router/index.js modified: src/views/login/index.vue
---
src/views/login/index.vue | 3
src/layout/components/Navbar.vue | 4
src/layout/index.vue | 132 ++++++++++++++++++++++++--------------------
src/router/index.js | 6 +-
4 files changed, 79 insertions(+), 66 deletions(-)
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index be3b829..ba4d987 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -107,7 +107,7 @@
},
async logout() {
// await this.$store.dispatch('user/logout')
- localStorage.removeItem("user")
+ sessionStorage.removeItem("user")
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
this.$router.replace({path: '/login'});
location.reload();
@@ -115,7 +115,7 @@
getUser(){
get(this.$url.info).then(res=>{
this.user = res.data
- localStorage.setItem("user",JSON.stringify(res.data))
+ sessionStorage.setItem("user",JSON.stringify(res.data))
})
}
}
diff --git a/src/layout/index.vue b/src/layout/index.vue
index 37ab14d..3424c5b 100644
--- a/src/layout/index.vue
+++ b/src/layout/index.vue
@@ -1,18 +1,18 @@
<template>
<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" />
<div class="main-container">
- <div :class="{'fixed-header':fixedHeader}">
+ <div :class="{ 'fixed-header': fixedHeader }">
<navbar />
</div>
<div class="clearFixed" />
<!-- 娓呴櫎瀹氫綅鐨勫奖鍝� -->
<div class="breadcrumb">
- <Breadcrumb class="breadcrumb-container" ref="breadcrumb" />
+ <Breadcrumb class="breadcrumb-container" ref="breadcrumb" />
</div>
<div class="app-main">
- <app-main ref="main" @triggerCombackBtn="triggerCombackBtn"/>
+ <app-main ref="main" @triggerCombackBtn="triggerCombackBtn" />
</div>
</div>
</div>
@@ -51,20 +51,26 @@
}
}
},
+ created() {
+ if (sessionStorage.getItem("flushPage") == 0) {
+ location.reload();
+ sessionStorage.setItem("flushPage",1)
+ }
+ },
methods: {
handleClickOutside() {
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
},
- combackPlan(){
- this.$refs.main.childMethod()
+ combackPlan() {
+ this.$refs.main.childMethod()
},
- indexAdd(){
+ indexAdd() {
this.$refs.main.mainAdd()
},
- showIndexAdd(){
+ showIndexAdd() {
this.$refs.breadcrumb.showadd()
},
- triggerCombackBtn(){
+ triggerCombackBtn() {
this.$refs.breadcrumb.triggerBtnPlan()
}
}
@@ -72,63 +78,69 @@
</script>
<style lang="scss" scoped>
- @import "~@/styles/mixin.scss";
- @import "~@/styles/variables.scss";
+@import "~@/styles/mixin.scss";
+@import "~@/styles/variables.scss";
- .app-wrapper {
- @include clearfix;
- position: relative;
- height: 100%;
- width: 100%;
- &.mobile.openSidebar{
- position: fixed;
- top: 0;
- }
- .sidebar-container{
- box-shadow: 0 0 0.857143rem rgba(0,0,0,.12);
- }
- .main-container{
- position: relative;
- background: #f0f2f5;
- .clearFixed{
- height: 50px;
- }
- .breadcrumb{
- position: fixed;
- left: 0.57rem !important;
- width: 93.8%;
- z-index: 999;
- }
- .app-main{
- margin-top: 4vh;
- }
- }
- }
- .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;
top: 0;
- right: 0;
- z-index: 9;
- width: calc(100% - #{$sideBarWidth});
- // width: calc(100% - 100px);
- transition: width 0.28s;
}
- .hideSidebar .fixed-header {
- width: calc(100% - #{$sideBarWidth})
+ .sidebar-container {
+ box-shadow: 0 0 0.857143rem rgba(0, 0, 0, .12);
}
- .mobile .fixed-header {
- width: 100%;
+ .main-container {
+ position: relative;
+ background: #f0f2f5;
+
+ .clearFixed {
+ height: 50px;
+ }
+
+ .breadcrumb {
+ position: fixed;
+ left: 0.57rem !important;
+ width: 93.8%;
+ z-index: 999;
+ }
+
+ .app-main {
+ margin-top: 4vh;
+ }
}
-</style>
+}
+
+.drawer-bg {
+ background: #000;
+ opacity: 0.3;
+ width: 100%;
+ top: 0;
+ height: 100%;
+ position: absolute;
+ z-index: 999;
+}
+
+.fixed-header {
+ position: fixed;
+ top: 0;
+ right: 0;
+ z-index: 9;
+ width: calc(100% - #{$sideBarWidth});
+ // width: calc(100% - 100px);
+ transition: width 0.28s;
+}
+
+.hideSidebar .fixed-header {
+ width: calc(100% - #{$sideBarWidth})
+}
+
+.mobile .fixed-header {
+ width: 100%;
+}</style>
diff --git a/src/router/index.js b/src/router/index.js
index 285386b..5f0ac20 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -526,8 +526,8 @@
function createRouter(Routees) {
- if (JSON.parse(localStorage.getItem("user")) != undefined && JSON.parse(localStorage.getItem("user")) != null) {
- let role = JSON.parse(localStorage.getItem("user")).role
+ if (JSON.parse(sessionStorage.getItem("user")) != undefined && JSON.parse(sessionStorage.getItem("user")) != null) {
+ let role = JSON.parse(sessionStorage.getItem("user")).role
let menuFather = baseRouter
const dataMenuFather = fn3(menuFather)
role.roleMenuList.forEach((r) => {
@@ -607,7 +607,7 @@
} else {
// 涓嶆槸鐧诲綍椤甸潰
// 2. 鍒ゆ柇 鏄惁鐧诲綍杩�
- let token = localStorage.getItem('user')
+ let token = sessionStorage.getItem('user')
if(token!=null&&token!=undefined){
await resetRouter()
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index d381e08..6fcb22a 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -96,7 +96,8 @@
this.$store.dispatch('user/login', this.loginForm).then(async () => {
await get(this.$url.info).then(res => {
this.user = res.data
- localStorage.setItem("user", JSON.stringify(res.data))
+ sessionStorage.setItem("user", JSON.stringify(res.data))
+ sessionStorage.setItem("flushPage",0)
})
this.$router.push({ path: this.redirect || '/' })
this.loading = false
--
Gitblit v1.9.3