消息-群设置功能

main
ysn 3 days ago
parent e5bee8ed0f
commit 224965c774
  1. 28
      src/views/message/components/GroupSetting.vue
  2. 41
      src/views/message/components/MessageDisplay.vue

@ -9,7 +9,10 @@
> >
<div class="group-setting"> <div class="group-setting">
<!-- 群头像和名称 --> <!-- 群头像和名称 -->
<div class="group-info"> <div
class="group-info"
v-if="currentChat.scene === ContactsScene.GROUP"
>
<el-avatar <el-avatar
:size="40" :size="40"
:src=" :src="
@ -34,7 +37,11 @@
<div class="section"> <div class="section">
<div class="section-title">群成员 {{ groupInfo.user_num }}</div> <div class="section-title">群成员 {{ groupInfo.user_num }}</div>
<div class="member-list"> <div class="member-list">
<div class="member-item" @click="showAddMember"> <div
class="member-item"
@click="showAddMember"
v-if="currentChat.scene === ContactsScene.GROUP"
>
<el-icon <el-icon
class="el-icon-circle-plus-outline" class="el-icon-circle-plus-outline"
style="font-size: 40px" style="font-size: 40px"
@ -68,13 +75,18 @@
<i class="el-icon-minus" /> <i class="el-icon-minus" />
</span> </span>
</div> </div>
<span class="member-name" :title="member.name">{{ member.name }}</span> <span class="member-name" :title="member.name">{{
member.name
}}</span>
</div> </div>
</div> </div>
</div> </div>
<!-- 群管理员 --> <!-- 群管理员 -->
<div <div
v-if="groupInfo.user_list.some((m) => m.id === groupInfo.user_id)" v-if="
groupInfo.user_list.some((m) => m.id === groupInfo.user_id) &&
currentChat.scene === ContactsScene.GROUP
"
class="section" class="section"
> >
<div class="section-title">群管理员</div> <div class="section-title">群管理员</div>
@ -93,12 +105,14 @@
member.avatar member.avatar
" "
/> />
<span class="member-name" :title="member.name">{{ member.name }}</span> <span class="member-name" :title="member.name">{{
member.name
}}</span>
</div> </div>
</div> </div>
</div> </div>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div class="actions"> <div class="actions" v-if="currentChat.scene === ContactsScene.GROUP">
<el-button type="danger" @click="handleQuitGroup"> <el-button type="danger" @click="handleQuitGroup">
退出群组 退出群组
</el-button> </el-button>
@ -369,7 +383,7 @@ export default {
font-size: 12px; font-size: 12px;
color: #606266; color: #606266;
text-align: center; text-align: center;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;

@ -19,7 +19,7 @@
type="text" type="text"
icon="el-icon-s-tools" icon="el-icon-s-tools"
@click="handleGroupSetting" @click="handleGroupSetting"
v-if="currentChat && currentChat.scene === ContactsScene.GROUP" v-if="currentChat"
/> />
</div> </div>
</div> </div>
@ -676,14 +676,11 @@ export default {
text = text.replace(/\n/g, "<br>"); text = text.replace(/\n/g, "<br>");
// @ - data // @ - data
let atIndex = 0; let atIndex = 0;
text = text.replace( text = text.replace(/@([^\s@]+)/g, (match, username) => {
/@([^\s@]+)/g, const result = `<span class="at-highlight" data-username="${username}" data-at-index="${atIndex}">@${username}</span>`;
(match, username) => { atIndex++;
const result = `<span class="at-highlight" data-username="${username}" data-at-index="${atIndex}">@${username}</span>`; return result;
atIndex++; });
return result;
}
);
// URL // URL
text = text.replace( text = text.replace(
/(https?:\/\/[^\s]+)/g, /(https?:\/\/[^\s]+)/g,
@ -697,11 +694,11 @@ export default {
if (target.classList.contains("at-highlight")) { if (target.classList.contains("at-highlight")) {
const username = target.dataset.username; const username = target.dataset.username;
const atIndex = parseInt(target.dataset.atIndex, 10); const atIndex = parseInt(target.dataset.atIndex, 10);
// at_userstp_ids ID // at_userstp_ids ID
const tpIds = msg.at_users || msg.tp_ids || []; const tpIds = msg.at_users || msg.tp_ids || [];
const userId = tpIds[atIndex]; const userId = tpIds[atIndex];
if (userId) { if (userId) {
this.getUserInfoById(userId); this.getUserInfoById(userId);
} else if (username) { } else if (username) {
@ -713,9 +710,9 @@ export default {
async getUserInfoById(userId) { async getUserInfoById(userId) {
try { try {
const response = await this.$http.get(`/api/v1/users/info`, { const response = await this.$http.get(`/api/v1/users/info`, {
params: { user_id: userId } params: { user_id: userId },
}); });
if (response.data.code === 200) { if (response.data.code === 200) {
const userInfo = response.data.data; const userInfo = response.data.data;
this.showUserInfoModal(userInfo); this.showUserInfoModal(userInfo);
@ -729,19 +726,25 @@ export default {
}, },
showUserInfoModal(userInfo) { showUserInfoModal(userInfo) {
this.$alert(` this.$alert(
`
<div style="text-align: left;"> <div style="text-align: left;">
<h3 style="margin-bottom: 15px;">${userInfo.name || userInfo.username}</h3> <h3 style="margin-bottom: 15px;">${
userInfo.name || userInfo.username
}</h3>
<p><strong>账号</strong>${userInfo.username}</p> <p><strong>账号</strong>${userInfo.username}</p>
<p><strong>手机</strong>${userInfo.phone || "-"}</p> <p><strong>手机</strong>${userInfo.phone || "-"}</p>
<p><strong>邮箱</strong>${userInfo.email || "-"}</p> <p><strong>邮箱</strong>${userInfo.email || "-"}</p>
<p><strong>部门</strong>${userInfo.department || "-"}</p> <p><strong>部门</strong>${userInfo.department || "-"}</p>
<p><strong>职位</strong>${userInfo.position || "-"}</p> <p><strong>职位</strong>${userInfo.position || "-"}</p>
</div> </div>
`, '用户信息', { `,
dangerouslyUseHTMLString: true, "用户信息",
confirmButtonText: '关闭' {
}); dangerouslyUseHTMLString: true,
confirmButtonText: "关闭",
}
);
}, },
getFileUrl(pathOrUrl) { getFileUrl(pathOrUrl) {

Loading…
Cancel
Save