feat: 消息的初始化处理
This commit is contained in:
@@ -48,7 +48,7 @@ export const CompName = {
|
||||
/// 发送的指令类型
|
||||
export const Command = {
|
||||
// 通知消息
|
||||
welcome: "Command.welcome",
|
||||
messageInit: "Command.init",
|
||||
// 快速预定
|
||||
quickBooking: "Command.quickBooking",
|
||||
// 探索发现
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<scroll-view class="main flex-full overflow-hidden scroll-y" scroll-y :scroll-top="scrollTop"
|
||||
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
|
||||
<!-- welcome栏 -->
|
||||
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" :welcomeMessage="welcomeMessage" />
|
||||
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
|
||||
<NoticeMessage v-if="notitceConent" :noticeContent="notitceConent"></NoticeMessage>
|
||||
|
||||
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
|
||||
@@ -135,7 +135,6 @@ const statusBarHeight = ref(20);
|
||||
const inputAreaRef = ref(null);
|
||||
const topNavBarRef = ref();
|
||||
const welcomeRef = ref();
|
||||
const welcomeMessage = ref("");
|
||||
const notitceConent = ref(null);
|
||||
|
||||
|
||||
@@ -426,11 +425,11 @@ const initWebSocket = async () => {
|
||||
// 连接成功后发送 welcome 消息 (messageType=4)
|
||||
try {
|
||||
// fire-and-forget, sendWebSocketMessage 会处理重连与队列
|
||||
sendWebSocketMessage(MessageType.notice, Command.welcome, { tryReconnect: true, messageId:IdUtils.generateMessageId() }).catch((e) => {
|
||||
console.warn('发送 Command.welcome 消息失败:', e);
|
||||
sendWebSocketMessage(MessageType.notice, Command.messageInit, { tryReconnect: true, messageId:IdUtils.generateMessageId() }).catch((e) => {
|
||||
console.warn('发送 Command.messageInit 消息失败:', e);
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('发送 Command.welcome 消息时异常:', e);
|
||||
console.warn('发送 Command.messageInit 消息时异常:', e);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -488,15 +487,6 @@ const handleWebSocketMessage = (data) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Welcome 消息 (messageType=4):用于更新顶部欢迎栏内容
|
||||
if (data.messageType && data.messageType === 'text') {
|
||||
console.log("收到 welcome 类型消息:", data);
|
||||
if (data.content) {
|
||||
welcomeMessage.value = data.content;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.messageType && data.messageType === 'broadcast') {
|
||||
console.log("收到 welcome 类型消息:", data);
|
||||
if (data.content) {
|
||||
|
||||
@@ -7,7 +7,7 @@ v
|
||||
:frameHeight="spriteStyle.frameHeight" :totalFrames="spriteStyle.totalFrames" :columns="spriteStyle.columns"
|
||||
:displayWidth="spriteStyle.displayWidth" :fps="16" />
|
||||
<view class="welcome-text font-size-14 font-500 font-family-misans-vf color-171717 line-height-24">
|
||||
{{ props.welcomeMessage || welcomeContent }}
|
||||
{{ welcomeContent }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -23,10 +23,6 @@ import ChatMoreTips from "../ChatMoreTips/index.vue";
|
||||
import SpriteAnimator from "@/components/Sprite/SpriteAnimator.vue";
|
||||
|
||||
const props = defineProps({
|
||||
welcomeMessage: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
mainPageDataModel: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
|
||||
Reference in New Issue
Block a user