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 { useLocalStorage } from '@vueuse/core'
6+ import { useLocalStorage } from '@vueuse/core'
77
8- import { localeConfigKey , getBrowserLang } from '@/locales/index'
8+ import { localeConfigKey , getBrowserLang } from '@/locales/index'
99import useThemeStore from './theme'
10- import { defaultPlatformSetting } from '@/utils/theme'
10+ import { defaultPlatformSetting } from '@/utils/theme'
1111import useLoginStore from './login'
1212
1313export interface userStateTypes {
@@ -73,6 +73,9 @@ const useUserStore = defineStore('user', {
7373 }
7474 } ,
7575
76+ is_admin ( ) {
77+ return this . userInfo ?. role . includes ( 'ADMIN' )
78+ } ,
7679 showXpack ( ) {
7780 return this . edition != 'CE'
7881 } ,
@@ -91,7 +94,7 @@ const useUserStore = defineStore('user', {
9194 isEE ( ) {
9295 return this . edition == 'EE' && this . license_is_valid
9396 } ,
94- getEditionName ( ) {
97+ getEditionName ( ) { 画
9598 return this . edition
9699 } ,
97100 async profile ( loading ?: Ref < boolean > ) {
@@ -100,7 +103,7 @@ const useUserStore = defineStore('user', {
100103 const workspace_list =
101104 ok . data . workspace_list && ok . data . workspace_list . length > 0
102105 ? ok . data . workspace_list
103- : [ { id : 'default' , name : 'default' } ]
106+ : [ { id : 'default' , name : 'default' } ]
104107 const workspace_id = this . getWorkspaceId ( )
105108 if ( ! workspace_id || ! workspace_list . some ( ( w ) => w . id == workspace_id ) ) {
106109 this . setWorkspaceId ( workspace_list [ 0 ] . id )
@@ -140,7 +143,7 @@ const useUserStore = defineStore('user', {
140143 } ,
141144 async postUserLanguage ( lang : string , loading ?: Ref < boolean > ) {
142145 return new Promise ( ( resolve , reject ) => {
143- LoginApi . postLanguage ( { language : lang } , loading )
146+ LoginApi . postLanguage ( { language : lang } , loading )
144147 . then ( async ( ok ) => {
145148 useLocalStorage ( localeConfigKey , 'en-US' ) . value = lang
146149 window . location . reload ( )
0 commit comments