acdr-ui/dist/dev/mp-weixin/modules/pet/message/privatechat.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
2024-10-01 09:15:35 +08:00
const common_vendor = require("../../../common/vendor.js");
const service_webSocket = require("../../../service/webSocket.js");
2024-09-19 07:20:14 +08:00
if (!Array) {
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
_component_layout_default_uni();
}
const _sfc_main = {
__name: "privatechat",
setup(__props) {
const { connectWebSocket, sendMessage, closeWebSocket } = service_webSocket.useWebSocket();
const message = common_vendor.ref("");
const sendMessageToServer = () => {
if (message.value.trim() !== "") {
sendMessage(message.value);
message.value = "";
}
};
common_vendor.onMounted(() => {
connectWebSocket();
});
common_vendor.onUnmounted(() => {
closeWebSocket();
});
return (_ctx, _cache) => {
return {
a: message.value,
b: common_vendor.o(($event) => message.value = $event.detail.value),
c: common_vendor.o(sendMessageToServer)
};
};
}
};
wx.createPage(_sfc_main);