From cee5f9b252703a4c333bccac9964c1924c136a9f Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 18 Dec 2025 15:13:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E8=BF=94=E5=9B=9E=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=A2=9D=E5=A4=96=E5=B1=9E=E6=80=A7=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 4 ++-- application/api/controller/Common.php | 4 ++-- application/common/model/Attachment.php | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index df8f8b82..c129f956 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -96,7 +96,7 @@ class Ajax extends Backend } catch (UploadException $e) { $this->error($e->getMessage()); } - $this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); + $this->success(__('Uploaded successful'), '', $attachment->getBaseData()); } elseif ($method == 'clean') { //删除冗余的分片文件 try { @@ -129,7 +129,7 @@ class Ajax extends Backend $this->error($e->getMessage()); } - $this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); + $this->success(__('Uploaded successful'), '', $attachment->getBaseData()); } } diff --git a/application/api/controller/Common.php b/application/api/controller/Common.php index 788126e8..87bd40eb 100644 --- a/application/api/controller/Common.php +++ b/application/api/controller/Common.php @@ -106,7 +106,7 @@ class Common extends Api } catch (UploadException $e) { $this->error($e->getMessage()); } - $this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); + $this->success(__('Uploaded successful'), $attachment->getBaseData()); } elseif ($method == 'clean') { //删除冗余的分片文件 try { @@ -141,7 +141,7 @@ class Common extends Api $this->error($e->getMessage()); } - $this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); + $this->success(__('Uploaded successful'), $attachment->getBaseData()); } } diff --git a/application/common/model/Attachment.php b/application/common/model/Attachment.php index 67f71787..c809d9f4 100644 --- a/application/common/model/Attachment.php +++ b/application/common/model/Attachment.php @@ -95,4 +95,20 @@ class Attachment extends Model $data['unclassed'] = __('Unclassed'); return $data; } + + /** + * 返回上传文件的相关信息 + */ + public function getBaseData() + { + $data = [ + 'url' => $this->url, + 'fullurl' => cdnurl($this->url, true), + 'category' => $this->category, + 'filename' => $this->filename, + 'filesize' => $this->filesize, + 'mimetype' => $this->mimetype, + ]; + return $data; + } }