From d83c2b1ab322d523df82e1070915c97b7fc620e9 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 11:49:49 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20openapi=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=96=E6=B6=88desc=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/controller/v1/Product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/openapi/controller/v1/Product.php b/app/openapi/controller/v1/Product.php index 5b4354e6..3a99b72d 100644 --- a/app/openapi/controller/v1/Product.php +++ b/app/openapi/controller/v1/Product.php @@ -35,7 +35,6 @@ class Product 'name', 'short_name', 'cover_image', - 'desc', 'deleted_at' ]) ->where(function($query) use($params) { @@ -101,6 +100,7 @@ class Product ]) ->withoutField([ 'language_id', + 'desc', 'stock_qty', 'seo_title', 'seo_keywords', @@ -112,7 +112,7 @@ class Product ->bypk($id) ->hidden(['category_id']) ->find(); -// dump($product);exit; + // 处理封面图 if (!empty($product['cover_image']) && !str_starts_with($product['cover_image'], 'http')) { $product['cover_image'] = image_domain_concat($product['cover_image']); From 5424e8b2cb948d974e8d92795950c64af5804711 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 13:47:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20openapi=E5=8F=96=E6=B6=88=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E8=AF=A6=E6=83=85sku->sort=E5=AD=97=E6=AE=B5=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/controller/v1/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/openapi/controller/v1/Product.php b/app/openapi/controller/v1/Product.php index 3a99b72d..2cc8b7e2 100644 --- a/app/openapi/controller/v1/Product.php +++ b/app/openapi/controller/v1/Product.php @@ -75,7 +75,7 @@ class Product 'params' => fn($query) => $query->field(['product_id', 'name', 'value']) ->hidden(['product_id']), // 关联sku - 'skus' => fn($query) => $query->withoutField(['created_at', 'updated_at']) + 'skus' => fn($query) => $query->withoutField(['sort', 'created_at', 'updated_at']) ->with([ 'sku_attr' => fn($query) => $query->with('attr')->hidden(['sku_id', 'attr_id']) ]) From 2fd187ed1736ad53c3cc45bd1b2dcf7d0df3c049 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 14:01:51 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20openapi=20=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=88=86=E7=B1=BBicon,desc=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/controller/v1/ProductCategory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/openapi/controller/v1/ProductCategory.php b/app/openapi/controller/v1/ProductCategory.php index 183d7d1e..64865322 100644 --- a/app/openapi/controller/v1/ProductCategory.php +++ b/app/openapi/controller/v1/ProductCategory.php @@ -27,6 +27,8 @@ class ProductCategory $categories = ProductCategoryModel::withoutField([ 'language_id', 'unique_id', + 'icon', + 'desc', 'related_tco_category', 'created_at', 'updated_at' From 7ed2f28b679b979b42be45af7467a73b541fce8d Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 14:02:17 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix:=20openapi=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=8F=96=E6=B6=88short=5Fname,=20desc?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/controller/v1/ArticleCategory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/openapi/controller/v1/ArticleCategory.php b/app/openapi/controller/v1/ArticleCategory.php index 42d65b8e..df0bd806 100644 --- a/app/openapi/controller/v1/ArticleCategory.php +++ b/app/openapi/controller/v1/ArticleCategory.php @@ -27,6 +27,8 @@ class ArticleCategory $categories = ArticleCategoryModel::withoutField([ 'language_id', 'unique_label', + 'short_name', + 'desc', 'created_at', 'updated_at', ]) From 3f4d3020358d297cc598888f0ebfc47c7adf3198 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 14:41:32 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20openapi=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=8F=96=E6=B6=88author=EF=BC=8Csource?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/openapi/controller/v1/Article.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/openapi/controller/v1/Article.php b/app/openapi/controller/v1/Article.php index 0e76e19f..e9868001 100644 --- a/app/openapi/controller/v1/Article.php +++ b/app/openapi/controller/v1/Article.php @@ -66,6 +66,8 @@ class Article ]) ->withoutField([ 'language_id', + 'author', + 'source', 'seo_title', 'seo_keywords', 'seo_desc', From c7b8c3a93f7f8a2be3f2e44448241e09dc5fa862 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Sat, 5 Jul 2025 15:19:46 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=E5=90=8E=E5=8F=B0=20=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0=E6=96=B0=E5=A2=9Ewebp=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/Upload.php | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/v1/Upload.php b/app/admin/controller/v1/Upload.php index 91488a0a..a2f729be 100644 --- a/app/admin/controller/v1/Upload.php +++ b/app/admin/controller/v1/Upload.php @@ -45,17 +45,39 @@ class Upload // 获取图片上传配置 list( 'filename_keep' => $filename_keep, - 'filemd5_unique' => $filemd5_unique + 'filemd5_unique' => $filemd5_unique, + 'filetype_to' => $filetype_to, ) = $this->getUploadOptions('upload_image'); + + // 获取文件大小 + $file_size = $file->getSize(); + // 获取文件mime类型 + $mime_type = $file->getOriginalMime(); + // 是否需要根据文件MD5值检查文件是否已存在 $image_model = $filemd5_unique ? SysImageUploadRecordModel::md5($filemd5)->find() : null; if (is_null($image_model)) { // 检查是否需要保留原文件名生成器 $name_rule = fn() => $filename_keep ? $this->filenameGenerator($file) : null; - $filename = Filesystem::disk('image')->putFile($param['module'], $file, $name_rule()); + // 处理图片 $image_manager = ImageManager::imagick(); - $image = $image_manager->read('.' . $storage . '/' . $filename); + if ($filetype_to == 'original') { + $filename = Filesystem::disk('image')->putFile($param['module'], $file, $name_rule()); + $image = $image_manager->read('.' . $storage . '/' . $filename); + } + else if ($filetype_to == 'webp') { + $image = $image_manager->read($file->getRealPath()); + // 转换为webp格式 + $webp = $image->toWebp(75); + $root = config('filesystem.disks.image.root'); + $filename = $param['module'] . '/' . ($name_rule() ?? date('Ymd') . '/' . md5((string)time()) . '.webp'); + $webp->save($root . '/' . $filename); + // 获取webp文件大小 + $file_size = $webp->size(); + // 获取webp文件mime类型 + $mime_type = $webp->mimetype(); + } // 水印 list( @@ -126,15 +148,15 @@ class Upload $idx = strrpos($filename, '.'); $thumb_filename = mb_substr($filename, 0, $idx) . '_thumb.' . mb_substr($filename, $idx + 1); $image->save('.' . $storage . '/' . $thumb_filename); - + // 保存图片 $image_model = new SysImageUploadRecordModel(); $image_model->language_id = request()->lang_id; $image_model->module = $param['module']; $image_model->image_path = $filename; $image_model->image_thumb = $thumb_filename; - $image_model->file_size = $file->getSize(); - $image_model->file_type = $file->getOriginalMime(); + $image_model->file_size = $file_size; + $image_model->file_type = $mime_type; $image_model->file_md5 = $filemd5; $image_model->file_sha1 = $filesha1; if (!$image_model->save()) { @@ -179,6 +201,7 @@ class Upload return [ 'filename_keep' => (int)data_get($options, 'filename_keep.value', 0) == 1, 'filemd5_unique' => (int)data_get($options, 'filemd5_unique.value', 0) == 1, + 'filetype_to' => data_get($options, 'filetype_to.value', 'original'), ]; } /**