feat(admin): 替换alert为Swal弹窗并优化样式

refactor: 统一代码缩进和格式化
style: 优化CSS样式和代码可读性
This commit is contained in:
2025-07-12 13:50:38 +08:00
parent 84f52e05b3
commit 5b009b838b
12 changed files with 332 additions and 265 deletions

View File

@@ -87,10 +87,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) {
} }
} }
header('Location: index.php?success=App 添加成功'); echo '<script>Swal.fire("成功", "App 添加成功", "success").then(() => { window.location.href = "index.php"; });</script>';
exit; exit;
} else { } else {
$error = 'App 添加失败: '. $conn->error; echo '<script>Swal.fire("错误", "App 添加失败: '. $conn->error .'", "error");</script>';
} }
} }
} }

View File

@@ -17,14 +17,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)'); $stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)');
$stmt->bind_param('ssi', $title, $content, $admin_id); $stmt->bind_param('ssi', $title, $content, $admin_id);
if ($stmt->execute()) { if ($stmt->execute()) {
header('Location: announcements.php?success=公告发布成功'); echo '<script>Swal.fire("成功", "公告发布成功", "success").then(() => { window.location.reload(); });</script>';
exit; exit;
} else { } else {
$error = '公告发布失败: ' . $conn->error; echo '<script>Swal.fire("错误", "公告发布失败: ' . $conn->error . '", "error");</script>';
} }
$stmt->close(); $stmt->close();
} else { } else {
$error = '标题和内容不能为空'; echo '<script>Swal.fire("错误", "标题和内容不能为空", "error");</script>';
} }
} }

View File

@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
// 验证App ID // 验证App ID
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
header('Location: index.php?error=无效的App ID'); echo '<script>Swal.fire("错误", "无效的App ID", "error").then(() => { window.location.href = "index.php"; });</script>';
exit; exit;
} }
$appId = $_GET['id']; $appId = $_GET['id'];
@@ -33,9 +33,9 @@ if ($stmt->execute() === TRUE) {
$verStmt->bind_param("i", $appId); $verStmt->bind_param("i", $appId);
$verStmt->execute(); $verStmt->execute();
header('Location: index.php?success=App 删除成功'); echo '<script>Swal.fire("成功", "App 删除成功", "success").then(() => { window.location.href = "index.php"; });</script>';
} else { } else {
header('Location: index.php?error=App 删除失败: '. $conn->error); echo '<script>Swal.fire("错误", "App 删除失败: '. $conn->error .'", "error").then(() => { window.location.href = "index.php"; });</script>';
} }
exit; exit;
?> ?>

View File

@@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) {
// 验证App ID // 验证App ID
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
header('Location: index.php?error=无效的App ID'); echo '<script>Swal.fire("错误", "无效的App ID", "error").then(() => { window.location.href = "index.php"; });</script>';
exit; exit;
} }
$appId = $_GET['id']; $appId = $_GET['id'];
@@ -23,7 +23,7 @@ $stmt->bind_param("i", $appId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
if ($result->num_rows === 0) { if ($result->num_rows === 0) {
header('Location: index.php?error=App不存在'); echo '<script>Swal.fire("错误", "App不存在", "error").then(() => { window.location.href = "index.php"; });</script>';
exit; exit;
} }
$app = $result->fetch_assoc(); $app = $result->fetch_assoc();
@@ -99,11 +99,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
$stmt->close(); $stmt->close();
} }
header('Location: index.php?success=App 更新成功'); $updateAppSql = "UPDATE apps SET name = ?, description = ?, age_rating = ?, platforms = ? WHERE id = ?";
exit; $updateStmt = $conn->prepare($updateAppSql);
} else { $updateStmt->bind_param("ssssi", $name, $description, $ageRating, $newPlatforms, $appId);
$error = 'App 更新失败: '. $conn->error; if ($updateStmt->execute() === TRUE) {
} echo '<script>Swal.fire("成功", "App 更新成功", "success").then(() => { window.location.href = "index.php"; });</script>';
exit;
} else {
echo '<script>Swal.fire("错误", "App 更新失败: '. $conn->error .'", "error");</script>';
}
$updateStmt->close();
}
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@@ -391,5 +397,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
$stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?"); $stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?");
$stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId); $stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId);
// ... existing code ...
?> ?>

View File

