Commit f0747279 by Sixong.Zhu

Merge branch 'pre' into release

parents fc59130b d4ea4c8a
...@@ -33,8 +33,10 @@ ...@@ -33,8 +33,10 @@
<div v-if="isMyMessage" class="msg-read pos-rel"> <div v-if="isMyMessage" class="msg-read pos-rel">
<span <span
@click="openReaderList" @click="openReaderList"
class="pointer" :class="[
:class="isAllRead ? 'all' : 'not-all'" isAllRead ? 'all' : 'not-all',
{ pointer: isChatMember },
]"
> >
<template v-if="isAllRead"> <template v-if="isAllRead">
<i <i
...@@ -582,9 +584,11 @@ ...@@ -582,9 +584,11 @@
} }
private openReaderList(e: MouseEvent) { private openReaderList(e: MouseEvent) {
if (this.isChatMember) {
this.readerListOffset = e.x < 450; this.readerListOffset = e.x < 450;
this.readListVisibility = true; this.readListVisibility = true;
} }
}
private executeHandled() { private executeHandled() {
this.setHandled({ this.setHandled({
......
...@@ -225,12 +225,17 @@ export default { ...@@ -225,12 +225,17 @@ export default {
if (chatid) { if (chatid) {
// 移除撤回的消息 // 移除撤回的消息
const newItems = data || []; const newItems = data || [];
const withdraw = newItems const hasWithdraw = newItems.find(
.filter((i) => i.type === MessageType.Withdraw) (i) => i.type === MessageType.Withdraw
.map((i) => +i.msg);
const filterout = newItems.filter(
(i) => !withdraw.includes(i.id)
); );
const withdraw = hasWithdraw
? newItems
.filter((i) => i.type === MessageType.Withdraw)
.map((i) => +i.msg)
: [];
const filterout = withdraw.length
? newItems.filter((i) => !withdraw.includes(i.id))
: newItems;
state[ChatStore.STATE_CHAT_MSG_HISTORY] = Object.freeze( state[ChatStore.STATE_CHAT_MSG_HISTORY] = Object.freeze(
filterMessages([...old, ...filterout], chatid) filterMessages([...old, ...filterout], chatid)
); );
...@@ -610,16 +615,11 @@ export default { ...@@ -610,16 +615,11 @@ export default {
data = await getMessages(); data = await getMessages();
} }
try {
commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data); commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data);
dbController.saveChatMessages(chatId, data); dbController.saveChatMessages(chatId, data);
await preCacheImgs(data); await preCacheImgs(data);
commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM); commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM);
return data; return data;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
}, },
async [ChatStore.ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID]( async [ChatStore.ACTION_GET_CHAT_MESSAGES_BEFORE_SPECIFIC_ID](
{ state, commit, getters }, { state, commit, getters },
......
...@@ -56,6 +56,17 @@ export function uuid() { ...@@ -56,6 +56,17 @@ export function uuid() {
return s.join("") return s.join("")
} }
export function copyTextToClipboard(text: string) {
const input = document.createElement("input");
input.setAttribute("readonly", "readonly");
input.setAttribute("value", text);
document.body.appendChild(input);
input.select();
const ret = document.execCommand("copy");
document.body.removeChild(input);
return ret;
}
const URL_REGEX = const URL_REGEX =
/((?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gim /((?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gim
......
...@@ -165,6 +165,7 @@ export class Xim { ...@@ -165,6 +165,7 @@ export class Xim {
lid = 0, lid = 0,
rid = 0, rid = 0,
limit = DefaultMsgPageSize, limit = DefaultMsgPageSize,
// = 0 正序(最新的消息在最下面),=1 倒序(最新的消息在最上面)
desc: boolean, desc: boolean,
p?: { isMember: boolean; model: string; obj: string } p?: { isMember: boolean; model: string; obj: string }
): Promise<Message[]> { ): Promise<Message[]> {
...@@ -195,8 +196,12 @@ export class Xim { ...@@ -195,8 +196,12 @@ export class Xim {
.getSdk() .getSdk()
.getAxios() .getAxios()
.get<any, Message[]>( .get<any, Message[]>(
`/general/xim/model/${p.model}/${p.obj}/msgs?lid=${lid}&rid=${rid}&limit=${limit}&desc=${desc ? 0 : 1}` `/general/xim/model/${p.model}/${
) p.obj
}/msgs?lid=${lid}&rid=${rid}&limit=${limit}&desc=${
desc ? 1 : 0
}`
);
} }
private setMessagesRead(chatId: number, msg: Message[]) { private setMessagesRead(chatId: number, msg: Message[]) {
...@@ -431,9 +436,12 @@ export class Xim { ...@@ -431,9 +436,12 @@ export class Xim {
vue.$once("hook:beforeDestroy", () => this.off("msg", action)); vue.$once("hook:beforeDestroy", () => this.off("msg", action));
} }
public withDrawMsgHandle(e: Message) { public withDrawMsgHandle(e: Message): number[] {
const ids = e.ref_id ? [e.ref_id] : e.msg.startsWith("[") ? JSON.parse(e.msg) : [+e.msg]; return e.ref_id
return ids; ? [e.ref_id]
: e.msg.startsWith("[")
? JSON.parse(e.msg)
: [+e.msg];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment