6642bd08 by renchao@pashanhoo.com

style:集成cas完成

1 parent 2fca351e
{
"TITLE": "不动产登记系统",
"SERVERAPI": "/bdcdj"
"SERVERAPI": "/bdcdj",
"ip": "http://192.168.2.38"
}
\ No newline at end of file
......
{
"TITLE": "不动产登记系统",
"SERVERAPI": "/bdcdj"
"SERVERAPI": "/bdcdj",
"ip": "http://192.168.2.38"
}
\ No newline at end of file
......
{
"TITLE": "不动产登记系统",
"SERVERAPI": "service-bdcdj-th"
"SERVERAPI": "service-bdcdj-th",
"ip": "http://192.168.2.38"
}
\ No newline at end of file
......
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-05-26 16:57:47
* @LastEditTime: 2023-05-31 15:33:18
-->
<!DOCTYPE html>
<html>
......@@ -18,6 +18,7 @@
</title>
</head>
<script>
window.baseUrl = location.origin || location.protocol + '//' + location.host
window._config = {
// 是否微服务模式,业务系统根据需要读取
cloudEnable: false,
......
......@@ -27,6 +27,7 @@
</div>
</template>
<script>
import axios from 'axios'
import { mapGetters } from 'vuex'
import NoticeBar from '@/components/NoticeBar/index'
import {
......@@ -72,9 +73,20 @@
})
},
logout () {
const url = baseUrl + "/sso-logout?redirect_uri=" + baseUrl + "/bdcdj";
window.open(url, "_self");
sessionStorage.removeItem("navList");
axios.post(this.BASE_API.ip + "/management/logout").then(() => {
localStorage.removeItem('token')
if (window._config.casEnable) {
window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(window.location.href);
} else {
this.$router.push({
path: '/login',
replace: true,
query: {
redirect: router.currentRoute.value.fullPath
}
})
}
})
},
themeChange (val) {
......
/*
* @Description: 项目权限
* @Autor: renchao
* @LastEditTime: 2023-05-30 16:27:26
* @LastEditTime: 2023-05-31 15:55:14
*/
import Vue from 'vue'
import router from './router'
......@@ -36,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
if (!token) {
let ticket = getUrlParam('ticket');
if (ticket) {
axios.get("http://192.168.2.38/management/cas/validate", {
axios.get(Vue.prototype.BASE_API.ip + "/management/cas/validate", {
params: {
'ticket': ticket,
'service': locationUrl
......@@ -44,26 +44,6 @@ router.beforeEach(async (to, from, next) => {
}).then(async (res) => {
localStorage.setItem('token', res.data.content.accessToken)
window.location.href = localStorage.getItem('location')
// cas
if (!hasAddDict) {
store.dispatch('dict/generateDic')
}
if (hasAddRoute) {
next()
// next({ ...to, replace: true })
} else {
const { result: getMenuData } = await getMenuInfo()
const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData)
// 获取用户信息
await store.dispatch('user/getUserInfo')
router.addRoutes([...accessRoutes, { path: '*', redirect: '/404', hidden: true }])
const routeTo = Cookies.get('routerTo')
if (routeTo && routeTo !== '/') {
next({ ...to, replace: true })
} else {
next('/home')
}
}
}).catch(e => {
console.log(e)
......@@ -71,9 +51,31 @@ router.beforeEach(async (to, from, next) => {
} else {
localStorage.setItem("location", window.location.href)
window.location.href = window._config.casBaseURL + '/login?service=' + encodeURIComponent(locationUrl);
permission()
}
} else {
next()
permission()
}
async function permission () {
if (!hasAddDict) {
store.dispatch('dict/generateDic')
}
if (hasAddRoute) {
next()
// next({ ...to, replace: true })
} else {
const { result: getMenuData } = await getMenuInfo()
const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData)
// 获取用户信息
await store.dispatch('user/getUserInfo')
router.addRoutes([...accessRoutes, { path: '*', redirect: '/404', hidden: true }])
const routeTo = Cookies.get('routerTo')
if (routeTo && routeTo !== '/') {
next({ ...to, replace: true })
} else {
next('/home')
}
}
}
} else {
if (!token) {
......
/*
* @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
* @Autor: renchao
* @LastEditTime: 2023-05-26 16:52:25
* @LastEditTime: 2023-05-31 15:30:02
*/
import axios from 'axios'
import { Message } from 'element-ui'
......@@ -9,6 +9,10 @@ import { endLoadingSubCount } from './requestLoading'
// create an axios instance
const service = axios.create({
baseURL:
process.env.NODE_ENV == "development"
? process.env.VUE_APP_BASE_API
: window.baseUrl + "/",
withCredentials: true, //是否允许跨域
headers: {
'Content-Type': 'application/json; charset=utf-8'
......
......@@ -18,7 +18,7 @@ module.exports = {
* Detail: https://cli.vuejs.org/config/#publicpath
*/
// 加载资源的路径
publicPath: '/bdcdj/',
publicPath: '/dj/',
// 设置项目打包生成的文件的存储目录,可以是静态路径也可以是相对路径
outputDir: 'dist',
// 设置放置打包生成的静态资源 (js、css、img、fonts) 的目录
......