Commit ab67dc8c by 姜雷

Merge branch 'develop' into 'test'

记录菜单状态 See merge request !80
parents 93b5e3fd 19ae235d
......@@ -63,6 +63,8 @@ import UserBox from './containers/layout/components/UserBox';
import IconMenus from './containers/layout/IconMenu/IconMenu';
import CollectMenu from './containers/layout/Collect/Collect';
import { mapGetters } from 'vuex';
import { getStorageData, setStorageData } from '@/utils/auth';
import { STSTEM_STATE_KEY } from '@/config';
export default {
name: 'App',
......@@ -78,15 +80,14 @@ export default {
},
},
data() {
console.log(this.$route);
const { selectedRoute, showFastLink, showSelected } = this.loadRouteState();
return {
title: '',
selectedRoute: [],
selectedRoute: selectedRoute,
routerDone: false,
isInnerPage: false,
showFastLink: false,
showSelected: false,
showFastLink: showFastLink,
showSelected: showSelected,
};
},
computed: {
......@@ -136,11 +137,37 @@ export default {
this.showFastLink = entity;
this.showSelected = false;
}
this.saveRouteState();
},
selectRouteMenu(routes) {
this.selectedRoute = routes;
this.showSelected = true;
this.showFastLink = false;
this.saveRouteState();
},
saveRouteState() {
const { selectedRoute, showFastLink, showSelected } = this;
setStorageData(
STSTEM_STATE_KEY,
JSON.stringify({
selectedRoute,
showFastLink,
showSelected,
})
);
},
loadRouteState() {
let dataStr = getStorageData(STSTEM_STATE_KEY);
if (dataStr) {
let data = JSON.parse(dataStr);
return data;
} else {
return {
selectedRoute: [],
showFastLink: false,
showSelected: false,
};
}
},
},
};
......
......@@ -56,6 +56,7 @@ service.interceptors.response.use(response => {
if (res.code !== SUCCESS_CODE) {
if (
response.headers &&
response.headers['content-type'] &&
/application\/octet-stream/.test(
response.headers['content-type'].toLowerCase()
)
......
export const TOKEN_KEY = 'dcrym';
export const STSTEM_STATE_KEY = 'dcrym-state';
export const SUCCESS_CODE = 1000;
export const LOGOUT_CODE = -2;
......
......@@ -57,6 +57,7 @@ const createBaseFetch = config => {
if (res.code !== SUCCESS_CODE) {
if (
response.headers &&
response.headers['content-type'] &&
/application\/octet-stream/.test(
response.headers['content-type'].toLowerCase()
)
......
import { TOKEN_KEY } from '@/config/index';
import { TOKEN_KEY, STSTEM_STATE_KEY } from '@/config/index';
const TokenKey = TOKEN_KEY;
export function getToken() {
return sessionStorage.getItem(TokenKey);
return getStorageData(TokenKey);
}
export function setToken(token, expires) {
return sessionStorage.setItem(TokenKey, token);
return setStorageData(TokenKey, token);
}
export function removeToken() {
return sessionStorage.removeItem(TOKEN_KEY);
removeStorageData(TOKEN_KEY);
removeStorageData(STSTEM_STATE_KEY);
return;
}
export function getStorageData(key) {
return sessionStorage.getItem(key);
}
export function setStorageData(key, data) {
return sessionStorage.setItem(key, data);
}
export function removeStorageData(key) {
return sessionStorage.removeItem(key);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment