From 57ea9a3f470d41cf242e1de5857d9edfb3b84ca6 Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:53:24 +0800 Subject: [PATCH] feat(install): optimize installation page and add .env configuration support - Update installation page layout and styling - Add support for reading database configuration from .env file - Improve error handling and user feedback during installation process - Refactor JavaScript code for better readability and performance --- app/index/controller/Install.php | 14 +++- .../common/css/{insatll.css => install.css} | 65 +++++++++++++------ view/index/install/index.html | 33 ++++++---- 3 files changed, 74 insertions(+), 38 deletions(-) rename public/static/common/css/{insatll.css => install.css} (63%) diff --git a/app/index/controller/Install.php b/app/index/controller/Install.php index f19d288..0219d4e 100644 --- a/app/index/controller/Install.php +++ b/app/index/controller/Install.php @@ -22,8 +22,8 @@ class Install extends BaseController // $this->redirect('/'); $isInstall = true; $errorInfo = '已安装系统,如需重新安装请删除文件:/config/install/lock/install.lock,或者删除 /install 路由'; - }elseif (version_compare(phpversion(), '8.0.0', '<')) { - $errorInfo = 'PHP版本不能小于8.0.0'; + }elseif (version_compare(phpversion(), '8.1.0', '<')) { + $errorInfo = 'PHP版本不能小于8.1.0'; }elseif (!extension_loaded("PDO")) { $errorInfo = '当前未开启PDO,无法进行安装'; } @@ -31,8 +31,16 @@ class Install extends BaseController $errorInfo = '.env 文件不存在,请先配置 .env 文件'; } if (!$request->isAjax()) { + $envInfo = [ + 'DB_HOST' => $isInstall ? '' : env('DB_HOST', '127.0.0.1'), + 'DB_NAME' => $isInstall ? '' : env('DB_NAME', 'easyadmin8'), + 'DB_USER' => $isInstall ? '' : env('DB_USER', 'root'), + 'DB_PASS' => $isInstall ? '' : env('DB_PASS', 'root'), + 'DB_PORT' => $isInstall ? '' : env('DB_PORT', 3306), + 'DB_PREFIX' => $isInstall ? '' : env('DB_PREFIX', 'ea8_'), + ]; $currentHost = '://'; - $result = compact('errorInfo', 'currentHost', 'isInstall'); + $result = compact('errorInfo', 'currentHost', 'isInstall', 'envInfo'); return view('index/install/index', $result); } if ($errorInfo) $this->error($errorInfo); diff --git a/public/static/common/css/insatll.css b/public/static/common/css/install.css similarity index 63% rename from public/static/common/css/insatll.css rename to public/static/common/css/install.css index 7be0649..22285d5 100644 --- a/public/static/common/css/insatll.css +++ b/public/static/common/css/install.css @@ -1,31 +1,37 @@ -body{ +body { text-align: center; } -h1{ + +h1 { margin-top: 20px; } -h1 img{ + +h1 img { width: 120px; height: 120px; } + h2 { font-size: 28px; font-weight: normal; color: #3C5675; margin-bottom: 0 } -.content{ + +.content { margin-top: 20px; } -.content p{ + +.content p { margin: 20px; } -.content form{ - margin:0 auto; + +.content form { width: 500px; - margin-bottom: 20px; + margin: 0 auto 20px; } -.content form .bg{ + +.content form .bg { margin-top: 20px; background-color: #fff; border: 1px solid #fff; @@ -33,51 +39,68 @@ h2 { padding: 14px 14px; box-shadow: 0 0 8px #cccccc; } -.content form .layui-form-item:last-child{ - margin-bottom:0!important; + +.content form .bg .layui-card { + background-color: #fafafa; + color: #ff8080; + font-size: 15px; + font-weight: bold; } -.content form .layui-btn{ + +.content form .layui-form-item:last-child { + margin-bottom: 0 !important; +} + +.content form .layui-btn { margin-top: 20px; } -.content .layui-elem-field legend{ + +.content .layui-elem-field legend { font-size: 16px; color: #8a8a8a; } -.content .tips{ + +.content .tips { float: left; margin-top: 5px; margin-bottom: 5px; font-size: 12px; color: #eca6a6 } -.content .admin-tips{ + +.content .admin-tips { float: left; margin-top: 5px; margin-bottom: 5px; font-size: 12px; color: #eca6a6 } -.content .desc{ + +.content .desc { font-size: 16px; color: #4E5465; margin-bottom: 30px; } -.content .desc a{ + +.content .desc a { color: #07adeb; margin-right: 10px; } -.content .desc a:first-child{ + +.content .desc a:first-child { margin-left: 10px; } -.error{ + +.error { background: #D83E3E; color: #fff; padding: 15px 20px; border-radius: 5px; margin-bottom: 20px; } -@media screen and (max-width:768px) { - .content form{ + +@media screen and (max-width: 768px) { + .content form { width: 95%; } } \ No newline at end of file diff --git a/view/index/install/index.html b/view/index/install/index.html index cf74ea6..07c8ad6 100644 --- a/view/index/install/index.html +++ b/view/index/install/index.html @@ -6,8 +6,8 @@ - - + +

@@ -32,45 +32,50 @@ {/if}
+
+
+ 自动读取 .env 配置,不需要手动创建数据库 +
+
- +
- +
- +
- +
- +
- +
@@ -111,11 +116,11 @@
- +