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); Doo::licenseSave($license);
} }
// //
return Base::retSuccess('success', [ $data = [
'license' => Doo::licenseContent(), 'license' => Doo::licenseContent(),
'info' => Doo::license(), 'info' => Doo::license(),
'macs' => Doo::macs(), 'macs' => Doo::macs(),
'doo_sn' => Doo::dooSN(), 'doo_sn' => Doo::dooSN(),
'user_count' => User::whereBot(0)->whereNull('disable_at')->count(), '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"> <div class="page-dashboard">
<PageTitle :title="$L('仪表盘')"/> <PageTitle :title="$L('仪表盘')"/>
<div class="dashboard-wrapper"> <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-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
<div class="dashboard-desc"> <div class="dashboard-desc">
{{$L('以下是你当前的任务统计数据')}} {{$L('以下是你当前的任务统计数据')}}
@ -92,33 +93,31 @@ export default {
data() { data() {
return { return {
nowTime: $A.Time(), nowTime: $A.Time(),
nowInterval: null, nowInter: null,
licenseTimer: null,
loadIng: 0, loadIng: 0,
dashboard: 'today', dashboard: 'today',
warningMsg: '',
} }
}, },
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = $A.Time();
}, 1000)
},
destroyed() {
clearInterval(this.nowInterval)
},
activated() { activated() {
this.$store.dispatch("getTaskForDashboard", 600); this.$store.dispatch("getTaskForDashboard", 600);
this.loadInterval(true);
this.loadLicense(true);
}, },
deactivated() { deactivated() {
this.$store.dispatch("forgetTaskCompleteTemp", true); this.$store.dispatch("forgetTaskCompleteTemp", true);
this.loadInterval(false);
this.loadLicense(false);
}, },
computed: { computed: {
...mapState(['userInfo', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']), ...mapState(['userInfo', 'userIsAdmin', 'cacheTasks', 'taskCompleteTemps', 'loadDashboardTasks']),
...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']), ...mapGetters(['dashboardTask', 'assistTask', 'transforTasks']),
@ -150,6 +149,13 @@ export default {
}, },
}, },
watch: {
windowActive(active) {
this.loadInterval(active)
this.loadLicense(active);
}
},
methods: { methods: {
getTitle(type) { getTitle(type) {
switch (type) { switch (type) {
@ -184,6 +190,41 @@ export default {
expiresFormat(date) { expiresFormat(date) {
return $A.countDownFormat(date, this.nowTime) 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> </script>

View File

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

View File

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

View File

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