diff --git a/admin/addapp.php b/admin/addapp.php index e07fe1d..3730e4e 100644 --- a/admin/addapp.php +++ b/admin/addapp.php @@ -47,6 +47,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) { if ($stmt->execute() === TRUE) { $appId = $stmt->insert_id; + // 保存标签关联 + if (!empty($_POST['tags'])) { + $stmt = $conn->prepare("INSERT INTO app_tags (app_id, tag_id) VALUES (?, ?)"); + foreach ($_POST['tags'] as $tagId) { + $stmt->bind_param("ii", $appId, $tagId); + $stmt->execute(); + } + $stmt->close(); + } + // 处理上传的预览图片 if (!empty($_FILES['images']['name'][0])) { $uploadDir = '../images/'; @@ -146,6 +156,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) { +
+ + + 按住Ctrl键可选择多个标签 +
diff --git a/admin/editapp.php b/admin/editapp.php index 043b7e8..f73a41e 100644 --- a/admin/editapp.php +++ b/admin/editapp.php @@ -84,11 +84,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) { } } - header('Location: index.php?success=App 更新成功'); - exit; - } else { - $error = 'App 更新失败: '. $conn->error; - } + // 更新标签关联 + $stmt = $conn->prepare("DELETE FROM app_tags WHERE app_id = ?"); + $stmt->bind_param("i", $appId); + $stmt->execute(); + $stmt->close(); + + if (!empty($_POST['tags'])) { + $stmt = $conn->prepare("INSERT INTO app_tags (app_id, tag_id) VALUES (?, ?)"); + foreach ($_POST['tags'] as $tagId) { + $stmt->bind_param("ii", $appId, $tagId); + $stmt->execute(); + } + $stmt->close(); + } + + header('Location: index.php?success=App 更新成功'); + exit; + } else { + $error = 'App 更新失败: '. $conn->error; + } } ?> @@ -150,7 +165,29 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) {
-
+
+ + +
按住Ctrl键可选择多个标签
+
+
diff --git a/admin/index.php b/admin/index.php index 1abefe3..306d86c 100644 --- a/admin/index.php +++ b/admin/index.php @@ -75,6 +75,9 @@ if (!$resultApps) {

App列表

+
+ 标签管理 +
diff --git a/admin/manage_tags.php b/admin/manage_tags.php new file mode 100644 index 0000000..fe69fc8 --- /dev/null +++ b/admin/manage_tags.php @@ -0,0 +1,155 @@ +prepare("INSERT INTO tags (name) VALUES (?)"); + $stmt->bind_param("s", $name); + if ($stmt->execute()) { + header('Location: manage_tags.php?success=标签添加成功'); + exit; + } else { + $error = '添加失败: ' . $conn->error; + } + } else { + $error = '标签名称不能为空'; + } +} + +// 处理标签删除 +if (isset($_GET['delete'])) { + $tagId = intval($_GET['delete']); + $stmt = $conn->prepare("DELETE FROM tags WHERE id = ?"); + $stmt->bind_param("i", $tagId); + if ($stmt->execute()) { + header('Location: manage_tags.php?success=标签删除成功'); + exit; + } else { + $error = '删除失败: ' . $conn->error; + } +} + +// 处理标签编辑 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_tag'])) { + $tagId = intval($_POST['tag_id']); + $name = trim($_POST['tag_name']); + if (!empty($name)) { + $stmt = $conn->prepare("UPDATE tags SET name = ? WHERE id = ?"); + $stmt->bind_param("si", $name, $tagId); + if ($stmt->execute()) { + header('Location: manage_tags.php?success=标签更新成功'); + exit; + } else { + $error = '更新失败: ' . $conn->error; + } + } else { + $error = '标签名称不能为空'; + } +} + +// 获取所有标签 +$tagsResult = $conn->query("SELECT * FROM tags ORDER BY created_at DESC"); +?> + + + + + + 标签管理 - 应用商店后台 + + + +
+

标签管理

+ 返回应用列表 + + +
+ + +
+ + + +
+
+
添加新标签
+
+
+
+
+ + +
+ + +
+
+ + +
+
+
现有标签
+
+
+
+ + + + + + + + + + fetch_assoc()): ?> + + + + + + + + + + + +
ID标签名称创建时间操作
+ + + 删除 +
+
+ + + + + + \ No newline at end of file diff --git a/api.php b/api.php index e9b2dc7..a938900 100644 --- a/api.php +++ b/api.php @@ -42,6 +42,14 @@ if (isset($_GET['action'])) { $stmtParams[] = &$ageRating; $paramTypes .= 's'; } + + // 标签过滤 + if (isset($_GET['tag'])) { + $tag = $_GET['tag']; + $conditions[] = "apps.id IN (SELECT app_id FROM app_tags JOIN tags ON app_tags.tag_id = tags.id WHERE tags.name = ?)"; + $stmtParams[] = &$tag; + $paramTypes .= 's'; + } // 分页参数处理 $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; @@ -155,6 +163,18 @@ if (isset($_GET['action'])) { } $app['reviews'] = $reviews; + // 获取应用标签 + $sqlTags = "SELECT tags.id, tags.name FROM app_tags JOIN tags ON app_tags.tag_id = tags.id WHERE app_tags.app_id = ?"; + $stmtTags = $conn->prepare($sqlTags); + $stmtTags->bind_param("i", $appId); + $stmtTags->execute(); + $resultTags = $stmtTags->get_result(); + $tags = []; + while ($tag = $resultTags->fetch_assoc()) { + $tags[] = $tag; + } + $app['tags'] = $tags; + echo json_encode($app); } else { http_response_code(404); @@ -198,6 +218,18 @@ if (isset($_GET['action'])) { echo json_encode($favorites); exit; } + + // 获取所有标签 + elseif ($action === 'tags' && $requestMethod === 'GET') { + $sql = "SELECT id, name FROM tags ORDER BY name"; + $result = $conn->query($sql); + $tags = []; + while ($row = $result->fetch_assoc()) { + $tags[] = $row; + } + echo json_encode($tags); + exit; + } // 获取应用推荐列表 elseif ($action === 'recommendations' && $requestMethod === 'GET') { diff --git a/app.php b/app.php index 89713b2..5438b01 100644 --- a/app.php +++ b/app.php @@ -100,7 +100,33 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) {

