feat: 调整优化登录的逻辑

This commit is contained in:
2025-09-15 22:52:44 +08:00
parent 66c256cefd
commit fc63bbc994
15 changed files with 190 additions and 159 deletions

View File

@@ -170,9 +170,9 @@ import {
import WebSocketManager from "@/utils/WebSocketManager";
import TypewriterManager from "@/utils/TypewriterManager";
import { IdUtils } from "@/utils";
import { useAppStore } from "@/store";
import { checkToken } from "@/hooks/useGoLogin";
import { goLogin } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
const appStore = useAppStore();
/// 导航栏相关
const statusBarHeight = ref(20);
@@ -356,7 +356,7 @@ onLoad(() => {
// token存在初始化数据
const initHandler = () => {
console.log("initHandler");
if (!appStore.hasToken) return;
loadRecentConversation();
///loadConversationMsgList();
initWebSocket();
@@ -368,6 +368,7 @@ watch(
() => appStore.hasToken,
(newValue) => {
if (newValue) {
console.log("token存在初始化数据");
initHandler();
}
}
@@ -380,7 +381,7 @@ onMounted(() => {
initTypewriterManager();
// 有token时加载最近会话、最近消息、初始化socket
checkToken().then(() => initHandler());
initHandler();
} catch (error) {
console.error("页面初始化错误:", error);
}
@@ -599,6 +600,13 @@ const initData = () => {
// 发送消息的参数拼接
const sendMessage = (message, isInstruct = false) => {
console.log("发送的消息:", message);
if (!appStore.hasToken) {
console.log("没有token跳转到登录页");
goLogin();
return;
}
if (isSessionActive.value) {
uni.showToast({
title: "请等待当前回复完成",