im language

This commit is contained in:
cansnow 2025-06-10 20:19:45 +08:00
parent 40caa96cc6
commit f628023a7e
5 changed files with 62 additions and 95 deletions

View File

@ -10,6 +10,19 @@
"nodata": "No data available",
"loading": "Data Loading...",
"copy": "Copy",
"im":{
"community":"MT Community",
"create_group":"Add",
"customer_service":"Union Customer Service",
"my_team":"My team",
"msg_none":"",
"pic_msg":"[Image]",
"loading_fail":"Loading fail",
"send_fail":"Send Fail",
"loading":"loading...",
"gallery":"gallery",
"camera":"camera"
},
"setIndex":{
"title": "setting",
"text1": "PIN code setting",

View File

@ -10,6 +10,19 @@
"nodata": "暂无数据",
"loading": "数据加载...",
"copy": "复制",
"im":{
"community":"MT 社区",
"create_group":"Add",
"customer_service":"客服服务",
"my_team":"我的团队",
"msg_none":"暂无消息",
"pic_msg":"[图片]",
"loading_fail":"加载失败",
"send_fail":"发送失败",
"loading":"加载中...",
"gallery":"照片",
"camera":"相机"
},
"setIndex":{
"title": "设置",
"text1": "PIN码设置",

View File

@ -2,12 +2,12 @@
<view class="container" :style="pageHeight">
<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back" :title="channel.name || $t('Chat')" :border="false"
backgroundColor="#F5F5F5" :statusBar="true">
<template v-slot:right>
<!-- <template v-slot:right>
<view class="nav-right">
<uni-icons v-if="channel.type === 'O'" type="more-filled" size="24"
@click="showGroupMenu"></uni-icons>
</view>
</template>
</template> -->
</uni-nav-bar>
<view class="box-1" @click="emoji_show=addons_show=false">
@ -19,7 +19,7 @@
<!-- 加载更多提示 -->
<view v-if="isLoading" class="loading-more">
<uni-icons type="spinner-cycle" size="20" color="#999"></uni-icons>
<text>加载中...</text>
<text>{{$t('im.loading')}}</text>
</view>
<!-- 消息列表 -->
@ -78,11 +78,11 @@
<view class="addons" v-show="addons_show">
<button @tap="sendphoto">
<uni-icons type="image" size="24" color="#666"></uni-icons>
{{$t('照片')}}
{{$t('im.gallery')}}
</button>
<button @tap="sendcamera">
<uni-icons type="camera-filled" size="24" color="#666"></uni-icons>
{{$t('拍摄')}}
{{$t('im.camera')}}
</button>
</view>
<view class="emoji" v-show="emoji_show">
@ -241,7 +241,7 @@ export default {
} catch (error) {
console.error('页面加载失败:', error);
uni.showToast({
title: this.$t('Load failed'),
title: this.$t('im.loading_fail'),
icon: 'none'
});
}
@ -258,20 +258,6 @@ export default {
let channel = await mattermost.getChannelById(options.target_id);
if(channel.type=='O'){
channel.name = channel.display_name || channel.name;
//
// const members = await mattermost.getChannelMembers(channel.id);
// console.log(':', members);
// const users_ids = [];
// for (const member of members) {
// if (member.user_id && member.user_id !== mattermost.getCurrentUserId()) {
// users_ids.push(member.user_id);
// }
// }
// const users = await mattermost.getUsersByIds(users_ids);
// console.log(':', users);
// for (const user of users.data) {
// mattermost.kown_users[user.id] = user;
// }
}
if(channel.type=='D'){
var target_user_id = channel.name.replace(mattermost.getCurrentUserId(),'').replace('__','')
@ -468,7 +454,7 @@ export default {
} catch (error) {
console.error('加载消息失败:', error);
uni.showToast({
title: '加载失败',
title: this.$t('im.loading_fail'),
icon: 'none'
});
} finally {
@ -502,7 +488,7 @@ export default {
} catch (error) {
console.error('发送消息失败:', error);
uni.showToast({
title: '发送失败',
title: this.$t('im.send_fail'),
icon: 'none'
});
}
@ -515,7 +501,7 @@ export default {
const result = await mattermost.sendImageMessage(this.channel.id, tempFilePath);
if (!result || !result.id) {
throw new Error('发送失败');
throw new Error(this.$t('im.send_fail'));
}
if(this.channel.type !='O'){
this.handleNewMessage({post:result});
@ -526,7 +512,7 @@ export default {
} catch (error) {
console.error('发送图片消息失败:', error);
uni.showToast({
title: '发送失败',
title: this.$t('im.send_fail'),
icon: 'none'
});
}
@ -670,7 +656,7 @@ export default {
} catch (error) {
this.talkList[index].status = 'failed';
uni.showToast({
title: this.$t('Resend failed'),
title: this.$t('im.send_fail'),
icon: 'none'
});
}

View File

@ -1,8 +1,8 @@
<template>
<view class="container">
<uni-nav-bar
:title="$t('MT Community')"
:right-text="$t('Add')"
:title="$t('im.community')"
:right-text="$t('im.create_group')"
right-icon="plus"
@clickRight="goto('/pages/im/index')"
:border="false"
@ -25,7 +25,7 @@
<uni-list>
<!-- 显示圆形头像 -->
<uni-list-item
:title="$t('Union customer service')"
:title="$t('im.customer_service')"
thumb="/static/im/kefu.png"
thumbSize="lg"
showArrow
@ -33,27 +33,27 @@
@click="show_kefu_popup"
></uni-list-item>
<uni-list-item
:title="$t('My team')"
:title="$t('im.my_team')"
thumb="/static/im/member.png"
thumbSize="lg"
showArrow
clickable
to="/pages/im/member"
></uni-list-item>
<template v-for="item in friend_list" >
<uni-list-chat
v-if="item.id"
:key="`${item.id}`"
:avatar-circle="true"
:title="item.display_name || item.name || item.nickname || item.email"
:avatar="item.id==='bkgjcxzi9j8wimrumt1nfosbgr' ? '/static/im/kefu1.png' : getAvatarUrl(item)"
:note="item.last_msg ? (item.last_msg_type === 'image' ? '[图片]' : item.last_msg) : '暂无消息'"
:time="item.last_post_at ? date(item.last_post_at) : ''"
:badge-text="item.unread_count > 0 ? (item.unread_count > 99 ? '99+' : item.unread_count) : ''"
clickable
@click="handleContactClick(item)"
></uni-list-chat>
</template>
<template v-for="item in friend_list" >
<uni-list-chat
v-if="item.id"
:key="`${item.id}`"
:avatar-circle="true"
:title="item.display_name || item.name || item.nickname || item.email"
:avatar="item.id==='bkgjcxzi9j8wimrumt1nfosbgr' ? '/static/im/kefu1.png' : getAvatarUrl(item)"
:note="item.last_msg ? (item.last_msg_type === 'image' ? $t('im.pic_msg') : item.last_msg) : $t('im.msg_none')"
:time="item.last_post_at ? date(item.last_post_at) : ''"
:badge-text="item.unread_count > 0 ? (item.unread_count > 99 ? '99+' : item.unread_count) : ''"
clickable
@click="handleContactClick(item)"
></uni-list-chat>
</template>
<!--这里显示最近联系人-->
</uni-list>
</scroll-view>
@ -123,10 +123,6 @@
scrollView: {
refresherTriggered: false //
},
// ID
kefu_ids: ['nps4r44g1fbwtn83cck18hn3iy', 'jj46siuqu3dzujk5uj3wekbqxe'],
// ID
fixed_channel_id: 'd5j75u5r5id77jmysszdtrijcr'
}
},
computed: {
@ -186,7 +182,7 @@
} catch (error) {
console.error('页面加载失败:', error);
uni.showToast({
title: '加载失败',
title: 'im.loading_fail',
icon: 'none'
});
}
@ -217,7 +213,7 @@
}
}
for (const key in recent_contacts) {
if (Object.prototype.hasOwnProperty.call(recent_contacts, key)) {
if (!Object.prototype.hasOwnProperty.call(sortedContacts, key) && Object.prototype.hasOwnProperty.call(recent_contacts, key)) {
sortedContacts[key] = recent_contacts[key];
}
}
@ -242,7 +238,7 @@
} catch (error) {
console.error('加载联系人列表失败:', error);
uni.showToast({
title: '加载失败',
title: this.$t('im.loading_fail'),
icon: 'none'
});
} finally {

View File

@ -1,7 +1,7 @@
<template>
<view class="container">
<uni-nav-bar
:title="$t('MT Team')"
:title="$t('im.my_team')"
left-icon="left"
@clickLeft="goto('/pages/im/index',2)"
:border="false"
@ -87,8 +87,6 @@
onUnload() {
//
mattermost.off('posted', this.handleNewMessage);
mattermost.off('post_deleted', this.handleMessageDeleted);
mattermost.off('post_edited', this.handleMessageEdited);
},
onPullDownRefresh() {
this.loadContactList().finally(() => {
@ -120,12 +118,10 @@
this.loadContactList();
//
mattermost.on('posted', this.handleNewMessage);
mattermost.on('post_deleted', this.handleMessageDeleted);
mattermost.on('post_edited', this.handleMessageEdited);
} catch (error) {
console.error('页面加载失败:', error);
uni.showToast({
title: '加载失败',
title: this.$t('im.loading_fail'),
icon: 'none'
});
}
@ -176,7 +172,7 @@
} catch (error) {
console.error('加载联系人列表失败:', error);
uni.showToast({
title: '加载失败',
title: this.$t('im.loading_fail'),
icon: 'none'
});
} finally {
@ -197,7 +193,7 @@
} catch (error) {
console.error('处理联系人点击失败:', error);
uni.showToast({
title: '操作失败',
title: this.$t('im.loading_fail'),
icon: 'none'
});
}
@ -261,43 +257,6 @@
this.friend_list = await updateContact(this.friend_list);
},
//
handleMessageDeleted(message) {
const updateContact = (list) => {
return list.map(contact => {
if(contact.id === message.channel_id) {
return {
...contact,
last_msg: '此消息已删除',
last_msg_type: 'text',
last_msg_time: message.create_at
};
}
return contact;
});
};
this.friend_list = updateContact(this.friend_list);
},
//
handleMessageEdited(message) {
const updateContact = (list) => {
return list.map(contact => {
if(contact.id === message.channel_id) {
return {
...contact,
last_msg: message.message,
last_msg_time: message.update_at
};
}
return contact;
});
};
this.friend_list = updateContact(this.friend_list);
},
refresherrefresh() {
this.scrollView.refresherTriggered = true;
this.ajax.page = 0;