diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index 9ed0449c7..5be00603c 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -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); } /** diff --git a/resources/assets/js/pages/manage/dashboard.vue b/resources/assets/js/pages/manage/dashboard.vue index 55750c881..71f676768 100644 --- a/resources/assets/js/pages/manage/dashboard.vue +++ b/resources/assets/js/pages/manage/dashboard.vue @@ -2,6 +2,7 @@
+ {{warningMsg}}
{{$L('欢迎您,' + userInfo.nickname)}}
{{$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) + } } } diff --git a/resources/assets/js/pages/manage/setting/license.vue b/resources/assets/js/pages/manage/setting/license.vue index 0a764a351..54ee6177d 100644 --- a/resources/assets/js/pages/manage/setting/license.vue +++ b/resources/assets/js/pages/manage/setting/license.vue @@ -6,7 +6,7 @@
-
    +
    • SN: {{formData.info.sn}} @@ -51,6 +51,12 @@
    • +
    • {{tip}}
    • +
    +
      +
    • + {{$L('加载中...')}} +
@@ -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('修改成功'); diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 152724d7c..9a3be1d60 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -131,6 +131,7 @@ export default { 'users/editpass', 'users/operation', 'users/delete/account', + 'system/license', 'users/bot/*', 'dialog/msg/*', ], true)) { diff --git a/resources/assets/sass/pages/page-dashboard.scss b/resources/assets/sass/pages/page-dashboard.scss index b9c5d7d78..2d5c72ce5 100644 --- a/resources/assets/sass/pages/page-dashboard.scss +++ b/resources/assets/sass/pages/page-dashboard.scss @@ -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 ,