fix: 修复权限判断错误

This commit is contained in:
wangdan-fit2cloud 2024-07-18 16:17:55 +08:00
parent d8f9622931
commit bd976a7368
2 changed files with 19 additions and 10 deletions

View File

@ -20,7 +20,7 @@
<span class="label">过期时间</span>
<span
>{{ licenseInfo?.expired || '-' }}
<span class="danger" v-if="fromNowDate(licenseInfo?.expired)"
<span class="danger" v-if="licenseInfo?.expired && fromNowDate(licenseInfo?.expired)"
>{{ fromNowDate(licenseInfo?.expired) }}</span
></span
>
@ -28,11 +28,14 @@
<div class="flex">
<span class="label">版本</span
><span>{{
licenseInfo?.edition ? EditionType[licenseInfo.edition as keyof typeof EditionType] : '-'
licenseInfo?.edition
? EditionType[licenseInfo.edition as keyof typeof EditionType]
: '社区版'
}}</span>
</div>
<div class="flex">
<span class="label">版本号</span><span>{{ licenseInfo?.licenseVersion || '-' }}</span>
<span class="label">版本号</span
><span>{{ licenseInfo?.licenseVersion || user.version }}</span>
</div>
<div class="flex">
<span class="label">序列号</span><span>{{ licenseInfo?.serialNo || '-' }}</span>
@ -41,7 +44,10 @@
<span class="label">备注</span><span>{{ licenseInfo?.remark || '-' }}</span>
</div>
<div class="mt-16 flex align-center" v-hasPermission="new Role('ADMIN')">
<div
class="mt-16 flex align-center"
v-hasPermission="new ComplexPermission(['ADMIN'], ['x-pack'], 'AND')"
>
<el-upload
ref="uploadRef"
action="#"
@ -55,15 +61,13 @@
<el-button class="border-primary ml-16" @click="toSupport">获取技术支持</el-button>
</div>
</div>
<!-- <div class="text-center">{{ $t('layout.topbar.avatar.version') }}:{{ user.version }}</div> -->
</el-dialog>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import licenseApi from '@/api/license'
import { EditionType } from '@/enums/common'
import { Role } from '@/utils/permission/type'
import { ComplexPermission } from '@/utils/permission/type'
import { fromNowDate } from '@/utils/time'
import useStore from '@/stores'
const { user } = useStore()
@ -76,7 +80,10 @@ const loading = ref(false)
const licenseInfo = ref<any>(null)
const open = () => {
getLicenseInfo()
if (user.isEnterprise()) {
getLicenseInfo()
}
aboutDialogVisible.value = true
}

View File

@ -78,10 +78,13 @@ const useUserStore = defineStore({
async asyncGetProfile() {
return new Promise((resolve, reject) => {
UserApi.getProfile()
.then((ok) => {
.then(async (ok) => {
this.version = ok.data?.version || '-'
this.isXPack = ok.data?.IS_XPACK
this.XPACK_LICENSE_IS_VALID = ok.data?.XPACK_LICENSE_IS_VALID
if (this.isEnterprise()) {
await this.theme()
}
resolve(ok)
})
.catch((error) => {
@ -104,7 +107,6 @@ const useUserStore = defineStore({
async profile() {
return UserApi.profile().then(async (ok) => {
this.userInfo = ok.data
await this.theme()
return this.asyncGetProfile()
})
},