mirror of
https://github.com/kuaifan/dootask.git
synced 2026-06-25 08:42:14 +00:00
refactor(config): app 内 env() 直读收敛到 config()
- 新增 config/dootask.php 承载 11 个无 config 对应的 env key(默认值随迁)
- 29 处 env() 替换:APP_KEY→config('app.key')、APP_NAME→config('app.name')、其余→config('dootask.*')
- 语义逐处保持一致(?:/三元留在调用点);消除 config:cache 后 env() 返回 null 的隐患
- 注:User.php / Setting.php 同时含本批 ide-helper 生成的 @property 注释增量
- 验证:grep env( app/ 归零;composer stan 通过;phpunit 146 测试全过
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
383664aef7
commit
04aa60b574
@ -36,7 +36,7 @@ class ApproveController extends AbstractController
|
||||
public function __construct()
|
||||
{
|
||||
Apps::isInstalledThrow('approve');
|
||||
$this->flow_url = env('FLOW_URL') ?: 'http://approve';
|
||||
$this->flow_url = config('dootask.flow_url') ?: 'http://approve';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3042,7 +3042,7 @@ class DialogController extends AbstractController
|
||||
*/
|
||||
public function group__transfer()
|
||||
{
|
||||
if (!Base::is_internal_ip(Base::getIp()) || Request::input("key") !== env('APP_KEY')) {
|
||||
if (!Base::is_internal_ip(Base::getIp()) || Request::input("key") !== config('app.key')) {
|
||||
$user = User::auth();
|
||||
}
|
||||
//
|
||||
@ -3352,7 +3352,7 @@ class DialogController extends AbstractController
|
||||
*/
|
||||
public function okr__push()
|
||||
{
|
||||
if (!Base::is_internal_ip(Base::getIp()) || Request::input("key") !== env('APP_KEY')) {
|
||||
if (!Base::is_internal_ip(Base::getIp()) || Request::input("key") !== config('app.key')) {
|
||||
User::auth();
|
||||
}
|
||||
$text = trim(Request::input('text'));
|
||||
|
||||
@ -737,7 +737,7 @@ class FileController extends AbstractController
|
||||
File::isNeedInstallApp('office');
|
||||
//
|
||||
$config = Request::input('config');
|
||||
$token = \Firebase\JWT\JWT::encode($config, env('APP_KEY') ,'HS256');
|
||||
$token = \Firebase\JWT\JWT::encode($config, config('app.key') ,'HS256');
|
||||
return Base::retSuccess('成功', [
|
||||
'token' => $token
|
||||
]);
|
||||
|
||||
@ -53,7 +53,7 @@ class SystemController extends AbstractController
|
||||
{
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
Base::checkClientVersion('0.41.11');
|
||||
@ -109,7 +109,7 @@ class SystemController extends AbstractController
|
||||
return Base::retError('自动归档时间不可大于100天!');
|
||||
}
|
||||
}
|
||||
if ($all['system_alias'] == env('APP_NAME')) {
|
||||
if ($all['system_alias'] == config('app.name')) {
|
||||
$all['system_alias'] = '';
|
||||
}
|
||||
if ($all['system_welcome'] == '欢迎您,{username}') {
|
||||
@ -183,7 +183,7 @@ class SystemController extends AbstractController
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$user->identity('admin');
|
||||
@ -253,7 +253,7 @@ class SystemController extends AbstractController
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Request::input();
|
||||
@ -277,7 +277,7 @@ class SystemController extends AbstractController
|
||||
}
|
||||
//
|
||||
$setting['open'] = $setting['open'] ?: 'close';
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
$setting['appid'] = substr($setting['appid'], 0, 4) . str_repeat('*', strlen($setting['appid']) - 8) . substr($setting['appid'], -4);
|
||||
$setting['app_certificate'] = substr($setting['app_certificate'], 0, 4) . str_repeat('*', strlen($setting['app_certificate']) - 8) . substr($setting['app_certificate'], -4);
|
||||
$setting['api_key'] = substr($setting['api_key'], 0, 4) . str_repeat('*', strlen($setting['api_key']) - 8) . substr($setting['api_key'], -4);
|
||||
@ -323,7 +323,7 @@ class SystemController extends AbstractController
|
||||
$filter = trim(Request::input('filter'));
|
||||
$setting = Base::setting('aibotSetting');
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
Base::checkClientVersion('0.41.11');
|
||||
@ -341,7 +341,7 @@ class SystemController extends AbstractController
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
//
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
foreach ($setting as $key => $item) {
|
||||
if (empty($item)) {
|
||||
continue;
|
||||
@ -395,7 +395,7 @@ class SystemController extends AbstractController
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Request::input();
|
||||
@ -544,7 +544,7 @@ class SystemController extends AbstractController
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Request::input();
|
||||
@ -609,7 +609,7 @@ class SystemController extends AbstractController
|
||||
return Base::retError($e->getMessage() ?: "验证失败:未知错误", config("ldap.connections.default"));
|
||||
}
|
||||
} elseif ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Base::newTrim(Request::input());
|
||||
@ -661,7 +661,7 @@ class SystemController extends AbstractController
|
||||
//
|
||||
$type = trim(Request::input('type'));
|
||||
if ($type == 'save') {
|
||||
if (env("SYSTEM_SETTING") == 'disabled') {
|
||||
if (config('dootask.system_setting') == 'disabled') {
|
||||
return Base::retError('当前环境禁止修改');
|
||||
}
|
||||
$all = Base::newTrim(Request::input());
|
||||
@ -694,8 +694,8 @@ class SystemController extends AbstractController
|
||||
*/
|
||||
public function demo()
|
||||
{
|
||||
$demo_account = env('DEMO_ACCOUNT');
|
||||
$demo_password = env('DEMO_PASSWORD');
|
||||
$demo_account = config('dootask.demo_account');
|
||||
$demo_password = config('dootask.demo_password');
|
||||
if (empty($demo_account) || empty($demo_password)) {
|
||||
return Base::retError('No demo account');
|
||||
}
|
||||
@ -916,7 +916,7 @@ class SystemController extends AbstractController
|
||||
*/
|
||||
public function get__info()
|
||||
{
|
||||
if (Request::input("key") !== env('APP_KEY')) {
|
||||
if (Request::input("key") !== config('app.key')) {
|
||||
return [];
|
||||
}
|
||||
return Base::retSuccess('success', [
|
||||
|
||||
@ -1635,7 +1635,7 @@ class UsersController extends AbstractController
|
||||
} elseif ($type === 'create') {
|
||||
$meetingid = strtoupper(Base::generatePassword(11, 1));
|
||||
$name = $name ?: Doo::translate("{$user?->nickname} 发起的会议");
|
||||
$channel = "DooTask:" . substr(md5($meetingid . env("APP_KEY")), 16);
|
||||
$channel = "DooTask:" . substr(md5($meetingid . config('app.key')), 16);
|
||||
$meeting = Meeting::createInstance([
|
||||
'meetingid' => $meetingid,
|
||||
'name' => $name,
|
||||
|
||||
@ -301,7 +301,7 @@ class IndexController extends InvokeController
|
||||
if (preg_match("/^\d+\.\d+\.\d+$/", $publishVersion)) {
|
||||
// 判断密钥
|
||||
$publishKey = Request::header('publish-key');
|
||||
if ($publishKey !== env('APP_KEY')) {
|
||||
if ($publishKey !== config('app.key')) {
|
||||
return Base::retError("key error");
|
||||
}
|
||||
// 判断版本
|
||||
|
||||
@ -51,7 +51,7 @@ class Setting extends AbstractModel
|
||||
switch ($this->name) {
|
||||
// 系统设置
|
||||
case 'system':
|
||||
$value['system_alias'] = ($value['system_alias'] ?? null) ?: env('APP_NAME');
|
||||
$value['system_alias'] = ($value['system_alias'] ?? null) ?: config('app.name');
|
||||
$value['image_compress'] = ($value['image_compress'] ?? null) ?: 'open';
|
||||
$value['image_quality'] = min(100, max(0, intval($value['image_quality'] ?? 0) ?: 90));
|
||||
$value['image_save_local'] = ($value['image_save_local'] ?? null) ?: 'open';
|
||||
|
||||
@ -305,12 +305,12 @@ class User extends AbstractModel
|
||||
if ($onlyUserid && $onlyUserid != $this->userid) {
|
||||
return;
|
||||
}
|
||||
if (env("PASSWORD_ADMIN") == 'disabled') {
|
||||
if (config('dootask.password_admin') == 'disabled') {
|
||||
if ($this->userid == 1) {
|
||||
throw new ApiException('当前环境禁止此操作');
|
||||
}
|
||||
}
|
||||
if (env("PASSWORD_OWNER") == 'disabled') {
|
||||
if (config('dootask.password_owner') == 'disabled') {
|
||||
throw new ApiException('当前环境禁止此操作');
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class Apps
|
||||
*/
|
||||
public static function dispatchUserHook(User $user, string $action, string $eventType = '', array $changedFields = []): void
|
||||
{
|
||||
$appKey = env('APP_KEY', '');
|
||||
$appKey = config('app.key') ?: '';
|
||||
if (empty($appKey)) {
|
||||
info('[appstore_hook] APP_KEY is empty, skip dispatchUserHook');
|
||||
return;
|
||||
|
||||
@ -53,7 +53,7 @@ class Doo
|
||||
*/
|
||||
public static function licenseContent(): string
|
||||
{
|
||||
if (env("SYSTEM_LICENSE") == 'hidden') {
|
||||
if (config('dootask.system_license') == 'hidden') {
|
||||
return '';
|
||||
}
|
||||
$paths = [
|
||||
|
||||
@ -29,8 +29,8 @@ class ManticoreBase
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->host = env('SEARCH_HOST', 'search');
|
||||
$this->port = (int) env('SEARCH_PORT', 9306);
|
||||
$this->host = config('dootask.search_host');
|
||||
$this->port = (int) config('dootask.search_port');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -65,7 +65,7 @@ class DeleteTmpTask extends AbstractTask
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$day = intval(env("AUTO_EMPTY_FILE_RECYCLE", 365));
|
||||
$day = intval(config('dootask.auto_empty_file_recycle'));
|
||||
if ($day <= 0) {
|
||||
return;
|
||||
}
|
||||
@ -81,7 +81,7 @@ class DeleteTmpTask extends AbstractTask
|
||||
break;
|
||||
|
||||
case 'tmp_file':
|
||||
$day = intval(env("AUTO_EMPTY_TEMP_FILE", 30));
|
||||
$day = intval(config('dootask.auto_empty_temp_file'));
|
||||
if ($day <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
38
config/dootask.php
Normal file
38
config/dootask.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
// 系统设置开关:设为 'disabled' 时禁止通过接口修改系统设置(SystemController)
|
||||
'system_setting' => env('SYSTEM_SETTING'),
|
||||
|
||||
// 许可证显示开关:设为 'hidden' 时隐藏系统许可证信息(Doo::license)
|
||||
'system_license' => env('SYSTEM_LICENSE'),
|
||||
|
||||
// 演示账号:登录页展示的演示账号(SystemController::demo)
|
||||
'demo_account' => env('DEMO_ACCOUNT'),
|
||||
|
||||
// 演示密码:登录页展示的演示账号密码(SystemController::demo)
|
||||
'demo_password' => env('DEMO_PASSWORD'),
|
||||
|
||||
// 管理员密码修改开关:设为 'disabled' 时禁止修改管理员密码(User 模型)
|
||||
'password_admin' => env('PASSWORD_ADMIN'),
|
||||
|
||||
// 创始人密码修改开关:设为 'disabled' 时禁止修改创始人密码(User 模型)
|
||||
'password_owner' => env('PASSWORD_OWNER'),
|
||||
|
||||
// 审批流服务地址:审批微服务的内部访问 URL(ApproveController)
|
||||
'flow_url' => env('FLOW_URL'),
|
||||
|
||||
// Manticore 全文搜索服务主机(ManticoreBase)
|
||||
'search_host' => env('SEARCH_HOST', 'search'),
|
||||
|
||||
// Manticore 全文搜索服务端口(ManticoreBase)
|
||||
'search_port' => env('SEARCH_PORT', 9306),
|
||||
|
||||
// 文件回收站自动清空天数(DeleteTmpTask)
|
||||
'auto_empty_file_recycle' => env('AUTO_EMPTY_FILE_RECYCLE', 365),
|
||||
|
||||
// 临时文件自动清理天数(DeleteTmpTask)
|
||||
'auto_empty_temp_file' => env('AUTO_EMPTY_TEMP_FILE', 30),
|
||||
|
||||
];
|
||||
Loading…
x
Reference in New Issue
Block a user