From a6ed9fd1cb4dac18afcb2fa569414d718127f779 Mon Sep 17 00:00:00 2001
From: Leonmmcoset
Date: Tue, 15 Jul 2025 18:08:39 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=94=B6?=
=?UTF-8?q?=E8=97=8F=E5=8A=9F=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
删除用户收藏表及相关SQL定义
移除前端收藏按钮及JavaScript逻辑
清理API中收藏相关接口
更新README文档移除收藏功能说明
---
README.md | 2 +-
api.php | 38 +------------------------------------
app_store.sql | 11 +----------
developer_apps.php | 2 +-
index.php | 2 +-
remove_favorite_feature.sql | 2 ++
version_list.php | 19 ++-----------------
7 files changed, 9 insertions(+), 67 deletions(-)
create mode 100644 remove_favorite_feature.sql
diff --git a/README.md b/README.md
index 4fb4b0a..856815e 100644
--- a/README.md
+++ b/README.md
@@ -213,7 +213,7 @@ php -S localhost:8000
"endpoints": {
"/api?action=list": "获取应用列表,支持search、platform、age_rating、tag、page、limit参数。search:搜索关键词;platform:平台;age_rating:年龄分级;tag:标签;page:页码;limit:每页数量",
"/api?action=app&id=1": "获取指定ID的应用详情,需传入app_id参数。包含应用基础信息、版本、图片、评价和标签信息",
- "/api?action=favorite": "收藏应用(POST方法,需app_id和user_id参数)"
+
},
"example": "GET /api?action=list&search=游戏&limit=10"
}
diff --git a/api.php b/api.php
index 353d3a5..2b64e76 100644
--- a/api.php
+++ b/api.php
@@ -15,7 +15,7 @@ if (!isset($_GET['action']) || $_GET['action'] === '') {
'endpoints' => [
'/api?action=list' => '获取应用列表,支持search、platform、age_rating、tag、page、limit参数。search:搜索关键词;platform:平台;age_rating:年龄分级;tag:标签;page:页码;limit:每页数量',
'/api?action=app&id=1' => '获取指定ID的应用详情,需传入app_id参数。包含应用基础信息、版本、图片、评价和标签信息',
- '/api?action=favorite' => '收藏应用(POST方法,需app_id和user_id参数)'
+
],
'example' => 'GET /api?action=list&search=游戏&limit=10'
]);
@@ -218,42 +218,6 @@ if (isset($_GET['action'])) {
exit;
}
- // 处理用户收藏应用
- elseif ($action === 'favorite' && isset($_GET['app_id']) && is_numeric($_GET['app_id']) && isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $requestMethod === 'POST') {
- $appId = $_GET['app_id'];
- $userId = $_GET['user_id'];
-
- $stmt = $conn->prepare("INSERT IGNORE INTO user_favorites (user_id, app_id) VALUES (?, ?)");
- $stmt->bind_param("ii", $userId, $appId);
-
- if ($stmt->execute()) {
- echo json_encode(['status' => 'success', 'message' => 'App added to favorites']);
- } else {
- http_response_code(500);
- echo json_encode(['error' => 'Failed to add to favorites']);
- }
- $stmt->close();
- exit;
- }
-
- // 获取用户收藏列表
- elseif ($action === 'favorites' && isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $requestMethod === 'GET') {
- $userId = $_GET['user_id'];
-
- $sql = "SELECT apps.* FROM user_favorites JOIN apps ON user_favorites.app_id = apps.id WHERE user_favorites.user_id = $userId";
- $result = $conn->query($sql);
-
- $favorites = [];
- if ($result->num_rows > 0) {
- while ($row = $result->fetch_assoc()) {
- $favorites[] = $row;
- }
- }
-
- echo json_encode($favorites);
- exit;
- }
-
// 获取所有标签
elseif ($action === 'tags' && $requestMethod === 'GET') {
$sql = "SELECT id, name FROM tags ORDER BY name";
diff --git a/app_store.sql b/app_store.sql
index 30e8755..9f0c647 100644
--- a/app_store.sql
+++ b/app_store.sql
@@ -160,16 +160,7 @@ CREATE TABLE IF NOT EXISTS download_history (
FOREIGN KEY (version_id) REFERENCES app_versions(id) ON DELETE CASCADE
);
--- 创建用户收藏表
-CREATE TABLE IF NOT EXISTS user_favorites (
- id INT AUTO_INCREMENT PRIMARY KEY,
- user_id INT NOT NULL,
- app_id INT NOT NULL,
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- UNIQUE KEY unique_favorite (user_id, app_id),
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
- FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE
-);
+
-- 创建公告表
CREATE TABLE IF NOT EXISTS announcements (
diff --git a/developer_apps.php b/developer_apps.php
index 15917d7..8bde11a 100644
--- a/developer_apps.php
+++ b/developer_apps.php
@@ -189,7 +189,7 @@ $resultApps = $conn->query($sqlApps);
查看详情
-
+
diff --git a/index.php b/index.php
index cc90e7e..1b67ac1 100644
--- a/index.php
+++ b/index.php
@@ -309,7 +309,7 @@ $announcement = $announcementResult && $announcementResult->num_rows > 0 ? $anno
echo '平台: '. implode(', ', $platforms) . '
';
echo '评分: '. round($row['avg_rating'] ?? 0, 1) . '/5
';
echo '查看详情';
- echo '';
+
echo '';
}
} else {
diff --git a/remove_favorite_feature.sql b/remove_favorite_feature.sql
new file mode 100644
index 0000000..1c3280d
--- /dev/null
+++ b/remove_favorite_feature.sql
@@ -0,0 +1,2 @@
+-- 删除收藏功能相关表
+DROP TABLE IF EXISTS user_favorites;
\ No newline at end of file
diff --git a/version_list.php b/version_list.php
index 4131a78..fd6547a 100644
--- a/version_list.php
+++ b/version_list.php
@@ -139,7 +139,7 @@ while ($row = $result->fetch_assoc()) {
版本
发布日期:
-
+
-
-
+