From 2cd6eafb026c940a9ce077a950df3746d80f35fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=80=E6=9C=AF=E8=80=81=E8=83=A1?= <1094551889@qq.com> Date: Thu, 5 Dec 2024 14:55:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=A8=8B=E5=BA=8F=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/InstallController.php | 18 ++++++++-- view/Install/index.html | 49 +++++++++++++--------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/app/controller/InstallController.php b/app/controller/InstallController.php index 6db1067..75ce509 100644 --- a/app/controller/InstallController.php +++ b/app/controller/InstallController.php @@ -29,7 +29,21 @@ class InstallController $dbConfig = $request->post(); // 保存数据库配置信息到配置文件 - $this->saveDbConfig($dbConfig); + if ($this->saveDbConfig($dbConfig) === false) { + return json(backMsg(1, '配置保存失败')); + } else { + return json(backMsg(0, '配置保存成功')); + }; + } + // 初始化数据库 + public function init(Request $request) + { + // 检查是否已经安装过 + if ($this->checkLock()) { + return backMsg(1, '已经安装'); + }; + // 获取表单提交的数据库配置信息 + $dbConfig = $request->post(); // 连接数据库并建表 $is_succ_tb = $this->createTables(); @@ -66,7 +80,7 @@ DB_PREFIX = mpay_ DEFAULT_LANG = zh-cn EOT; - file_put_contents($envPath, $envContent); + return file_put_contents($envPath, $envContent); } private function createTables() diff --git a/view/Install/index.html b/view/Install/index.html index d116df3..373ea8f 100644 --- a/view/Install/index.html +++ b/view/Install/index.html @@ -6,9 +6,9 @@ 程序安装