|
@@ -1,9 +1,12 @@
|
|
|
<template>
|
|
|
- <div class="container" :style="{height: `calc(100% - ${currentBottomHeight}px)`}">
|
|
|
+ <div
|
|
|
+ class="container"
|
|
|
+ :style="{ height: `calc(100% - ${currentBottomHeight}px)` }"
|
|
|
+ >
|
|
|
<div class="chat-bg"></div>
|
|
|
<div class="header-chat">
|
|
|
<svg-icon class="page-icon" name="lf-arrow" @click="goBack" />
|
|
|
- <div class="header-title">群聊2(8) </div>
|
|
|
+ <div class="header-title">群聊2(8)</div>
|
|
|
<svg-icon class="page-icon" name="more" @click="goDetail" />
|
|
|
</div>
|
|
|
<div class="chat-list">
|
|
@@ -58,20 +61,32 @@
|
|
|
class="input"
|
|
|
v-model="text"
|
|
|
@focus="onFocus"
|
|
|
- placeholder="输入文本"
|
|
|
+ placeholder="输入文本"
|
|
|
+ @keyup.enter="sendMessage"
|
|
|
/>
|
|
|
- <svg-icon class="page-icon mr12" name="emoji" @click="toggleAppBox(1)"/>
|
|
|
- <svg-icon class="page-icon" name="add2" @click="toggleAppBox(2)"/>
|
|
|
+ <svg-icon
|
|
|
+ class="page-icon mr12"
|
|
|
+ name="emoji"
|
|
|
+ @click="toggleAppBox(1)"
|
|
|
+ />
|
|
|
+ <svg-icon class="page-icon" name="add2" @click="toggleAppBox(2)" />
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<!-- 表情面板 -->
|
|
|
- <div class="app-box" v-show="showEmoji" :style="{height: `${appBoxHeight}px`}">
|
|
|
+ <div
|
|
|
+ class="app-box"
|
|
|
+ v-show="showEmoji"
|
|
|
+ :style="{ height: `${appBoxHeight}px` }"
|
|
|
+ >
|
|
|
😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌 😍
|
|
|
-
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<!-- 工具栏面板 -->
|
|
|
- <div class="app-box" v-show="showTools" :style="{height: `${appBoxHeight}px`}">
|
|
|
+ <div
|
|
|
+ class="app-box"
|
|
|
+ v-show="showTools"
|
|
|
+ :style="{ height: `${appBoxHeight}px` }"
|
|
|
+ >
|
|
|
<!-- 工具栏内容:可放按钮、图标等 -->
|
|
|
<div class="tool-btn">照片</div>
|
|
|
<div class="tool-btn">视频</div>
|
|
@@ -85,11 +100,14 @@
|
|
|
<script setup>
|
|
|
import { ref, computed } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
|
-import { Keyboard } from '@capacitor/keyboard';
|
|
|
+import { Keyboard } from "@capacitor/keyboard";
|
|
|
+import { useWebSocketStore } from "@/stores/modules/webSocketStore.js";
|
|
|
|
|
|
const router = useRouter();
|
|
|
const text = ref("");
|
|
|
|
|
|
+const wsStore = useWebSocketStore();
|
|
|
+
|
|
|
// 状态管理
|
|
|
const keyboardHeight = ref(0);
|
|
|
const showEmoji = ref(false);
|
|
@@ -113,7 +131,7 @@ const toggleAppBox = async (type) => {
|
|
|
// 先隐藏键盘(如果正在显示)
|
|
|
await Keyboard.hide();
|
|
|
keyboardHeight.value = 0; // 立即重置键盘高度
|
|
|
-
|
|
|
+
|
|
|
// 切换面板状态
|
|
|
if (type === 1) {
|
|
|
showEmoji.value = !showEmoji.value;
|
|
@@ -133,11 +151,11 @@ const onFocus = () => {
|
|
|
|
|
|
// 键盘监听
|
|
|
const setupKeyboardListeners = async () => {
|
|
|
- Keyboard.addListener('keyboardWillShow', (info) => {
|
|
|
+ Keyboard.addListener("keyboardWillShow", (info) => {
|
|
|
keyboardHeight.value = info.keyboardHeight;
|
|
|
});
|
|
|
-
|
|
|
- Keyboard.addListener('keyboardWillHide', () => {
|
|
|
+
|
|
|
+ Keyboard.addListener("keyboardWillHide", () => {
|
|
|
keyboardHeight.value = 0;
|
|
|
});
|
|
|
};
|
|
@@ -147,10 +165,25 @@ const goBack = () => {
|
|
|
};
|
|
|
const goDetail = () => {
|
|
|
router.push("detail");
|
|
|
-}
|
|
|
+};
|
|
|
+
|
|
|
+// 发送消息
|
|
|
+const sendMessage = () => {
|
|
|
+ if (!text.value.trim()) {
|
|
|
+ return; // 空消息不发送
|
|
|
+ }
|
|
|
+
|
|
|
+ let message = {
|
|
|
+ content: text.value,
|
|
|
+ contentType: 1,
|
|
|
+ };
|
|
|
+ wsStore.sendMessage(message);
|
|
|
+ // 清空输入框
|
|
|
+ text.value = "";
|
|
|
+};
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- if (Capacitor.getPlatform() !== 'web') {
|
|
|
+ if (Capacitor.getPlatform() !== "web") {
|
|
|
Keyboard.removeAllListeners();
|
|
|
}
|
|
|
});
|
|
@@ -339,7 +372,7 @@ onUnmounted(() => {
|
|
|
transition: transform 0.3s ease;
|
|
|
transform: translateY(100%);
|
|
|
background-color: yellow;
|
|
|
-
|
|
|
+
|
|
|
&.visible {
|
|
|
transform: translateY(0);
|
|
|
}
|