diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index bf0beb94d..f244ebef6 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -87,6 +87,7 @@ class FileController extends AbstractController } return Base::retError($msg, $data); } + $fileLink->increment("num"); } else { return Base::retError('参数错误'); } diff --git a/app/Http/Controllers/Api/ReportController.php b/app/Http/Controllers/Api/ReportController.php index 4dc70132b..a2b83c4a4 100755 --- a/app/Http/Controllers/Api/ReportController.php +++ b/app/Http/Controllers/Api/ReportController.php @@ -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); } diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index faecbba16..984bf7e3a 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -939,7 +939,7 @@ class WebSocketDialogMsg extends AbstractModel } } } - // @成员、#任务、~文件 + // @成员、#任务、~文件、%报告 preg_match_all("/.*?<\/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); - continue; - } + 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>)+$/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 动作 diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 63a2016df..91003312d 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -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";