仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ install/index.php 35.9 KB · 689 行 原始文件
Z zfhsh first commit 2 天前
1<?php
2// 版本徽章/文案的唯一来源:MPHX/BL.php 的 $WEBQB,发版只改那里
3include_once __DIR__ . '/../MPHX/BL.php';
4?>
5<!DOCTYPE html>
6<html lang="zh-CN">
7<head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <title>梦奈宝塔主机系统(MNBT) · 安装向导</title>
11 <link rel="stylesheet" href="./index.install.css" />
12</head>
13<body class="d-none">
14
15<!-- 背景柔和装饰 -->
16<div class="deco deco-1"></div>
17<div class="deco deco-2"></div>
18
19<div class="install-card">
20
21 <!-- 顶部品牌栏 -->
22 <header class="install-header">
23 <div class="brand">
24 <div class="brand-logo"><img src="/imsetes/images/logo-ico.png" alt="MNBT" /></div>
25 <div>
26 <h1>MNBT 梦奈宝塔主机系统</h1>
27 <p>安装向导 · 欢迎使用</p>
28 </div>
29 </div>
30 <span class="ver-badge">V<span class="mn-vs"><?=mnbt_version_num()?></span></span>
31 </header>
32
33 <!-- 横向步骤条 -->
34 <div class="steps install-page-num">
35 <div class="step">
36 <div class="dot"><span>1</span></div>
37 <div class="label"><b>欢迎</b><i>系统介绍</i></div>
38 </div>
39 <div class="step">
40 <div class="dot"><span>2</span></div>
41 <div class="label"><b>许可协议</b><i>阅读条款</i></div>
42 </div>
43 <div class="step">
44 <div class="dot"><span>3</span></div>
45 <div class="label"><b>环境监测</b><i>兼容检测</i></div>
46 </div>
47 <div class="step">
48 <div class="dot"><span>4</span></div>
49 <div class="label"><b>数据库</b><i>连接信息</i></div>
50 </div>
51 <div class="step">
52 <div class="dot"><span>5</span></div>
53 <div class="label"><b>站点配置</b><i>管理员</i></div>
54 </div>
55 <div class="step">
56 <div class="dot"><span>6</span></div>
57 <div class="label"><b>等待安装</b><i>执行安装</i></div>
58 </div>
59 <div class="step">
60 <div class="dot"><span>7</span></div>
61 <div class="label"><b>完成</b><i>安装成功</i></div>
62 </div>
63 </div>
64
65 <!-- 主体 -->
66 <div class="install-body">
67 <div class="progress-row progress-text">
68 <span>步骤 1 / 7</span>
69 <span class="pct">0%</span>
70 </div>
71 <div class="progress-track">
72 <div class="progress-fill progress-bar-anim" style="width: 0;"></div>
73 </div>
74
75 <div id="content-page-main">
76
77 <!-- 1 欢迎 -->
78 <div>
79 <div class="panel-head">
80 <div class="panel-icon">
81 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"/><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/></svg>
82 </div>
83 <div>
84 <h2>欢迎使用 梦奈宝塔主机系统</h2>
85 <p>版本 V<span class="mn-vs"><?=mnbt_version_num()?></span> &middot; 约需 2 分钟</p>
86 </div>
87 </div>
88 <p class="welcome-lead">
89 欢迎使用由梦奈基于光年 V4 框架原创的 <b>MN 宝塔主机系统</b>(简称 MNBT)!
90 本系统免费发布于网络,提供虚拟主机全生命周期管理与自动化运维能力。
91 </p>
92 <p class="welcome-links">
93 官网:<a target="_blank" href="https://mf.mengnai.top/">mf.mengnai.top</a>
94 &nbsp;·&nbsp; QQ群:994752422
95 </p>
96 <div class="tip-box warn d-none mn-install-lock">
97 <span class="mdi">⚠</span>
98 <span>您已经安装了本系统,如需重新安装请删除 install 目录下的 install.lock 文件,然后刷新本页面。</span>
99 </div>
100 </div>
101
102 <!-- 2 许可协议 -->
103 <div>
104 <div class="panel-head">
105 <div class="panel-icon">
106 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>
107 </div>
108 <div>
109 <h2>许可协议</h2>
110 <p>请阅读并接受以下条款</p>
111 </div>
112 </div>
113 <div class="license-box">
114 <iframe src="/xy.html"></iframe>
115 </div>
116 <div class="agree-card use-terms must">
117 <div class="check">
118 <svg viewBox="0 0 11 9" fill="none"><path d="M1 4L4 7L10 1" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
119 </div>
120 <div>
121 <b>我已阅读并同意上述许可协议的所有条款</b>
122 <small>继续安装即表示您接受本协议</small>
123 </div>
124 </div>
125 </div>
126
127 <!-- 3 系统环境监测 -->
128 <div>
129 <div class="panel-head">
130 <div class="panel-icon">
131 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
132 </div>
133 <div>
134 <h2>系统环境监测</h2>
135 <p>检测系统环境是否满足运行要求</p>
136 </div>
137 </div>
138 <div class="sys-list install-system-info">
139 <div class="sys-item php_vs">
140 <div class="s-ico">
141 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/></svg>
142 </div>
143 <div>
144 <b>PHP</b>
145 <span>需要 PHP 7.4 及以上</span>
146 </div>
147 </div>
148 <div class="sys-item curl_exec">
149 <div class="s-ico">
150 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"/><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"/></svg>
151 </div>
152 <div>
153 <b>curl_exec</b>
154 <span>用于与宝塔 API 通信</span>
155 </div>
156 </div>
157 <div class="sys-item mn_link">
158 <div class="s-ico">
159 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>
160 </div>
161 <div>
162 <b>MNBT 更新支持</b>
163 <span>用户在线升级系统至最新版本</span>
164 </div>
165 </div>
166 </div>
167 </div>
168
169 <!-- 4 数据库配置 -->
170 <div>
171 <div class="panel-head">
172 <div class="panel-icon">
173 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5v14a9 3 0 0 0 18 0V5"/><path d="M3 12a9 3 0 0 0 18 0"/></svg>
174 </div>
175 <div>
176 <h2>数据库配置</h2>
177 <p>请填写数据库连接信息</p>
178 </div>
179 </div>
180 <form class="form-database">
181 <div class="form-item">
182 <label for="db_host">数据库地址</label>
183 <input id="db_host" type="text" placeholder="数据库连接地址,例如 127.0.0.1" value="localhost" required />
184 </div>
185 <div class="form-item">
186 <label for="db_port">数据库端口</label>
187 <input id="db_port" type="text" placeholder="数据库端口,例如 3306" value="3306" required />
188 </div>
189 <div class="form-item">
190 <label for="db_user">数据库用户名</label>
191 <input id="db_user" type="text" placeholder="数据库用户名" value="" required />
192 </div>
193 <div class="form-item">
194 <label for="db_name">数据库名</label>
195 <input id="db_name" type="text" placeholder="数据库名" value="" required />
196 </div>
197 <div class="form-item">
198 <label for="db_pwd">数据库密码</label>
199 <input id="db_pwd" type="text" placeholder="数据库密码" value="" required />
200 </div>
201 </form>
202 </div>
203
204 <!-- 5 站点与管理员 -->
205 <div>
206 <div class="panel-head">
207 <div class="panel-icon">
208 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
209 </div>
210 <div>
211 <h2>站点与管理员</h2>
212 <p>设置网站信息与后台登录账号</p>
213 </div>
214 </div>
215 <form class="form-site">
216 <div class="form-item">
217 <label for="site_name">控制面板名称</label>
218 <input id="site_name" type="text" placeholder="例如:梦奈主机控制面板" value="MNBT 控制面板" maxlength="80" required />
219 </div>
220 <div class="form-item">
221 <label for="site_qq">站长 QQ(选填)</label>
222 <input id="site_qq" type="text" placeholder="用于用户联系" value="" maxlength="20" />
223 </div>
224 <div class="form-item">
225 <label for="site_gg">网站公告(选填)</label>
226 <textarea id="site_gg" rows="2" placeholder="安装后显示在前台/后台的公告" maxlength="2000"></textarea>
227 </div>
228 <div class="form-item">
229 <label for="admin_user">管理员账号</label>
230 <input id="admin_user" type="text" placeholder="后台登录用户名" value="admin" maxlength="50" required />
231 </div>
232 <div class="form-item">
233 <label for="admin_pwd">管理员密码</label>
234 <input id="admin_pwd" type="password" placeholder="至少 6 位" value="" minlength="6" maxlength="64" required />
235 </div>
236 <div class="form-item">
237 <label for="admin_pwd2">确认密码</label>
238 <input id="admin_pwd2" type="password" placeholder="再次输入密码" value="" minlength="6" maxlength="64" required />
239 </div>
240 </form>
241 </div>
242
243 <!-- 6 安装模式 -->
244 <div>
245 <div class="panel-head">
246 <div class="panel-icon">
247 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"/><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/></svg>
248 </div>
249 <div>
250 <h2>安装模式选择</h2>
251 <p>选择安装方式或点击下一步</p>
252 </div>
253 </div>
254 <div class="tip-box info new-install-tip">
255 <span class="mdi">✓</span>
256 <span>数据库与站点信息已就绪,点击「开始安装」即可完成安装。</span>
257 </div>
258 <div class="new-install-select d-none">
259 <div class="tip-box warn">
260 <span class="mdi">⚠</span>
261 <span>检测到您已安装过梦奈宝塔主机系统,请选择操作方式。</span>
262 </div>
263 <div class="choice-list install-type-btn">
264 <div class="choice-item use-terms mn-upgrade">
265 <div class="check"><svg viewBox="0 0 11 9" fill="none"><path d="M1 4L4 7L10 1" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>
266 <div>
267 <b>覆盖更新(保留数据升级到 <?=mnbt_version()?>)<span class="mn-upgrade-detail"></span></b>
268 <small>添加 <?=mnbt_version()?> 新增表和字段,自动补全缺失项,保留所有已有数据</small>
269 </div>
270 </div>
271 <div class="choice-item use-terms mn-repair">
272 <div class="check"><svg viewBox="0 0 11 9" fill="none"><path d="M1 4L4 7L10 1" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>
273 <div>
274 <b>修复数据库(补齐缺失的表和字段)</b>
275 <small>仅扫描并创建缺失的数据库表和字段,不覆盖已有数据</small>
276 </div>
277 </div>
278 <div class="choice-item use-terms mn-new-install">
279 <div class="check"><svg viewBox="0 0 11 9" fill="none"><path d="M1 4L4 7L10 1" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>
280 <div>
281 <b>强制全新安装</b>
282 <small>清空所有旧数据,全新创建数据库表(不可恢复)</small>
283 </div>
284 </div>
285 </div>
286 </div>
287 </div>
288
289 <!-- 7 完成 -->
290 <div>
291 <div class="done-box">
292 <div class="done-ico">
293 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21.801 10A10 10 0 1 1 17 3.335"/><path d="m9 11 3 3L22 4"/></svg>
294 </div>
295 <h2>安装成功!</h2>
296 <p>梦奈宝塔主机系统已安装到您的站点中</p>
297 <p>请妥善保存管理员账号;为安全建议删除站点下的 install 目录</p>
298 </div>
299 <div class="admin-info">
300 <p class="ai-title">管理员登录信息</p>
301 <p class="ai-row">后台地址:<code>域名/admin</code></p>
302 <p class="ai-row">账号:<code class="install-admin-user">admin</code></p>
303 <p class="ai-row">密码:<code class="install-admin-pwd">(安装时设置)</code></p>
304 <p class="ai-row">控制面板名称:<code class="install-site-name">—</code></p>
305 </div>
306 <div class="entry-list">
307 <a class="entry primary" href="../admin" target="_blank">
308 <div class="e-ico"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg></div>
309 <div><b>访问应用后台</b><small>使用上方账号登录</small></div>
310 <span class="e-arrow"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg></span>
311 </a>
312 <a class="entry" href="../user" target="_blank">
313 <div class="e-ico"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg></div>
314 <div><b>访问主机控制面板</b><small>默认地址:域名/user</small></div>
315 <span class="e-arrow"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg></span>
316 </a>
317 <a class="entry" href="http://mf.mengnai.top/" target="_blank">
318 <div class="e-ico"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg></div>
319 <div><b>访问官网</b><small>梦奈宝塔主机系统官方网站</small></div>
320 <span class="e-arrow"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg></span>
321 </a>
322 <a class="entry" href="http://wpa.qq.com/msgrd?v=3&uin=994752422&site=qq&menu=yes" target="_blank">
323 <div class="e-ico"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/></svg></div>
324 <div><b>加入 QQ 交流群</b><small>与数千名用户交流分享</small></div>
325 <span class="e-arrow"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg></span>
326 </a>
327 </div>
328 </div>
329
330 </div>
331 </div>
332
333 <!-- 底部操作区 -->
334 <footer class="install-foot">
335 <div class="tip-msg next-tips">
336 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
337 <span>您必须填写完整后才能继续安装</span>
338 </div>
339 <button class="btn-next" id="btn-install-next">开始安装 →</button>
340 </footer>
341
342</div>
343
344<script src="/imsetes/js/jquery.min.js"></script>
345<script>
346 let curr_index=1;
347 const MAX_INDEX=6;
348 const COUNT_INDEX=7;
349 let siteConfigCache={};
350 const NEXT_BTN_FUN={
351 //禁用下一步按钮
352 disabled: ()=>{
353 $('#btn-install-next').prop('disabled',true);
354 },
355 //取消禁用下一步按钮
356 removeDisabled: ()=>{
357 $('#btn-install-next').prop('disabled',false).html(curr_index!==1?'下一步 →':'开始安装 →');
358 },
359 //按钮显示加载信息并禁用
360 loading: (msg)=>{
361 $('#btn-install-next').prop('disabled',true).html(msg || '加载中...');
362 },
363 //显示提示
364 TipsShow:(msg)=>{
365 $('.next-tips').show().children('span').html(msg).parents('div.mt-auto').removeClass('justify-end').addClass('justify-between');
366 },
367 //禁用提示
368 TipsHide:()=>{
369 $('.next-tips').hide().parents('div.mt-auto').removeClass('justify-between').addClass('justify-end');
370 }
371 }
372
373 //初始化
374 $(async ()=>{
375 refresh();
376 $(`#content-page-main>div:eq(${curr_index-1})`).addClass('page-active');
377 $('body.d-none').removeClass('d-none');
378 let info=await request('index');
379 if(info.data){
380 $('.mn-vs').html(info.data.vs);
381 if(info.data.is_install){
382 $('.mn-install-lock').removeClass('d-none');
383 NEXT_BTN_FUN.loading('您已安装!');
384 }
385 }
386 });
387
388 const refresh=()=>{
389 NEXT_BTN_FUN.TipsHide();
390 $(`.install-page-num>div.curr-page-active`).removeClass('curr-page-active');
391 $(`.install-page-num>div:eq(${curr_index-1})`).addClass('curr-page-active');
392
393 let progress=Math.floor(((curr_index-1)/(COUNT_INDEX-1))*100);
394 $('.progress-bar-anim').css('width',`${progress}%`);
395 $('.progress-text>span:first,.progress-text-info').html(`步骤 ${curr_index} / 7`);
396 $('.progress-text>span:last').html(`${progress}%`);
397 let btn_text_arr={
398 1:'开始安装 →',
399 6:'完成安装 →',
400 };
401 let btn=$("#btn-install-next");
402 btn.html(btn_text_arr[curr_index] || '下一步 →');
403 if(curr_index===7)btn.hide();
404 else btn.show();
405 }
406
407 //点击下一页按钮
408 $('#btn-install-next').on('click', async function() {
409 if (curr_index>MAX_INDEX)return;
410 NEXT_BTN_FUN.disabled();
411
412 //提交数据库配置信息
413 if (curr_index===4){
414 let data={};
415 let inputTotal=$(".form-database input").each(function () {
416 let ts=$(this);
417 let val=$(this).val();
418 if (val === '') return false;
419 data[ts.attr('id')]=val;
420 }).length;
421 if (Object.keys(data).length<inputTotal) {
422 return NEXT_BTN_FUN.TipsShow('请将表单填写完整,表单可下滑');
423 }
424 NEXT_BTN_FUN.loading('连接中....');
425 let result = await request('database_info_wire',data);
426 if (result.code!==1){
427 NEXT_BTN_FUN.removeDisabled();
428 return NEXT_BTN_FUN.TipsShow(result.msg);
429 }
430 if(result.data.in_table){
431 console.log('[安装检测] 发现已有数据表', result.data);
432 $('.new-install-select').removeClass('d-none');
433 $('.new-install-tip').addClass('d-none');
434 NEXT_BTN_FUN.disabled();
435 NEXT_BTN_FUN.TipsShow('正在检测更新项...');
436 let upgradeInfo = await request('check_upgrade');
437 console.log('[升级检测] 结果:', upgradeInfo);
438 if(upgradeInfo.code === 1 && upgradeInfo.data){
439 if(upgradeInfo.data.need_upgrade){
440 let detail = [];
441 if(upgradeInfo.data.missing_tables && upgradeInfo.data.missing_tables.length>0){
442 detail.push('缺'+upgradeInfo.data.missing_tables.length+'张表');
443 }
444 if(upgradeInfo.data.missing_columns && upgradeInfo.data.missing_columns.length>0){
445 detail.push('缺'+upgradeInfo.data.missing_columns.length+'个字段');
446 }
447 $('.mn-upgrade-detail').text(detail.length>0 ? '('+detail.join(',')+')' : '');
448 $('.mn-upgrade').parent().show();
449 $('.mn-repair').parent().show();
450 } else {
451 console.log('[升级检测] 数据完整,无需升级');
452 $('.mn-upgrade-detail').text('(当前已是 <?=mnbt_version()?>,无需升级)');
453 $('.mn-upgrade').parent().show();
454 $('.mn-repair').parent().show();
455 }
456 } else {
457 console.warn('[升级检测] 检测失败,显示全部选项', upgradeInfo);
458 $('.mn-upgrade').parent().show();
459 $('.mn-repair').parent().show();
460 }
461 NEXT_BTN_FUN.TipsShow('请在上方选择一个操作方式');
462 } else {
463 console.log('[安装检测] 全新数据库,无旧表');
464 $('.new-install-select').addClass('d-none');
465 $('.new-install-tip').removeClass('d-none');
466 }
467 }else if(curr_index===5){
468 let siteCheck=validateSiteForm(true);
469 if(!siteCheck.ok){
470 NEXT_BTN_FUN.removeDisabled();
471 return NEXT_BTN_FUN.TipsShow(siteCheck.msg);
472 }
473 siteConfigCache=siteCheck.data;
474 }else if(curr_index===6){
475 let install_mode = 'install';
476 let repair_only = false;
477 if(!$('.new-install-select').hasClass('d-none')){
478 if($('.mn-upgrade.use-terms').hasClass('terms-yes')){
479 install_mode = 'upgrade';
480 } else if($('.mn-repair.use-terms').hasClass('terms-yes')){
481 install_mode = 'upgrade';
482 repair_only = true;
483 } else if($('.mn-new-install.use-terms').hasClass('terms-yes')){
484 install_mode = 'install';
485 } else {
486 install_mode = 'skip';
487 }
488 }
489 if(repair_only){
490 NEXT_BTN_FUN.loading('修复中...');
491 let result = await request('repair');
492 if(result.code!==1){
493 NEXT_BTN_FUN.removeDisabled();
494 return NEXT_BTN_FUN.TipsShow(result.msg);
495 }
496 $('.install-admin-user').text(siteConfigCache.admin_user || '(保持原设置)');
497 $('.install-admin-pwd').text('(保持原设置)');
498 $('.install-site-name').text(siteConfigCache.site_name || '—');
499 next(curr_index++);
500 refresh();
501 if (curr_index===6)NEXT_BTN_FUN.removeDisabled();
502 return;
503 }
504 NEXT_BTN_FUN.loading(install_mode==='upgrade'?'升级中...':'安装中...');
505 let payload=Object.assign({
506 install_mode: install_mode
507 }, siteConfigCache);
508 let result = await request('install', payload);
509 if(result.code!==1){
510 NEXT_BTN_FUN.removeDisabled();
511 return NEXT_BTN_FUN.TipsShow(result.msg);
512 }
513 $('.install-admin-user').text(siteConfigCache.admin_user || 'admin');
514 $('.install-admin-pwd').text(siteConfigCache.admin_pwd || '(已设置)');
515 $('.install-site-name').text(siteConfigCache.site_name || '—');
516 }
517 //进入下一页
518 next(curr_index++);
519 refresh();
520 if (curr_index===6){
521 if(!$('.new-install-select').hasClass('d-none') && !$('.mn-upgrade.use-terms').hasClass('terms-yes') && !$('.mn-repair.use-terms').hasClass('terms-yes') && !$('.mn-new-install.use-terms').hasClass('terms-yes')){
522 NEXT_BTN_FUN.disabled();
523 NEXT_BTN_FUN.TipsShow('请在上方选择一个操作方式');
524 } else {
525 NEXT_BTN_FUN.removeDisabled();
526 }
527 }
528 else if (curr_index===5){
529 NEXT_BTN_FUN.TipsShow('请填写站点信息与管理员账号');
530 checkSiteFormValidation();
531 }
532 else if (curr_index===4)NEXT_BTN_FUN.TipsShow('您必须将表单填写完整后才能继续安装,表单可下滑');
533 else if (curr_index===3)await systemCheck();
534 else if (curr_index===2) NEXT_BTN_FUN.TipsShow('您必须同意许可协议才能继续安装');
535 });
536
537
538 //进入到下一页(先移除旧面板激活态,避免多个面板同时在文档流中堆积)
539 const next=(index)=>{
540 let currDom=$('#content-page-main>div.page-active');
541 let nextDom=$(`#content-page-main>div:eq(${index})`);
542 currDom.removeClass('page-active').css('animation-name','exit');
543 nextDom.css('animation-name','entry').addClass('page-active');
544 }
545
546 const request=async (action,data={})=>{
547 try{
548 return await $.ajax({
549 url: './install.api.php?action='+action,
550 type: 'POST',
551 data: data,
552 dataType: 'json',
553 }).then((data)=>{
554 if (data.redirect!==null){
555 if (data.redirect!==curr_index){
556 NEXT_BTN_FUN.TipsShow(data.msg);
557 setTimeout(()=>{
558 alert(data.msg)
559 window.location.reload();
560 },1000)
561 }
562 }
563 return data;
564 });
565 }catch(error){
566 console.log(error);
567 NEXT_BTN_FUN.TipsShow('安装模块异常,请联系官方,QQ群:994752422');
568 alert('安装模块异常,请联系官方,QQ群:994752422');
569 return {code: -1, msg: '网络异常,请刷新重试'};
570 }
571 }
572
573 //协议相关监听
574 $('.use-terms').on('click', function() {
575 let thisClass=$(this);
576 // 安装类型按钮:互斥选择(选升级则取消重装,选重装则取消升级)
577 if(thisClass.hasClass('mn-upgrade') || thisClass.hasClass('mn-repair') || thisClass.hasClass('mn-new-install')){
578 if(thisClass.hasClass('terms-yes')) {
579 thisClass.removeClass('terms-yes');
580 NEXT_BTN_FUN.disabled();
581 NEXT_BTN_FUN.TipsShow('请在上方选择一个操作方式');
582 } else {
583 $('.install-type-btn .use-terms').removeClass('terms-yes');
584 thisClass.addClass('terms-yes');
585 NEXT_BTN_FUN.removeDisabled();
586 NEXT_BTN_FUN.TipsHide();
587 }
588 return;
589 }
590 if(thisClass.hasClass('terms-yes')) {
591 thisClass.removeClass('terms-yes').next().removeClass('d-none');
592 if (thisClass.hasClass('must')) {
593 NEXT_BTN_FUN.disabled();
594 NEXT_BTN_FUN.TipsShow('您必须同意许可协议才能继续安装');
595 }
596 }else{
597 thisClass.addClass('terms-yes').next().addClass('d-none');
598 if (thisClass.hasClass('must')) {
599 NEXT_BTN_FUN.removeDisabled();
600 NEXT_BTN_FUN.TipsHide();
601 }
602 }
603 });
604
605 const checkFormValidation = function() {
606 let isAllFilled = true;
607 $(".form-database input").each(function () {
608 if ($(this).val() === '') {
609 isAllFilled = false;
610 return false;
611 }
612 });
613 if (isAllFilled) {
614 NEXT_BTN_FUN.removeDisabled();
615 NEXT_BTN_FUN.TipsHide();
616 $('.next-tips').hide();
617 } else {
618 NEXT_BTN_FUN.disabled();
619 $('.next-tips').show();
620 NEXT_BTN_FUN.TipsShow('您必须将表单填写完整后才能继续安装,表单可下滑');
621 }
622 return isAllFilled;
623 };
624
625 $(".form-database input").on("change input", checkFormValidation);
626
627 const validateSiteForm = function(strict) {
628 let site_name=($('#site_name').val()||'').trim();
629 let site_qq=($('#site_qq').val()||'').trim();
630 let site_gg=($('#site_gg').val()||'').trim();
631 let admin_user=($('#admin_user').val()||'').trim();
632 let admin_pwd=$('#admin_pwd').val()||'';
633 let admin_pwd2=$('#admin_pwd2').val()||'';
634 if(!site_name) return {ok:false, msg:'请填写控制面板名称'};
635 if(!admin_user) return {ok:false, msg:'请填写管理员账号'};
636 if(admin_user.length<3) return {ok:false, msg:'管理员账号至少 3 位'};
637 if(!/^[a-zA-Z0-9_\u4e00-\u9fa5-]+$/.test(admin_user)) return {ok:false, msg:'管理员账号含非法字符'};
638 if(admin_pwd.length<6) return {ok:false, msg:'管理员密码至少 6 位'};
639 if(admin_pwd!==admin_pwd2) return {ok:false, msg:'两次输入的密码不一致'};
640 if(site_qq && !/^\d{5,15}$/.test(site_qq)) return {ok:false, msg:'QQ 号格式不正确'};
641 return {
642 ok:true,
643 data:{site_name, site_qq, site_gg, admin_user, admin_pwd}
644 };
645 };
646
647 const checkSiteFormValidation = function() {
648 if(curr_index!==5) return;
649 let r=validateSiteForm(true);
650 if(r.ok){
651 NEXT_BTN_FUN.removeDisabled();
652 NEXT_BTN_FUN.TipsHide();
653 }else{
654 NEXT_BTN_FUN.disabled();
655 NEXT_BTN_FUN.TipsShow(r.msg);
656 }
657 return r.ok;
658 };
659
660 $(".form-site input, .form-site textarea").on("change input", checkSiteFormValidation);
661
662 const systemCheck=async ()=>{
663 let result = await request('system');
664 $('.install-system-info>div').addClass('yes');
665 if (!result.data.vs.is_vs_install)$('.php_vs').addClass('no');
666 if (!result.data.curl_exec)$('.curl_exec').addClass('no');
667 if (!result.data.mn_link)$('.mn_link').addClass('mn-no');
668 $('.install-system-info>div.no').length<=0 && NEXT_BTN_FUN.removeDisabled();
669 }
670
671 //防抖
672 function debounce(func, wait) {
673 let timeout;
674 return function(...args) {
675 if (timeout) clearTimeout(timeout);
676 timeout = setTimeout(() => {
677 func.apply(this, args);
678 }, wait);
679 };
680 }
681
682 //5秒后强制显示页面
683 setTimeout(()=>{
684 $('body.d-none').removeClass('d-none');
685 },5000);
686</script>
687
688</body>
689</html>