diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index d6055f08..fe157e20 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -17,6 +17,7 @@ use Illuminate\Routing\Controller as BaseController; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; use Illuminate\Validation\ValidationException; use Illuminate\View\View; @@ -31,6 +32,9 @@ class Controller extends BaseController public function install(Request $request): View|Response { if (file_exists(base_path('installed.lock'))) { + if ($request->expectsJson()) { + return $this->error('Already installed. if you want to reinstall, please remove installed.lock file.'); + } abort(404); } @@ -67,13 +71,23 @@ class Controller extends BaseController 'account.email' => '管理员账号邮箱', 'account.password' => '管理员账号密码' ]); - } catch (ValidationException $e) { + + $data = collect($request->except('account'))->transform(fn($item, $key) => ['--'.$key => $item])->collapse(); + $stream = fopen('php://output', 'w'); + $exitCode = Artisan::call('lsky:install', $data->toArray(), new StreamOutput($stream)); + $response = str_replace(PHP_EOL, '
', ob_get_clean()); + $user = new User([ + 'name' => '超级管理员', + 'email' => $request->input('account.email'), + 'password' => Hash::make($request->input('account.password')), + 'is_adminer' => true, + ]); + $user->email_verified_at = date('Y-m-d H:i:s'); + $user->save(); + } catch (ValidationException|\Throwable $e) { + @unlink(base_path('installed.lock')); return $this->error($e->getMessage()); } - $data = collect($request->except('account'))->transform(fn($item, $key) => ['--'.$key => $item])->collapse(); - $stream = fopen('php://output', 'w'); - $exitCode = Artisan::call('lsky:install', $data->toArray(), new StreamOutput($stream)); - $response = str_replace(PHP_EOL, '
', ob_get_clean()); if (! $exitCode) { return $this->error('安装失败', compact('response')); } diff --git a/composer.lock b/composer.lock index 1d05fd4d..1352e8ad 100644 --- a/composer.lock +++ b/composer.lock @@ -6,6 +6,68 @@ ], "content-hash": "1fe0910fc1866099d3e670222bb1747d", "packages": [ + { + "name": "asm89/stack-cors", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/asm89/stack-cors.git", + "reference": "73e5b88775c64ccc0b84fb60836b30dc9d92ac4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/asm89/stack-cors/zipball/73e5b88775c64ccc0b84fb60836b30dc9d92ac4a", + "reference": "73e5b88775c64ccc0b84fb60836b30dc9d92ac4a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": "^7.2|^8.0", + "symfony/http-foundation": "^4|^5|^6", + "symfony/http-kernel": "^4|^5|^6" + }, + "require-dev": { + "phpunit/phpunit": "^7|^9", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Asm89\\Stack\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexander", + "email": "iam.asm89@gmail.com" + } + ], + "description": "Cross-origin resource sharing library and stack middleware", + "homepage": "https://github.com/asm89/stack-cors", + "keywords": [ + "cors", + "stack" + ], + "support": { + "issues": "https://github.com/asm89/stack-cors/issues", + "source": "https://github.com/asm89/stack-cors/tree/v2.1.1" + }, + "time": "2022-01-18T09:12:03+00:00" + }, { "name": "aws/aws-crt-php", "version": "v1.0.2", @@ -64,16 +126,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.209.29", + "version": "3.209.30", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "d2a7902ea12fbcfc26a0ae6a07d0e5f8c6e5e9a1" + "reference": "54c1e491b8de74360bbe94d727706db384c8d9a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d2a7902ea12fbcfc26a0ae6a07d0e5f8c6e5e9a1", - "reference": "d2a7902ea12fbcfc26a0ae6a07d0e5f8c6e5e9a1", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/54c1e491b8de74360bbe94d727706db384c8d9a8", + "reference": "54c1e491b8de74360bbe94d727706db384c8d9a8", "shasum": "", "mirrors": [ { @@ -155,9 +217,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.209.29" + "source": "https://github.com/aws/aws-sdk-php/tree/3.209.30" }, - "time": "2022-02-22T19:14:12+00:00" + "time": "2022-02-23T19:14:31+00:00" }, { "name": "brick/math", @@ -999,16 +1061,16 @@ }, { "name": "fruitcake/laravel-cors", - "version": "v2.1.0", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/fruitcake/laravel-cors.git", - "reference": "361d71f00a0eea8b74da26ae75d0d207c53aa5b3" + "reference": "783a74f5e3431d7b9805be8afb60fd0a8f743534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fruitcake/laravel-cors/zipball/361d71f00a0eea8b74da26ae75d0d207c53aa5b3", - "reference": "361d71f00a0eea8b74da26ae75d0d207c53aa5b3", + "url": "https://api.github.com/repos/fruitcake/laravel-cors/zipball/783a74f5e3431d7b9805be8afb60fd0a8f743534", + "reference": "783a74f5e3431d7b9805be8afb60fd0a8f743534", "shasum": "", "mirrors": [ { @@ -1018,7 +1080,7 @@ ] }, "require": { - "fruitcake/php-cors": "^1", + "asm89/stack-cors": "^2.0.1", "illuminate/contracts": "^6|^7|^8|^9", "illuminate/support": "^6|^7|^8|^9", "php": ">=7.2" @@ -1068,7 +1130,7 @@ ], "support": { "issues": "https://github.com/fruitcake/laravel-cors/issues", - "source": "https://github.com/fruitcake/laravel-cors/tree/v2.1.0" + "source": "https://github.com/fruitcake/laravel-cors/tree/v2.2.0" }, "funding": [ { @@ -1080,7 +1142,7 @@ "type": "github" } ], - "time": "2022-02-19T14:17:28+00:00" + "time": "2022-02-23T14:25:13+00:00" }, { "name": "fruitcake/php-cors", @@ -8676,16 +8738,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.11", + "version": "9.2.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f" + "reference": "deac8540cb7bd40b2b8cfa679b76202834fd04e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/665a1ac0a763c51afc30d6d130dac0813092b17f", - "reference": "665a1ac0a763c51afc30d6d130dac0813092b17f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/deac8540cb7bd40b2b8cfa679b76202834fd04e8", + "reference": "deac8540cb7bd40b2b8cfa679b76202834fd04e8", "shasum": "", "mirrors": [ { @@ -8747,7 +8809,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.11" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.13" }, "funding": [ { @@ -8755,7 +8817,7 @@ "type": "github" } ], - "time": "2022-02-18T12:46:09+00:00" + "time": "2022-02-23T17:02:38+00:00" }, { "name": "phpunit/php-file-iterator", @@ -9024,16 +9086,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.14", + "version": "9.5.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189" + "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1883687169c017d6ae37c58883ca3994cfc34189", - "reference": "1883687169c017d6ae37c58883ca3994cfc34189", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5ff8c545a50226c569310a35f4fa89d79f1ddfdc", + "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc", "shasum": "", "mirrors": [ { @@ -9055,7 +9117,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -9117,7 +9179,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.14" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.16" }, "funding": [ { @@ -9129,7 +9191,7 @@ "type": "github" } ], - "time": "2022-02-18T12:54:07+00:00" + "time": "2022-02-23T17:10:58+00:00" }, { "name": "sebastian/cli-parser", diff --git a/public/css/app.css b/public/css/app.css index 7321206a..040519ec 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -1181,6 +1181,9 @@ select { --tw-divide-opacity: 1; border-color: rgb(229 231 235 / var(--tw-divide-opacity)); } +.overflow-auto { + overflow: auto; +} .overflow-hidden { overflow: hidden; } @@ -1375,6 +1378,14 @@ select { --tw-bg-opacity: 1; background-color: rgb(156 163 175 / var(--tw-bg-opacity)); } +.bg-slate-900 { + --tw-bg-opacity: 1; + background-color: rgb(15 23 42 / var(--tw-bg-opacity)); +} +.bg-slate-700 { + --tw-bg-opacity: 1; + background-color: rgb(51 65 85 / var(--tw-bg-opacity)); +} .bg-opacity-75 { --tw-bg-opacity: 0.75; } @@ -1576,6 +1587,10 @@ select { font-size: 1rem; line-height: 1.5rem; } +.text-8xl { + font-size: 6rem; + line-height: 1; +} .font-medium { font-weight: 500; } @@ -1747,6 +1762,10 @@ select { --tw-text-opacity: 1; color: rgb(13 148 136 / var(--tw-text-opacity)); } +.text-teal-500 { + --tw-text-opacity: 1; + color: rgb(20 184 166 / var(--tw-text-opacity)); +} .underline { -webkit-text-decoration-line: underline; text-decoration-line: underline; diff --git a/resources/views/install.blade.php b/resources/views/install.blade.php index 65b4ac4a..85304b2b 100644 --- a/resources/views/install.blade.php +++ b/resources/views/install.blade.php @@ -1,27 +1,47 @@ - + + + + + + + Lsky Pro 安装程序 + + + + + + + + + + + + + +

Install Lsky Pro

-

运行环境检测

+

Step 1 > 运行环境检测

@foreach($extensions as $extension) -
-
-
- {{ $extension['name'] }} -

{{ $extension['intro'] }}

-
-
- @if($extension['result']) - - @else - - @endif -
-
-
+
+
+
+ {{ $extension['name'] }} +

{{ $extension['intro'] }}

+
+
+ @if($extension['result']) + + @else + + @endif +
+
+
@endforeach
@@ -35,7 +55,7 @@
+
+ + - @endpush - - + $('#install').click(function () { + $('#response').html('').addClass('hidden'); + axios.post('{{ route('install') }}', $('#installing form').serialize()).then(response => { + $('#response').addClass('hidden') + if (response.data.status) { + $('#installing').hide(); + $('#success').show(); + } else { + $('#response').html(response.data.message + ' ' +(response.data.data.response || '')).removeClass('hidden'); + } + }); + }); + +