From 501872e8d2165bd96922744b5bca6d705b617235 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 2 Nov 2024 10:50:20 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AE=A1=E6=89=B9=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/ApproveController.php | 14 ++++++++ app/Models/WebSocketDialogMsg.php | 36 ++++++++++++------- .../template/approve-comment-notifier.vue | 19 ++++++---- .../DialogView/template/approve-reviewer.vue | 15 ++++++-- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/Api/ApproveController.php b/app/Http/Controllers/Api/ApproveController.php index 38aca09ca..756be9e74 100755 --- a/app/Http/Controllers/Api/ApproveController.php +++ b/app/Http/Controllers/Api/ApproveController.php @@ -985,6 +985,20 @@ class ApproveController extends AbstractController 'comment_content' => $process['comment_contents']['content'] ?? '', 'comment_pictures' => $process['comment_contents']['pictures'] ?? [] ]; + $thumb = null; + if ($type === 'approve_reviewer') { + $thumb = $process['var']['other']; + } elseif ($type === 'approve_comment_notifier') { + $thumb = $data['comment_pictures'] ? $data['comment_pictures'][0] : null; + } + if ($thumb && file_exists(public_path($thumb))) { + $imageSize = getimagesize(public_path($thumb)); + $data['thumb'] = [ + 'url' => $thumb, + 'width' => $imageSize[0], + 'height' => $imageSize[1] + ]; + } $msgAction = null; $msgData = [ 'type' => $type, diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index ff661dfcf..31be91fcb 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -149,19 +149,29 @@ class WebSocketDialogMsg extends AbstractModel if (!is_array($msg)) { $msg = Base::json2array($msg); } - if ($type === 'file') { - $msg['type'] = in_array($msg['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file'; - $msg['path'] = Base::fillUrl($msg['path']); - $msg['thumb'] = Base::fillUrl($msg['thumb'] ?: Base::extIcon($msg['ext'])); - } else if ($type === 'record') { - $msg['path'] = Base::fillUrl($msg['path']); - $textUserid = is_array($msg['text_userid']) ? $msg['text_userid'] : []; - if (isset($msg['text_userid'])) { - unset($msg['text_userid']); - } - if ($msg['text'] && !in_array(Doo::userId(), $textUserid)) { - $msg['text'] = ""; - } + switch ($type) { + case 'file': + $msg['type'] = in_array($msg['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file'; + $msg['path'] = Base::fillUrl($msg['path']); + $msg['thumb'] = Base::fillUrl($msg['thumb'] ?: Base::extIcon($msg['ext'])); + break; + + case 'record': + $msg['path'] = Base::fillUrl($msg['path']); + $textUserid = is_array($msg['text_userid']) ? $msg['text_userid'] : []; + if (isset($msg['text_userid'])) { + unset($msg['text_userid']); + } + if ($msg['text'] && !in_array(Doo::userId(), $textUserid)) { + $msg['text'] = ""; + } + break; + + case 'template': + if ($msg['data']['thumb']) { + $msg['data']['thumb']['url'] = Base::fillUrl($msg['data']['thumb']['url']); + } + break; } return $msg; } diff --git a/resources/assets/js/pages/manage/components/DialogView/template/approve-comment-notifier.vue b/resources/assets/js/pages/manage/components/DialogView/template/approve-comment-notifier.vue index 21903f487..240c5ce86 100644 --- a/resources/assets/js/pages/manage/components/DialogView/template/approve-comment-notifier.vue +++ b/resources/assets/js/pages/manage/components/DialogView/template/approve-comment-notifier.vue @@ -5,7 +5,7 @@

{{$L('申请人')}}:@{{ msg.data.nickname }} {{ msg.data.department }}

{{$L('评论内容')}}

{{ msg.data.comment_content }}

-

[{{$L('图片')}}]

+

@@ -21,13 +21,18 @@ export default { data() { return {}; }, - computed: { - isPicture() { - const {comment_pictures} = this.msg.data - return $A.isArray(comment_pictures) && comment_pictures.length > 0 - }, + methods: { + imageHtml(info) { + const data = $A.imageRatioHandle({ + src: info.url, + width: info.width, + height: info.height, + crops: {ratio: 3, percentage: '320x0'}, + scaleSize: 220, + }) + return `` + } }, - methods: {}, } diff --git a/resources/assets/js/pages/manage/components/DialogView/template/approve-reviewer.vue b/resources/assets/js/pages/manage/components/DialogView/template/approve-reviewer.vue index 010f7b30b..922cfcb0d 100644 --- a/resources/assets/js/pages/manage/components/DialogView/template/approve-reviewer.vue +++ b/resources/assets/js/pages/manage/components/DialogView/template/approve-reviewer.vue @@ -8,6 +8,7 @@

{{$L("开始时间")}}:{{ msg.data.start_time }} ({{ msg.data.start_day_of_week }})

{{$L("结束时间")}}:{{ msg.data.end_time }} ({{ msg.data.end_day_of_week }})

{{$L("事由")}}:{{ msg.data.description }}

+

@@ -29,7 +30,17 @@ export default { data() { return {}; }, - computed: {}, - methods: {}, + methods: { + imageHtml(info) { + const data = $A.imageRatioHandle({ + src: info.url, + width: info.width, + height: info.height, + crops: {ratio: 3, percentage: '320x0'}, + scaleSize: 220, + }) + return `` + } + }, }