Commit e205bd5b authored by sheng du's avatar sheng du
Browse files

缓存登陆账号

parent e01e0a41
......@@ -63,6 +63,9 @@ export default {
})
.then(() => {
this.$store.dispatch("user/setUserAuth", []);
localStorage.removeItem("userInfo");
localStorage.removeItem("userAuth");
this.$router.replace("/login");
})
.catch(() => {});
......
......@@ -98,6 +98,12 @@ const router = new VueRouter({
});
router.beforeEach((to, from, next) => {
let storeAuth = localStorage.getItem("userAuth");
let storeUserInfo = localStorage.getItem("userInfo");
store.dispatch("user/setUserAuth", JSON.parse(storeAuth));
store.dispatch("user/setUserInfo", JSON.parse(storeUserInfo));
let userAuth = store.state.user.userAuth;
// console.log(to, userAuth);
if (to.meta.keepAlive) {
......
......@@ -127,6 +127,14 @@ export default {
name: "刘云",
type: 1,
});
localStorage.setItem("userAuth", JSON.stringify(this.testAuthUser));
localStorage.setItem(
"userInfo",
JSON.stringify({
name: "刘云",
type: 1,
})
);
this.$message.success("登陆成功");
this.$nextTick(() => {
this.$router.replace({
......@@ -141,6 +149,18 @@ export default {
name: "重庆伟星新型建材有限公司",
type: 2,
});
localStorage.setItem(
"userAuth",
JSON.stringify(this.testAuthEnterprise)
);
localStorage.setItem(
"userInfo",
JSON.stringify({
name: "重庆伟星新型建材有限公司",
type: 2,
})
);
this.$message.success("登陆成功");
this.$nextTick(() => {
this.$router.replace({
......
......@@ -2,7 +2,7 @@ const path = require("path");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = {
publicPath: "./",
publicPath: "/admin/",
lintOnSave: process.env.NODE_ENV === "development",
productionSourceMap: false,
devServer: {
......
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