夏滨修改登录
This commit is contained in:
parent
794918ba09
commit
628eed1b40
@ -1,7 +1,6 @@
|
||||
import actions from './actions';
|
||||
|
||||
const { VITE_APP_SUB_OS, VITE_APP_SUB_OA, VITE_APP_SUB_ADMIN, VITE_APP_SUB_GAS, VITE_APP_SUB_GSS, VITE_APP_SUB_GSR, VITE_APP_VIST_URL } = import.meta.env;
|
||||
|
||||
export const leftApps = [
|
||||
{
|
||||
name: 'sub-operation-service',
|
||||
@ -37,7 +36,11 @@ export const rightApps = [
|
||||
{
|
||||
name: 'sub-government-affairs-service',
|
||||
entry: VITE_APP_SUB_GAS,
|
||||
activeRule: '/sub-government-affairs-service',
|
||||
activeRule:
|
||||
'http://localhost:9528/sub-government-affairs-service/home?source=main&token=' +
|
||||
JSON.parse(localStorage.getItem('daimp-front-main_userStore'))?.token +
|
||||
'&userInfo=' +
|
||||
JSON.parse(localStorage.getItem('daimp-front-main_userStore'))?.userInfo,
|
||||
title: '政务服务',
|
||||
icon: 'images/platform/icon-home.png',
|
||||
},
|
||||
@ -85,7 +88,11 @@ export const defaultApps = [
|
||||
{
|
||||
name: 'sub-government-affairs-service',
|
||||
entry: VITE_APP_SUB_GAS,
|
||||
activeRule: '/sub-government-affairs-service',
|
||||
activeRule:
|
||||
'http://localhost:9528/sub-government-affairs-service/home?source=main&token=' +
|
||||
JSON.parse(localStorage.getItem('daimp-front-main_userStore'))?.token +
|
||||
'&userInfo=' +
|
||||
JSON.parse(localStorage.getItem('daimp-front-main_userStore'))?.userInfo,
|
||||
title: '政务服务',
|
||||
icon: 'images/platform/icon-home.png',
|
||||
},
|
||||
|
@ -12,15 +12,17 @@
|
||||
</template>
|
||||
|
||||
<script setup name="app">
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { computed, onMounted, onBeforeMount } from 'vue';
|
||||
import { useSettingStore } from '@/store/modules/setting';
|
||||
// 配置element中文
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
onMounted(() => {
|
||||
if (localStorage.getItem('source')) {
|
||||
if (route.query.source) {
|
||||
localStorage.setItem('source', route.query.source);
|
||||
router.push('/sub-government-affairs-service/home');
|
||||
} else {
|
||||
if (localStorage.getItem('daimp-front-main_userStore') && JSON.parse(localStorage.getItem('daimp-front-main_userStore')).token) {
|
||||
|
@ -55,6 +55,8 @@ const logOut = async () => {
|
||||
});
|
||||
localStorage.removeItem('daimp-front-main_userStore');
|
||||
} else {
|
||||
localStorage.removeItem('daimp-front-main_userStore');
|
||||
window.location.href = 'http://192.168.18.99/platform';
|
||||
console.log('退出到门户页');
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import Cookies from 'js-cookie';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { login, GetCodeImg, GetInfo } from '@/apis/login';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { isEmpty, encode, decode } from '@/utils';
|
||||
const router = useRouter();
|
||||
|
||||
let codeUrl = ref('');
|
||||
@ -81,7 +82,6 @@ const goHome = async () => {
|
||||
const res = await login(loginForms.value);
|
||||
UserStore.setToken(res.data.access_token);
|
||||
const userInfo = await GetInfo();
|
||||
console.log(userInfo);
|
||||
UserStore.setUserInfo(userInfo.user);
|
||||
UserStore.setOrgList(userInfo.roles);
|
||||
if (userInfo.code == 200) {
|
||||
|
@ -22,6 +22,9 @@ export const useUserStore = defineStore({
|
||||
setUserInfo(userInfo) {
|
||||
this.userInfo = encode(JSON.stringify(userInfo), true);
|
||||
},
|
||||
// setUserInfo(userInfo) {
|
||||
// this.userInfo = userInfo;
|
||||
// },
|
||||
getUserInfo() {
|
||||
return !isEmpty(this.userInfo) ? JSON.parse(decode(this.userInfo, true)) : {};
|
||||
},
|
||||
|
@ -10,6 +10,8 @@ import { ElNotification } from 'element-plus';
|
||||
import router from '@/router';
|
||||
import { isEmpty } from '@/utils';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { useRoute } from 'vue-router';
|
||||
const route = useRoute();
|
||||
|
||||
const { VITE_APP_BASE_API, VITE_APP_UPLOAD_API, VITE_APP_DICDATA_API } = import.meta.env;
|
||||
|
||||
@ -56,8 +58,12 @@ publicAxios.interceptors.request.use(async (config) => {
|
||||
}
|
||||
}
|
||||
console.log('312321313');
|
||||
if (localStorage.getItem('source')) {
|
||||
config.headers['source'] = localStorage.getItem('source');
|
||||
} else {
|
||||
config.headers['source'] = 'gov-pc';
|
||||
}
|
||||
|
||||
config.headers['source'] = 'gov-pc';
|
||||
if (UserStore.hasToken()) {
|
||||
config.headers['authorization'] = config.headers['authorization'] ?? UserStore.token;
|
||||
config.headers['cache-control'] = 'no-cache';
|
||||
|
@ -11,17 +11,28 @@ import 'nprogress/nprogress.css';
|
||||
import router from '@/router';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { usePermissionStore } from '@/store/modules/permission';
|
||||
|
||||
NProgress.configure({ showSpinner: false });
|
||||
import { useRoute } from 'vue-router';
|
||||
import { isEmpty, encode, decode } from '@/utils';
|
||||
|
||||
const { VITE_APP_MIAN_URL } = import.meta.env;
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const userStore = useUserStore();
|
||||
if (!userStore.token) {
|
||||
userStore.setToken(to.query.token);
|
||||
userStore.token = to.query.token;
|
||||
}
|
||||
if (!userStore.userInfo) {
|
||||
userStore.setToken(JSON.parse(decode(to.query.userInfo, true)));
|
||||
}
|
||||
// debugger;
|
||||
NProgress.start();
|
||||
// NProgress.done();
|
||||
if (typeof to.meta.title === 'string') {
|
||||
document.title = '政务服务 | ' + to.meta.title;
|
||||
}
|
||||
|
||||
const userStore = useUserStore();
|
||||
const hasToken = userStore.hasToken();
|
||||
console.log('sub', hasToken);
|
||||
if (hasToken) {
|
||||
|
@ -18,6 +18,7 @@ import { useSettingStore } from '@/store/modules/setting';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import { useRouter } from 'vue-router';
|
||||
const router = useRouter();
|
||||
|
||||
onMounted(() => {
|
||||
if (localStorage.getItem('source')) {
|
||||
router.push('/sub-operation-service/dashboard/home');
|
||||
|
@ -153,6 +153,8 @@ const loginOut = () => {
|
||||
message: '退出登录成功!',
|
||||
});
|
||||
} else {
|
||||
localStorage.removeItem('daimp-front-main_userStore');
|
||||
window.location.href = 'http://192.168.18.99/platform';
|
||||
console.log('退出到门户页');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user