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

View File

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