mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-03 11:48:17 +00:00
perf: 优化推送预览
This commit is contained in:
parent
36cb8290f4
commit
19a1ae9bec
@ -679,18 +679,14 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回引用消息(如果是文本消息则截取)
|
* 返回引用消息(如果是文本只取预览)
|
||||||
* @param int $strlen
|
|
||||||
* @return array|mixed
|
* @return array|mixed
|
||||||
*/
|
*/
|
||||||
public function quoteTextMsg($strlen = 30)
|
public function quoteTextMsg()
|
||||||
{
|
{
|
||||||
$msg = $this->msg;
|
$msg = $this->msg;
|
||||||
if ($this->type === 'text') {
|
if ($this->type === 'text') {
|
||||||
$msg['text'] = $this->previewTextMsg($msg['text']);
|
$msg['text'] = $this->previewTextMsg($msg['text']);
|
||||||
if (mb_strlen($msg['text']) > $strlen) {
|
|
||||||
$msg['text'] = mb_substr($msg['text'], 0, $strlen - 3) . "...";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
@ -710,6 +706,10 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
if (!$preserveHtml) {
|
if (!$preserveHtml) {
|
||||||
$text = strip_tags($text);
|
$text = strip_tags($text);
|
||||||
$text = str_replace([" ", "&", "<", ">"], [" ", "&", "<", ">"], $text);
|
$text = str_replace([" ", "&", "<", ">"], [" ", "&", "<", ">"], $text);
|
||||||
|
$text = preg_replace("/\s+/", " ", $text);
|
||||||
|
if (mb_strlen($text) > 30) {
|
||||||
|
$text = mb_substr($text, 0, 30) . "...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|||||||
5
resources/assets/js/functions/web.js
vendored
5
resources/assets/js/functions/web.js
vendored
@ -270,10 +270,15 @@ import {MarkdownPreview} from "../store/markdown";
|
|||||||
.replace(/&/g, "&")
|
.replace(/&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/>/g, ">")
|
.replace(/>/g, ">")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
if (imgClassName) {
|
if (imgClassName) {
|
||||||
text = text.replace(/\[image:(.*?)\]/g, `<img class="${imgClassName}" src="$1">`)
|
text = text.replace(/\[image:(.*?)\]/g, `<img class="${imgClassName}" src="$1">`)
|
||||||
text = text.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
|
text = text.replace(/\{\{RemoteURL\}\}/g, this.apiUrl('../'))
|
||||||
}
|
}
|
||||||
|
const tmpText = text.substring(0, 30)
|
||||||
|
if (tmpText.length < text.length) {
|
||||||
|
text = tmpText + '...'
|
||||||
|
}
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1074,22 +1074,13 @@ export default {
|
|||||||
return; // 窗口激活且最后打开的会话是通知的会话时不通知
|
return; // 窗口激活且最后打开的会话是通知的会话时不通知
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
const {id, dialog_id, dialog_type, type, msg, userid} = data;
|
const {id, dialog_id, dialog_type, userid} = data;
|
||||||
if (userid == this.userId) {
|
if (userid == this.userId) {
|
||||||
return; // 自己的消息不通知
|
return; // 自己的消息不通知
|
||||||
}
|
}
|
||||||
let body;
|
const body = $A.getMsgSimpleDesc(data);
|
||||||
switch (type) {
|
|
||||||
case 'text':
|
|
||||||
body = $A.getMsgTextPreview(msg.type === 'md' ? MarkdownPreview(msg.text) : msg.text)
|
|
||||||
break;
|
|
||||||
case 'file':
|
|
||||||
body = '[' + this.$L(msg.type == 'img' ? '图片信息' : '文件信息') + ']'
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.__notificationId = id;
|
this.__notificationId = id;
|
||||||
|
//
|
||||||
const notificationFuncA = (title) => {
|
const notificationFuncA = (title) => {
|
||||||
if (dialog_type === 'group') {
|
if (dialog_type === 'group') {
|
||||||
let tempUser = this.cacheUserBasic.find(item => item.userid == userid);
|
let tempUser = this.cacheUserBasic.find(item => item.userid == userid);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user