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,11 +30,12 @@ const useUserStore = defineStore( ...@@ -30,11 +30,12 @@ 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 const config = system.appConfig;
34 data.platformGuid = "7f16f697aec111ef8656fa163e60becd"; 35 data.platformGuid = "7f16f697aec111ef8656fa163e60becd";
35 data.userType = 2; 36 data.userType = 2;
36 data.appKey = '672c2c38e4b0cac8732a6106'; 37 // data.appKey = '672c2c38e4b0cac8732a6106';
37 // data.appKey = system.__APP_CONFIG__.appKey; 38 data.appKey = config.appKey ;
38 data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/'; 39 data.validateUri = location.origin == 'http://localhost:9000' ? 'http://localhost:9000/' : location.origin + '/';
39 return getTokenPromise.value = getTokenByCode(data).then((res: any) => { 40 return getTokenPromise.value = getTokenByCode(data).then((res: any) => {
40 getTokenPromise.value = null; 41 getTokenPromise.value = null;
...@@ -56,7 +57,7 @@ const useUserStore = defineStore( ...@@ -56,7 +57,7 @@ const useUserStore = defineStore(
56 currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : ''; 57 currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
57 localStorage.setItem('currentTenantGuid', currentTenantGuid.value); 58 localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
58 let currentTenant = res.data.tenantInfoList?.[0]; 59 let currentTenant = res.data.tenantInfoList?.[0];
59 return getCurrentUserInfo({tenantGuid: currentTenantGuid.value}).then((res: any) => { 60 return getCurrentUserInfo({ tenantGuid: currentTenantGuid.value }).then((res: any) => {
60 console.log(res, 'getCurrentUserInfo'); 61 console.log(res, 'getCurrentUserInfo');
61 if (res.code == '00000') { 62 if (res.code == '00000') {
62 userName.value = res.data.staffName; 63 userName.value = res.data.staffName;
......
...@@ -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!