lcw
This commit is contained in:
15
src/App.vue
15
src/App.vue
@ -2,13 +2,17 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component }" v-if="isRouterAlive">
|
||||
<keep-alive :include="store.getters.keepLiiveRoute">
|
||||
<Component :is="Component"></Component>
|
||||
<Watermark :text="content" :color="'rgba(0, 0, 0, .15)'">
|
||||
<Component :is="Component"></Component>
|
||||
</Watermark>
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, nextTick, provide, onMounted } from "vue";
|
||||
import { useStore } from "vuex";
|
||||
import Watermark from "@/components/Watermark.vue";
|
||||
import { timeValidate } from "@/utils/tools.js";
|
||||
import { getItem } from "@/utils/storage";
|
||||
import { qcckPost, qcckGet, qcckPut, qcckDelete } from "@/api/qcckApi.js";
|
||||
import { generateNewStyle, writeNewStyle } from "@/utils/theme";
|
||||
@ -26,9 +30,16 @@ const reload = () => {
|
||||
provide("reload", reload);
|
||||
onMounted(() => {
|
||||
let dept = getItem("deptId");
|
||||
frashJs()
|
||||
document.title = "林芝";
|
||||
});
|
||||
|
||||
const content=ref([])
|
||||
const frashJs = () => {
|
||||
const sfzh= getItem("idEntityCard")
|
||||
const userName= getItem("USERNAME")
|
||||
const time = timeValidate()
|
||||
content.value=[userName,sfzh,time,"林芝市环林卡口综合管理","禁止泄露公民个人信息和警务工作秘密"]
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import "./styles/index.scss";
|
||||
|
||||
@ -599,8 +599,8 @@ export const selectUserDeptPage = (data = {}) => {
|
||||
///unifiedLogin
|
||||
export const unifiedLogin = (data) => {
|
||||
return request({
|
||||
url: api + `/unifiedLogin`,
|
||||
url: api + `/ssoLogin`,
|
||||
method: "POST",
|
||||
data
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
removeAllItem
|
||||
} from "@/utils/storage";
|
||||
// 白名单
|
||||
const whiteList = ['/login','/','/StationLevel', '/oatuh_login','/editPassword', '/404', '/401']
|
||||
const whiteList = ['/login', '/', '/StationLevel', '/oatuh_login', '/editPassword', '/404', '/401']
|
||||
/**
|
||||
* 路由前置守卫
|
||||
* to 去哪里
|
||||
@ -14,42 +14,43 @@ const whiteList = ['/login','/','/StationLevel', '/oatuh_login','/editPassword',
|
||||
* next 往下走
|
||||
*/
|
||||
let onRun = true;
|
||||
// router.beforeEach(async (to, from, next) => {
|
||||
// // 存在 token ,进入主页
|
||||
// // if (store.state.user.token) {
|
||||
// // 快捷访问
|
||||
// if (store.getters.token) {
|
||||
// // 判断用户资料是否获取
|
||||
// // 若不存在用户信息,则需要获取用户信息
|
||||
// // 触发获取用户信息的 action,并获取用户当前权限
|
||||
// await store.commit('permission/setRouteReady', true)
|
||||
// // 添加完动态路由之后,需要在进行一次主动跳转
|
||||
// const afterMenuList = await getItem('menusPermission');
|
||||
// // 处理用户权限,筛选出需要添加的权限
|
||||
// if (store.state.permission.routes == 0) {
|
||||
// const filterRoutes = await store.dispatch('permission/filterRoutes', afterMenuList)
|
||||
// filterRoutes.forEach(item => {
|
||||
// router.addRoute(item)
|
||||
// })
|
||||
// next({
|
||||
// ...to,
|
||||
// replace: true
|
||||
// })
|
||||
// } else {
|
||||
// next()
|
||||
// }
|
||||
// // 利用 addRoute 循环添加
|
||||
// } else {
|
||||
// const isOatuh = getItem('isOatuh')
|
||||
// // 没有token的情况下,可以进入白名单
|
||||
// if (whiteList.indexOf(to.path) > -1) {
|
||||
// next()
|
||||
// } else {
|
||||
// if (isOatuh) {
|
||||
// next('/oatuh_login')
|
||||
// } else {
|
||||
// next('/login')
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
// 存在 token ,进入主页
|
||||
// if (store.state.user.token) {
|
||||
// 快捷访问
|
||||
if (store.getters.token) {
|
||||
// 判断用户资料是否获取
|
||||
// 若不存在用户信息,则需要获取用户信息
|
||||
// 触发获取用户信息的 action,并获取用户当前权限
|
||||
await store.commit('permission/setRouteReady', true)
|
||||
// 添加完动态路由之后,需要在进行一次主动跳转
|
||||
const afterMenuList = await getItem('menusPermission');
|
||||
// 处理用户权限,筛选出需要添加的权限
|
||||
if (store.state.permission.routes == 0) {
|
||||
const filterRoutes = await store.dispatch('permission/filterRoutes', afterMenuList)
|
||||
filterRoutes.forEach(item => {
|
||||
router.addRoute(item)
|
||||
})
|
||||
next({
|
||||
...to,
|
||||
replace: true
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
// 利用 addRoute 循环添加
|
||||
} else {
|
||||
const isOatuh = getItem('isOatuh')
|
||||
// 没有token的情况下,可以进入白名单
|
||||
if (whiteList.indexOf(to.path) > -1) {
|
||||
next()
|
||||
} else {
|
||||
if (isOatuh) {
|
||||
const idEntityCard = getItem('idEntityCard')
|
||||
next(`/oatuh_login?token=${Base64.encode(idEntityCard)}`)
|
||||
} else {
|
||||
next('/login')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -21,6 +21,11 @@ export const privateRoutes = [];
|
||||
* 公开路由表
|
||||
*/
|
||||
export const publicRoutes = [
|
||||
{
|
||||
path: "/oatuh_login",
|
||||
name: "oatuh_login",
|
||||
component: () => import("@/views/login/oatuh_login")
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
name: "login",
|
||||
|
||||
@ -132,44 +132,37 @@ export default {
|
||||
*单点登录
|
||||
*/
|
||||
oatuhLogin(ctx, userInfo) {
|
||||
const {
|
||||
token,
|
||||
systemId,
|
||||
} = userInfo;
|
||||
const { token, systemId, } = userInfo;
|
||||
return new Promise((resolve, reject) => {
|
||||
unifiedLogin({
|
||||
token,
|
||||
systemId,
|
||||
unifiedLogin({ token, systemId }).then((data) => {
|
||||
if (data.deptList.length === 1) {
|
||||
this.commit("user/setToken", data.jwtToken);
|
||||
|
||||
this.commit("user/setDeptId", data.deptList);
|
||||
this.commit("user/setUserName", data.userName);
|
||||
setItem("USERNAME", data.userName);
|
||||
setItem('fzUserId', data.fzUserId)
|
||||
setItem("SFRH", data.sfrh);
|
||||
setItem("USERID", data.userId);
|
||||
setItem("PermissionsInfo", data.permissionsInfo);
|
||||
this.commit("user/setMenuList", data.menuList);
|
||||
setItem("menusPermission", data.menuCodeSet);
|
||||
setItem('isOatuh', 1)
|
||||
setItem("idEntityCard", data.idEntityCard);
|
||||
this.commit("user/setUserInfo", {
|
||||
token: data.jwtToken,
|
||||
permission: {
|
||||
buttonPermission: ["removeTest", "viewTest"],
|
||||
menus: data.menuCodeSet
|
||||
},
|
||||
menuList: data.menuList,
|
||||
deptList: data.deptList
|
||||
});
|
||||
}
|
||||
// 保存登录时间
|
||||
setTimeStamp();
|
||||
resolve(data);
|
||||
})
|
||||
.then((data) => {
|
||||
|
||||
if (data.deptList.length === 1) {
|
||||
this.commit("user/setToken", data.jwtToken);
|
||||
this.commit("user/setDeptId", data.deptList);
|
||||
this.commit("user/setUserName", data.userName);
|
||||
setItem("USERNAME", data.userName);
|
||||
|
||||
setItem("SFRH", data.sfrh);
|
||||
setItem("USERID", data.userId);
|
||||
setItem("PermissionsInfo", data.permissionsInfo);
|
||||
this.commit("user/setMenuList", data.menuList);
|
||||
setItem("menusPermission", data.menuCodeSet);
|
||||
setItem('isOatuh', 1)
|
||||
setItem("idEntityCard", data.idEntityCard);
|
||||
this.commit("user/setUserInfo", {
|
||||
token: data.jwtToken,
|
||||
permission: {
|
||||
buttonPermission: ["removeTest", "viewTest"],
|
||||
menus: data.menuCodeSet
|
||||
},
|
||||
menuList: data.menuList,
|
||||
deptList: data.deptList
|
||||
});
|
||||
}
|
||||
// 保存登录时间
|
||||
setTimeStamp();
|
||||
resolve(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
42
src/views/login/oatuh_login.vue
Normal file
42
src/views/login/oatuh_login.vue
Normal file
@ -0,0 +1,42 @@
|
||||
<template></template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useStore } from "vuex";
|
||||
import { useRouter } from "vue-router";
|
||||
import {
|
||||
setItem
|
||||
} from "@/utils/storage";
|
||||
const loginDialog = ref(false);
|
||||
const deptList = ref([]);
|
||||
const store = useStore();
|
||||
function redirectAuth() {
|
||||
|
||||
let token = location.hash.slice(20) || null;
|
||||
if (token != null) {
|
||||
token = token.replace(/\ +/g, "");
|
||||
setItem("SSOTOKEN", token)
|
||||
handleLogin({ token: token});
|
||||
} else {
|
||||
window.location.href = `http://155.240.22.102:40992`;
|
||||
}
|
||||
}
|
||||
|
||||
const handleLogin = (e) => {
|
||||
store.dispatch("user/oatuhLogin", e).then((res) => {
|
||||
// 登录后操作
|
||||
if (res.deptList.length === 1) {
|
||||
window.location.hash = "/";
|
||||
} else {
|
||||
deptList.value = [...res.deptList];
|
||||
loginDialog.value = true;
|
||||
authorization.value = res.jwtToken;
|
||||
}
|
||||
});
|
||||
};
|
||||
onMounted(() => {
|
||||
redirectAuth();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
@ -4,8 +4,8 @@ function resolve(dir) {
|
||||
return path.join(__dirname, dir);
|
||||
}
|
||||
|
||||
// const serverHost = "http://192.192.8.9:8006";
|
||||
const serverHost = "http://192.168.1.32:8066"
|
||||
const serverHost = "http://192.168.8.15:8006"
|
||||
// const serverHost = "http://192.168.1.32:8066"
|
||||
// const serverHost = "http://127.0.0.1:8006"
|
||||
module.exports = {
|
||||
publicPath: "./",
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
ylth/static/css/app.4456a200.css
Normal file
1
ylth/static/css/app.4456a200.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/css/chunk-4f97dd65.95053c02.css
Normal file
1
ylth/static/css/chunk-4f97dd65.95053c02.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/js/app.98a36ec2.js
Normal file
1
ylth/static/js/app.98a36ec2.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/js/chunk-2cab96f2.e49b2b39.js
Normal file
1
ylth/static/js/chunk-2cab96f2.e49b2b39.js
Normal file
File diff suppressed because one or more lines are too long
1
ylth/static/js/chunk-2d22bd3e.c9c7cbcf.js
Normal file
1
ylth/static/js/chunk-2d22bd3e.c9c7cbcf.js
Normal file
@ -0,0 +1 @@
|
||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d22bd3e"],{f141:function(t,e,n){"use strict";n.r(e);var o=n("7a23"),c=n("5502"),a=n("5d2d"),u={__name:"oatuh_login",setup(t){const e=Object(o["ref"])(!1),n=Object(o["ref"])([]),u=Object(c["b"])();function i(){let t=location.hash.slice(20)||null;null!=t?(t=t.replace(/\ +/g,""),Object(a["c"])("SSOTOKEN",t),l({token:t})):window.location.href="http://155.240.22.102:40992"}const l=t=>{u.dispatch("user/oatuhLogin",t).then(t=>{1===t.deptList.length?window.location.hash="/":(n.value=[...t.deptList],e.value=!0,authorization.value=t.jwtToken)})};return Object(o["onMounted"])(()=>{i()}),(t,e)=>null}};const i=u;e["default"]=i}}]);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/js/chunk-4f97dd65.da75633d.js
Normal file
1
ylth/static/js/chunk-4f97dd65.da75633d.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/js/chunk-68f1b5e1.fcb039ca.js
Normal file
1
ylth/static/js/chunk-68f1b5e1.fcb039ca.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ylth/static/js/chunk-e7d361ca.009aa460.js
Normal file
1
ylth/static/js/chunk-e7d361ca.009aa460.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user