diff --git a/index.html b/index.html
index d4f9349..c66961d 100644
--- a/index.html
+++ b/index.html
@@ -492,6 +492,10 @@
+
加载中...
diff --git a/js/api.js b/js/api.js
index 27c2fbd..13a8345 100644
--- a/js/api.js
+++ b/js/api.js
@@ -281,6 +281,33 @@ const API = {
return data.data || [];
},
+ // ============================================================
+ // 用户屏蔽
+ // ============================================================
+ async blockUser(userId) {
+ const data = await apiFetch('/users/' + userId + '/block', { method: 'POST' });
+ if (data.error) throw new Error(data.error);
+ return data;
+ },
+
+ async unblockUser(userId) {
+ const data = await apiFetch('/users/' + userId + '/block', { method: 'DELETE' });
+ if (data.error) throw new Error(data.error);
+ return data;
+ },
+
+ async getBlockedUsers() {
+ const data = await apiFetch('/blocks');
+ if (data.error) throw new Error(data.error);
+ return data.data || [];
+ },
+
+ async getBlockStatus(userId) {
+ const data = await apiFetch('/users/' + userId + '/block-status');
+ if (data.error) throw new Error(data.error);
+ return data;
+ },
+
async getOrCreateConversation(other_user_id) {
const data = await apiFetch('/conversations', {
method: 'POST',
diff --git a/js/app.js b/js/app.js
index 2692367..7980e1a 100644
--- a/js/app.js
+++ b/js/app.js
@@ -440,10 +440,14 @@ async function updateUnreadBadge() {
function openMessageList() {
document.getElementById('messageListModal').classList.add('active');
- // 每次打开都回到会话列表状态,避免上次的搜索词残留
+ // 每次打开都回到会话列表状态,避免上次的搜索词或「已屏蔽」视图残留
const searchInput = document.getElementById('dmUserSearchInput');
if (searchInput) searchInput.value = '';
syncDmSearchClear();
+ const tabConv = document.getElementById('dmTabConversations');
+ const tabBlocked = document.getElementById('dmTabBlocked');
+ if (tabConv) tabConv.classList.add('active');
+ if (tabBlocked) tabBlocked.classList.remove('active');
renderMessageList();
}
@@ -491,12 +495,38 @@ async function renderDmUserSearch(keyword) {
${escapeHTML(u.username)}
${escapeHTML(u.signature || '点击发送私信')}
+