'
@@ -1056,33 +1076,27 @@
});
listEl.innerHTML = html;
- // 绑定删除按钮
listEl.querySelectorAll('.fav-folder-del').forEach(function (btn) {
btn.addEventListener('click', function () {
var id = btn.getAttribute('data-id');
if (!confirm('确定要删除此收藏夹?其中的收藏内容也将被清除。')) return;
- var xhr = new XMLHttpRequest();
- xhr.open('DELETE', '/api/folders/' + id, true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState !== 4) return;
- try {
- var r = JSON.parse(xhr.responseText);
+ api('DELETE', '/api/folders/' + id)
+ .then(function (r) {
if (r.success) {
showSettingsToast('收藏夹已删除');
loadFolders();
} else {
showSettingsToast(r.message || '删除失败', true);
}
- } catch (e) {
+ })
+ .catch(function () {
showSettingsToast('删除失败', true);
- }
- };
- xhr.send();
+ });
});
});
})
.catch(function () {
- listEl.innerHTML = '
加载失败
';
+ listEl.innerHTML = '
加载失败,请刷新页面重试
';
});
}
@@ -1094,24 +1108,18 @@
showSettingsToast('收藏夹名称不能超过 50 个字符', true);
return;
}
- var xhr = new XMLHttpRequest();
- xhr.open('POST', '/api/folders', true);
- xhr.setRequestHeader('Content-Type', 'application/json');
- xhr.onreadystatechange = function () {
- if (xhr.readyState !== 4) return;
- try {
- var r = JSON.parse(xhr.responseText);
+ api('POST', '/api/folders', { name: name.trim(), description: '', is_public: false })
+ .then(function (r) {
if (r.success) {
showSettingsToast('收藏夹已创建');
loadFolders();
} else {
showSettingsToast(r.message || '创建失败', true);
}
- } catch (e) {
+ })
+ .catch(function () {
showSettingsToast('创建失败', true);
- }
- };
- xhr.send(JSON.stringify({ name: name.trim(), description: '', is_public: false }));
+ });
});
}
diff --git a/templates/MetaLab-2026/static/css/posts.css b/templates/MetaLab-2026/static/css/posts.css
index ba90377..042869e 100644
--- a/templates/MetaLab-2026/static/css/posts.css
+++ b/templates/MetaLab-2026/static/css/posts.css
@@ -790,6 +790,184 @@
font-weight: 500;
}
+/* ========== 选择收藏夹弹窗 ========== */
+.fav-overlay {
+ position: fixed;
+ top: 0; left: 0; right: 0; bottom: 0;
+ background: rgba(0, 0, 0, 0.45);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 9999;
+}
+
+.fav-modal {
+ background: #fff;
+ border-radius: 12px;
+ width: 400px;
+ max-width: 92vw;
+ max-height: 80vh;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
+ overflow: hidden;
+}
+
+.fav-modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 20px 24px 16px;
+ border-bottom: 1px solid #f0f0f0;
+ flex-shrink: 0;
+}
+
+.fav-modal-header h3 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 600;
+ color: #111827;
+}
+
+.fav-close {
+ background: none;
+ border: none;
+ font-size: 24px;
+ color: #9ca3af;
+ cursor: pointer;
+ padding: 0;
+ line-height: 1;
+}
+
+.fav-close:hover {
+ color: #374151;
+}
+
+.fav-modal-body {
+ padding: 16px 24px;
+ overflow-y: auto;
+ flex: 1;
+}
+
+.fav-loading {
+ text-align: center;
+ padding: 24px 0;
+ font-size: 14px;
+ color: #9ca3af;
+}
+
+.fav-loading.fav-error {
+ color: #ef4444;
+}
+
+.fav-empty {
+ text-align: center;
+ padding: 24px 0;
+ font-size: 14px;
+ color: #9ca3af;
+}
+
+.fav-folder-list {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ margin-bottom: 16px;
+}
+
+.fav-folder-option {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 12px 14px;
+ border-radius: 8px;
+ border: 1px solid #e5e7eb;
+ cursor: pointer;
+ transition: all 0.15s ease;
+}
+
+.fav-folder-option:hover {
+ border-color: #f59e0b;
+ background: #fffbeb;
+}
+
+.fav-folder-option.active {
+ border-color: #f59e0b;
+ background: #fef3c7;
+ font-weight: 500;
+}
+
+.fav-folder-option.active::after {
+ content: "✓";
+ color: #f59e0b;
+ font-weight: 700;
+ font-size: 16px;
+}
+
+.fav-folder-opt-name {
+ font-size: 14px;
+ color: #1f2937;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ margin-right: 8px;
+}
+
+.fav-folder-opt-name small {
+ font-weight: 400;
+ color: #9ca3af;
+}
+
+.fav-folder-opt-count {
+ font-size: 12px;
+ color: #9ca3af;
+ flex-shrink: 0;
+}
+
+.fav-new-folder {
+ display: flex;
+ gap: 8px;
+ align-items: center;
+}
+
+.fav-new-input {
+ flex: 1;
+ padding: 10px 14px;
+ border: 1px solid #d1d5db;
+ border-radius: 8px;
+ font-size: 14px;
+ font-family: inherit;
+ outline: none;
+ transition: border-color 0.15s;
+}
+
+.fav-new-input:focus {
+ border-color: #f59e0b;
+ box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
+}
+
+.fav-new-btn {
+ padding: 10px 16px;
+ border: none;
+ border-radius: 8px;
+ background: #f59e0b;
+ color: #fff;
+ font-size: 13px;
+ font-weight: 500;
+ font-family: inherit;
+ cursor: pointer;
+ transition: background 0.15s;
+ white-space: nowrap;
+}
+
+.fav-new-btn:hover {
+ background: #d97706;
+}
+
+.fav-new-btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+}
+
/* ========== 评论区 ========== */
.comments-section {
max-width: 800px;