@@ -30,7 +30,7 @@ $resultApps = $conn->query($sqlApps);
if (!$resultApps) { if (!$resultApps) {
error_log("Database query failed: " . $conn->error); error_log("Database query failed: " . $conn->error);
echo '<div class="alert alert-danger">获取App列表失败请联系管理员。</div>'; echo '<script>Swal.fire("错误", "获取App列表失败请联系管理员。", "error");</script>';
} else { } else {
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@@ -59,6 +59,7 @@ if (!$resultApps) {
<link href="../css/bootstrap.min.css" rel="stylesheet"> <link href="../css/bootstrap.min.css" rel="stylesheet">
<!-- 自定义CSS --> <!-- 自定义CSS -->
<link rel="stylesheet" href="../styles.css"> <link rel="stylesheet" href="../styles.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Fluent Design 模糊效果 --> <!-- Fluent Design 模糊效果 -->
<style> <style>
.blur-bg { .blur-bg {
@@ -104,13 +105,22 @@ if (!$resultApps) {
</nav> </nav>
<div class="container mt-4"> <div class="container mt-4">
<script>
<?php if (isset($_GET['success'])): ?> <?php if (isset($_GET['success'])): ?>
<div class="alert alert-success"><?php echo $_GET['success']; ?></div> Swal.fire({
icon: "success",
title: "成功",
text: "<?php echo addslashes($_GET['success']); ?>",
});
<?php endif; ?> <?php endif; ?>
<?php if (isset($_GET['error'])): ?> <?php if (isset($_GET['error'])): ?>
<div class="alert alert-danger"><?php echo $_GET['error']; ?></div> Swal.fire({
icon: "error",
title: "错误",
text: "<?php echo addslashes($_GET['error']); ?>",
});
<?php endif; ?> <?php endif; ?>
</script>
<h2>App列表</h2> <h2>App列表</h2>
<div class="mb-3"> <div class="mb-3">
<a href="manage_tags.php" class="btn btn-info">标签管理</a> <a href="manage_tags.php" class="btn btn-info">标签管理</a>
@@ -135,7 +145,19 @@ if (!$resultApps) {
<td> <td>
<a href="editapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-primary">编辑</a> <a href="editapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-primary">编辑</a>
<a href="manage_versions.php?app_id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-secondary">版本管理</a> <a href="manage_versions.php?app_id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-secondary">版本管理</a>
<a href="deleteapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('确定要删除吗?');">删除</a> <a href="deleteapp.php?id=<?php echo $app['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="event.preventDefault(); Swal.fire({
title: '确定要删除吗?',
text: '删除后将无法恢复!',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: '确定删除'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = this.href;
}
});">删除</a>
</td> </td>
</tr> </tr>
<?php endwhile; ?> <?php endwhile; ?>

View File

@@ -4,37 +4,8 @@ require_once '../config.php';
// 检查管理员登录状态 // 检查管理员登录状态
session_start(); session_start();
// 顶栏样式
echo '<style>
.navbar.scrolled {
background-color: rgba(255, 255, 255, 0.95) !important;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
</style>';
// 导航栏
echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container">
<a class="navbar-brand" href="../index.php">'. APP_STORE_NAME . '</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="../index.php">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.php">管理后台</a>
</li>
</ul>
</div>
</div>
</nav>';
// 为内容添加顶部内边距
echo '<div style="padding-top: 70px;">';
if (!isset($_SESSION['admin'])) { if (!isset($_SESSION['admin'])) {
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username']; $username = $_POST['username'];
$password = $_POST['password']; $password = $_POST['password'];
@@ -50,62 +21,89 @@ if (!isset($_SESSION['admin'])) {
$error = '用户名或密码错误'; $error = '用户名或密码错误';
} }
} }
?>
// 显示登录表单 <!DOCTYPE html>
echo '<!DOCTYPE html>'; <html lang="zh-CN">
echo '<html lang="zh-CN">'; <head>
echo '<head>'; <meta charset="UTF-8">
echo ' <meta charset="UTF-8">'; <meta name="viewport" content="width=device-width, initial-scale=1.0">
echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">'; <title>管理员登录 - <?php echo APP_STORE_NAME; ?></title>
echo ' <title>管理员登录 - '. APP_STORE_NAME . '</title>'; <!-- Bootstrap CSS -->
echo ' <!-- Bootstrap CSS -->'; <link href="../css/bootstrap.min.css" rel="stylesheet">
echo ' <link href="../css/bootstrap.min.css" rel="stylesheet">'; <!-- 自定义CSS -->
echo ' <!-- 自定义CSS -->'; <link rel="stylesheet" href="../styles.css">
echo ' <link rel="stylesheet" href="../styles.css">'; <!-- 顶栏样式 -->
echo ' <!-- Fluent Design 模糊效果 -->'; <style>
echo ' <style>'; .navbar.scrolled {
echo ' .blur-bg {'; background-color: rgba(255, 255, 255, 0.95) !important;
echo ' backdrop-filter: blur(10px);'; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
echo ' background-color: rgba(255, 255, 255, 0.5);'; }
echo ' }'; .blur-bg {
echo ' </style>'; backdrop-filter: blur(10px);
echo '</head>'; background-color: rgba(255, 255, 255, 0.5);
echo '<body>'; }
echo ' <div class="container mt-5">'; </style>
echo ' <div class="row justify-content-center">'; <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
echo ' <div class="col-md-6">'; </head>
echo ' <div class="card blur-bg">'; <body>
echo ' <div class="card-header">管理员登录</div>'; <!-- 导航栏 -->
echo ' <div class="card-body">'; <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
if (isset($error)) { <div class="container">
echo '<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>'; <a class="navbar-brand" href="../index.php"><?php echo APP_STORE_NAME; ?></a>
echo '<script> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
Swal.fire({ <span class="navbar-toggler-icon"></span>
icon: "error", </button>
title: "错误", <div class="collapse navbar-collapse" id="navbarNav">
text: "'. addslashes($error) . '", <ul class="navbar-nav">
}); <li class="nav-item">
</script>'; <a class="nav-link" href="../index.php">首页</a>
} </li>
echo ' <form method="post">'; <li class="nav-item">
echo ' <div class="mb-3">'; <a class="nav-link" href="index.php">管理后台</a>
echo ' <label for="username" class="form-label">用户名</label>'; </li>
echo ' <input type="text" class="form-control" id="username" name="username" required>'; </ul>
echo ' </div>'; </div>
echo ' <div class="mb-3">'; </div>
echo ' <label for="password" class="form-label">密码</label>'; </nav>
echo ' <input type="password" class="form-control" id="password" name="password" required>';
echo ' </div>'; <!-- 为内容添加顶部内边距 -->
echo ' <button type="submit" class="btn btn-primary">登录</button>'; <div style="padding-top: 70px;">
echo ' </form>'; <div class="container mt-5">
echo ' </div>'; <div class="row justify-content-center">
echo ' </div>'; <div class="col-md-6">
echo ' </div>'; <div class="card blur-bg">
echo ' </div>'; <div class="card-header">管理员登录</div>
echo ' </div>'; <div class="card-body">
echo ' <!-- Bootstrap JS Bundle with Popper -->'; <?php if (isset($error)): ?>
echo ' <script src="/js/bootstrap.bundle.js"></script>'; <script>
echo '</body>'; Swal.fire({
echo '</html>'; icon: "error",
title: "错误",
text: "<?php echo addslashes($error); ?>",
});
</script>
<?php endif; ?>
<form method="post">
<div class="mb-3">
<label for="username" class="form-label">用户名</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">密码</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">登录</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS Bundle with Popper -->
<script src="/js/bootstrap.bundle.js"></script>
</body>
</html>
<?php
exit; exit;
} }

View File

@@ -1,24 +1,70 @@
<?php <?php
session_start(); session_start();
require_once '../config.php'; require_once '../config.php';
// 删除文件 // 删除文件
function delete_file($file_path) { function delete_file($file_path) {
if (file_exists($file_path)) { if (file_exists($file_path)) {
return unlink($file_path); return unlink($file_path);
}
return false;
} }
return false;
}
// 处理删除请求 // 处理删除请求
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$upload_dirs = [ $upload_dirs = [
'../uploads/apps', '../uploads/apps',
'../uploads/images' '../uploads/images'
]; ];
// 全量删除 // 全量删除
if (isset($_POST['delete_all'])) { if (isset($_POST['delete_all'])) {
foreach ($upload_dirs as $dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
$file_path = $dir . '/' . $file;
if (is_file($file_path)) {
delete_file($file_path);
}
}
}
}
}
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
// 单个删除
if (isset($_POST['delete_files'])) {
foreach ($_POST['delete_files'] as $file_info) {
list($type, $filename) = explode('|', $file_info);
$dir = $type === '图片' ? '../uploads/images' : '../uploads/apps';
$file_path = $dir . '/' . $filename;
delete_file($file_path);
}
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
}
// 验证管理员权限
if (!isset($_SESSION['admin'])) {
header('Location: login.php');
exit;
}
// 获取上传文件和图片信息
function get_uploaded_files_info() {
$uploaded_files = [];
// 上传目录配置
$upload_dirs = [
'../uploads/apps',
'../uploads/images'
];
foreach ($upload_dirs as $dir) { foreach ($upload_dirs as $dir) {
if (is_dir($dir)) { if (is_dir($dir)) {
$files = scandir($dir); $files = scandir($dir);
@@ -26,68 +72,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($file !== '.' && $file !== '..') { if ($file !== '.' && $file !== '..') {
$file_path = $dir . '/' . $file; $file_path = $dir . '/' . $file;
if (is_file($file_path)) { if (is_file($file_path)) {
delete_file($file_path); $file_size = filesize($file_path);
$uploaded_files[] = [
'name' => $file,
'size' => $file_size,
'type' => strpos($dir, 'images') !== false ? '图片' : '文件'
];
} }
} }
} }
} }
} }
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
// 单个删除
if (isset($_POST['delete_files'])) {
foreach ($_POST['delete_files'] as $file_info) {
list($type, $filename) = explode('|', $file_info);
$dir = $type === '图片' ? '../uploads/images' : '../uploads/apps';
$file_path = $dir . '/' . $filename;
delete_file($file_path);
}
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
}
// 验证管理员权限 return $uploaded_files;
if (!isset($_SESSION['admin'])) {
header('Location: login.php');
exit;
}
// 获取上传文件和图片信息
function get_uploaded_files_info() {
$uploaded_files = [];
// 上传目录配置
$upload_dirs = [
'../uploads/apps',
'../uploads/images'
];
foreach ($upload_dirs as $dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
$file_path = $dir . '/' . $file;
if (is_file($file_path)) {
$file_size = filesize($file_path);
$uploaded_files[] = [
'name' => $file,
'size' => $file_size,
'type' => strpos($dir, 'images') !== false ? '图片' : '文件'
];
}
}
}
}
} }
return $uploaded_files;
}
$uploaded_files = get_uploaded_files_info(); $uploaded_files = get_uploaded_files_info();
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
@@ -105,7 +105,7 @@ $uploaded_files = get_uploaded_files_info();
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container"> <div class="container">
<a class="navbar-brand" href="index.php">管理员面板</a> <a class="navbar-brand" href="index.php">管理员面板</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarNav"> <div class="collapse navbar-collapse" id="navbarNav">

