Sfoglia il codice sorgente

导航新增字段

bianjunhui 2 giorni fa
parent
commit
1eb349537d

+ 32 - 0
packages/Longyi/FrontMenu/src/Database/Migrations/2026_08_28_000006_add_show_icon_to_front_menu_items.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('front_menu_items', function (Blueprint $table) {
+            if (! Schema::hasColumn('front_menu_items', 'show_icon')) {
+                $table->boolean('show_icon')->default(false)->after('wap_banner');
+            }
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('front_menu_items', function (Blueprint $table) {
+            if (Schema::hasColumn('front_menu_items', 'show_icon')) {
+                $table->dropColumn('show_icon');
+            }
+        });
+    }
+};

+ 3 - 0
packages/Longyi/FrontMenu/src/Http/Controllers/FrontMenuController.php

@@ -50,6 +50,7 @@ class FrontMenuController extends Controller
             'banner'     => 'nullable|string|max:2048',
             'banner'     => 'nullable|string|max:2048',
             'wap_image'  => 'nullable|string|max:2048',
             'wap_image'  => 'nullable|string|max:2048',
             'wap_banner' => 'nullable|string|max:2048',
             'wap_banner' => 'nullable|string|max:2048',
+            'show_icon'  => 'nullable|boolean',
             'parent_id'  => 'nullable|exists:front_menu_items,id',
             'parent_id'  => 'nullable|exists:front_menu_items,id',
             'sort_order' => 'nullable|integer',
             'sort_order' => 'nullable|integer',
             'status'     => 'nullable|boolean',
             'status'     => 'nullable|boolean',
@@ -86,6 +87,7 @@ class FrontMenuController extends Controller
             'banner'     => 'nullable|string|max:2048',
             'banner'     => 'nullable|string|max:2048',
             'wap_image'  => 'nullable|string|max:2048',
             'wap_image'  => 'nullable|string|max:2048',
             'wap_banner' => 'nullable|string|max:2048',
             'wap_banner' => 'nullable|string|max:2048',
+            'show_icon'  => 'nullable|boolean',
             'parent_id'  => 'nullable|exists:front_menu_items,id',
             'parent_id'  => 'nullable|exists:front_menu_items,id',
             'sort_order' => 'nullable|integer',
             'sort_order' => 'nullable|integer',
             'status'     => 'nullable|boolean',
             'status'     => 'nullable|boolean',
@@ -176,6 +178,7 @@ class FrontMenuController extends Controller
         $data['parent_id'] = $request->filled('parent_id') ? (int) $request->input('parent_id') : null;
         $data['parent_id'] = $request->filled('parent_id') ? (int) $request->input('parent_id') : null;
         $data['sort_order'] = $request->input('sort_order', 0);
         $data['sort_order'] = $request->input('sort_order', 0);
         $data['status'] = $request->has('status') ? (bool) $request->input('status') : true;
         $data['status'] = $request->has('status') ? (bool) $request->input('status') : true;
+        $data['show_icon'] = $request->has('show_icon') ? (bool) $request->input('show_icon') : false;
         $data['created_by'] = auth()->guard('admin')->user()->id ?? null;
         $data['created_by'] = auth()->guard('admin')->user()->id ?? null;
 
 
         return $data;
         return $data;

+ 2 - 0
packages/Longyi/FrontMenu/src/Models/FrontMenuItem.php

@@ -17,6 +17,7 @@ class FrontMenuItem extends Model
         'banner',
         'banner',
         'wap_image',
         'wap_image',
         'wap_banner',
         'wap_banner',
+        'show_icon',
         'parent_id',
         'parent_id',
         'sort_order',
         'sort_order',
         'status',
         'status',
@@ -25,6 +26,7 @@ class FrontMenuItem extends Model
 
 
     protected $casts = [
     protected $casts = [
         'status'     => 'boolean',
         'status'     => 'boolean',
+        'show_icon'  => 'boolean',
         'sort_order' => 'integer',
         'sort_order' => 'integer',
         'parent_id'  => 'integer',
         'parent_id'  => 'integer',
     ];
     ];

+ 4 - 0
packages/Longyi/FrontMenu/src/Resources/lang/en/app.php

