feat: disable user messaging and retain公益 service guidance
CI/CD Pipeline / Test Shell Guard (Phase 23 Gate) (push) Canceled after 0s
CI/CD Pipeline / Backend Build & Test (push) Canceled after 0s
CI/CD Pipeline / Admin Web Build (push) Canceled after 0s
CI/CD Pipeline / Mini Program Compile Check (push) Canceled after 0s
CI/CD Pipeline / Migration Validation (push) Canceled after 0s
CI/CD Pipeline / UI Contracts (source-structure gates) (push) Canceled after 0s
CI/CD Pipeline / E2E (live stack) (push) Canceled after 0s
CI/CD Pipeline / Test Shell Guard (Phase 23 Gate) (push) Canceled after 0s
CI/CD Pipeline / Backend Build & Test (push) Canceled after 0s
CI/CD Pipeline / Admin Web Build (push) Canceled after 0s
CI/CD Pipeline / Mini Program Compile Check (push) Canceled after 0s
CI/CD Pipeline / Migration Validation (push) Canceled after 0s
CI/CD Pipeline / UI Contracts (source-structure gates) (push) Canceled after 0s
CI/CD Pipeline / E2E (live stack) (push) Canceled after 0s
This commit is contained in:
+5
-19
@@ -15,6 +15,7 @@
|
||||
const authStore = require('./authStore');
|
||||
const userStore = require('./userStore');
|
||||
const matchStore = require('./matchStore');
|
||||
// 兼容未注册的历史聊天页面源码;页面与服务端入口均已下线,不在启动流程中初始化。
|
||||
const messageStore = require('./messageStore');
|
||||
const activityStore = require('./activityStore');
|
||||
const matchmakerStore = require('./matchmakerStore');
|
||||
@@ -128,53 +129,40 @@ function isProfileApproved() {
|
||||
// ============ 跨 Store 编排 ============
|
||||
|
||||
/**
|
||||
* 拉黑用户:触发 MatchStore 与 MessageStore 同步副作用
|
||||
* - MatchStore:从推荐/Mutual 列表移除该用户
|
||||
* - MessageStore:标记对应会话不可发消息(AGENTS 第 4 条)
|
||||
* 拉黑用户:从推荐/Mutual 列表移除该用户。
|
||||
* @param {string} userId
|
||||
* @param {string} [reason]
|
||||
*/
|
||||
async function blockUser(userId, reason) {
|
||||
await matchStore.block(userId, reason);
|
||||
// 查找对应会话并标记停用
|
||||
const conv = messageStore.state.conversations.find(
|
||||
(c) => c.targetUserId === userId || c.conversationId === userId,
|
||||
);
|
||||
if (conv) messageStore.markConversationBlocked(conv.conversationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like 用户:若返回 mutualMatch=true,自动刷新会话列表
|
||||
* Like 用户:若返回 mutualMatch=true,仅保留匹配结果和公益服务引导。
|
||||
* @param {string} userId
|
||||
* @returns {Promise<import('../types').LikeResult>}
|
||||
*/
|
||||
async function likeUser(userId) {
|
||||
const result = await matchStore.like(userId);
|
||||
if (result && result.mutualMatch) {
|
||||
// Mutual Match 达成,刷新会话列表,让用户能立即开始聊天
|
||||
await messageStore.fetchConversations();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解除匹配:触发 MatchStore 与 MessageStore 同步副作用
|
||||
* 解除匹配。
|
||||
* @param {string} matchId
|
||||
*/
|
||||
async function unmatchConversation(matchId) {
|
||||
await matchStore.unmatch(matchId);
|
||||
messageStore.markConversationBlocked(matchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功牵手:双确认第二步(仅被请求方调用),成功后刷新 userStore 与会话列表
|
||||
* 成功牵手:双确认第二步(仅被请求方调用),成功后刷新 userStore。
|
||||
* @param {string} matchId
|
||||
*/
|
||||
async function confirmSuccess(matchId) {
|
||||
const result = await matchStore.confirmSuccess(matchId);
|
||||
// 成功牵手后关系状态变化,需刷新 userState
|
||||
try { await userStore.fetchStatus(); } catch (e) { /* 不阻塞主流程 */ }
|
||||
try { await messageStore.fetchConversations(); } catch (e) { /* 同上 */ }
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -185,14 +173,12 @@ async function confirmSuccess(matchId) {
|
||||
* 1. appStore.init() — 拉取服务端配置(不阻塞核心)
|
||||
* 2. authStore.hydrate() — 从本地恢复登录态
|
||||
* 3. userStore.hydrate() — 从本地恢复用户状态快照
|
||||
* 4. messageStore.hydrate() — 从本地恢复未读数(兜底)
|
||||
* 5. 若已登录,异步刷新 userStore.fetchStatus()(不阻塞启动)
|
||||
*/
|
||||
async function bootstrap() {
|
||||
// 同步阶段:本地状态恢复(避免白屏)
|
||||
authStore.hydrate();
|
||||
userStore.hydrate();
|
||||
messageStore.hydrate();
|
||||
|
||||
// 异步阶段:服务端配置 + 用户状态刷新
|
||||
// 配置失败不阻塞启动;状态失败由路由守卫处理(跳登录页)
|
||||
|
||||
Reference in New Issue
Block a user