diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index 16515b77e..5eb96d010 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -513,6 +513,41 @@ class SystemController extends AbstractController return Base::retSuccess('success', $setting); } + /** + * @api {post} api/system/license 08. License + * + * @apiDescription 获取License信息、保存License(限管理员) + * @apiVersion 1.0.0 + * @apiGroup system + * @apiName license + * + * @apiParam {String} type + * - get: 获取 + * - save: 保存 + * @apiParam {String} license License 原文 + * + * @apiSuccess {Number} ret 返回状态码(1正确、0错误) + * @apiSuccess {String} msg 返回信息(错误描述) + * @apiSuccess {Object} data 返回数据 + */ + public function license() + { + User::auth('admin'); + // + $type = trim(Request::input('type')); + if ($type == 'save') { + $license = Base::getPostValue('license'); + Doo::licenseSave($license); + } + // + return Base::retSuccess('success', [ + 'license' => Doo::licenseContent(), + 'info' => Doo::license(), + 'macs' => Doo::macs(), + 'user_count' => User::whereBot(0)->whereNull('disable_at')->count(), + ]); + } + /** * @api {get} api/system/get/info 10. 获取终端详细信息 * diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 1b5e5a8b9..7970dff29 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -24,6 +24,9 @@ class VerifyCsrfToken extends Middleware // 保存创建项目列表模板 'api/system/column/template/', + // License 设置 + 'api/system/license/', + // 添加任务 'api/project/task/add/', diff --git a/app/Module/Doo.php b/app/Module/Doo.php index 310d2edac..f4437ade4 100644 --- a/app/Module/Doo.php +++ b/app/Module/Doo.php @@ -43,6 +43,7 @@ class Doo char* tokenDecode(char* val); char* translate(char* val, char* val); char* md5s(char* text, char* password); + char* macs(); EOF, "/usr/lib/doo/doo.so"); $token = $token ?: Base::headerOrInput('token'); $language = $language ?: Base::headerOrInput('language'); @@ -55,7 +56,8 @@ class Doo * @param $language * @return mixed */ - public static function doo($token = null, $language = null) { + public static function doo($token = null, $language = null) + { if (self::$doo == null) { self::load($token, $language); } @@ -86,6 +88,14 @@ class Doo } } + $macs = explode(",", $array['mac']); + $array['mac'] = []; + foreach ($macs as $mac) { + if (Base::isMac($mac)) { + $array['mac'][] = $mac; + } + } + $emails = explode(",", $array['email']); $array['email'] = []; foreach ($emails as $email) { @@ -97,6 +107,28 @@ class Doo return $array; } + /** + * 获取License原文 + * @return string + */ + public static function licenseContent(): string + { + $paths = [ + config_path("LICENSE"), + config_path("license"), + app_path("LICENSE"), + app_path("license"), + ]; + $content = ""; + foreach ($paths as $path) { + if (file_exists($path)) { + $content = file_get_contents($path); + break; + } + } + return $content; + } + /** * 解析License * @param $license @@ -237,4 +269,20 @@ class Doo { return self::string(self::doo()->md5s($text, $password)); } + + /** + * 获取php容器mac地址组 + * @return array + */ + public static function macs(): array + { + $macs = explode(",", self::string(self::doo()->macs())); + $array = []; + foreach ($macs as $mac) { + if (Base::isMac($mac)) { + $array[] = $mac; + } + } + return $array; + } } diff --git a/docker-compose.yml b/docker-compose.yml index de65f67b6..9a1aaab31 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: '3' services: php: container_name: "dootask-php-${APP_ID}" - image: "kuaifan/php:swoole-8.0.rc4" + image: "kuaifan/php:swoole-8.0.rc5" shm_size: "1024m" volumes: - ./docker/crontab/crontab.conf:/etc/supervisor/conf.d/crontab.conf diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 7b1a584e9..59122c610 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -539,7 +539,7 @@ export default { array.push(...[ {path: 'personal', name: '个人设置', divided: true}, {path: 'system', name: '系统设置'}, - {path: 'clearCache', name: '清除缓存'}, + {path: 'license', name: 'License Key'}, {path: 'version', name: '更新版本', divided: true, visible: !!this.clientNewVersion}, @@ -551,7 +551,6 @@ export default { } else { array.push(...[ {path: 'personal', name: '个人设置', divided: true}, - {path: 'clearCache', name: '清除缓存'}, {path: 'version', name: '更新版本', divided: true, visible: !!this.clientNewVersion}, @@ -562,11 +561,13 @@ export default { if (needStartHome) { array.push(...[ {path: 'goHome', name: '打开首页', divided: true}, + {path: 'clearCache', name: '清除缓存'}, {path: 'logout', name: '退出登录', style: {color: '#f40'}} ]) } else { array.push(...[ - {path: 'logout', name: '退出登录', style: {color: '#f40'}, divided: true} + {path: 'clearCache', name: '清除缓存', divided: true}, + {path: 'logout', name: '退出登录', style: {color: '#f40'}} ]) } return array diff --git a/resources/assets/js/pages/manage/setting/components/SystemTaskPriority.vue b/resources/assets/js/pages/manage/setting/components/SystemTaskPriority.vue index 7d68c4fa1..d249a014c 100644 --- a/resources/assets/js/pages/manage/setting/components/SystemTaskPriority.vue +++ b/resources/assets/js/pages/manage/setting/components/SystemTaskPriority.vue @@ -4,12 +4,12 @@ {{$L('名称')}} - +
{{$L('级别')}}
- +
{{$L('天数')}}
diff --git a/resources/assets/js/pages/manage/setting/index.vue b/resources/assets/js/pages/manage/setting/index.vue index f3330e051..8e60ea3dd 100644 --- a/resources/assets/js/pages/manage/setting/index.vue +++ b/resources/assets/js/pages/manage/setting/index.vue @@ -99,15 +99,13 @@ export default { if (this.userIsAdmin) { menu.push(...[ {path: 'system', name: '系统设置', divided: true}, - {path: 'clearCache', name: '清除缓存'}, - {path: 'logout', name: '退出登录'}, - ]) - } else { - menu.push(...[ - {path: 'clearCache', name: '清除缓存', divided: true}, - {path: 'logout', name: '退出登录'}, + {path: 'license', name: 'License Key'}, ]) } + menu.push(...[ + {path: 'clearCache', name: '清除缓存', divided: true}, + {path: 'logout', name: '退出登录'}, + ]) return menu; }, diff --git a/resources/assets/js/pages/manage/setting/license.vue b/resources/assets/js/pages/manage/setting/license.vue new file mode 100644 index 000000000..20be24eae --- /dev/null +++ b/resources/assets/js/pages/manage/setting/license.vue @@ -0,0 +1,156 @@ + + + + diff --git a/resources/assets/js/routes.js b/resources/assets/js/routes.js index 0461afe9a..230cf1324 100755 --- a/resources/assets/js/routes.js +++ b/resources/assets/js/routes.js @@ -59,6 +59,11 @@ export default [ path: 'keyboard', component: () => import('./pages/manage/setting/keyboard.vue'), }, + { + name: 'manage-setting-license', + path: 'license', + component: () => import('./pages/manage/setting/license.vue'), + }, { name: 'manage-setting-password', path: 'password',