From e94ecf5debfa3595e8171df91884b71f81c75a81 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Thu, 10 Jul 2025 23:17:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9C=AC=E4=BF=AE=E6=94=B9=E5=92=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在version_control.php中实现版本修改功能,支持更新版本号、更新日志和文件 - 添加版本删除功能,包括文件删除和数据库记录删除 - 使用模态框和确认对话框提升用户体验 - 在review_apps.php中显示应用下载链接和标签信息 - 移除index.php中的分页逻辑,改为懒加载方式 --- admin/review_apps.php | 41 +++++++ developer/version_control.php | 210 ++++++++++++++++++++++++++++++++++ index.php | 60 ++++------ 3 files changed, 275 insertions(+), 36 deletions(-) diff --git a/admin/review_apps.php b/admin/review_apps.php index dccefa4..21f6d0c 100644 --- a/admin/review_apps.php +++ b/admin/review_apps.php @@ -1,6 +1,7 @@
+

+ prepare("SELECT file_path FROM app_versions WHERE app_id = ? ORDER BY created_at DESC LIMIT 1"); + if ($getDownloadLinkStmt) { + $getDownloadLinkStmt->bind_param("i", $appId); + $getDownloadLinkStmt->execute(); + $downloadLinkResult = $getDownloadLinkStmt->get_result(); + $downloadLinkInfo = $downloadLinkResult->fetch_assoc(); + $downloadLink = $downloadLinkInfo ? $downloadLinkInfo['file_path'] : ''; + $getDownloadLinkStmt->close(); + } else { + $downloadLink = ''; + log_error('数据库准备语句错误: ' . $conn->error, __FILE__, __LINE__); + } + + // 获取应用标签 + $getTagsStmt = $conn->prepare("SELECT t.name FROM tags t JOIN app_tags at ON t.id = at.tag_id WHERE at.app_id = ?"); + if ($getTagsStmt) { + $getTagsStmt->bind_param("i", $appId); + $getTagsStmt->execute(); + $tagsResult = $getTagsStmt->get_result(); + $tags = []; + while ($tag = $tagsResult->fetch_assoc()) { + $tags[] = $tag['name']; + } + $tagString = implode(', ', $tags); + $getTagsStmt->close(); + } else { + $tagString = ''; + log_error('数据库准备语句错误: ' . $conn->error, __FILE__, __LINE__); + } + ?> + +

下载链接: 点击下载

+ + +

标签:

+

开发者:

提交时间:

描述:

diff --git a/developer/version_control.php b/developer/version_control.php index 49dcaa6..a2f5ceb 100644 --- a/developer/version_control.php +++ b/developer/version_control.php @@ -91,6 +91,108 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_version'])) { } } +// 处理版本修改请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['version_id'])) { + $versionId = $_POST['version_id']; + $version = $_POST['version']; + $changelog = $_POST['changelog'] ?? ''; + + // 检查是否有新文件上传 + if (!empty($_FILES['new_app_file']['name'])) { + $uploadDir = '../files/'; + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0755, true); + } + $fileName = basename($_FILES['new_app_file']['name']); + $newFilePath = $uploadDir . $fileName; + + if (move_uploaded_file($_FILES['new_app_file']['tmp_name'], $newFilePath)) { + // 获取旧文件路径并删除 + $getOldPathSql = "SELECT file_path FROM app_versions WHERE id = ?"; + $getOldPathStmt = $conn->prepare($getOldPathSql); + if (!$getOldPathStmt) { + log_error("获取旧文件路径查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + unlink($newFilePath); + } else { + $getOldPathStmt->bind_param("i", $versionId); + $getOldPathStmt->execute(); + $oldPathResult = $getOldPathStmt->get_result(); + if ($oldPathResult->num_rows > 0) { + $oldPathRow = $oldPathResult->fetch_assoc(); + $oldFilePath = $oldPathRow['file_path']; + if (file_exists($oldFilePath)) { + unlink($oldFilePath); + } + } + + // 更新版本信息 + $updateVersionSql = "UPDATE app_versions SET version = ?, changelog = ?, file_path = ? WHERE id = ?"; + $updateVersionStmt = $conn->prepare($updateVersionSql); + if (!$updateVersionStmt) { + log_error("版本更新查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + unlink($newFilePath); + } else { + $updateVersionStmt->bind_param("sssi", $version, $changelog, $newFilePath, $versionId); + if ($updateVersionStmt->execute()) { + $success = '版本修改成功'; + } else { + $error = '版本修改失败: ' . $conn->error; + unlink($newFilePath); + } + } + } + } else { + $error = '文件上传失败'; + } + } else { + // 仅更新版本号和更新日志 + $updateVersionSql = "UPDATE app_versions SET version = ?, changelog = ? WHERE id = ?"; + $updateVersionStmt = $conn->prepare($updateVersionSql); + if (!$updateVersionStmt) { + log_error("版本更新查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + } else { + $updateVersionStmt->bind_param("ssi", $version, $changelog, $versionId); + if ($updateVersionStmt->execute()) { + $success = '版本修改成功'; + } else { + $error = '版本修改失败: ' . $conn->error; + } + } + } +} + +// 处理版本删除请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_version'])) { + $versionId = $_POST['version_id']; + $filePath = $_POST['file_path']; + + // 删除文件 + if (file_exists($filePath)) { + if (!unlink($filePath)) { + log_error("文件删除失败: " . $filePath, __FILE__, __LINE__); + $error = '版本删除失败,请稍后再试'; + } + } + + // 从数据库删除版本记录 + $deleteVersionSql = "DELETE FROM app_versions WHERE id = ?"; + $deleteVersionStmt = $conn->prepare($deleteVersionSql); + if (!$deleteVersionStmt) { + log_error("版本删除查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本删除失败,请稍后再试'; + } else { + $deleteVersionStmt->bind_param("i", $versionId); + if ($deleteVersionStmt->execute()) { + $success = '版本删除成功'; + } else { + $error = '版本删除失败: ' . $conn->error; + } + } +} + // 获取现有版本列表 $versions = []; $getVersionsSql = "SELECT * FROM app_versions WHERE app_id = ? ORDER BY id DESC"; @@ -213,6 +315,8 @@ if (!$verStmt) { 下载 + 修改 + 删除 当前版本 @@ -228,5 +332,111 @@ if (!$verStmt) {
+ \ No newline at end of file diff --git a/index.php b/index.php index 4c6507a..6ca3deb 100644 --- a/index.php +++ b/index.php @@ -58,7 +58,6 @@ if (!isset($conn) || !$conn instanceof mysqli) { 管理 - @@ -232,8 +231,6 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno num_rows > 0 ? $anno } $sql .= "GROUP BY apps.id - ORDER BY apps.created_at DESC - LIMIT ? OFFSET ?"; - $limitVal = $limit; - $offsetVal = $offset; - $params[] = &$limitVal; - $params[] = &$offsetVal; - // 添加分页参数类型 - $paramTypes .= 'ii'; - + ORDER BY apps.created_at DESC"; + // 执行查询 if (!empty($params)) { $stmt = $conn->prepare($sql); @@ -316,7 +306,7 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { - echo '
'; + echo '
'; echo '
'; echo '
'; @@ -329,30 +319,28 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno echo '
'; } } + ?> + + -
- -
- +