feat: 调整优化登录的逻辑
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
|
||||
<!-- 输入框/语音按钮容器 -->
|
||||
<view class="input-button-container">
|
||||
<Interceptor />
|
||||
|
||||
<textarea
|
||||
ref="textareaRef"
|
||||
v-if="!isVoiceMode"
|
||||
@@ -63,9 +61,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const plugin = requirePlugin("WechatSI");
|
||||
const manager = plugin.getRecordRecognitionManager();
|
||||
@@ -117,8 +113,7 @@ const toggleVoiceMode = () => {
|
||||
|
||||
// 处理语音按钮长按开始
|
||||
const handleVoiceTouchStart = () => {
|
||||
checkToken().then(() => {
|
||||
manager.start({ lang: "zh_CN" });
|
||||
manager.start({ lang: "zh_CN" });
|
||||
|
||||
visibleWaveBtn.value = true;
|
||||
|
||||
@@ -128,7 +123,6 @@ const handleVoiceTouchStart = () => {
|
||||
recordingWaveBtnRef.value.startAnimation();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 处理语音按钮长按结束
|
||||
|
||||
@@ -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: "请等待当前回复完成",
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
:key="index"
|
||||
>
|
||||
<view class="more-tips-item-title" @click="sendReply(item)">
|
||||
<Interceptor />
|
||||
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
@@ -18,9 +16,6 @@
|
||||
|
||||
<script setup>
|
||||
import { defineProps } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const emits = defineEmits(["replySent"]);
|
||||
|
||||
defineProps({
|
||||
@@ -39,8 +34,7 @@ defineProps({
|
||||
});
|
||||
|
||||
const sendReply = (text) => {
|
||||
// 向父组件传递数据
|
||||
checkToken().then(() => emits("replySent", text));
|
||||
emits("replySent", text);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
:key="index"
|
||||
@click="sendReply(item)"
|
||||
>
|
||||
<Interceptor />
|
||||
|
||||
<image
|
||||
class="quick-access-item-bg"
|
||||
src="/static/quick/quick_icon_bg.png"
|
||||
@@ -26,15 +24,12 @@
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const itemList = ref([]);
|
||||
|
||||
const emits = defineEmits(["replySent"]);
|
||||
|
||||
const sendReply = (item) => {
|
||||
checkToken().then(() => emits("replySent", item)); // 向父组件传递数据
|
||||
emits("replySent", item); // 向父组件传递数据
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -11,18 +11,30 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineEmits, ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
||||
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
const showLeft = ref(false);
|
||||
|
||||
// 打开窗口
|
||||
const showDrawer = (e) => {
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
showLeft.value.open();
|
||||
// 发送抽屉显示事件
|
||||
uni.$emit("drawerShow");
|
||||
};
|
||||
// 关闭窗口
|
||||
const closeDrawer = (e) => {
|
||||
showLeft.value.close();
|
||||
// 发送抽屉隐藏事件
|
||||
uni.$emit("drawerHide");
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user