@@ -48,15 +48,9 @@ const useUserStore = defineStore('user', {
4848 changeTheme ( data ?. [ 'theme' ] )
4949 this . themeInfo = cloneDeep ( data )
5050 } ,
51- async profile ( loading ?: Ref < boolean > ) {
52- return UserApi . getUserProfile ( loading ) . then ( ( ok ) => {
53- this . userInfo = ok . data
54- useLocalStorage < string > ( localeConfigKey , 'en-US' ) . value =
55- ok ?. data ?. language || this . getLanguage ( )
56- const theme = useThemeStore ( )
57- theme . setTheme ( )
58- return this . asyncGetProfile ( )
59- } )
51+ setWorkspaceId ( workspace_id : string ) {
52+ this . workspace_id = workspace_id
53+ localStorage . setItem ( 'workspace_id' , workspace_id )
6054 } ,
6155 getWorkspaceId ( ) : string | null {
6256 if ( this . workspace_id ) {
@@ -68,28 +62,7 @@ const useUserStore = defineStore('user', {
6862 }
6963 return workspace_id
7064 } ,
71- async asyncGetProfile ( ) {
72- return new Promise ( ( resolve , reject ) => {
73- UserApi . getProfile ( )
74- . then ( async ( ok ) => {
75- // this.version = ok.data?.version || '-'
76- this . license_is_valid = ok . data . license_is_valid
77- this . edition = ok . data . edition
7865
79- if ( this . isEE ( ) || this . isPE ( ) ) {
80- await this . theme ( )
81- } else {
82- this . themeInfo = {
83- ...defaultPlatformSetting ,
84- }
85- }
86- resolve ( ok )
87- } )
88- . catch ( ( error ) => {
89- reject ( error )
90- } )
91- } )
92- } ,
9366 getPermissions ( ) {
9467 if ( this . userInfo ) {
9568 if ( this . isEE ( ) ) {
@@ -121,16 +94,7 @@ const useUserStore = defineStore('user', {
12194 return [ ]
12295 }
12396 } ,
124- async theme ( loading ?: Ref < boolean > ) {
125- return await ThemeApi . getThemeInfo ( loading ) . then ( ( ok ) => {
126- this . setTheme ( ok . data )
127- // window.document.title = this.themeInfo['title'] || 'MaxKB'
128- // const link = document.querySelector('link[rel="icon"]') as any
129- // if (link) {
130- // link['href'] = this.themeInfo['icon'] || '/favicon.ico'
131- // }
132- } )
133- } ,
97+
13498 showXpack ( ) {
13599 return this . edition != 'CE'
136100 } ,
@@ -154,7 +118,49 @@ const useUserStore = defineStore('user', {
154118 const login = useLoginStore ( )
155119 login . userAccessToken = token || ''
156120 } ,
121+ async theme ( loading ?: Ref < boolean > ) {
122+ return await ThemeApi . getThemeInfo ( loading ) . then ( ( ok ) => {
123+ this . setTheme ( ok . data )
124+ // window.document.title = this.themeInfo['title'] || 'MaxKB'
125+ // const link = document.querySelector('link[rel="icon"]') as any
126+ // if (link) {
127+ // link['href'] = this.themeInfo['icon'] || '/favicon.ico'
128+ // }
129+ } )
130+ } ,
131+ async profile ( loading ?: Ref < boolean > ) {
132+ return UserApi . getUserProfile ( loading ) . then ( ( ok ) => {
133+ this . userInfo = ok . data
134+ useLocalStorage < string > ( localeConfigKey , 'en-US' ) . value =
135+ ok ?. data ?. language || this . getLanguage ( )
136+ const theme = useThemeStore ( )
137+ theme . setTheme ( )
138+ return this . asyncGetProfile ( )
139+ } )
140+ } ,
157141
142+ async asyncGetProfile ( ) {
143+ return new Promise ( ( resolve , reject ) => {
144+ UserApi . getProfile ( )
145+ . then ( async ( ok ) => {
146+ // this.version = ok.data?.version || '-'
147+ this . license_is_valid = ok . data . license_is_valid
148+ this . edition = ok . data . edition
149+
150+ if ( this . isEE ( ) || this . isPE ( ) ) {
151+ await this . theme ( )
152+ } else {
153+ this . themeInfo = {
154+ ...defaultPlatformSetting ,
155+ }
156+ }
157+ resolve ( ok )
158+ } )
159+ . catch ( ( error ) => {
160+ reject ( error )
161+ } )
162+ } )
163+ } ,
158164 async postUserLanguage ( lang : string , loading ?: Ref < boolean > ) {
159165 return new Promise ( ( resolve , reject ) => {
160166 LoginApi . postLanguage ( { language : lang } , loading )
0 commit comments