feat: 未登录状态调整

This commit is contained in:
duanshuwen
2025-09-13 16:09:37 +08:00
parent c03a4200be
commit 11141ae436
8 changed files with 103 additions and 48 deletions

View File

@@ -136,7 +136,7 @@
</template>
<script setup>
import { onMounted, nextTick, onUnmounted, ref, defineEmits } from "vue";
import { onMounted, nextTick, onUnmounted, ref, defineEmits, watch } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import {
SCROLL_TO_BOTTOM,
@@ -353,6 +353,18 @@ onLoad(() => {
});
});
// token存在初始化数据
const initHandler = () => {
console.log("initHandler");
loadRecentConversation();
loadConversationMsgList();
initWebSocket();
};
// 监听token变化
uni.$on("TOKEN_CHANGE", () => initHandler());
onMounted(() => {
try {
getMainPageData();
@@ -360,11 +372,7 @@ onMounted(() => {
initTypewriterManager();
// 有token时加载最近会话、最近消息、初始化socket
checkToken().then(async () => {
await loadRecentConversation();
loadConversationMsgList();
initWebSocket();
});
checkToken().then(() => initHandler());
} catch (error) {
console.error("页面初始化错误:", error);
}