1- import { defineStore } from 'pinia'
2- import { type Ref } from 'vue'
3- import type { User } from '@/api/type/user'
1+ import { defineStore } from 'pinia'
2+ import { type Ref } from 'vue'
3+ import type { User } from '@/api/type/user'
44import UserApi from '@/api/user/user'
55import LoginApi from '@/api/user/login'
6- import { cloneDeep } from 'lodash'
6+ import { cloneDeep } from 'lodash'
77import ThemeApi from '@/api/systemSettings/theme'
88// import { defaultPlatformSetting } from '@/utils/theme'
9- import { useLocalStorage } from '@vueuse/core'
10- import { localeConfigKey , getBrowserLang } from '@/locales/index'
9+ import { useLocalStorage } from '@vueuse/core'
10+ import { localeConfigKey , getBrowserLang } from '@/locales/index'
1111import useThemeStore from './theme'
12- import { useElementPlusTheme } from " use-element-plus-theme" ;
13- import { defaultPlatformSetting } from " @/utils/theme.ts" ;
12+ import { useElementPlusTheme } from ' use-element-plus-theme'
13+ import { defaultPlatformSetting } from ' @/utils/theme.ts'
1414
1515export interface userStateTypes {
1616 userType : number // 1 系统操作者 2 对话用户
1717 userInfo : User | null
1818 version ?: string
19- XPACK_LICENSE_IS_VALID : true
20- isXPack : true
19+ license_is_valid : boolean
20+ edition : 'CE' | 'PE' | 'EE'
2121 themeInfo : any
2222 token : any
2323}
@@ -27,10 +27,10 @@ const useLoginStore = defineStore('user', {
2727 userType : 1 , // 1 系统操作者 2 对话用户
2828 userInfo : null ,
2929 version : '' ,
30- XPACK_LICENSE_IS_VALID : false ,
31- isXPack : false ,
30+ license_is_valid : false ,
31+ edition : 'CE' ,
3232 themeInfo : null ,
33- token : ''
33+ token : '' ,
3434 } ) ,
3535 actions : {
3636 getLanguage ( ) {
@@ -42,7 +42,7 @@ const useLoginStore = defineStore('user', {
4242 return ! this . themeInfo ?. theme || this . themeInfo ?. theme === '#3370FF'
4343 } ,
4444 setTheme ( data : any ) {
45- const { changeTheme} = useElementPlusTheme ( this . themeInfo ?. theme )
45+ const { changeTheme } = useElementPlusTheme ( this . themeInfo ?. theme )
4646 changeTheme ( data ?. [ 'theme' ] )
4747 this . themeInfo = cloneDeep ( data )
4848 } ,
@@ -61,14 +61,15 @@ const useLoginStore = defineStore('user', {
6161 UserApi . getProfile ( )
6262 . then ( async ( ok ) => {
6363 // this.version = ok.data?.version || '-'
64- this . isXPack = true
65- this . XPACK_LICENSE_IS_VALID = true
64+ console . log ( ok )
65+ this . license_is_valid = ok . data . license_is_valid
66+ this . edition = ok . data . edition
6667
67- if ( this . isEnterprise ( ) ) {
68- // await this.theme()
68+ if ( this . isEE ( ) || this . isPE ( ) ) {
69+ // await this.theme()
6970 } else {
7071 this . themeInfo = {
71- ...defaultPlatformSetting
72+ ...defaultPlatformSetting ,
7273 }
7374 }
7475 resolve ( ok )
@@ -106,22 +107,28 @@ const useLoginStore = defineStore('user', {
106107 } )
107108 } ,
108109 showXpack ( ) {
109- return this . isXPack
110+ return this . edition != 'CE'
111+ } ,
112+ isEnterprise ( ) {
113+ return this . edition != 'CE' && ! this . license_is_valid
110114 } ,
111-
112115 isExpire ( ) {
113- return this . isXPack && ! this . XPACK_LICENSE_IS_VALID
116+ return this . edition != 'CE' && ! this . license_is_valid
114117 } ,
115- isEnterprise ( ) {
116- return this . isXPack && this . XPACK_LICENSE_IS_VALID
118+ isCE ( ) {
119+ return this . edition == 'CE' && this . license_is_valid
120+ } ,
121+ isPE ( ) {
122+ return this . edition == 'PE' && this . license_is_valid
123+ } ,
124+ isEE ( ) {
125+ return this . edition == 'EE' && this . license_is_valid
117126 } ,
118-
119127 // changeUserType(num: number, token?: string) {
120128 // this.userType = num
121129 // this.userAccessToken = token
122130 // },
123131
124-
125132 async dingCallback ( code : string ) {
126133 return LoginApi . getDingCallback ( code ) . then ( ( ok ) => {
127134 this . token = ok . data
@@ -184,7 +191,7 @@ const useLoginStore = defineStore('user', {
184191 reject ( error )
185192 } )
186193 } )
187- }
194+ } ,
188195 } ,
189196} )
190197
0 commit comments