78 lines
3.4 KiB
TypeScript
78 lines
3.4 KiB
TypeScript
/**
|
|
* 微信小程序全局类型声明
|
|
*/
|
|
/// <reference types="miniprogram-api-typings" />
|
|
|
|
// ===== Stores 模块类型 =====
|
|
declare module '../../stores' {
|
|
export const authStore: {
|
|
state: { isLoggedIn: boolean; userId: string | null; phoneBound: boolean; authStatus: string }
|
|
loginWithWechat: (code: string) => Promise<any>
|
|
logout: () => Promise<void>
|
|
}
|
|
export const userStore: {
|
|
state: { userState: any; profile: any }
|
|
hydrate: () => void
|
|
fetchStatus: () => Promise<void>
|
|
subscribe: (cb: (state: any) => void) => () => void
|
|
bindToPage: (page: any, fields: Record<string, string>) => () => void
|
|
}
|
|
export const matchStore: {
|
|
state: { recommendations: any[]; recState: string; likersCount: number }
|
|
fetchRecommendations: () => Promise<void>
|
|
loadMoreRecommendations: () => Promise<void>
|
|
fetchLikersCount: () => Promise<void>
|
|
like: (userId: string) => Promise<any>
|
|
pass: (userId: string) => Promise<void>
|
|
block: (userId: string, reason?: string) => Promise<void>
|
|
unmatch: (matchId: string) => Promise<void>
|
|
confirmSuccess: (matchId: string) => Promise<any>
|
|
subscribe: (cb: (state: any) => void) => () => void
|
|
bindToPage: (page: any, fields: Record<string, string>) => () => void
|
|
}
|
|
export const messageStore: {
|
|
state: { conversations: any[]; currentConversationId: string | null }
|
|
openConversation: (id: string) => Promise<void>
|
|
closeConversation: () => void
|
|
fetchConversations: () => Promise<void>
|
|
markConversationRead: (id: string) => Promise<void>
|
|
markConversationBlocked: (id: string) => void
|
|
onMessage: (convId: string, cb: (msg: any) => void) => () => void
|
|
subscribe: (cb: (state: any) => void) => () => void
|
|
bindToPage: (page: any, fields: Record<string, string>) => () => void
|
|
}
|
|
export const appStore: {
|
|
state: { loading: boolean }
|
|
init: () => Promise<void>
|
|
toast: (msg: string) => void
|
|
toastSuccess: (msg: string) => void
|
|
toastError: (msg: string, fallback?: string) => void
|
|
showLoading: (msg?: string) => void
|
|
hideLoading: () => void
|
|
confirm: (opts: { title: string; content: string; confirmText: string; danger?: boolean }) => Promise<boolean>
|
|
}
|
|
export const blockUser: (userId: string, reason?: string) => Promise<void>
|
|
export const likeUser: (userId: string) => Promise<any>
|
|
}
|
|
|
|
// ===== Constants 模块类型 =====
|
|
declare module '../../constants' {
|
|
export const ROUTE: {
|
|
TAB: { HOME: string; DISCOVER: string; MESSAGES: string; ACTIVITY: string; MINE: string }
|
|
MAIN: { DISCOVER: string; FATE_CENTER: string }
|
|
DETAIL: { PROFILE_DETAIL: string; ACTIVITY_REGISTER: string; MATCHMAKER_APPLY: string; LIKERS: string; MATCHMAKER_PROGRESS: string }
|
|
REVIEW: { PENDING: string; REJECTED: string; ACCOUNT_STATUS: string }
|
|
AUTH: { LOGIN: string }
|
|
}
|
|
export const to: {
|
|
detail: (userId: string) => string
|
|
chat: (convId: string) => string
|
|
}
|
|
export const BUSINESS_LIMITS: { MAX_PROFILE_PHOTOS: number }
|
|
export const RECOMMENDATION_STATE: { IDLE: string; LOADING: string; ERROR: string; EMPTY: string }
|
|
export const PROFILE_REVIEW: { NOT_SUBMITTED: string; PENDING: string; APPROVED: string; NEED_EDIT: string; REJECTED: string }
|
|
export const ACCOUNT_STATUS: { NORMAL: string; BANNED: string; SUSPENDED: string }
|
|
export const DANGER_ACTION: { BLOCK: string; UNMATCH: string }
|
|
export const BUSINESS_ERROR_CODE: { PROFILE_NOT_APPROVED: string; ACCOUNT_BANNED: string }
|
|
}
|