View File

@@ -14,7 +14,9 @@
<!-- Font Awesome --> <!-- Font Awesome -->
<link rel="stylesheet" href="/css/all.min.css"> <link rel="stylesheet" href="/css/all.min.css">
<style> <style>
body { padding-top: 56px; } body {
padding-top: 56px;
}
.blur-bg { .blur-bg {
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
background-color: rgba(255, 255, 255, 0.5); background-color: rgba(255, 255, 255, 0.5);

View File

@@ -1,54 +1,54 @@
<?php <?php
ob_start(); ob_start();
require_once 'config.php'; require_once 'config.php';
// 验证版本ID // 验证版本ID
if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) { if (!isset($_GET['version_id']) || !is_numeric($_GET['version_id'])) {
http_response_code(400); http_response_code(400);
exit('无效的版本ID'); exit('无效的版本ID');
} }
$versionId = $_GET['version_id']; $versionId = $_GET['version_id'];
// 获取版本信息 // 获取版本信息
$version = null; $version = null;
$getVersionSql = "SELECT * FROM app_versions WHERE id = ?"; $getVersionSql = "SELECT * FROM app_versions WHERE id = ?";
$stmt = $conn->prepare($getVersionSql); $stmt = $conn->prepare($getVersionSql);
$stmt->bind_param("i", $versionId); $stmt->bind_param("i", $versionId);
$stmt->execute(); $stmt->execute();
$result = $stmt->get_result(); $result = $stmt->get_result();
if ($result->num_rows !== 1) { if ($result->num_rows !== 1) {
http_response_code(404); http_response_code(404);
exit('版本不存在'); exit('版本不存在');
} }
$version = $result->fetch_assoc(); $version = $result->fetch_assoc();
// 获取绝对文件路径 // 获取绝对文件路径
$filePath = realpath(__DIR__ . '/' . $version['file_path']); $filePath = realpath(__DIR__ . '/' . $version['file_path']);
// 验证文件存在性 // 验证文件存在性
if (!$filePath || !file_exists($filePath)) { if (!$filePath || !file_exists($filePath)) {
http_response_code(404); http_response_code(404);
exit('文件不存在'); exit('文件不存在');
} }
// 设置下载响应头 // 设置下载响应头
$fileName = basename($filePath); $fileName = basename($filePath);
$fileSize = filesize($filePath); $fileSize = filesize($filePath);
// 清除输出缓冲区并发送 headers // 清除输出缓冲区并发送 headers
ob_end_clean(); ob_end_clean();
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName)); header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($fileName));
header('Content-Length: ' . $fileSize); header('Content-Length: ' . $fileSize);
header('Cache-Control: no-cache, must-revalidate'); header('Cache-Control: no-cache, must-revalidate');
header('Expires: 0'); header('Expires: 0');
header('Pragma: public'); header('Pragma: public');
// 输出文件内容 // 输出文件内容
if (!readfile($filePath)) { if (!readfile($filePath)) {
http_response_code(500); http_response_code(500);
exit('无法读取文件'); exit('无法读取文件');
} }
exit; exit;
?> ?>

