mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 消息内容支持待办列表
This commit is contained in:
parent
182e5a6974
commit
a46ffa1089
@ -832,6 +832,72 @@ class DialogController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} api/dialog/msg/checked 16. 设置消息checked
|
||||||
|
*
|
||||||
|
* @apiDescription 需要token身份
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiGroup dialog
|
||||||
|
* @apiName msg__checked
|
||||||
|
*
|
||||||
|
* @apiParam {Number} dialog_id 对话ID
|
||||||
|
* @apiParam {Number} msg_id 消息ID
|
||||||
|
* @apiParam {Number} index li 位置
|
||||||
|
* @apiParam {Number} checked 标记、取消标记
|
||||||
|
*
|
||||||
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
|
* @apiSuccess {Object} data 返回数据
|
||||||
|
* @apiSuccessExample {json} data:
|
||||||
|
{
|
||||||
|
"id": 43,
|
||||||
|
"msg": {
|
||||||
|
// ....
|
||||||
|
},
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public function msg__checked()
|
||||||
|
{
|
||||||
|
$user = User::auth();
|
||||||
|
//
|
||||||
|
$dialog_id = intval(Request::input('dialog_id'));
|
||||||
|
$msg_id = intval(Request::input('msg_id'));
|
||||||
|
$index = intval(Request::input('index'));
|
||||||
|
$checked = intval(Request::input('checked'));
|
||||||
|
//
|
||||||
|
$dialogMsg = WebSocketDialogMsg::whereId($msg_id)->whereDialogId($dialog_id)->first();
|
||||||
|
if (empty($dialogMsg)) {
|
||||||
|
return Base::retError('消息不存在');
|
||||||
|
}
|
||||||
|
if ($dialogMsg->userid != $user->userid) {
|
||||||
|
return Base::retError('仅支持修改自己的消息');
|
||||||
|
}
|
||||||
|
if ($dialogMsg->type !== 'text') {
|
||||||
|
return Base::retError('仅支持文本消息');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$oldMsg = Base::json2array($dialogMsg->getRawOriginal('msg'));
|
||||||
|
$oldText = $oldMsg['text'] ?? '';
|
||||||
|
$newText = preg_replace_callback('/<li[^>]*>/i', function ($matches) use ($index, $checked) {
|
||||||
|
static $i = 0;
|
||||||
|
if ($i++ == $index) {
|
||||||
|
$checked = $checked ? 'checked' : 'unchecked';
|
||||||
|
return '<li data-list="' . $checked . '">';
|
||||||
|
}
|
||||||
|
return $matches[0];
|
||||||
|
}, $oldText);
|
||||||
|
//
|
||||||
|
$dialogMsg->updateInstance([
|
||||||
|
'msg' => array_merge($oldMsg, ['text' => $newText]),
|
||||||
|
]);
|
||||||
|
$dialogMsg->save();
|
||||||
|
//
|
||||||
|
return Base::retSuccess('success', [
|
||||||
|
'id' => $dialogMsg->id,
|
||||||
|
'msg' => $dialogMsg->msg,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} api/dialog/msg/stream 17. 通知成员监听消息
|
* @api {post} api/dialog/msg/stream 17. 通知成员监听消息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -751,6 +751,15 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
$text = str_replace($str, "[:QUICK:{$quickKey}:{$quickLabel}:]", $text);
|
$text = str_replace($str, "[:QUICK:{$quickKey}:{$quickLabel}:]", $text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 处理 li 标签
|
||||||
|
preg_match_all("/<li[^>]*?>/i", $text, $matchs);
|
||||||
|
foreach ($matchs[0] as $str) {
|
||||||
|
if (preg_match("/data-list=['\"](bullet|ordered|checked|unchecked)['\"]/i", $str, $match)) {
|
||||||
|
$text = str_replace($str, '<li data-list="' . $match[1] . '">', $text);
|
||||||
|
} else {
|
||||||
|
$text = str_replace($str, '<li>', $text);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 处理链接标签
|
// 处理链接标签
|
||||||
preg_match_all("/<a[^>]*?href=([\"'])(.*?)\\1[^>]*?>(.*?)<\/a>/is", $text, $matchs);
|
preg_match_all("/<a[^>]*?href=([\"'])(.*?)\\1[^>]*?>(.*?)<\/a>/is", $text, $matchs);
|
||||||
foreach ($matchs[0] as $key => $str) {
|
foreach ($matchs[0] as $key => $str) {
|
||||||
@ -785,7 +794,7 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
}
|
}
|
||||||
// 过滤标签
|
// 过滤标签
|
||||||
$text = strip_tags($text, '<blockquote> <strong> <pre> <ol> <ul> <li> <em> <p> <s> <u> <a>');
|
$text = strip_tags($text, '<blockquote> <strong> <pre> <ol> <ul> <li> <em> <p> <s> <u> <a>');
|
||||||
$text = preg_replace_callback("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u)(.*?)\>/is", function (array $match) { // 不用去除a标签,上面已经处理过了
|
$text = preg_replace_callback("/\<(blockquote|strong|pre|ol|ul|em|p|s|u)(.*?)\>/is", function (array $match) { // 不用去除 li 和 a 标签,上面已经处理过了
|
||||||
preg_match("/<[^>]*?style=([\"'])(.*?)\\1[^>]*?>/is", $match[0], $matchs);
|
preg_match("/<[^>]*?style=([\"'])(.*?)\\1[^>]*?>/is", $match[0], $matchs);
|
||||||
$attach = '';
|
$attach = '';
|
||||||
if ($matchs) {
|
if ($matchs) {
|
||||||
|
|||||||
@ -273,7 +273,7 @@ export default {
|
|||||||
toolbar: {
|
toolbar: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => {
|
default: () => {
|
||||||
return ['bold', 'strike', 'italic', 'underline', 'blockquote', {'list': 'ordered'}, {'list': 'bullet'}]
|
return ['bold', 'strike', 'italic', 'underline', 'blockquote', {'list': 'ordered'}, {'list': 'bullet'}, {'list': 'check'}]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
maxlength: {
|
maxlength: {
|
||||||
|
|||||||
@ -3051,6 +3051,9 @@ export default {
|
|||||||
// 打开审批详情
|
// 打开审批详情
|
||||||
let approveElement = target;
|
let approveElement = target;
|
||||||
while (approveElement) {
|
while (approveElement) {
|
||||||
|
if (approveElement.classList.contains('dialog-scroller')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (approveElement.classList.contains('open-approve-details')) {
|
if (approveElement.classList.contains('open-approve-details')) {
|
||||||
const dataId = approveElement.getAttribute("data-id")
|
const dataId = approveElement.getAttribute("data-id")
|
||||||
if (window.innerWidth < 426) {
|
if (window.innerWidth < 426) {
|
||||||
@ -3061,15 +3064,13 @@ export default {
|
|||||||
this.approveDetails = {id: dataId};
|
this.approveDetails = {id: dataId};
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
}
|
|
||||||
if (approveElement.classList.contains('dialog-item')) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
approveElement = approveElement.parentElement;
|
approveElement = approveElement.parentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target.nodeName) {
|
switch (target.nodeName) {
|
||||||
|
// 打开图片
|
||||||
case "IMG":
|
case "IMG":
|
||||||
if (target.classList.contains('browse')) {
|
if (target.classList.contains('browse')) {
|
||||||
this.onViewPicture(target.currentSrc);
|
this.onViewPicture(target.currentSrc);
|
||||||
@ -3080,6 +3081,7 @@ export default {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// 打开任务、打开OKR
|
||||||
case "SPAN":
|
case "SPAN":
|
||||||
if (target.classList.contains('mention') && target.classList.contains('task')) {
|
if (target.classList.contains('mention') && target.classList.contains('task')) {
|
||||||
this.$store.dispatch("openTask", $A.runNum(target.getAttribute("data-id")));
|
this.$store.dispatch("openTask", $A.runNum(target.getAttribute("data-id")));
|
||||||
@ -3089,6 +3091,48 @@ export default {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// 更新待办列表
|
||||||
|
case "LI":
|
||||||
|
const dataClass = target.getAttribute('data-list')
|
||||||
|
if (['checked', 'unchecked'].includes(dataClass)) {
|
||||||
|
let listElement = el.parentElement;
|
||||||
|
while (listElement) {
|
||||||
|
if (listElement.classList.contains('dialog-scroller')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (listElement.classList.contains('dialog-view')) {
|
||||||
|
const dataId = listElement.getAttribute("data-id")
|
||||||
|
const dataIndex = [].indexOf.call(el.querySelectorAll(target.tagName), target);
|
||||||
|
if (dataClass === 'checked') {
|
||||||
|
target.setAttribute('data-list', 'unchecked')
|
||||||
|
} else {
|
||||||
|
target.setAttribute('data-list', 'checked')
|
||||||
|
}
|
||||||
|
this.$store.dispatch("setLoad", {
|
||||||
|
key: `msg-${dataId}`,
|
||||||
|
delay: 600
|
||||||
|
})
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'dialog/msg/checked',
|
||||||
|
data: {
|
||||||
|
dialog_id: this.dialogId,
|
||||||
|
msg_id: dataId,
|
||||||
|
index: dataIndex,
|
||||||
|
checked: dataClass === 'checked' ? 0 : 1
|
||||||
|
},
|
||||||
|
}).then(({data}) => {
|
||||||
|
this.$store.dispatch("saveDialogMsg", data);
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
$A.modalError(msg);
|
||||||
|
}).finally(_ => {
|
||||||
|
this.$store.dispatch("cancelLoad", `msg-${dataId}`)
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
listElement = listElement.parentElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -176,6 +176,22 @@
|
|||||||
width: auto;
|
width: auto;
|
||||||
min-width: 1.2em;
|
min-width: 1.2em;
|
||||||
}
|
}
|
||||||
|
&[data-list=checked],
|
||||||
|
&[data-list=unchecked] {
|
||||||
|
> .ql-ui:before {
|
||||||
|
font-family: "taskfont", "serif" !important;
|
||||||
|
font-size: 14px;
|
||||||
|
content: "\e6ed";
|
||||||
|
font-weight: normal;
|
||||||
|
transform: scale(1.12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-list=unchecked] {
|
||||||
|
> .ql-ui:before {
|
||||||
|
content: "\e6f1";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -830,6 +830,31 @@
|
|||||||
min-width: 1.2em;
|
min-width: 1.2em;
|
||||||
content: counter(list-0, decimal) '. ';
|
content: counter(list-0, decimal) '. ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[data-list=bullet] {
|
||||||
|
&:before {
|
||||||
|
content: '\2022';
|
||||||
|
font-weight: 900;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-list=checked],
|
||||||
|
&[data-list=unchecked] {
|
||||||
|
&:before {
|
||||||
|
font-family: "taskfont", "serif" !important;
|
||||||
|
font-size: 14px;
|
||||||
|
content: "\e6ed";
|
||||||
|
font-weight: normal;
|
||||||
|
transform: scale(1.12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[data-list=unchecked] {
|
||||||
|
&:before {
|
||||||
|
content: "\e6f1";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user