From 28d92d8b402049284b52ce321ac788487c1143a1 Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Thu, 28 Jul 2022 17:24:33 +0800 Subject: [PATCH] wip --- .../Http/Controllers/BrandController.php | 4 +++ beike/Models/Brand.php | 2 +- public/build/beike/admin/js/app.js | 13 +++++++++ resources/beike/admin/js/app.js | 11 +++++++ .../admin/views/layouts/master.blade.php | 1 + .../admin/views/pages/brands/index.blade.php | 29 ++++++++++++++----- .../admin/views/shared/vue-image.blade.php | 9 ------ 7 files changed, 52 insertions(+), 17 deletions(-) diff --git a/beike/Admin/Http/Controllers/BrandController.php b/beike/Admin/Http/Controllers/BrandController.php index bd67f9db..9cf3aaf0 100644 --- a/beike/Admin/Http/Controllers/BrandController.php +++ b/beike/Admin/Http/Controllers/BrandController.php @@ -23,6 +23,10 @@ class BrandController extends Controller 'brands' => $brands, ]; + if ($request->expectsJson()) { + return json_success('成功', $data); + } + return view('admin::pages.brands.index', $data); } diff --git a/beike/Models/Brand.php b/beike/Models/Brand.php index 5ff054fa..84559d4f 100644 --- a/beike/Models/Brand.php +++ b/beike/Models/Brand.php @@ -18,7 +18,7 @@ class Brand extends Base { use HasFactory; - protected $fillable = ['name', 'country_id', 'code', 'sort_order', 'status']; + protected $fillable = ['name', 'country_id', 'first', 'logo', 'code', 'sort_order', 'status']; public function products() :HasMany { diff --git a/public/build/beike/admin/js/app.js b/public/build/beike/admin/js/app.js index 4b41e279..6036edd2 100644 --- a/public/build/beike/admin/js/app.js +++ b/public/build/beike/admin/js/app.js @@ -2066,6 +2066,7 @@ __webpack_require__.r(__webpack_exports__); window.$http = _js_http__WEBPACK_IMPORTED_MODULE_0__["default"]; var base = document.querySelector('base').href; +var asset = document.querySelector('meta[name="asset"]').content; $(document).on('click', '.open-file-manager', function (event) { var $this = $(this); layer.open({ @@ -2088,6 +2089,18 @@ $(document).on('click', '.open-file-manager', function (event) { } }); }); + +if (typeof Vue != 'undefined') { + Vue.prototype.thumbnail = function thumbnail(image, width, height) { + // 判断 image 是否以 http 开头 + if (image.indexOf('http') === 0) { + return image; + } + + return asset + image; + }; +} + $(document).ready(function ($) { $.ajaxSetup({ headers: { diff --git a/resources/beike/admin/js/app.js b/resources/beike/admin/js/app.js index 4396bf00..0a39e8d6 100644 --- a/resources/beike/admin/js/app.js +++ b/resources/beike/admin/js/app.js @@ -1,6 +1,7 @@ import http from "../../../js/http"; window.$http = http; const base = document.querySelector('base').href; +const asset = document.querySelector('meta[name="asset"]').content; $(document).on('click', '.open-file-manager', function(event) { const $this = $(this); @@ -25,6 +26,16 @@ $(document).on('click', '.open-file-manager', function(event) { }); }); +if (typeof Vue != 'undefined') { + Vue.prototype.thumbnail = function thumbnail(image, width, height) { + // 判断 image 是否以 http 开头 + if (image.indexOf('http') === 0) { + return image; + } + + return asset + image; + }; +} $(document).ready(function ($) { $.ajaxSetup({ diff --git a/resources/beike/admin/views/layouts/master.blade.php b/resources/beike/admin/views/layouts/master.blade.php index e364e03b..22f4ad47 100644 --- a/resources/beike/admin/views/layouts/master.blade.php +++ b/resources/beike/admin/views/layouts/master.blade.php @@ -5,6 +5,7 @@ + diff --git a/resources/beike/admin/views/pages/brands/index.blade.php b/resources/beike/admin/views/pages/brands/index.blade.php index 3b519a7b..739e07ce 100644 --- a/resources/beike/admin/views/pages/brands/index.blade.php +++ b/resources/beike/admin/views/pages/brands/index.blade.php @@ -3,7 +3,7 @@ @section('title', '品牌管理') @section('content') -
+
@@ -15,16 +15,18 @@ 名称 图标 排序 + 首字母 状态 操作 - + @{{ brand.id }} @{{ brand.name }} - @{{ brand.logo }} +
@{{ brand.sort_order }} + @{{ brand.first }} @{{ brand.status }} @@ -37,7 +39,7 @@ {{-- {{ $brands->links('admin::vendor/pagination/bootstrap-4') }} --}}
- @@ -49,6 +51,10 @@ + + + + @@ -67,6 +73,7 @@ @endsection + @push('footer') @include('admin::shared.vue-image')