feat: 未登录状态调整
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user