feat: 重构数据库配置并支持多数据库类型

- 将数据库配置从硬编码改为从外部文件加载
- 支持MySQL 5.7+和SQLite两种数据库类型
- 改进安装向导流程,增加数据库类型选择
- 更新README文档说明数据库要求
- 替换CDN链接为国内镜像源
- 增加安装完成后的安全提醒

重构数据库类以支持更灵活的配置方式,包括端口设置和MySQL 5.7兼容性处理。安装向导现在可以正确配置SQLite或MySQL数据库,并生成相应的配置文件。同时优化了前端资源加载速度。
This commit is contained in:
2025-05-26 18:22:24 +08:00
parent d75163b2b4
commit bbbf936bdd
7 changed files with 170 additions and 96 deletions

View File

@@ -102,37 +102,66 @@ $offset = ($page - 1) * $limit;
$limit = (int)$limit;
$offset = (int)$offset;
// 检查数据库版本
$is_mysql_57 = $database->isMySQL57();
if ($type === 'website') {
$count_stmt = $db->prepare("SELECT COUNT(*) FROM website_submissions WHERE status = ?");
$count_stmt->execute([$filter]);
$total = $count_stmt->fetchColumn();
$stmt = $db->prepare("
SELECT id, url, title, description, platforms, contact, status, admin_note, created_at
FROM website_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ?, ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $offset, PDO::PARAM_INT);
$stmt->bindValue(3, $limit, PDO::PARAM_INT);
if ($is_mysql_57) {
$stmt = $db->prepare("
SELECT id, url, title, description, platforms, contact, status, admin_note, created_at
FROM website_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ?, ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $offset, PDO::PARAM_INT);
$stmt->bindValue(3, $limit, PDO::PARAM_INT);
} else {
$stmt = $db->prepare("
SELECT id, url, title, description, platforms, contact, status, admin_note, created_at
FROM website_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ? OFFSET ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $limit, PDO::PARAM_INT);
$stmt->bindValue(3, $offset, PDO::PARAM_INT);
}
$stmt->execute();
} else {
$count_stmt = $db->prepare("SELECT COUNT(*) FROM app_submissions WHERE status = ?");
$count_stmt->execute([$filter]);
$total = $count_stmt->fetchColumn();
$stmt = $db->prepare("
SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at
FROM app_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ?, ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $offset, PDO::PARAM_INT);
$stmt->bindValue(3, $limit, PDO::PARAM_INT);
if ($is_mysql_57) {
$stmt = $db->prepare("
SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at
FROM app_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ?, ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $offset, PDO::PARAM_INT);
$stmt->bindValue(3, $limit, PDO::PARAM_INT);
} else {
$stmt = $db->prepare("
SELECT id, name, platform, version, icon_url, download_url, website_url, description, platforms, contact, status, admin_note, created_at
FROM app_submissions
WHERE status = ?
ORDER BY created_at DESC
LIMIT ? OFFSET ?
");
$stmt->bindValue(1, $filter, PDO::PARAM_STR);
$stmt->bindValue(2, $limit, PDO::PARAM_INT);
$stmt->bindValue(3, $offset, PDO::PARAM_INT);
}
$stmt->execute();
}
@@ -146,7 +175,7 @@ $total_pages = ceil($total / $limit);
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理后台 - 内容投稿系统</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
* {
margin: 0;