From c415ace4533b73031356a6d1f09c7381f2c70d58 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 1 May 2025 12:24:30 +0800 Subject: [PATCH] no message --- app/Models/WebSocketDialog.php | 63 ++++++++++++++-------------- app/Module/Base.php | 17 +++++--- resources/assets/js/pages/manage.vue | 3 +- 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index 1b14b204a..42d2c829f 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -891,7 +891,7 @@ class WebSocketDialog extends AbstractModel $data = []; foreach ($dialogIds as $dialog_id) { $dialog = WebSocketDialog::checkDialog($dialog_id); - // + $action = $replyId > 0 ? "reply-$replyId" : ""; $path = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; if ($image64) { @@ -916,40 +916,41 @@ class WebSocketDialog extends AbstractModel "compressVideo" => $setting['compress_video'] === 'open', ]); } - // if (Base::isError($data)) { throw new ApiException($data['msg']); - } else { - $fileData = $data['data']; - $filePath = $fileData['file']; - $fileName = $fileData['name']; - $fileData['thumb'] = Base::unFillUrl($fileData['thumb']); - $fileData['size'] *= 1024; - // - if ($dialog->type === 'group' && $dialog->group_type === 'task') { // 任务群组保存文件 - if ($imageAttachment || !in_array($fileData['ext'], File::imageExt)) { // 如果是图片不保存 - $task = ProjectTask::whereDialogId($dialog->id)->first(); - if ($task) { - $file = ProjectTaskFile::createInstance([ - 'project_id' => $task->project_id, - 'task_id' => $task->id, - 'name' => $fileData['name'], - 'size' => $fileData['size'], - 'ext' => $fileData['ext'], - 'path' => $fileData['path'], - 'thumb' => $fileData['thumb'], - 'userid' => $user->userid, - ]); - $file->save(); - } + } + $fileData = $data['data']; + $filePath = $fileData['file']; + $fileName = $fileData['name']; + $fileData['thumb'] = Base::unFillUrl($fileData['thumb']); + $fileData['size'] *= 1024; + + // 任务群组保存文件 + if ($dialog->group_type === 'task') { + // 如果是图片不保存 + if ($imageAttachment || !in_array($fileData['ext'], File::imageExt)) { + $task = ProjectTask::whereDialogId($dialog->id)->first(); + if ($task) { + $file = ProjectTaskFile::createInstance([ + 'project_id' => $task->project_id, + 'task_id' => $task->id, + 'name' => $fileData['name'], + 'size' => $fileData['size'], + 'ext' => $fileData['ext'], + 'path' => $fileData['path'], + 'thumb' => $fileData['thumb'], + 'userid' => $user->userid, + ]); + $file->save(); } } - // - $result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid); - if (Base::isSuccess($result)) { - if (isset($task)) { - $result['data']['task_id'] = $task->id; - } + } + + // 发送消息 + $result = WebSocketDialogMsg::sendMsg($action, $dialog_id, 'file', $fileData, $user->userid); + if (Base::isSuccess($result)) { + if (isset($task)) { + $result['data']['task_id'] = $task->id; } } } diff --git a/app/Module/Base.php b/app/Module/Base.php index b1f637ebe..3d5e8e078 100755 --- a/app/Module/Base.php +++ b/app/Module/Base.php @@ -827,12 +827,19 @@ class Base } return $str; } - try { - $find = url(''); - } catch (\Throwable) { - $find = self::getSchemeAndHost(); + if (empty($str)) { + return $str; } - return Base::leftDelete($str, $find . '/'); + $parsedUrl = parse_url($str); + if (isset($parsedUrl['scheme']) && isset($parsedUrl['host'])) { + $relativePath = $parsedUrl['path'] ?? ''; + $relativePath = ltrim($relativePath, '/'); + $absolutePath = public_path($relativePath); + if (file_exists($absolutePath) || file_exists(Base::thumbRestore($absolutePath))) { + return $relativePath; + } + } + return $str; } /** diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 06d4c07fc..59387ca65 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -341,7 +341,7 @@ - + @@ -521,7 +521,6 @@ export default { 'okrWindow', 'formOptions', 'mobileTabbar', - 'keyboardShow', 'longpressData', ]),