feat: 接入PostgreSQL/MariaDB + 首次安装向导 + 登录页独立 + 设置重构 + 文件夹识别兜底
- 数据库层 lib/Db.php:统一 PDO 支持 pgsql/mysql/sqlite,连接参数存 data/db.json (git-ignored),migrate 建 ny_settings/ny_roster 表(三方言兼容 upsert) - 配置/名单读写:bootstrap ny_load_config/ny_save_config 与 Roster 均改为 '数据库可用则走 DB、否则回退 data/config.json/roster.json' 的文件降级模式 - 首次安装向导 install.php:选择存储后端(文件/PostgreSQL/MariaDB),测试连接+ 建表+写入卷王连接信息与默认满分;支持 ?force=1 重新配置 - 登录门分离:新增 login.php 独立登录页(仅需密码,账号预填)+logout.php+ 会话(ny_session_start/ny_is_auth/ny_login/ny_logout);index/dashboard 未安装 跳 install、未登录跳 login;api.php 加会话保护与 auth_check - 设置重构:删除卷王系统地址/接口前缀/登录账号/登录密码(连接信息由安装向导 配置);新增布局配置(默认/成绩明细与缺考名单同行)与各试卷独立满分列表(默认 分数作用于全部);工具栏布局下拉移除 - 文件夹识别兜底:app.js/dashboard.php 双策略 — mode 含 folder 优先,缺省时用 parent_id 引用反推(应对部分版本无 mode 字段);空文件夹自动隐藏 验证:php -l 全部通过、node --check app.js 通过;SQLite 等价实测 Db 层 (migrate/config upsert/Roster 读写/ny_load_config)与会话辅助函数全部PASS; e2e(内置服务器)验证路由:未装→install、装完→login、index/dashboard 未登录 跳转、api 401 保护、?force=1 重配、logout 302 均正确。本机无真实 pgsql/mysql 服务器,DB 连接按部署环境实测。
This commit is contained in:
@@ -2,6 +2,15 @@
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
if (!ny_is_installed()) {
|
||||
header('Location: install.php');
|
||||
exit;
|
||||
}
|
||||
if (!ny_is_auth()) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$cfg = ny_load_config();
|
||||
$rosterCount = Roster::count();
|
||||
?>
|
||||
@@ -33,29 +42,6 @@ $rosterCount = Roster::count();
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- ================= 登录门 ================= -->
|
||||
<div class="login-gate" id="loginGate">
|
||||
<div class="login-box">
|
||||
<div class="login-brand">
|
||||
<span class="logo">NY</span>
|
||||
<div class="brand-text">
|
||||
<strong>NY问卷考试系统数据平台</strong>
|
||||
<small>实时数据统计</small>
|
||||
</div>
|
||||
</div>
|
||||
<p class="login-tip">请输入系统连接信息,完成连接测试后登录。密码需每次输入,避免依赖一次配置直接查看数据。</p>
|
||||
<div class="fi"><label>系统网址</label><input type="text" id="lgBase" placeholder="https://exam.nxxy335.top"></div>
|
||||
<div class="fi"><label>API 路由</label><input type="text" id="lgPrefix" placeholder="/api"></div>
|
||||
<div class="fi"><label>账号</label><input type="text" id="lgUser" placeholder="admin"></div>
|
||||
<div class="fi"><label>密码</label><input type="password" id="lgPwd" placeholder="请输入密码" autocomplete="current-password"></div>
|
||||
<div class="login-actions">
|
||||
<button class="btn" id="lgTest">测试连接</button>
|
||||
<button class="btn btn-primary" id="lgLogin" disabled>登录</button>
|
||||
</div>
|
||||
<div class="login-msg" id="lgMsg"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<main class="wrap">
|
||||
|
||||
<section class="toolbar">
|
||||
@@ -75,13 +61,6 @@ $rosterCount = Roster::count();
|
||||
<label>组别</label>
|
||||
<select id="grpSel"><option value="">全部组别</option></select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>布局</label>
|
||||
<select id="layoutSel">
|
||||
<option value="default">默认(缺考+未匹配同行)</option>
|
||||
<option value="side">成绩明细与缺考名单同行</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>自动刷新</label>
|
||||
<div class="inline">
|
||||
@@ -175,26 +154,12 @@ $rosterCount = Roster::count();
|
||||
<div class="modal-body">
|
||||
<div class="form-grid">
|
||||
<div class="fi full">
|
||||
<label>卷王系统地址</label>
|
||||
<input type="text" id="cfgBase" placeholder="http://127.0.0.1:1991">
|
||||
<p class="hint">例如 http://192.168.1.10:1991,结尾不要带 /</p>
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>接口前缀</label>
|
||||
<input type="text" id="cfgPrefix" placeholder="/api">
|
||||
<p class="hint">社区版默认 /api(企业版可填 /admin-api)</p>
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>每页拉取条数</label>
|
||||
<input type="number" id="cfgPageSize" min="20" max="1000">
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>登录账号</label>
|
||||
<input type="text" id="cfgUser">
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>登录密码</label>
|
||||
<input type="password" id="cfgPwd" placeholder="留空表示不修改">
|
||||
<label>布局</label>
|
||||
<div class="fi-inline">
|
||||
<label class="chk"><input type="radio" name="cfgLayout" value="default" id="layoutDef"> 默认(缺考+未匹配同行)</label>
|
||||
<label class="chk"><input type="radio" name="cfgLayout" value="side" id="layoutSide"> 成绩明细与缺考名单同行</label>
|
||||
</div>
|
||||
<p class="hint">主界面三个面板(成绩明细 / 缺考名单 / 未匹配答卷)的排版方式</p>
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>默认刷新间隔(秒)</label>
|
||||
@@ -205,15 +170,25 @@ $rosterCount = Roster::count();
|
||||
<input type="number" id="cfgTimeout" min="3" max="120">
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>满分(用于合格率)</label>
|
||||
<input type="number" id="cfgFull" min="1" max="1000">
|
||||
<p class="hint" id="cfgFullHint">未选择试卷时,作为所有试卷的默认值</p>
|
||||
<label>每页拉取条数</label>
|
||||
<input type="number" id="cfgPageSize" min="20" max="1000">
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>默认满分(用于合格率)</label>
|
||||
<input type="number" id="cfgFull" min="1" max="1000">
|
||||
<p class="hint" id="cfgFullHint">未选中试卷时的默认值</p>
|
||||
</div>
|
||||
<div class="fi full">
|
||||
<label>姓名题关键词</label>
|
||||
<input type="text" id="cfgKeywords">
|
||||
<p class="hint">英文逗号分隔,用于自动识别"姓名"题目</p>
|
||||
</div>
|
||||
<div class="fi">
|
||||
<label>各试卷独立满分</label>
|
||||
<div id="fullScoresBox" class="fullscores">
|
||||
<span class="hint" id="fullScoresHint">未选中试卷时,此处为空;选中某套试卷后保存即在设置中为该卷单独设定满分</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fi full checks">
|
||||
<label><input type="checkbox" id="cfgDedupe"> 同一学号只保留最新一份答卷</label>
|
||||
<label><input type="checkbox" id="cfgTemp"> 包含"暂存"未提交的答卷</label>
|
||||
@@ -223,8 +198,7 @@ $rosterCount = Roster::count();
|
||||
<div id="pingResult" class="ping-result hidden"></div>
|
||||
</div>
|
||||
<div class="modal-foot">
|
||||
<button class="btn" id="btnPing">测试连接</button>
|
||||
<button class="btn" id="btnDiag">详细诊断</button>
|
||||
<span class="hint" style="align-self:center">连接信息由安装向导配置,此处仅调整显示与统计</span>
|
||||
<span class="spacer"></span>
|
||||
<button class="btn" data-close>取消</button>
|
||||
<button class="btn btn-primary" id="btnSaveCfg">保存</button>
|
||||
|
||||
Reference in New Issue
Block a user