From 0f2b5dfe446a6a79519ffebe75c1b6ef66b9dcfc Mon Sep 17 00:00:00 2001 From: terrylee Date: Thu, 16 Jul 2026 10:27:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-ui):=20P1~P6=20=E5=8A=A0=E5=BB=BA?= =?UTF-8?q?=E8=AD=B0=E5=B0=BA=E5=AF=B8=E6=8F=90=E7=A4=BA=20+=20crop=20?= =?UTF-8?q?=E6=97=97=E6=A8=99(=E6=8C=89=E9=88=95=E9=A1=9E=E4=B8=8D?= =?UTF-8?q?=E8=A3=81=E5=88=87=E4=BF=9D=E7=95=99=E5=8E=9F=E6=AF=94=E4=BE=8B?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P 系列填實際圖檔尺寸(838x155 等)供下拉提示;controller 依 part.crop 決定是否置中裁切;提示文字改中性 Co-Authored-By: Claude Opus 4.8 (1M context) --- app/Http/Controllers/Admin/UiElementController.php | 14 ++++++-------- config/ui_parts.php | 14 +++++++------- lang/en.json | 2 +- lang/zh_TW.json | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Admin/UiElementController.php b/app/Http/Controllers/Admin/UiElementController.php index bbb9c1b..c638b25 100644 --- a/app/Http/Controllers/Admin/UiElementController.php +++ b/app/Http/Controllers/Admin/UiElementController.php @@ -49,14 +49,12 @@ class UiElementController extends Controller $part = config("ui_parts.parts.{$validated['part_key']}"); - // 依部位建議尺寸做居中裁切,存為 webp - $path = $this->storeAsWebp( - $request->file('file'), - 'ui_elements', - 80, - $part['width'] ?? null, - $part['height'] ?? null - ); + // crop=true(預設,滿版類)→ 依部位尺寸置中裁切;crop=false(按鈕/icon 類)→ 保留原比例不裁切 + $crop = $part['crop'] ?? true; + $targetW = $crop ? ($part['width'] ?? null) : null; + $targetH = $crop ? ($part['height'] ?? null) : null; + + $path = $this->storeAsWebp($request->file('file'), 'ui_elements', 80, $targetW, $targetH); UiElement::create([ 'part_key' => $validated['part_key'], diff --git a/config/ui_parts.php b/config/ui_parts.php index 9139808..928fbf3 100644 --- a/config/ui_parts.php +++ b/config/ui_parts.php @@ -29,13 +29,13 @@ return [ // === E 系列:交易結果 === 'E1' => ['label' => 'E1 - 交易失敗/客服圖', 'group' => 'transaction', 'type' => 'image', 'width' => 720, 'height' => 1280, 'active' => true], - // === P 系列:支付方式按鈕圖(不裁切、保留原比例,width/height=null)=== - 'P1' => ['label' => 'P1 - 信用卡支付', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], - 'P2' => ['label' => 'P2 - 卡片/電子票證', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], - 'P3' => ['label' => 'P3 - 玉山掃碼支付', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], - 'P4' => ['label' => 'P4 - 手機支付', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], - 'P5' => ['label' => 'P5 - 現金支付', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], - 'P6' => ['label' => 'P6 - TapPay 掃碼', 'group' => 'payment', 'type' => 'image', 'width' => null, 'height' => null, 'active' => true], + // === P 系列:支付方式按鈕圖(width/height=建議尺寸提示;crop=false 不裁切、保留原比例)=== + 'P1' => ['label' => 'P1 - 信用卡支付', 'group' => 'payment', 'type' => 'image', 'width' => 838, 'height' => 155, 'crop' => false, 'active' => true], + 'P2' => ['label' => 'P2 - 卡片/電子票證', 'group' => 'payment', 'type' => 'image', 'width' => 704, 'height' => 159, 'crop' => false, 'active' => true], + 'P3' => ['label' => 'P3 - 玉山掃碼支付', 'group' => 'payment', 'type' => 'image', 'width' => 579, 'height' => 282, 'crop' => false, 'active' => true], + 'P4' => ['label' => 'P4 - 手機支付', 'group' => 'payment', 'type' => 'image', 'width' => 684, 'height' => 169, 'crop' => false, 'active' => true], + 'P5' => ['label' => 'P5 - 現金支付', 'group' => 'payment', 'type' => 'image', 'width' => 846, 'height' => 266, 'crop' => false, 'active' => true], + 'P6' => ['label' => 'P6 - TapPay 掃碼', 'group' => 'payment', 'type' => 'image', 'width' => 579, 'height' => 282, 'crop' => false, 'active' => true], // --- 以下為舊後台既有部位,Phase 2+ 逐步啟用(active=false 時後台不顯示、不下發)--- 'A4' => ['label' => 'A4 - 對話框標頭', 'group' => 'fullscreen', 'type' => 'image', 'width' => 1080, 'height' => 192, 'active' => false], diff --git a/lang/en.json b/lang/en.json index 6bb4b88..405dc89 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2355,7 +2355,7 @@ "No image selected": "No image selected", "Current Bundle": "Current Bundle", "Bind UI Bundle": "Bind UI Bundle", - "Image will be center-cropped to the category size.": "Image will be center-cropped to the category size.", + "Image will be center-cropped to the category size.": "Numbers show the recommended size per category (full-screen types are center-cropped; button types keep their aspect ratio).", "(deleted)": "(deleted)", "Unable to read the image archive": "Unable to read the image archive", "Unassigned": "Unassigned", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index ec844ed..9b92b62 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -2356,7 +2356,7 @@ "No image selected": "尚未選擇圖片", "Current Bundle": "當前組合", "Bind UI Bundle": "綁定 UI 組合", - "Image will be center-cropped to the category size.": "圖片會依類別建議尺寸置中裁切。", + "Image will be center-cropped to the category size.": "括號內為各類別建議上傳尺寸(滿版類會置中裁切,按鈕類保留原比例)。", "(deleted)": "(已刪除)", "Unable to read the image archive": "無法讀取圖片壓縮檔", "Unassigned": "未指派",