From a0553258f8bf4a55e3e9ae0873ede0a924baa649 Mon Sep 17 00:00:00 2001 From: terrylee Date: Thu, 16 Jul 2026 13:34:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-ui):=20Phase3=20=E5=BE=8C=E5=8F=B0=20?= =?UTF-8?q?=E2=80=94=20=E6=94=AF=E6=8F=B4=20color=20=E5=9E=8B=E9=83=A8?= =?UTF-8?q?=E4=BD=8D(=E8=89=B2=E7=A5=A8=E9=81=B8=E6=93=87=E5=99=A8)+=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20BG0=E6=95=B4=E9=A0=81=E8=83=8C=E6=99=AF/C0?= =?UTF-8?q?=E5=BA=95=E8=89=B2/T0=E6=96=87=E5=AD=97=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config 加 background/bgcolor/textcolor 群組 + BG0(image)/C0/T0(color) - 內容設定頁 color 型渲染勾選套用+色票(input color);updateBundleContent 存 color_value - B014 下發 color 型已支援(不需改) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Controllers/Admin/UiElementController.php | 31 +++++++-- config/ui_parts.php | 12 ++++ lang/en.json | 1 + lang/zh_TW.json | 1 + .../admin/app/ui-bundles/content.blade.php | 66 ++++++++++++------- 5 files changed, 83 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/Admin/UiElementController.php b/app/Http/Controllers/Admin/UiElementController.php index 57b7381..49f87d4 100644 --- a/app/Http/Controllers/Admin/UiElementController.php +++ b/app/Http/Controllers/Admin/UiElementController.php @@ -161,21 +161,42 @@ class UiElementController extends Controller public function updateBundleContent(Request $request, UiBundle $uiBundle) { $parts = $this->activeParts(); - $input = $request->input('parts', []); + $input = $request->input('parts', []); // 圖片型:part_key => ui_element_id + $colorInput = $request->input('parts_color', []); // 色彩型:part_key => #RRGGBB + $colorEnabled = $request->input('parts_enabled', []); // 色彩型:part_key => "1"(有勾才套用) - foreach (array_keys($parts) as $key) { + foreach ($parts as $key => $part) { + $type = $part['type'] ?? 'image'; + + // 色彩型(C 底色 / T 文字色) + if ($type === 'color') { + $isOn = !empty($colorEnabled[$key]); + $color = $colorInput[$key] ?? null; + $valid = is_string($color) && preg_match('/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/', $color); + + if (!$isOn || !$valid) { + $uiBundle->items()->where('part_key', $key)->delete(); + continue; + } + + UiBundleItem::updateOrCreate( + ['ui_bundle_id' => $uiBundle->id, 'part_key' => $key], + ['ui_element_id' => null, 'color_value' => strtoupper($color)] + ); + continue; + } + + // 圖片型 $elementId = $input[$key] ?? null; $elementId = ($elementId === null || $elementId === '' || trim((string) $elementId) === '') ? null : (int) $elementId; if ($elementId === null) { - // 未設定 → 移除該部位設定 $uiBundle->items()->where('part_key', $key)->delete(); continue; } // 只接受屬於該部位的元素 - $valid = UiElement::where('id', $elementId)->where('part_key', $key)->exists(); - if (!$valid) { + if (!UiElement::where('id', $elementId)->where('part_key', $key)->exists()) { continue; } diff --git a/config/ui_parts.php b/config/ui_parts.php index db7e15e..cf5cd4f 100644 --- a/config/ui_parts.php +++ b/config/ui_parts.php @@ -25,6 +25,9 @@ return [ 'fullscreen' => '滿版畫面(A 系列)', 'transaction' => '交易結果(E 系列)', 'payment' => '支付方式(P 系列)', + 'background' => '整頁背景', + 'bgcolor' => '背景色(C 系列)', + 'textcolor' => '文字色(T 系列)', ], 'parts' => [ @@ -44,6 +47,15 @@ return [ '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], + // === 整頁背景(image,滿版裁切)=== + 'BG0' => ['label' => 'BG0 - 整頁背景(待機/銷售頁)', 'group' => 'background', 'type' => 'image', 'width' => 1080, 'height' => 1920, 'active' => true], + + // === C 系列:背景色(color)=== + 'C0' => ['label' => 'C0 - 機台資訊列底色', 'group' => 'bgcolor', 'type' => 'color', 'active' => true], + + // === T 系列:文字色(color)=== + 'T0' => ['label' => 'T0 - 機台資訊列文字色', 'group' => 'textcolor', 'type' => 'color', 'active' => true], + // --- 以下為舊後台既有部位,Phase 2+ 逐步啟用(active=false 時後台不顯示、不下發)--- 'A4' => ['label' => 'A4 - 對話框標頭', 'group' => 'fullscreen', 'type' => 'image', 'width' => 1080, 'height' => 192, 'active' => false], 'A7' => ['label' => 'A7 - 購買頁廣告底圖', 'group' => 'fullscreen', 'type' => 'image', 'width' => 1080, 'height' => 620, 'active' => false], diff --git a/lang/en.json b/lang/en.json index f3e1ffc..03a8b22 100644 --- a/lang/en.json +++ b/lang/en.json @@ -2357,6 +2357,7 @@ "Content Settings": "Content Settings", "Not set": "Not set", "No image selected": "No image selected", + "Apply": "Apply", "Current Bundle": "Current Bundle", "Bind UI Bundle": "Bind UI Bundle", "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).", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index 1aa78cb..75c9985 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -2358,6 +2358,7 @@ "Content Settings": "內容設定", "Not set": "未設定", "No image selected": "尚未選擇圖片", + "Apply": "套用", "Current Bundle": "當前組合", "Bind UI Bundle": "綁定 UI 組合", "Image will be center-cropped to the category size.": "括號內為各類別建議上傳尺寸(滿版類會置中裁切,按鈕類保留原比例)。", diff --git a/resources/views/admin/app/ui-bundles/content.blade.php b/resources/views/admin/app/ui-bundles/content.blade.php index 49a1e35..65d3989 100644 --- a/resources/views/admin/app/ui-bundles/content.blade.php +++ b/resources/views/admin/app/ui-bundles/content.blade.php @@ -34,30 +34,50 @@

{{ $groupDefs[$groupKey] ?? $groupKey }}

@foreach($grouped[$groupKey] as $key => $part) - @php - $currentId = optional($itemsByPart->get($key))->ui_element_id; - $currentThumb = optional(optional($itemsByPart->get($key))->element)->image_url ?? ''; - @endphp -
- - -
- -

{{ __('No image selected') }}

+ @php $item = $itemsByPart->get($key); $partType = $part['type'] ?? 'image'; @endphp + + @if($partType === 'color') + {{-- 色彩型(C 底色 / T 文字色):勾選套用 + 色票 --}} + @php $currentColor = $item->color_value ?? ''; @endphp +
+ + +
+ + +
-
+ @else + {{-- 圖片型:選對應類別的 UI 元素 --}} + @php + $currentId = optional($item)->ui_element_id; + $currentThumb = optional(optional($item)->element)->image_url ?? ''; + @endphp +
+ + +
+ +

{{ __('No image selected') }}

+
+
+ @endif @endforeach
@endforeach