c6be18f0 by lxs

通过config.js配置appKey

1 parent 49419e23
1 system.__APP_CONFIG__ = { 1 var system = {
2 appKey: '672c2c38e4b0cac8732a6106', 2 appConfig: {
3 appKey: "672c2c38e4b0cac8732a6106",
4 }
3 } 5 }
......
...@@ -30,57 +30,58 @@ const useUserStore = defineStore( ...@@ -30,57 +30,58 @@ const useUserStore = defineStore(
30 const idassLoginUrl = import.meta.env.VITE_IDASS_BASEURL; 30 const idassLoginUrl = import.meta.env.VITE_IDASS_BASEURL;
31 const timer: any = ref(null); 31 const timer: any = ref(null);
32 //获取token. 32 //获取token.
33 function getToken(data, state) { 33 async function getToken(data, state) {
34 data.platformGuid = "7f16f697aec111ef8656fa163e60becd"; 34 const config = system.appConfig;
35 data.userType = 2; 35 data.platformGuid = "7f16f697aec111ef8656fa163e60becd";
36 data.appKey = '672c2c38e4b0cac8732a6106'; 36 data.userType = 2;
37 // data.appKey = system.__APP_CONFIG__.appKey; 37 // data.appKey = '672c2c38e4b0cac8732a6106';
38 data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/'; 38 data.appKey = config.appKey ;
39 return getTokenPromise.value = getTokenByCode(data).then((res: any) => { 39 data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/';
40 getTokenPromise.value = null; 40 return getTokenPromise.value = getTokenByCode(data).then((res: any) => {
41 console.log(res); 41 getTokenPromise.value = null;
42 console.log(res);
43 if (res.code == '00000') {
44 console.log(res.data);
45 isLogin.value = true;
46 localStorage.setItem('code', `${data.code}`);
47 localStorage.setItem('state', state);
48 localStorage.setItem('token', res.data.token || "");
49 token.value = res.data.access_token;
50 localStorage.setItem('refresh_token', res.data.refreshToken || "");
51 const expiresIn = (Date.now() + 1700000) + "";
52 localStorage.setItem('expiresIn', expiresIn);
53 refreshUserToken(false);
54 //获取用户信息
55 account.value = res.data.logonUser
56 userId.value = res.data.userId
57 currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
58 localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
59 let currentTenant = res.data.tenantInfoList?.[0];
60 return getCurrentUserInfo({ tenantGuid: currentTenantGuid.value }).then((res: any) => {
61 console.log(res, 'getCurrentUserInfo');
42 if (res.code == '00000') { 62 if (res.code == '00000') {
43 console.log(res.data); 63 userName.value = res.data.staffName;
44 isLogin.value = true; 64 localStorage.setItem('userName', res.data?.staffName);
45 localStorage.setItem('code', `${data.code}`); 65 localStorage.setItem('userData', JSON.stringify(res.data));
46 localStorage.setItem('state', state); 66 userData.value = localStorage.getItem('userData');
47 localStorage.setItem('token', res.data.token || ""); 67 return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
48 token.value = res.data.access_token; 68 if (info.code == '00000') {
49 localStorage.setItem('refresh_token', res.data.refreshToken || ""); 69 localStorage.setItem('userInfoData', JSON.stringify(info.data));
50 const expiresIn = (Date.now() + 1700000) + ""; 70 userInfoData.value = info.data;
51 localStorage.setItem('expiresIn', expiresIn); 71 // window.location.href = location.origin + info.data[0].menuList[0].path
52 refreshUserToken(false);
53 //获取用户信息
54 account.value = res.data.logonUser
55 userId.value = res.data.userId
56 currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
57 localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
58 let currentTenant = res.data.tenantInfoList?.[0];
59 return getCurrentUserInfo({tenantGuid: currentTenantGuid.value}).then((res: any) => {
60 console.log(res, 'getCurrentUserInfo');
61 if (res.code == '00000') {
62 userName.value = res.data.staffName;
63 localStorage.setItem('userName', res.data?.staffName);
64 localStorage.setItem('userData', JSON.stringify(res.data));
65 userData.value = localStorage.getItem('userData');
66 return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
67 if (info.code == '00000') {
68 localStorage.setItem('userInfoData', JSON.stringify(info.data));
69 userInfoData.value = info.data;
70 // window.location.href = location.origin + info.data[0].menuList[0].path
71 } else {
72 ElMessage.error(info.msg)
73 }
74 })
75 } else { 72 } else {
76 ElMessage.error(res.msg) 73 ElMessage.error(info.msg)
77 } 74 }
78 }) 75 })
79 } else { 76 } else {
80 isLogin.value = false; 77 ElMessage.error(res.msg)
81 // ElMessage.error(res.msg);//授权码被重复使用,不抛出异常。
82 } 78 }
83 }); 79 })
80 } else {
81 isLogin.value = false;
82 // ElMessage.error(res.msg);//授权码被重复使用,不抛出异常。
83 }
84 });
84 } 85 }
85 86
86 async function refreshUserToken(isExec = true) { 87 async function refreshUserToken(isExec = true) {
......
...@@ -275,12 +275,3 @@ declare namespace Menu { ...@@ -275,12 +275,3 @@ declare namespace Menu {
275 children: recordRaw[] 275 children: recordRaw[]
276 } 276 }
277 } 277 }
278
279 // 配置appKey
280 declare global {
281 interface System {
282 __APP_CONFIG__: {
283 appKey: string
284 };
285 }
286 }
......
...@@ -61,6 +61,7 @@ export default ({ mode, command }) => { ...@@ -61,6 +61,7 @@ export default ({ mode, command }) => {
61 build: { 61 build: {
62 outDir: mode === 'product' ? 'dist' : `dist-${mode}`, 62 outDir: mode === 'product' ? 'dist' : `dist-${mode}`,
63 sourcemap: env.VITE_BUILD_SOURCEMAP === 'true', 63 sourcemap: env.VITE_BUILD_SOURCEMAP === 'true',
64 assetsInlineLimit: 0 // 确保config.js不会被内联
64 }, 65 },
65 define: { 66 define: {
66 __SYSTEM_INFO__: JSON.stringify({ 67 __SYSTEM_INFO__: JSON.stringify({
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!