Skip to content

Commit dca1df5

Browse files
committed
refactor: license
1 parent a08dd98 commit dca1df5

File tree

3 files changed

+76
-43
lines changed

3 files changed

+76
-43
lines changed

ui/src/api/system/license.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Result } from '@/request/Result'
2+
import { get, post, del, put } from '@/request/index'
3+
import { type Ref } from 'vue'
4+
5+
const prefix = '/license'
6+
7+
/**
8+
* 获得license信息
9+
*/
10+
const getLicense: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
11+
return get(`${prefix}/profile`, undefined, loading)
12+
}
13+
/**
14+
* 更新license信息
15+
* @param 参数 license_file:file
16+
*/
17+
const putLicense: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (data, loading) => {
18+
return put(`${prefix}/profile`, data, undefined, loading)
19+
}
20+
21+
export default {
22+
getLicense,
23+
putLicense
24+
}

ui/src/layout/layout-header/avatar/AboutDialog.vue

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
>
77
<template #header="{ titleId, titleClass }">
88
<div class="logo flex-center" :id="titleId" :class="titleClass">
9-
<LogoFull height="59px" />
9+
<LogoFull height="59px"/>
1010
</div>
1111
</template>
1212
<div class="about-ui" v-loading="loading">
@@ -16,20 +16,21 @@
1616
</div>
1717
<div class="flex">
1818
<span class="label">{{ $t('layout.about.expiredTime') }}</span>
19-
<!-- <span
20-
>{{ licenseInfo?.expired || '-' }}
21-
<span class="color-danger" v-if="licenseInfo?.expired && fromNowDate(licenseInfo?.expired)"
22-
>({{ fromNowDate(licenseInfo?.expired) }})</span
23-
></span
24-
> -->
19+
<!-- <span-->
20+
<!-- >{{ licenseInfo?.expired || '-' }}-->
21+
<!-- <span class="color-danger"-->
22+
<!-- v-if="licenseInfo?.expired && fromNowDate(licenseInfo?.expired)"-->
23+
<!-- >({{ fromNowDate(licenseInfo?.expired) }})</span-->
24+
<!-- ></span-->
25+
<!-- >-->
2526
</div>
2627
<div class="flex">
2728
<span class="label">{{ $t('layout.about.edition.label') }}</span>
2829
<span>{{
29-
user.showXpack()
30-
? $t('layout.about.edition.professional')
31-
: $t('layout.about.edition.community')
32-
}}</span>
30+
user.showXpack()
31+
? $t('layout.about.edition.professional')
32+
: $t('layout.about.edition.community')
33+
}}</span>
3334
</div>
3435
<div class="flex">
3536
<span class="label">{{ $t('layout.about.version') }}</span
@@ -53,7 +54,8 @@
5354
v-hasPermission="new Role('ADMIN')"
5455
>
5556
<el-button class="border-primary mr-16"
56-
>{{ $t('layout.about.update') }} License</el-button
57+
>{{ $t('layout.about.update') }} License
58+
</el-button
5759
>
5860
</el-upload>
5961
</div>
@@ -64,12 +66,13 @@
6466
</el-dialog>
6567
</template>
6668
<script setup lang="ts">
67-
import { ref, computed, watch } from 'vue'
68-
// import licenseApi from '@/api/license'
69-
// import { fromNowDate } from '@/utils/time'
70-
import { Role } from '@/utils/permission/type'
69+
import {ref, computed, watch} from 'vue'
70+
import licenseApi from '@/api/system/license'
71+
//import {fromNowDate} from '@/utils/time'
72+
import {Role} from '@/utils/permission/type'
7173
import useStore from '@/stores'
72-
const { user, theme } = useStore()
74+
75+
const {user, theme} = useStore()
7376
const isDefaultTheme = computed(() => {
7477
return theme.isDefaultTheme()
7578
})
@@ -98,38 +101,43 @@ const open = () => {
98101
const onChange = (file: any) => {
99102
const fd = new FormData()
100103
fd.append('license_file', file.raw)
101-
// licenseApi.putLicense(fd, loading).then((res: any) => {
102-
// getLicenseInfo()
103-
// isUpdate.value = true
104-
// })
104+
licenseApi.putLicense(fd, loading).then((res: any) => {
105+
getLicenseInfo()
106+
isUpdate.value = true
107+
})
105108
}
109+
106110
function getLicenseInfo() {
107-
// licenseApi.getLicense(loading).then((res: any) => {
108-
// licenseInfo.value = res.data?.license
109-
// })
111+
licenseApi.getLicense(loading).then((res: any) => {
112+
licenseInfo.value = res.data?.license
113+
})
110114
}
111115
112-
defineExpose({ open })
116+
defineExpose({open})
113117
</script>
114118
<style lang="scss" scope>
115119
.about-dialog {
116120
padding: 0 0 24px 0;
117121
width: 620px;
118122
font-weight: 400;
123+
119124
.el-dialog__header {
120125
background: var(--app-header-bg-color);
121126
margin-right: 0;
122127
height: 140px;
123128
box-sizing: border-box;
124129
border-radius: 4px 4px 0 0;
130+
125131
&.show-close {
126132
padding-right: 0;
127133
}
128134
}
135+
129136
.el-dialog__title {
130137
height: 140px;
131138
box-sizing: border-box;
132139
}
140+
133141
.about-ui {
134142
margin: 0 auto;
135143
font-weight: 400;
@@ -144,6 +152,7 @@ defineExpose({ open })
144152
color: var(--app-text-color-secondary);
145153
}
146154
}
155+
147156
&.dialog-custom-header {
148157
.el-dialog__header {
149158
background: var(--el-color-primary-light-9) !important;

ui/src/layout/layout-header/avatar/index.vue

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<el-dropdown trigger="click" type="primary">
33
<div class="flex-center cursor">
44
<el-avatar :size="30">
5-
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
5+
<img src="@/assets/user-icon.svg" style="width: 54%" alt=""/>
66
</el-avatar>
77
<span class="ml-8 color-text-primary">{{ user.userInfo?.username }}</span>
88
<el-icon class="el-icon--right">
9-
<CaretBottom />
9+
<CaretBottom/>
1010
</el-icon>
1111
</div>
1212

@@ -15,15 +15,15 @@
1515
<div class="userInfo flex align-center">
1616
<div class="mr-12 flex align-center">
1717
<el-avatar :size="30">
18-
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
18+
<img src="@/assets/user-icon.svg" style="width: 54%" alt=""/>
1919
</el-avatar>
2020
</div>
2121
<div style="width: 90%">
2222
<p class="bold mb-4" style="font-size: 14px">{{ user.userInfo?.username }}</p>
2323
<template v-if="user.userInfo?.role && user.userInfo.role.length > 0">
2424
<el-tag size="small" class="default-tag">{{ user.userInfo?.role[0] }}</el-tag>
2525
<el-tag size="small" class="default-tag ml-4" v-if="user.userInfo?.role?.length > 1"
26-
>+{{ user.userInfo?.role?.length - 1 }}
26+
>+{{ user.userInfo?.role?.length - 1 }}
2727
</el-tag>
2828
</template>
2929
</div>
@@ -41,7 +41,7 @@
4141
<div class="flex-between w-full" style="line-height: 22px; padding: 12px 11px">
4242
<span> {{ $t('layout.language') }}</span>
4343
<el-icon>
44-
<ArrowRight />
44+
<ArrowRight/>
4545
</el-icon>
4646
</div>
4747

@@ -55,14 +55,14 @@
5555
class="flex-between"
5656
>
5757
<span :class="lang.value === user.userInfo?.language ? 'primary' : ''">{{
58-
lang.label
59-
}}</span>
58+
lang.label
59+
}}</span>
6060

6161
<el-icon
6262
:class="lang.value === user.userInfo?.language ? 'primary' : ''"
6363
v-if="lang.value === user.userInfo?.language"
6464
>
65-
<Check />
65+
<Check/>
6666
</el-icon>
6767
</el-dropdown-item>
6868
</el-dropdown-menu>
@@ -86,24 +86,24 @@
8686
</el-dropdown-menu>
8787
</template>
8888
</el-dropdown>
89-
<APIKeyDialog :user-id="user.userInfo?.id" ref="APIKeyDialogRef" />
89+
<APIKeyDialog :user-id="user.userInfo?.id" ref="APIKeyDialogRef"/>
9090
<ResetPassword ref="resetPasswordRef"></ResetPassword>
91-
<!-- <AboutDialog ref="AboutDialogRef"></AboutDialog>
92-
-->
91+
<AboutDialog ref="AboutDialogRef"></AboutDialog>
92+
9393
<!-- <UserPwdDialog ref="UserPwdDialogRef" /> -->
9494
</template>
9595
<script setup lang="ts">
96-
import { ref, onMounted } from 'vue'
96+
import {ref, onMounted} from 'vue'
9797
import useStore from '@/stores'
98-
import { useRouter } from 'vue-router'
98+
import {useRouter} from 'vue-router'
9999
import ResetPassword from './ResetPassword.vue'
100-
// import AboutDialog from './AboutDialog.vue'
100+
import AboutDialog from './AboutDialog.vue'
101101
// import UserPwdDialog from '@/views/user-manage/component/UserPwdDialog.vue'
102102
import APIKeyDialog from './APIKeyDialog.vue'
103-
import { ComplexPermission } from '@/utils/permission/type'
104-
import { langList } from '@/locales/index'
103+
import {ComplexPermission} from '@/utils/permission/type'
104+
import {langList} from '@/locales/index'
105105
106-
const { user, login } = useStore()
106+
const {user, login} = useStore()
107107
const router = useRouter()
108108
109109
const AboutDialogRef = ref()
@@ -129,7 +129,7 @@ const openResetPassword = () => {
129129
130130
const logout = () => {
131131
login.logout().then(() => {
132-
router.push({ name: 'login' })
132+
router.push({name: 'login'})
133133
})
134134
}
135135

0 commit comments

Comments
 (0)