43 lines
944 B
Vue
43 lines
944 B
Vue
|
|
<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>
|