feat: 在应用详情页显示标签并简化版本控制交互

添加应用标签显示功能,从数据库查询并展示应用关联标签
移除版本控制页面中的SweetAlert弹窗,改为直接刷新页面
This commit is contained in:
2025-07-11 08:28:34 +08:00
parent e94ecf5deb
commit 4903c0aed4
2 changed files with 38 additions and 47 deletions

15
app.php
View File

@@ -215,6 +215,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) {
?></p>
<p>评分: <?php echo round($app['avg_rating'], 1); ?>/5</p>
<p>开发者: <?php if ($developerId == 0 || empty($developerName)): ?>管理员<?php else: ?><a href="developer_apps.php?id=<?php echo $developerId; ?>"><?php echo htmlspecialchars($developerName); ?></a><?php endif; ?></p>
<?php
// 获取应用标签
$sqlTags = "SELECT 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['name'];
}
if (!empty($tags)): ?>
<p>标签: <?php echo implode(', ', $tags); ?></p>
<?php endif; ?>
</div>
<div class="col-md-6">
<div id="imageCarousel" class="carousel slide" data-bs-ride="carousel">

View File

@@ -191,6 +191,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_version'])) {
$error = '版本删除失败: ' . $conn->error;
}
}
if (!empty($success)) {
echo $success;
} else {
echo $error;
}
exit;
}
// 获取现有版本列表
@@ -256,10 +263,10 @@ if (!$verStmt) {
<div class="container mt-4">
<?php if (!empty($success)): ?>
<script>Swal.fire('成功', '<?php echo addslashes($success); ?>', 'success');</script>
<!-- <script>Swal.fire('成功', '<?php echo addslashes($success); ?>', 'success');</script> -->
<?php endif; ?>
<?php if (!empty($error)): ?>
<script>Swal.fire('错误', '<?php echo addslashes($error); ?>', 'error');</script>
<!-- <script>Swal.fire('错误', '<?php echo addslashes($error); ?>', 'error');</script> -->
<?php endif; ?>
<div class="card blur-bg mb-4">
@@ -382,59 +389,28 @@ if (!$verStmt) {
.then(response => response.text())
.then(data => {
editModal.hide();
Swal.fire({
title: '成功',
text: '版本修改成功',
icon: 'success'
}).then(() => window.location.reload());
window.location.reload();
})
.catch(error => {
editModal.hide();
Swal.fire({
title: '错误',
text: '版本修改失败: ' + error.message,
icon: 'error'
});
window.location.reload();
});
});
}
function confirmDelete(versionId, filePath) {
Swal.fire({
title: '确认删除',
text: '确定要删除这个版本吗?删除后无法恢复!',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: '确定删除'
}).then((result) => {
if (result.isConfirmed) {
const formData = new FormData();
formData.append('delete_version', 'true');
formData.append('version_id', versionId);
formData.append('file_path', filePath);
fetch('version_control.php', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(data => {
Swal.fire({
title: '成功',
text: '版本删除成功',
icon: 'success'
}).then(() => window.location.reload());
})
.catch(error => {
Swal.fire({
title: '错误',
text: '版本删除失败: ' + error.message,
icon: 'error'
});
});
}
const formData = new FormData();
formData.append('delete_version', 'true');
formData.append('version_id', versionId);
formData.append('file_path', filePath);
fetch('version_control.php', { method: 'POST', body: formData })
.then(response => response.text())
.then(data => {
window.location.reload();
})
.catch(error => {
window.location.reload();
});
}
</script>