license 提醒

This commit is contained in:
kuaifan 2023-04-06 12:47:32 +08:00
parent e69a91feb3
commit 6107bde666
5 changed files with 107 additions and 18 deletions

View File

@ -550,13 +550,40 @@ class SystemController extends AbstractController
Doo::licenseSave($license);
}
//
return Base::retSuccess('success', [
$data = [
'license' => Doo::licenseContent(),
'info' => Doo::license(),
'macs' => Doo::macs(),
'doo_sn' => Doo::dooSN(),
'user_count' => User::whereBot(0)->whereNull('disable_at')->count(),
]);
'error' => []
];
if ($data['info']['people'] > 3) {
// 小于3人的License不检查
if ($data['info']['sn'] != $data['doo_sn']) {
$data['error'][] = '终端SN与License不匹配';
}
if ($data['info']['mac']) {
$approved = false;
foreach ($data['info']['mac'] as $mac) {
if (in_array($mac, $data['macs'])) {
$approved = true;
break;
}
}
if (!$approved) {
$data['error'][] = '终端MAC与License不匹配';
}
}
if ($data['user_count'] > $data['info']['people']) {
$data['error'][] = '终端用户数超过License限制';
}
if ($data['info']['expired_at'] && strtotime($data['info']['expired_at']) <= Base::time()) {
$data['error'][] = '终端License已过期';
}
}
//
return Base::retSuccess('success', $data);
}
/**

View File

@ -2,6 +2,7 @@
<div class="page-dashboard">
<PageTitle :title="$L('仪表盘')"/>
<div class="dashboard-wrapper">
<Alert v-if="warningMsg" class="dashboard-warning" type="warning" show-icon>{{warningMsg}}</Alert>
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
<div class="dashboard-desc">
{{$L('以下是你当前的任务统计数据')}}
@ -92,33 +93,31 @@ export default {
data() {
return {
nowTime: $A.Time(),
nowInterval: null,
nowInter: null,
licenseTimer: null,
loadIng: 0,
dashboard: 'today',
warningMsg: '',
}
},
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = $A.Time();
}, 1000)
},
destroyed() {
clearInterval(this.nowInterval)
},
activated() {
this.$store.dispatch("getTaskForDashboard", 600);
this.loadInterval(true);
this.loadLicense(true);
},
deactivated() {
this.$store.dispatch("forgetTaskCompleteTemp", true);
this.loadInterval(false);
this.loadLicense(false);
},
computed: {
...mapState(['userInfo', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
...mapState(['userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']),
@ -150,6 +149,13 @@ export default {
},
},
watch: {
windowActive(active) {
this.loadInterval(active)
this.loadLicense(active);
}
},
methods: {
getTitle(type) {
switch (type) {
@ -184,6 +190,41 @@ export default {
expiresFormat(date) {
return $A.countDownFormat(date, this.nowTime)
},
loadInterval(load) {
if (this.nowInter) {
clearInterval(this.nowInter)
this.nowInter = null;
}
if (load === false) {
return
}
this.nowInter = setInterval(_ => {
this.nowTime = $A.Time()
}, 1000)
},
loadLicense(load) {
if (this.licenseTimer) {
clearTimeout(this.licenseTimer)
this.licenseTimer = null;
}
if (load === false || !this.userIsAdmin) {
return
}
this.licenseTimer = setTimeout(_ => {
this.$store.dispatch("call", {
url: 'system/license',
data: {
type: 'get'
}
}).then(({data}) => {
this.warningMsg = data.error.length > 0 ? data.error[0] : '';
}).catch(_ => {
this.warningMsg = '';
})
}, 1500)
}
}
}
</script>

View File

@ -6,7 +6,7 @@
</FormItem>
<FormItem :label="$L('详细信息')">
<div class="license-box">
<ul>
<ul v-if="formData.info.sn">
<li>
<em>SN:</em>
<span>{{formData.info.sn}}</span>
@ -51,6 +51,12 @@
<Icon class="information" type="ios-information-circle-outline" />
</ETooltip>
</li>
<li v-for="tip in formData.error" class="warning">{{tip}}</li>
</ul>
<ul v-else>
<li>
{{$L('加载中...')}}
</li>
</ul>
</div>
</FormItem>
@ -72,6 +78,10 @@
line-height: 22px;
padding-bottom: 6px;
display: flex;
&.warning {
font-weight: 500;
color: #ed4014;
}
> em {
flex-shrink: 0;
font-style: normal;
@ -103,7 +113,8 @@ export default {
info: {},
macs: [],
doo_sn: '',
user_count: 0
user_count: 0,
error: []
},
}
},
@ -129,9 +140,11 @@ export default {
systemSetting(save) {
this.loadIng++;
this.$store.dispatch("call", {
url: 'system/license?type=' + (save ? 'save' : 'get'),
url: 'system/license',
data: Object.assign(this.formData, {
type: save ? 'save' : 'get'
}),
method: 'post',
data: this.formData,
}).then(({data}) => {
if (save) {
$A.messageSuccess('修改成功');

View File

@ -131,6 +131,7 @@ export default {
'users/editpass',
'users/operation',
'users/delete/account',
'system/license',
'users/bot/*',
'dialog/msg/*',
], true)) {

View File

@ -13,6 +13,13 @@
display: flex;
flex-direction: column;
align-items: center;
.dashboard-warning {
border-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.dashboard-hello,
.dashboard-desc ,
.dashboard-block ,