feat: 添加应用审核状态检查和使用SweetAlert弹窗

- 在app.php中添加应用审核状态检查,未通过审核时显示提示弹窗
- 引入SweetAlert2库用于统一弹窗样式
- 修改登录逻辑支持邮箱/用户名两种登录方式
- 修复profile.php中的表单标签错误
- 在数据库中添加is_approved字段标记应用审核状态
- 添加项目规则文档规定统一使用SweetAlert弹窗
This commit is contained in:
2025-07-09 14:38:04 +08:00
parent 4a77edc087
commit 379a72ecd3
5 changed files with 32 additions and 11 deletions

View File

@@ -0,0 +1 @@
弹窗都用Sweet Alert弹窗

21
app.php
View File

@@ -28,6 +28,24 @@ if (!$app) {
die("<h1>错误:应用不存在</h1><p>找不到ID为 $appId 的应用。请检查ID是否正确。</p>");
}
// 检查应用审核状态
if ($app['status'] != 'approved') {
echo '<script>
document.addEventListener("DOMContentLoaded", function() {
Swal.fire({
title: "应用审核中",
text: "该应用正在审核中,暂时无法访问。",
icon: "info",
confirmButtonText: "确定"
}).then((result) => {
if (result.isConfirmed) {
window.history.back();
}
});
});
</script>';
}
// 处理评价加载请求
if (isset($_GET['action']) && $_GET['action'] === 'load_reviews') {
header('Content-Type: text/html; charset=UTF-8');
@@ -118,6 +136,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) {
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- SweetAlert2 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js"></script>
<!-- 本地 Chart.js -->
<script src="js/charts.js"></script>
<!-- 自定义CSS -->

View File

@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS apps (
changelog TEXT NOT NULL,
file_path VARCHAR(255) NOT NULL,
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
is_approved TINYINT(1) DEFAULT 0 COMMENT '应用是否已审核',
developer_email VARCHAR(255) NOT NULL
);

View File

@@ -41,23 +41,23 @@ if (isset($_GET['register_success']) && $_GET['register_success'] == 1) {
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email']);
$loginId = trim($_POST['login_id']);
$password = $_POST['password'];
if (empty($email) || empty($password)) {
$error = '邮箱和密码不能为空';
if (empty($loginId) || empty($password)) {
$error = '邮箱/用户名和密码不能为空';
} else {
// 检查数据库连接是否为 MySQLi 对象
if (!($conn instanceof mysqli)) {
log_error('数据库连接错误: 连接不是MySQLi实例', __FILE__, __LINE__);
$error = '数据库连接错误,请检查配置';
} else {
$stmt = $conn->prepare('SELECT id, username, password FROM developers WHERE email = ?');
$stmt = $conn->prepare('SELECT id, username, password FROM developers WHERE email = ? OR username = ?');
if (!$stmt) {
log_error('登录查询准备失败: ' . $conn->error, __FILE__, __LINE__);
$error = '登录时发生错误,请稍后再试';
} else {
$stmt->bind_param('s', $email);
$stmt->bind_param('ss', $loginId, $loginId);
if (!$stmt->execute()) {
log_error('登录查询执行失败: ' . $stmt->error, __FILE__, __LINE__);
$error = '登录时发生错误,请稍后再试';
@@ -70,7 +70,7 @@ if (!($conn instanceof mysqli)) {
header('Location: dashboard.php');
exit;
} else {
$error = '邮箱或密码错误';
$error = '邮箱/用户名或密码错误';
}
}
}
@@ -104,8 +104,8 @@ if (!($conn instanceof mysqli)) {
<?php endif; ?>
<form method="post">
<div class="mb-3">
<label for="email" class="form-label">邮箱</label>
<input type="email" id="email" name="email" class="form-control" required>
<label for="login_id" class="form-label">邮箱/用户名</label>
<input type="text" id="login_id" name="login_id" class="form-control" placeholder="请输入邮箱或用户名" required>
</div>
<div class="form-group">
<label for="password" class="form-label">密码</label>

View File

@@ -167,9 +167,7 @@ if (!($conn instanceof mysqli)) {
<label for="username">用户名</label>
<input type="text" class="form-control" id="username" name="username" value="<?php echo htmlspecialchars($developer['username']); ?>" placeholder="请输入用户名">
</div>
<button type="submit" class="btn btn-primary">保存更改</button>
?>" required>
</div>
<div class="form-group">
<label for="email">邮箱</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($developer['email']); ?>" required>