修改路由

zhangtao
laozt 1 year ago
parent c1f0505fb9
commit bc193f10dc

@ -15,11 +15,15 @@ ENV = 'development'
# VUE_APP_BASE_API = 'http://39.101.188.84:9033'
# VUE_APP_BASE_API = 'http://192.168.0.106:9033'
VUE_APP_BASE_API = 'http://180.108.205.123:13002'
# 政务
# VUE_APP_LOCATION = 'http://2.46.4.197:8090'
# 外网
VUE_APP_LOCATION = 'http://180.108.205.123:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
# 统一登录-内
# VUE_APP_SSO_LOGIN = 'http://2.46.4.197:8090/sso-server/oauth2/sso?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
# 统一登录-外网
VUE_APP_SSO_LOGIN = 'http://180.108.205.123:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
# 退出登录-内网
# VUE_APP_SSO_LOGOUT ='http://2.46.4.197:8090/sso-server/oauth2/logout?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F'
# 退出登录-外网
VUE_APP_SSO_LOGOUT ='http://180.108.205.123:8090/sso-server/oauth2/logout?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true

@ -8,9 +8,16 @@ ENV = 'production'
# VUE_APP_BASE_API = 'http://192.168.0.105:9033'
# VUE_APP_BASE_API = 'http://39.101.188.84:9033'
VUE_APP_BASE_API = 'http://180.108.205.123:13002'
# 统一登录-内网
# VUE_APP_SSO_LOGIN = 'http://2.46.4.197:8090/sso-server/oauth2/sso?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
# 统一登录-外网
VUE_APP_SSO_LOGIN = 'http://180.108.205.123:8090/sso-server/oauth2/sso?aid=17847210&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
VUE_APP_LOCATION = 'http://2.46.4.197:8090/sso-server/oauth2/sso?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F&response_type=code'
# 退出登录-内网
# VUE_APP_SSO_LOGOUT ='http://2.46.4.197:8090/sso-server/oauth2/logout?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F'
# 退出登录-外网
VUE_APP_SSO_LOGOUT ='http://180.108.205.123:8090/sso-server/oauth2/logout?aid=77434376&cbu=http%3A%2F%2F180.108.205.123%3A13001%2F'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true

@ -11,15 +11,22 @@ import ThemePicker from "@/components/ThemePicker";
export default {
name: "App",
destroyed() {
localStorage.removeItem("isGovernmentAffairsNetwork");
},
components: { ThemePicker },
metaInfo() {
return {
title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
titleTemplate: title => {
return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
}
}
}
metaInfo() {
return {
title:
this.$store.state.settings.dynamicTitle &&
this.$store.state.settings.title,
titleTemplate: (title) => {
return title
? `${title} - ${process.env.VUE_APP_TITLE}`
: process.env.VUE_APP_TITLE;
},
};
},
};
</script>
<style scoped>

@ -125,7 +125,7 @@ export default {
"isGovernmentAffairsNetwork"
);
if (isGovernmentAffairsNetwork == "1") {
location.href = process.env.VUE_APP_LOCATION;
location.href = process.env.VUE_APP_SSO_LOGOUT;
} else {
location.href = "/login?redirect=%2Findex";
}