@@ -52,6 +52,10 @@ return [
             'wap-banner' => 'WAP Banner',
             'wap-banner' => 'WAP Banner',
             'wap-banner-placeholder' => 'WAP banner image URL or upload path',
             'wap-banner-placeholder' => 'WAP banner image URL or upload path',
 
 
+            'show-icon' => 'Show badge icon',
+            'show-icon-yes' => 'Show',
+            'show-icon-no' => 'Hide',
+
             'drag-hint' => 'Drag to reorder and change hierarchy',
             'drag-hint' => 'Drag to reorder and change hierarchy',
 
 
             'parent' => 'Parent Menu',
             'parent' => 'Parent Menu',

+ 4 - 0
packages/Longyi/FrontMenu/src/Resources/lang/zh_CN/app.php

@@ -52,6 +52,10 @@ return [
             'wap-banner' => 'WAP 横幅',
             'wap-banner' => 'WAP 横幅',
             'wap-banner-placeholder' => 'WAP 横幅图片 URL 或上传路径',
             'wap-banner-placeholder' => 'WAP 横幅图片 URL 或上传路径',
 
 
+            'show-icon' => '显示角标图标',
+            'show-icon-yes' => '显示',
+            'show-icon-no' => '不显示',
+
             'drag-hint' => '拖动可调整顺序与层级',
             'drag-hint' => '拖动可调整顺序与层级',
 
 
             'parent' => '父级菜单',
             'parent' => '父级菜单',

+ 16 - 0
packages/Longyi/FrontMenu/src/Resources/views/admin/menu/create.blade.php

@@ -97,6 +97,22 @@
                     />
                     />
                 </div>
                 </div>
 
 
+                <div>
+                    <label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
+                        @lang('frontmenu::app.admin.menu.show-icon')
+                    </label>
+                    <div class="mt-2 flex items-center gap-6">
+                        <label class="inline-flex items-center gap-2">
+                            <input type="radio" name="show_icon" value="1" {{ old('show_icon') == 1 ? 'checked' : '' }}>
+                            @lang('frontmenu::app.admin.menu.show-icon-yes')
+                        </label>
+                        <label class="inline-flex items-center gap-2">
+                            <input type="radio" name="show_icon" value="0" {{ old('show_icon', 0) == 0 ? 'checked' : '' }}>
+                            @lang('frontmenu::app.admin.menu.show-icon-no')
+                        </label>
+                    </div>
+                </div>
+
                 <div>
                 <div>
                     <label class="block text-sm font-medium text-gray-700 dark:text-gray-300" for="parent_id">
                     <label class="block text-sm font-medium text-gray-700 dark:text-gray-300" for="parent_id">
                         @lang('frontmenu::app.admin.menu.parent')
                         @lang('frontmenu::app.admin.menu.parent')

+ 16 - 0
packages/Longyi/FrontMenu/src/Resources/views/admin/menu/edit.blade.php

@@ -98,6 +98,22 @@
                     />
                     />
                 </div>
                 </div>
 
 
+                <div>
+                    <label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
+                        @lang('frontmenu::app.admin.menu.show-icon')
+                    </label>
+                    <div class="mt-2 flex items-center gap-6">
+                        <label class="inline-flex items-center gap-2">
+                            <input type="radio" name="show_icon" value="1" {{ old('show_icon', $menuItem->show_icon) == 1 ? 'checked' : '' }}>
+                            @lang('frontmenu::app.admin.menu.show-icon-yes')
+                        </label>
+                        <label class="inline-flex items-center gap-2">
+                            <input type="radio" name="show_icon" value="0" {{ old('show_icon', $menuItem->show_icon) == 0 ? 'checked' : '' }}>
+                            @lang('frontmenu::app.admin.menu.show-icon-no')
+                        </label>
+                    </div>
+                </div>
+
                 <div>
                 <div>
                     <label class="block text-sm font-medium text-gray-700 dark:text-gray-300" for="parent_id">
                     <label class="block text-sm font-medium text-gray-700 dark:text-gray-300" for="parent_id">
                         @lang('frontmenu::app.admin.menu.parent')
                         @lang('frontmenu::app.admin.menu.parent')