no message

This commit is contained in:
kuaifan 2025-03-16 22:57:21 +08:00
parent 04acd7c56d
commit 0b1da914cd
4 changed files with 40 additions and 19 deletions

View File

@ -87,6 +87,7 @@ class FileController extends AbstractController
}
return Base::retError($msg, $data);
}
$fileLink->increment("num");
} else {
return Base::retError('参数错误');
}

View File

@ -486,6 +486,7 @@ class ReportController extends AbstractController
}
$one = Report::getOne($link->rid);
$one->report_link = $link;
$link->increment("num");
}
return Base::retSuccess("success", $one);
}

View File

@ -939,7 +939,7 @@ class WebSocketDialogMsg extends AbstractModel
}
}
}
// @成员、#任务、~文件
// @成员、#任务、~文件、%报告
preg_match_all("/<span\s+class=\"mention\"(.*?)>.*?<\/span>.*?<\/span>.*?<\/span>/s", $text, $matchs);
foreach ($matchs[1] as $key => $str) {
preg_match("/data-denotation-char=\"(.*?)\"/", $str, $matchChar);
@ -947,6 +947,7 @@ class WebSocketDialogMsg extends AbstractModel
preg_match("/data-value=\"(.*?)\"/s", $str, $matchValye);
$keyId = $matchId[1];
if ($matchChar[1] === "~") {
// 文件特殊处理
if (Base::isNumber($keyId)) {
$file = File::permissionFind($keyId, User::auth());
if ($file->type == 'folder') {
@ -963,6 +964,7 @@ class WebSocketDialogMsg extends AbstractModel
}
}
} elseif ($matchChar[1] === "%") {
// 报告特殊处理
if (Base::isNumber($keyId)) {
$reportLink = ReportLink::generateLink($keyId, User::userid());
$keyId = $reportLink['code'];
@ -1002,31 +1004,18 @@ class WebSocketDialogMsg extends AbstractModel
foreach ($matchs[0] as $key => $str) {
$herf = $matchs[2][$key];
$title = $matchs[3][$key] ?: $herf;
preg_match("/\/single\/file\/(.*?)$/i", strip_tags($title), $match);
if ($match && strlen($match[1]) >= 8) {
$file = File::select(['files.id', 'files.name', 'files.ext'])->join('file_links as L', 'files.id', '=', 'L.file_id')->where('L.code', $match[1])->first();
if ($file && $file->name) {
$name = $file->ext ? "{$file->name}.{$file->ext}" : $file->name;
$text = str_replace($str, "[:~:{$match[1]}:{$name}:]", $text);
if (self::formatLink($str, strip_tags($title), $text)) {
continue;
}
}
$herf = base64_encode($herf);
$title = base64_encode($title);
$text = str_replace($str, "[:LINK:{$herf}:{$title}:]", $text);
}
// 文件分享链接
// 分享链接
preg_match_all("/(https?:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#|@|,|!)+)/i", $text, $matchs);
if ($matchs) {
foreach ($matchs[0] as $str) {
preg_match("/\/single\/file\/(.*?)$/i", $str, $match);
if ($match && strlen($match[1]) >= 8) {
$file = File::select(['files.id', 'files.name', 'files.ext'])->join('file_links as L', 'files.id', '=', 'L.file_id')->where('L.code', $match[1])->first();
if ($file && $file->name) {
$name = $file->ext ? "{$file->name}.{$file->ext}" : $file->name;
$text = str_replace($str, "[:~:{$match[1]}:{$name}:]", $text);
}
}
self::formatLink($str, $str, $text);
}
}
// 过滤标签
@ -1061,6 +1050,36 @@ class WebSocketDialogMsg extends AbstractModel
return preg_replace("/^(<p><\/p>)+|(<p><\/p>)+$/i", "", $text);
}
/**
* 链接转换处理
* @param $search
* @param $subject
* @param $content
* @return bool
*/
public static function formatLink($search, $subject, &$content)
{
$ret = false;
preg_match("/\/single\/file\/(.*?)$/i", $subject, $match);
if ($match && strlen($match[1]) >= 8) {
$file = File::select(['files.id', 'files.name', 'files.ext'])->join('file_links as L', 'files.id', '=', 'L.file_id')->where('L.code', $match[1])->first();
if ($file && $file->name) {
$name = $file->ext ? "{$file->name}.{$file->ext}" : $file->name;
$content = str_replace($search, "[:~:{$match[1]}:{$name}:]", $content);
$ret = true;
}
}
preg_match("/\/single\/report\/detail\/(.*?)$/i", $subject, $match);
if ($match && strlen($match[1]) >= 8) {
$report = Report::select(['reports.id', 'reports.title'])->join('report_links as L', 'reports.id', '=', 'L.rid')->where('L.code', $match[1])->first();
if ($report && $report->title) {
$content = str_replace($search, "[:%:{$match[1]}:{$report->title}:]", $content);
$ret = true;
}
}
return $ret;
}
/**
* 发送消息、修改消息
* @param string $action 动作

View File

@ -295,7 +295,7 @@ import TransferDom from "../../../../directives/transfer-dom";
import clickoutside from "../../../../directives/clickoutside";
import longpress from "../../../../directives/longpress";
import {inputLoadAdd, inputLoadIsLast, inputLoadRemove} from "./one";
import {getLanguage, languageList} from "../../../../language";
import {languageList} from "../../../../language";
import {isMarkdownFormat} from "../../../../store/markdown";
import emitter from "../../../../store/events";