@ -67,6 +67,7 @@
</template>
<script>
import { mapState } from "vuex";
import Cookies from "js-cookie";
export default {
data() {
@ -115,9 +116,9 @@ export default {
let isGovernmentAffairsNetwork = localStorage.getItem(
"isGovernmentAffairsNetwork"
);
// console.log("");
if (isGovernmentAffairsNetwork == "1") {
// console.log("");
location.href = process.env.VUE_APP_LOCATION;
location.href = process.env.VUE_APP_SSO_LOGOUT;
} else {
location.href = "/login?redirect=%2Findex";
}

@ -37,7 +37,7 @@ router.beforeEach((to, from, next) => {
if (store.state.user.new1.indexOf(to.path) != -1) {
refresh = to.path;
}
console.log(to.path);
// console.log(to.path);
//进入添加的第一个路由
next({ path: refresh || res[0].path });
});
@ -71,7 +71,7 @@ router.beforeEach((to, from, next) => {
// console.log(code)
getUseInfo({ code: code })
.then((user) => {
console.log(user, "用户信息");
// console.log(user, "用户信息");
localStorage.setItem("isGovernmentAffairsNetwork", "1");
store
.dispatch("LoginNoCaptcha", {
@ -83,7 +83,7 @@ router.beforeEach((to, from, next) => {
});
})
.catch((err) => {
location.href = process.env.VUE_APP_LOCATION;
location.href = process.env.VUE_APP_SSO_LOGIN;
});
} else {
// console.log('没code')
@ -92,7 +92,7 @@ router.beforeEach((to, from, next) => {
next();
NProgress.done();
} else {
location.href = process.env.VUE_APP_LOCATION;
location.href = process.env.VUE_APP_SSO_LOGIN;
NProgress.done();
}
}

@ -1,7 +1,6 @@
import { login, login2, logout, getInfo, loginNoCaptcha } from "@/api/login";
import { xzTree, listDist } from "@/api/yingji/keyEnterprise";
import { getToken, setToken, removeToken } from "@/utils/auth";
import Cookies from 'js-cookie'
const user = {
state: {
token: getToken(),
@ -16,24 +15,24 @@ const user = {
newRouter: [],
old1: [],
new1: [],
district:[],
district: [],
},
mutations: {
setOld: (state, route) => {
state.old1 = route
state.old1 = route;
},
SET_DISTRICT: (state,data) => {
state.district = data
SET_DISTRICT: (state, data) => {
state.district = data;
},
setNew: (state, route) => {
state.new1 = route
state.new1 = route;
},
getOldRouter: (state, route) => {
state.oldRouter = route
state.oldRouter = route;
},
getNewRouter: (state, route) => {
state.newRouter = route
state.newRouter = route;
},
get_dept: (state, id) => {
state.dept = id;
@ -74,7 +73,7 @@ const user = {
});
});
},
LoginNoCaptcha({commit},userInfo) {
LoginNoCaptcha({ commit }, userInfo) {
const username = userInfo.username.trim();
const password = userInfo.password;
return new Promise((resolve, reject) => {
@ -90,7 +89,7 @@ const user = {
});
},
// 获取行政区划
Getdistrict({ commit }){
Getdistrict({ commit }) {
return new Promise((resolve, reject) => {
xzTree()
.then((res) => {
@ -170,20 +169,20 @@ const user = {
icon1: require("../../assets/images/qiye.png"),
icon2: require("../../assets/images/qiye-change.png"),
},
]
let arr2 = []
let A1 = []
let A2 = []
let toRouter = ''
commit("getOldRouter", arr1)
];
let arr2 = [];
let A1 = [];
let A2 = [];
let toRouter = "";
commit("getOldRouter", arr1);
arr1.forEach((value) => {
A1.push(value.path)
})
commit("setOld", A1)
if (res.roles.indexOf('admin') != -1) {
commit("getNewRouter", arr1)
commit("setNew", A1)
toRouter = arr1
A1.push(value.path);
});
commit("setOld", A1);
if (res.roles.indexOf("admin") != -1) {
commit("getNewRouter", arr1);
commit("setNew", A1);
toRouter = arr1;
} else {
//区级和镇级
if (user.dept.parentId != 0) {
@ -191,15 +190,15 @@ const user = {
return value.path == "/planManage";
});
arr2.forEach((value) => {
A2.push(value.path)
})
commit("getNewRouter", arr2)
commit("setNew", A2)
toRouter = arr2
A2.push(value.path);
});
commit("getNewRouter", arr2);
commit("setNew", A2);
toRouter = arr2;
} else {
commit("getNewRouter", arr1)
commit("setNew", A1)
toRouter = arr1
commit("getNewRouter", arr1);
commit("setNew", A1);
toRouter = arr1;
}
}
@ -221,7 +220,6 @@ const user = {
commit("SET_TOKEN", "");
commit("SET_ROLES", []);
commit("SET_PERMISSIONS", []);
Cookies.remove('token')
removeToken();
resolve();
})
@ -230,15 +228,6 @@ const user = {
});
});
},
// 前端 登出
FedLogOut({ commit }) {
return new Promise((resolve) => {
commit("SET_TOKEN", "");
removeToken();
resolve();
});
},
},
};

@ -15,7 +15,7 @@ axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
// 创建axios实例
const service = axios.create({
// axios中请求配置有baseURL选项表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
baseURL: process.env.VUE_APP_BASE_API,
// 超时
timeout: 100000,
});
@ -97,6 +97,23 @@ service.interceptors.response.use(
return res.data;
}
if (code === 401) {
let isGovernmentAffairsNetwork = localStorage.getItem(
"isGovernmentAffairsNetwork"
);
if (isGovernmentAffairsNetwork == "1") {
//token过期重新登录跳转路由不需要提示
store
.dispatch("LoginNoCaptcha", {
username: "admin",
password: "admin@123Jichuang",
})
.then((res) => {
next("/home");
});
} else {
location.href = "/login?redirect=%2Findex";
}
// if (!isRelogin.show) {
// isRelogin.show = true;
// MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {

Loading…
Cancel
Save