@@ -49,32 +49,30 @@ const userState = reactive({
4949 username : '' ,
5050 token : null ,
5151 expireTime : null ,
52- tenantId : ''
52+ tenantId : '' ,
53+ tenant : [ ]
5354 } ,
5455 needToLogin : false
5556} )
5657
5758const getLoginStatus = ( ) => userState . needToLogin
5859
59- const setNeedToLogin = ( value : boolean , tenantId : any ) => {
60+ const setNeedToLogin = ( value : boolean ) => {
6061 userState . needToLogin = value
6162 if ( ! value ) {
62- const baseUrl = `${ window . location . origin } ${ window . location . pathname } ?type=app&`
63- const id = getBaseInfo ( ) . id
64- const baseTenantId = getBaseInfo ( ) . tenantId
65-
66- // 浏览器Url没有组织id,都默认公共组织,应用id默认为公共组织的应用1
67- if ( ! baseTenantId ) {
68- window . location . href = `${ baseUrl } id=1&tenant=${ tenantId } `
69- }
70-
71- if ( baseTenantId && ! id ) {
72- window . location . href = `${ baseUrl } tenant=${ baseTenantId } `
73- }
74-
75- if ( baseTenantId && id ) {
76- window . location = window . location
63+ const defaultTenantId = userState . userInfo . tenant ?. [ 0 ] ?. id
64+ if ( defaultTenantId ) {
65+ const currentUrl = new URL ( window . location . href )
66+ const currentTenant = getBaseInfo ( ) . tenantId
67+
68+ const filterList = userState . userInfo . tenant . filter ( ( item ) => item . id === currentTenant ) || [ ]
69+ // 只有当tenant值不存在时才更新
70+ if ( ! filterList ?. length ) {
71+ currentUrl . searchParams . set ( 'tenant' , String ( defaultTenantId ) )
72+ window . history . replaceState ( window . history . state , '' , currentUrl . href )
73+ }
7774 }
75+ window . location . reload ( )
7876 }
7977}
8078
@@ -86,7 +84,12 @@ const setUserInfo = (data: any) => {
8684
8785const fetchUserInfo = ( ) => {
8886 // 获取登录用户信息
89- return getMetaApi ( META_SERVICE . Http ) . get ( '/platform-center/api/user/me' )
87+ return getMetaApi ( META_SERVICE . Http ) . get ( '/platform-center/api/user/me' , {
88+ transformRequest : ( data : any , headers : any ) => {
89+ delete headers [ 'x-lowcode-org' ]
90+ return data
91+ }
92+ } )
9093}
9194
9295const setTenantInfo = ( id : any ) => {
0 commit comments