debug: 修复时序问题导致的获取会话列表为空的问题
This commit is contained in:
parent
b2bbba8db6
commit
9ca89209af
|
|
@ -115,6 +115,23 @@ export const conversationApi = {
|
||||||
*/
|
*/
|
||||||
async fetchConversations(): Promise<Conversation[]> {
|
async fetchConversations(): Promise<Conversation[]> {
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
// 等待 authStore 初始化完成
|
||||||
|
if (!authStore.isInitialized) {
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
const unwatch = authStore.$subscribe(() => {
|
||||||
|
if (authStore.isInitialized) {
|
||||||
|
unwatch();
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 如果已经初始化了,立即 resolve
|
||||||
|
if (authStore.isInitialized) {
|
||||||
|
unwatch();
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const userId = authStore.userId;
|
const userId = authStore.userId;
|
||||||
|
|
||||||
// 构建 URL,添加 user_id 查询参数
|
// 构建 URL,添加 user_id 查询参数
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue