no message
This commit is contained in:
parent
8233411831
commit
01529b1b99
3
App.vue
3
App.vue
@ -22,12 +22,9 @@ export default {
|
|||||||
async initIMOnLaunch() {
|
async initIMOnLaunch() {
|
||||||
try {
|
try {
|
||||||
const account = accountStore();
|
const account = accountStore();
|
||||||
|
|
||||||
// 检查是否已有账户信息(包含 openId)
|
// 检查是否已有账户信息(包含 openId)
|
||||||
const storedAccount = uni.getStorageSync("account");
|
const storedAccount = uni.getStorageSync("account");
|
||||||
const storedOpenId = uni.getStorageSync("openid");
|
const storedOpenId = uni.getStorageSync("openid");
|
||||||
debugger;
|
|
||||||
|
|
||||||
if (storedOpenId) {
|
if (storedOpenId) {
|
||||||
console.log("检测到已登录的 openId,开始初始化 IM:", storedOpenId);
|
console.log("检测到已登录的 openId,开始初始化 IM:", storedOpenId);
|
||||||
account.openid = storedOpenId;
|
account.openid = storedOpenId;
|
||||||
|
|||||||
@ -286,7 +286,6 @@ defineExpose({
|
|||||||
|
|
||||||
.popup-footer {
|
.popup-footer {
|
||||||
padding: 20rpx 32rpx;
|
padding: 20rpx 32rpx;
|
||||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
|
||||||
border-top: 1rpx solid #f0f0f0;
|
border-top: 1rpx solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -348,23 +348,30 @@ $primary-color: #0877F1;
|
|||||||
.text-input,
|
.text-input,
|
||||||
.voice-input-btn {
|
.voice-input-btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 46rpx;
|
padding: 16rpx 46rpx;
|
||||||
background-color: #f3f5fa;
|
background-color: #f3f5fa;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
margin: 0 16rpx;
|
margin: 0 16rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
height: 80rpx;
|
min-height: 80rpx;
|
||||||
|
max-height: 200rpx;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
line-height: 1.5;
|
||||||
align-items: center;
|
|
||||||
line-height: 96rpx;
|
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.voice-input-btn {
|
||||||
|
height: 80rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 46rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.voice-input-btn {
|
.voice-input-btn {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
line-height: 80rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.more-panel {
|
.more-panel {
|
||||||
|
|||||||
@ -6,8 +6,9 @@
|
|||||||
<uni-icons v-else type="mic" size="28" color="#666" />
|
<uni-icons v-else type="mic" size="28" color="#666" />
|
||||||
</view>
|
</view>
|
||||||
<view class="input-area">
|
<view class="input-area">
|
||||||
<input v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
|
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
|
||||||
@confirm="sendTextMessage" @focus="handleInputFocus" />
|
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
|
||||||
|
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" />
|
||||||
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
|
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
|
||||||
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
|
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
|
||||||
</input>
|
</input>
|
||||||
@ -334,6 +335,13 @@ function handleInputFocus() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleInput(e) {
|
||||||
|
// textarea 输入时触发,可以在这里处理额外逻辑
|
||||||
|
nextTick().then(() => {
|
||||||
|
emit("scrollToBottom");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 初始化录音管理器
|
// 初始化录音管理器
|
||||||
initRecorderManager();
|
initRecorderManager();
|
||||||
|
|||||||
@ -444,24 +444,7 @@ onShow(async () => {
|
|||||||
|
|
||||||
// 初始化IM
|
// 初始化IM
|
||||||
const imReady = await initIM();
|
const imReady = await initIM();
|
||||||
if (!imReady) {
|
if (!imReady) initIMAfterLogin();
|
||||||
console.error("IM初始化失败");
|
|
||||||
uni.showToast({
|
|
||||||
title: "连接失败,请重试",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 二次验证:确保 TIM 实例存在
|
|
||||||
if (!globalTimChatManager || !globalTimChatManager.tim) {
|
|
||||||
console.error("IM初始化后 TIM 实例仍不存在");
|
|
||||||
uni.showToast({
|
|
||||||
title: "初始化异常,请重启应用",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 先加载初始会话列表
|
// 先加载初始会话列表
|
||||||
await loadConversationList();
|
await loadConversationList();
|
||||||
// 再设置监听器,后续通过事件更新列表
|
// 再设置监听器,后续通过事件更新列表
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user