-

适用平台:

+

适用平台: '', + 'Mac' => '', + 'Linux' => '', + 'Android' => '', + 'iOS' => '' + ]; + $platformMap = [ + 'android' => 'Android', + 'ios' => 'iOS', + 'windows_win7' => 'Windows(Windows 7以上)', + 'windows_xp' => 'Windows XP', + 'macos' => 'MacOS', + 'linux_arch' => 'Linux(适用于Arch Linux)', + 'linux_ubuntu' => 'Linux(适用于Ubuntu)', + ]; + + $platformTexts = []; + foreach ($platforms as $platform) { + $icon = $platformIcons[$platform] ?? $platformIcons[ucfirst($platform)] ?? ''; + $readableName = $platformMap[strtolower($platform)] ?? ucfirst($platform); + $platformTexts[] = $icon . ' ' . $readableName; + } + echo implode(', ', $platformTexts); + ?>

评分: /5

diff --git a/app_store.sql b/app_store.sql index aa71e41..7d81003 100644 --- a/app_store.sql +++ b/app_store.sql @@ -64,6 +64,22 @@ CREATE TABLE IF NOT EXISTS users ( last_login TIMESTAMP NULL ); +-- 创建标签表 +CREATE TABLE IF NOT EXISTS tags ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL UNIQUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 创建应用标签关联表 +CREATE TABLE IF NOT EXISTS app_tags ( + app_id INT NOT NULL, + tag_id INT NOT NULL, + PRIMARY KEY (app_id, tag_id), + FOREIGN KEY (app_id) REFERENCES apps(id) ON DELETE CASCADE, + FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE +); + -- 创建应用分类表 CREATE TABLE IF NOT EXISTS categories ( id INT AUTO_INCREMENT PRIMARY KEY, diff --git a/files/cloudmusic.exe b/files/cloudmusic.exe new file mode 100644 index 0000000..63f5dde Binary files /dev/null and b/files/cloudmusic.exe differ diff --git a/files/fabric-installer-1.0.1.jar b/files/fabric-installer-1.0.1.jar new file mode 100644 index 0000000..a85af08 Binary files /dev/null and b/files/fabric-installer-1.0.1.jar differ diff --git a/images/139649.jpg b/images/139649.jpg new file mode 100644 index 0000000..33c8922 Binary files /dev/null and b/images/139649.jpg differ diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000..0eee89b Binary files /dev/null and b/images/icon.png differ diff --git a/index.php b/index.php index 5687c8a..56a9895 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,10 @@ + +if (!isset($conn) || !$conn instanceof mysqli) { + die('数据库连接失败,请检查配置文件。'); +}?> @@ -31,23 +34,53 @@ require_once 'config.php';
-
-
- - + + +
+
+ +
+
+ +
+
+ +

最新应用

@@ -55,26 +88,83 @@ require_once 'config.php'; prepare($sql); - $searchTerm = "%$search%"; - $stmt->bind_param("ss", $searchTerm, $searchTerm); - $stmt->execute(); + if (!$stmt) { + die('预处理语句失败: ' . $conn->error); + } + call_user_func_array([$stmt, 'bind_param'], array_merge([$paramTypes], $params)); + if (!$stmt->execute()) { + die('执行语句失败: ' . $stmt->error); + } $result = $stmt->get_result(); } else { $result = $conn->query($sql); + if (!$result) { + die('查询失败: ' . $conn->error); + } } if ($result->num_rows > 0) { diff --git a/tags.php b/tags.php new file mode 100644 index 0000000..ebbbe82 --- /dev/null +++ b/tags.php @@ -0,0 +1,170 @@ +prepare($sql); + if (!$stmt) { + die('预处理语句失败: ' . $conn->error); + } + $stmt->bind_param($paramTypes, ...$params); + if (!$stmt->execute()) { + die('执行语句失败: ' . $stmt->error); + } + $result = $stmt->get_result(); +} else { + $result = $conn->query($sql); + if (!$result) { + die('查询失败: ' . $conn->error); + } +} + +$tagResult = $conn->query("SELECT id, name FROM tags ORDER BY name"); +?> + + + + + + 应用标签 + + + + + + + + + + + +
+

应用标签

+
+ query("SELECT id, name FROM tags ORDER BY name"); ?> + fetch_assoc()): ?> + + + + +
+
+
+
+ +
+
+ +
+
+
+
+ num_rows > 0): ?> + fetch_assoc()): ?> +
+
+ <?php echo $row['name']; ?> +
+
+

...

+

评分: /5

+ 查看详情 +
+
+
+ + +
+

未找到相关应用。

+
+ +
+
+ + + + + + \ No newline at end of file