增加ico文件
This commit is contained in:
+57
-1
@@ -175,6 +175,7 @@ async function loadPosts() {
|
||||
<td>${post.published_at ? new Date(post.published_at).toLocaleDateString() : '-'}</td>
|
||||
<td>
|
||||
<button class="btn-success" onclick="editPost(${post.id})">编辑</button>
|
||||
${post.status !== 'published' ? `<button class="btn-primary" onclick="changePostStatus(${post.id}, 'published')">发布</button>` : `<button class="btn-secondary" onclick="changePostStatus(${post.id}, 'draft')">下架</button>`}
|
||||
<button class="btn-danger" onclick="deletePost(${post.id})">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -272,6 +273,29 @@ async function handlePostSubmit(e) {
|
||||
}
|
||||
}
|
||||
|
||||
// 更改文章状态
|
||||
async function changePostStatus(id, status) {
|
||||
const actionText = status === 'published' ? '发布' : '下架';
|
||||
if (!confirm(`确定要${actionText}这篇文章吗?`)) return;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/admin/posts/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify({ status })
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
loadPosts();
|
||||
} else {
|
||||
const err = await res.json();
|
||||
alert(err.error || '操作失败');
|
||||
}
|
||||
} catch (err) {
|
||||
alert('网络错误');
|
||||
}
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
async function deletePost(id) {
|
||||
if (!confirm('确定要删除这篇文章吗?')) return;
|
||||
@@ -437,14 +461,17 @@ async function handleModalSubmit(e) {
|
||||
const id = document.getElementById('modal-id').value;
|
||||
|
||||
const data = {
|
||||
name: document.getElementById('modal-name').value,
|
||||
slug: document.getElementById('modal-slug').value
|
||||
};
|
||||
|
||||
// 页面使用 title,分类和标签使用 name
|
||||
if (type === 'page') {
|
||||
data.title = document.getElementById('modal-name').value;
|
||||
data.content = document.getElementById('modal-content').value;
|
||||
data.order = parseInt(document.getElementById('modal-order').value) || 0;
|
||||
data.status = 'published';
|
||||
} else {
|
||||
data.name = document.getElementById('modal-name').value;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -499,6 +526,35 @@ function editTag(id, name, slug) {
|
||||
document.getElementById('modal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
// 编辑页面
|
||||
async function editPage(id) {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/pages/${id}`, { headers: getHeaders() });
|
||||
const data = await res.json();
|
||||
const page = data.data;
|
||||
|
||||
document.getElementById('modal-type').value = 'page';
|
||||
document.getElementById('modal-id').value = id;
|
||||
document.getElementById('modal-title').textContent = '编辑页面';
|
||||
document.getElementById('modal-name').value = page.title;
|
||||
document.getElementById('modal-slug').value = page.slug;
|
||||
|
||||
// 添加内容区域
|
||||
document.querySelector('.modal-extra').innerHTML = `
|
||||
<label>内容</label>
|
||||
<textarea id="modal-content" rows="5"></textarea>
|
||||
<label>排序</label>
|
||||
<input type="number" id="modal-order" value="0">
|
||||
`;
|
||||
document.getElementById('modal-content').value = page.content;
|
||||
document.getElementById('modal-order').value = page.order;
|
||||
|
||||
document.getElementById('modal').classList.remove('hidden');
|
||||
} catch (err) {
|
||||
alert('加载页面失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 删除分类
|
||||
async function deleteCategory(id) {
|
||||
if (!confirm('确定要删除这个分类吗?')) return;
|
||||
|
||||
@@ -247,6 +247,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/admin/app.js?v=3"></script>
|
||||
<script src="/static/admin/app.js?v=6"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -354,6 +354,65 @@ a:hover {
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
/* 文章导航 - 上一篇/下一篇 */
|
||||
.post-navigation {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
margin: 30px 0;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.nav-prev,
|
||||
.nav-next {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.nav-next {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.nav-link.disabled {
|
||||
color: #999;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.nav-link.disabled:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 13px;
|
||||
color: #999;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.nav-link:hover .nav-title {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.site-title {
|
||||
@@ -373,4 +432,13 @@ a:hover {
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.post-navigation {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.nav-next {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Reference in New Issue
Block a user