feat: 在应用详情页显示标签并简化版本控制交互
添加应用标签显示功能,从数据库查询并展示应用关联标签 移除版本控制页面中的SweetAlert弹窗,改为直接刷新页面
This commit is contained in:
15
app.php
15
app.php
@@ -215,6 +215,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['rating'])) {
|
|||||||
?></p>
|
?></p>
|
||||||
<p>评分: <?php echo round($app['avg_rating'], 1); ?>/5</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>
|
<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>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div id="imageCarousel" class="carousel slide" data-bs-ride="carousel">
|
<div id="imageCarousel" class="carousel slide" data-bs-ride="carousel">
|
||||||
|
|||||||
@@ -191,6 +191,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_version'])) {
|
|||||||
$error = '版本删除失败: ' . $conn->error;
|
$error = '版本删除失败: ' . $conn->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($success)) {
|
||||||
|
echo $success;
|
||||||
|
} else {
|
||||||
|
echo $error;
|
||||||
|
}
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取现有版本列表
|
// 获取现有版本列表
|
||||||
@@ -256,10 +263,10 @@ if (!$verStmt) {
|
|||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<?php if (!empty($success)): ?>
|
<?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 endif; ?>
|
||||||
<?php if (!empty($error)): ?>
|
<?php if (!empty($error)): ?>
|
||||||
<script>Swal.fire('错误', '<?php echo addslashes($error); ?>', 'error');</script>
|
<!-- <script>Swal.fire('错误', '<?php echo addslashes($error); ?>', 'error');</script> -->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="card blur-bg mb-4">
|
<div class="card blur-bg mb-4">
|
||||||
@@ -382,59 +389,28 @@ if (!$verStmt) {
|
|||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
editModal.hide();
|
editModal.hide();
|
||||||
Swal.fire({
|
window.location.reload();
|
||||||
title: '成功',
|
|
||||||
text: '版本修改成功',
|
|
||||||
icon: 'success'
|
|
||||||
}).then(() => window.location.reload());
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
editModal.hide();
|
editModal.hide();
|
||||||
Swal.fire({
|
window.location.reload();
|
||||||
title: '错误',
|
|
||||||
text: '版本修改失败: ' + error.message,
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmDelete(versionId, filePath) {
|
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();
|
const formData = new FormData();
|
||||||
formData.append('delete_version', 'true');
|
formData.append('delete_version', 'true');
|
||||||
formData.append('version_id', versionId);
|
formData.append('version_id', versionId);
|
||||||
formData.append('file_path', filePath);
|
formData.append('file_path', filePath);
|
||||||
|
|
||||||
fetch('version_control.php', {
|
fetch('version_control.php', { method: 'POST', body: formData })
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
})
|
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
Swal.fire({
|
window.location.reload();
|
||||||
title: '成功',
|
|
||||||
text: '版本删除成功',
|
|
||||||
icon: 'success'
|
|
||||||
}).then(() => window.location.reload());
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Swal.fire({
|
window.location.reload();
|
||||||
title: '错误',
|
|
||||||
text: '版本删除失败: ' + error.message,
|
|
||||||
icon: 'error'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user