mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-17 17:26:40 +08:00
修复首次安装程序报错问题
This commit is contained in:
parent
cd9d416bc1
commit
2cd6eafb02
@ -29,7 +29,21 @@ class InstallController
|
|||||||
$dbConfig = $request->post();
|
$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();
|
$is_succ_tb = $this->createTables();
|
||||||
@ -66,7 +80,7 @@ DB_PREFIX = mpay_
|
|||||||
|
|
||||||
DEFAULT_LANG = zh-cn
|
DEFAULT_LANG = zh-cn
|
||||||
EOT;
|
EOT;
|
||||||
file_put_contents($envPath, $envContent);
|
return file_put_contents($envPath, $envContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createTables()
|
private function createTables()
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
<title>程序安装</title>
|
<title>程序安装</title>
|
||||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||||
<style>
|
<style>
|
||||||
.logo1 {
|
.logo1 {
|
||||||
width: 180px !important;
|
width: 180px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 30px !important;
|
font-size: 30px !important;
|
||||||
@ -124,32 +124,27 @@
|
|||||||
// 监听提交
|
// 监听提交
|
||||||
form.on('submit(formSubmit)', function (data) {
|
form.on('submit(formSubmit)', function (data) {
|
||||||
const field = data.field;
|
const field = data.field;
|
||||||
// 提交表单
|
(async () => {
|
||||||
fetch('/install/install', {
|
const saveRes = await fetch('/install/install', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) });
|
||||||
method: 'POST',
|
const saveJson = await saveRes.json();
|
||||||
headers: {
|
if (saveJson.code == 0) {
|
||||||
'Content-Type': 'application/json'
|
const initRes = await fetch('/install/init', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(field) });
|
||||||
},
|
if (initRes.status != 200) { layer.msg('初始化失败,请检查配置'); return; }
|
||||||
body: JSON.stringify(field)
|
const initJson = await initRes.json();
|
||||||
}).then(res => {
|
if (initJson.code == 0) {
|
||||||
if (res.ok) {
|
layer.msg(initJson.msg, {
|
||||||
return res.json();
|
time: 1000,
|
||||||
}
|
end: () => {
|
||||||
throw new Error('数据库配置错误');
|
window.location.href = '/User/login';
|
||||||
}).then(res => {
|
}
|
||||||
if (res.code == 0) {
|
});
|
||||||
layer.msg(res.msg, {
|
} else {
|
||||||
time: 1000,
|
layer.msg(initJson.msg);
|
||||||
end: () => {
|
}
|
||||||
window.location.href = '/User/login';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
layer.msg(res.msg);
|
layer.msg(json.msg);
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
})()
|
||||||
layer.msg(err.message);
|
|
||||||
})
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user