c6be18f0 by lxs

通过config.js配置appKey

1 parent 49419e23
system.__APP_CONFIG__ = {
appKey: '672c2c38e4b0cac8732a6106',
var system = {
appConfig: {
appKey: "672c2c38e4b0cac8732a6106",
}
}
......
......@@ -30,57 +30,58 @@ const useUserStore = defineStore(
const idassLoginUrl = import.meta.env.VITE_IDASS_BASEURL;
const timer: any = ref(null);
//获取token.
function getToken(data, state) {
data.platformGuid = "7f16f697aec111ef8656fa163e60becd";
data.userType = 2;
data.appKey = '672c2c38e4b0cac8732a6106';
// data.appKey = system.__APP_CONFIG__.appKey;
data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/';
return getTokenPromise.value = getTokenByCode(data).then((res: any) => {
getTokenPromise.value = null;
console.log(res);
async function getToken(data, state) {
const config = system.appConfig;
data.platformGuid = "7f16f697aec111ef8656fa163e60becd";
data.userType = 2;
// data.appKey = '672c2c38e4b0cac8732a6106';
data.appKey = config.appKey ;
data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/';
return getTokenPromise.value = getTokenByCode(data).then((res: any) => {
getTokenPromise.value = null;
console.log(res);
if (res.code == '00000') {
console.log(res.data);
isLogin.value = true;
localStorage.setItem('code', `${data.code}`);
localStorage.setItem('state', state);
localStorage.setItem('token', res.data.token || "");
token.value = res.data.access_token;
localStorage.setItem('refresh_token', res.data.refreshToken || "");
const expiresIn = (Date.now() + 1700000) + "";
localStorage.setItem('expiresIn', expiresIn);
refreshUserToken(false);
//获取用户信息
account.value = res.data.logonUser
userId.value = res.data.userId
currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
let currentTenant = res.data.tenantInfoList?.[0];
return getCurrentUserInfo({ tenantGuid: currentTenantGuid.value }).then((res: any) => {
console.log(res, 'getCurrentUserInfo');
if (res.code == '00000') {
console.log(res.data);
isLogin.value = true;
localStorage.setItem('code', `${data.code}`);
localStorage.setItem('state', state);
localStorage.setItem('token', res.data.token || "");
token.value = res.data.access_token;
localStorage.setItem('refresh_token', res.data.refreshToken || "");
const expiresIn = (Date.now() + 1700000) + "";
localStorage.setItem('expiresIn', expiresIn);
refreshUserToken(false);
//获取用户信息
account.value = res.data.logonUser
userId.value = res.data.userId
currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
let currentTenant = res.data.tenantInfoList?.[0];
return getCurrentUserInfo({tenantGuid: currentTenantGuid.value}).then((res: any) => {
console.log(res, 'getCurrentUserInfo');
if (res.code == '00000') {
userName.value = res.data.staffName;
localStorage.setItem('userName', res.data?.staffName);
localStorage.setItem('userData', JSON.stringify(res.data));
userData.value = localStorage.getItem('userData');
return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
if (info.code == '00000') {
localStorage.setItem('userInfoData', JSON.stringify(info.data));
userInfoData.value = info.data;
// window.location.href = location.origin + info.data[0].menuList[0].path
} else {
ElMessage.error(info.msg)
}
})
userName.value = res.data.staffName;
localStorage.setItem('userName', res.data?.staffName);
localStorage.setItem('userData', JSON.stringify(res.data));
userData.value = localStorage.getItem('userData');
return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
if (info.code == '00000') {
localStorage.setItem('userInfoData', JSON.stringify(info.data));
userInfoData.value = info.data;
// window.location.href = location.origin + info.data[0].menuList[0].path
} else {
ElMessage.error(res.msg)
ElMessage.error(info.msg)
}
})
} else {
isLogin.value = false;
// ElMessage.error(res.msg);//授权码被重复使用,不抛出异常。
ElMessage.error(res.msg)
}
});
})
} else {
isLogin.value = false;
// ElMessage.error(res.msg);//授权码被重复使用,不抛出异常。
}
});
}
async function refreshUserToken(isExec = true) {
......
......@@ -275,12 +275,3 @@ declare namespace Menu {
children: recordRaw[]
}
}
// 配置appKey
declare global {
interface System {
__APP_CONFIG__: {
appKey: string
};
}
}
......
......@@ -61,6 +61,7 @@ export default ({ mode, command }) => {
build: {
outDir: mode === 'product' ? 'dist' : `dist-${mode}`,
sourcemap: env.VITE_BUILD_SOURCEMAP === 'true',
assetsInlineLimit: 0 // 确保config.js不会被内联
},
define: {
__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!