diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 2ad8cb376..8f849fe30 100755 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -8,6 +8,7 @@ use App\Tasks\DeleteTmpTask; use App\Tasks\OverdueRemindEmailTask; use Hhxsv5\LaravelS\Swoole\Task\Task; use Redirect; +use Request; /** @@ -38,6 +39,19 @@ class IndexController extends InvokeController return view('main', ['version' => Base::getVersion()]); } + /** + * 获取版本号 + * @return array + */ + public function version() + { + return [ + 'version' => Base::getVersion(), + 'owner' => 'kuaifan', + 'repo' => 'dootask-test', + ]; + } + /** * 接口文档 * @return \Illuminate\Http\RedirectResponse @@ -68,6 +82,43 @@ class IndexController extends InvokeController return "success"; } + /** + * 桌面客户端发布 + */ + public function desktop__publish($name = '') + { + $body = Request::input('body'); + $genericVersion = Request::header('generic-version'); + // + $latestFile = public_path("uploads/desktop/latest"); + if (preg_match("/^\d+\.\d+\.\d+$/", $genericVersion)) { + $genericPath = "uploads/desktop/" . $genericVersion . "/"; + $res = Base::upload([ + "file" => Request::file('file'), + "type" => 'desktop', + "path" => $genericPath, + "fileName" => true + ]); + if ($res) { + if ($body) { + file_put_contents(public_path($genericPath . "change.md"), $body); + } + file_put_contents($latestFile, $genericVersion); + } + return $res; + } + if ($name && file_exists($latestFile)) { + $genericVersion = file_get_contents($latestFile); + if (preg_match("/^\d+\.\d+\.\d+$/", $genericVersion)) { + $filePath = public_path("uploads/desktop/{$genericVersion}/{$name}"); + if (file_exists($filePath)) { + return response()->download($filePath); + } + } + } + return abort(404); + } + /** * 提取所有中文 * @return array|string diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index da0a6baec..60cdfc939 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -50,5 +50,8 @@ class VerifyCsrfToken extends Middleware // 保存汇报 'api/report/store/', + + // 发布桌面端 + 'desktop/publish/', ]; } diff --git a/app/Module/Base.php b/app/Module/Base.php index 98d5985d0..f6eda4554 100755 --- a/app/Module/Base.php +++ b/app/Module/Base.php @@ -2301,6 +2301,9 @@ class Base case 'md': $type = ['md']; break; + case 'desktop': + $type = ['yml', 'yaml', 'dmg', 'blockmap', 'zip', 'exe', 'msi']; + break; case 'more': $type = [ 'text', 'md', 'markdown', @@ -2343,7 +2346,9 @@ class Base $fileSize = 0; } $scaleName = ""; - if ($param['fileName']) { + if ($param['fileName'] === true) { + $fileName = $file->getClientOriginalName(); + } elseif ($param['fileName']) { $fileName = $param['fileName']; } else { if ($param['scale'] && is_array($param['scale'])) { diff --git a/config/laravels.php b/config/laravels.php index e0e0f40a3..e407cd1b5 100644 --- a/config/laravels.php +++ b/config/laravels.php @@ -300,9 +300,9 @@ return [ 'log_level' => 4, 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))), 'document_root' => base_path('public'), - 'buffer_output_size' => 200 * 1024 * 1024, - 'socket_buffer_size' => 256 * 1024 * 1024, - 'package_max_length' => 200 * 1024 * 1024, + 'buffer_output_size' => 512 * 1024 * 1024, + 'socket_buffer_size' => 512 * 1024 * 1024, + 'package_max_length' => 512 * 1024 * 1024, 'reload_async' => true, 'max_wait_time' => 60, 'enable_reuse_port' => true, diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf index 0b20b89d6..3942ab18f 100644 --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -25,7 +25,7 @@ server { root /var/www/public; - client_max_body_size 200M; + client_max_body_size 512M; autoindex off; index index.html index.htm index.php; diff --git a/docker/php/php.ini b/docker/php/php.ini index 1636beaa3..7a76ff14a 100644 --- a/docker/php/php.ini +++ b/docker/php/php.ini @@ -700,7 +700,7 @@ auto_globals_jit = On ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size -post_max_size = 200M +post_max_size = 512M ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file @@ -852,7 +852,7 @@ file_uploads = On ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize -upload_max_filesize = 200M +upload_max_filesize = 512M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 100