-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathAboutDialog.vue
More file actions
176 lines (163 loc) · 4.52 KB
/
AboutDialog.vue
File metadata and controls
176 lines (163 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
<el-dialog
v-model="aboutDialogVisible"
class="about-dialog border-r-6"
:class="!isDefaultTheme ? 'dialog-custom-header' : ''"
>
<template #header="{ titleId, titleClass }">
<div class="logo flex-center" :id="titleId" :class="titleClass">
<LogoFull height="59px"/>
</div>
</template>
<div class="about-ui" v-loading="loading">
<div class="flex">
<span class="label">{{ $t('layout.about.authorize') }}</span
><span>{{ licenseInfo?.corporation || '-' }}</span>
</div>
<div class="flex">
<span class="label">{{ $t('layout.about.expiredTime') }}</span>
<span
>{{ licenseInfo?.expired || '-' }}
<span class="color-danger"
v-if="licenseInfo?.expired && fromNowDate(licenseInfo?.expired)"
>({{ fromNowDate(licenseInfo?.expired) }})</span>
</span
>
</div>
<div class="flex">
<span class="label">{{ $t('layout.about.edition.label') }}</span>
<span>{{
editionText
}}</span>
</div>
<div class="flex">
<span class="label">{{ $t('layout.about.version') }}</span
><span>{{ user.version }}</span>
</div>
<div class="flex">
<span class="label">{{ $t('layout.about.serialNo') }}</span
><span>{{ licenseInfo?.serialNo || '-' }}</span>
</div>
<div class="flex">
<span class="label">{{ $t('layout.about.remark') }}</span
><span>{{ licenseInfo?.remark || '-' }}</span>
</div>
<div class="mt-16 flex align-center" v-if="user.showXpack()">
<el-upload
ref="uploadRef"
action="#"
:auto-upload="false"
:show-file-list="false"
:on-change="onChange"
v-if="hasPermission([
RoleConst.ADMIN,
PermissionConst.ABOUT_UPDATE
],'OR')"
>
<el-button class="border-primary mr-16"
>{{ $t('layout.about.update') }} License
</el-button
>
</el-upload>
</div>
</div>
<div class="border-t text-center mt-16 p-16 pb-0">
<el-text type="info">{{ $t('layout.copyright') }}</el-text>
</div>
</el-dialog>
</template>
<script setup lang="ts">
import {ref, computed, watch} from 'vue'
import licenseApi from '@/api/system/license'
import {fromNowDate} from '@/utils/time'
import {Role} from '@/utils/permission/type'
import useStore from '@/stores'
import { t } from '@/locales'
import { hasPermission } from '@/utils/permission'
import { PermissionConst, RoleConst } from '@/utils/permission/data'
const {user, theme} = useStore()
const isDefaultTheme = computed(() => {
return theme.isDefaultTheme()
})
const aboutDialogVisible = ref(false)
const loading = ref(false)
const licenseInfo = ref<any>(null)
const isUpdate = ref(false)
watch(aboutDialogVisible, (bool) => {
if (!bool) {
if (isUpdate.value) {
window.location.reload()
}
isUpdate.value = false
}
})
const open = () => {
if (user.showXpack()) {
getLicenseInfo()
}
aboutDialogVisible.value = true
}
const onChange = (file: any) => {
const fd = new FormData()
fd.append('license_file', file.raw)
licenseApi.putLicense(fd, loading).then((res: any) => {
getLicenseInfo()
isUpdate.value = true
})
}
const editionText = computed(() => {
if (!user) return '-'
if (user.getEditionName() === 'PE') {
return t('layout.about.edition.professional')
} else if (user.getEditionName() === 'EE') {
return t('layout.about.edition.enterprise')
} else {
return t('layout.about.edition.community')
}
})
function getLicenseInfo() {
licenseApi.getLicense(loading).then((res: any) => {
licenseInfo.value = res.data?.license
})
}
defineExpose({open})
</script>
<style lang="scss" scope>
.about-dialog {
padding: 0 0 24px 0;
width: 620px;
font-weight: 400;
.el-dialog__header {
background: var(--app-header-bg-color);
margin-right: 0;
height: 140px;
box-sizing: border-box;
border-radius: 4px 4px 0 0;
&.show-close {
padding-right: 0;
}
}
.el-dialog__title {
height: 140px;
box-sizing: border-box;
}
.about-ui {
margin: 0 auto;
font-weight: 400;
font-size: 14px;
margin-top: 24px;
line-height: 36px;
padding: 0 40px;
.label {
width: 150px;
text-align: left;
color: var(--app-text-color-secondary);
}
}
&.dialog-custom-header {
.el-dialog__header {
background: var(--el-color-primary-light-9) !important;
}
}
}
</style>