View File

@@ -6,10 +6,30 @@
<title>404 - 页面未找到</title> <title>404 - 页面未找到</title>
<link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap.min.css" rel="stylesheet">
<style> <style>
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f8f9fa; } body {
.error-container { text-align: center; padding: 2rem; background-color: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } display: flex;
h1 { font-size: 5rem; margin: 0; color: #6c757d; } justify-content: center;
p { font-size: 1.2rem; margin: 1rem 0; } align-items: center;
height: 100vh;
margin: 0;
background-color: #f8f9fa;
}
.error-container {
text-align: center;
padding: 2rem;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
font-size: 5rem;
margin: 0;
color: #6c757d;
}
p {
font-size: 1.2rem;
margin: 1rem 0;
}
</style> </style>
</head> </head>
<body> <body>

View File

@@ -6,10 +6,30 @@
<title>500 - 服务器内部错误</title> <title>500 - 服务器内部错误</title>
<link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap.min.css" rel="stylesheet">
<style> <style>
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f8f9fa; } body {
.error-container { text-align: center; padding: 2rem; background-color: white; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } display: flex;
h1 { font-size: 5rem; margin: 0; color: #dc3545; } justify-content: center;
p { font-size: 1.2rem; margin: 1rem 0; } align-items: center;
height: 100vh;
margin: 0;
background-color: #f8f9fa;
}
.error-container {
text-align: center;
padding: 2rem;
background-color: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
font-size: 5rem;
margin: 0;
color: #dc3545;
}
p {
font-size: 1.2rem;
margin: 1rem 0;
}
</style> </style>
</head> </head>
<body> <body>

View File

@@ -1,38 +1,38 @@
<?php <?php
// 路由脚本用于PHP内置服务器 // 路由脚本用于PHP内置服务器
// 将所有/api开头的请求转发到api.php // 将所有/api开头的请求转发到api.php
// 顶栏样式 // 顶栏样式
echo '<style> echo '<style>
.navbar.scrolled { .navbar.scrolled {
background-color: rgba(255, 255, 255, 0.95) !important; background-color: rgba(255, 255, 255, 0.95) !important;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
} }
</style>'; </style>';
// 导航栏 // 导航栏
echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top"> echo '<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">
<div class="container"> <div class="container">
<a class="navbar-brand" href="index.php">'. APP_STORE_NAME . '</a> <a class="navbar-brand" href="index.php">'. APP_STORE_NAME . '</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarNav"> <div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="index.php">首页</a> <a class="nav-link" href="index.php">首页</a>
</li> </li>
</ul> </ul>
</div>
</div> </div>
</div> </nav>';
</nav>';
// 为内容添加顶部内边距 // 为内容添加顶部内边距
echo '<div style="padding-top: 70px;">'; echo '<div style="padding-top: 70px;">';
if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) { if (preg_match('/^\/api/', $_SERVER['REQUEST_URI'])) {
include 'api.php'; include 'api.php';
exit; exit;
} }
// 其他请求按正常方式处理 // 其他请求按正常方式处理
return false; return false;