Browse Source

feat: video updated

igb 4 months ago
parent
commit
b9ac7a392a

+ 70 - 10
app/Http/Controllers/VideoController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use App\Services\LiquidRenderer;
 use App\Services\LiquidRenderer;
 use App\Models\DistVideo ;
 use App\Models\DistVideo ;
+use App\Models\DistVideoCategory ;
 class VideoController extends Controller
 class VideoController extends Controller
 {
 {
     protected $liquidRenderer;
     protected $liquidRenderer;
@@ -25,16 +26,69 @@ class VideoController extends Controller
         return $this->liquidRenderer->render('videos.index', ['videos' => $videos]);
         return $this->liquidRenderer->render('videos.index', ['videos' => $videos]);
     }
     }
 
 
-    /**
-     * Display the specified video.
-     *
-     * @param  int  $id
-     * @return \Illuminate\Http\Response
-     */
-    public function show($id)
+    public function category($slug)
+    {
+
+
+        // 获取分类信息
+        $category = DistVideoCategory::findOrFail($slug);
+        // 获取分类下的所有产品,并按 is_pinned 排序,然后进行分页
+        $videos = DistVideo::where('category_id', $category->id)
+            ->where('dist_id', getDistId())
+            ->where('enabled', 1)
+
+            ->orderBy('order', 'desc') // 按 is_pinned 降序排序
+            ->paginate(12);
+
+
+        // 创建分页数据结构
+        $paginator = [
+            'previous_page' => $videos->previousPageUrl() ? true : false, // 是否有上一页
+            'previous_page_url' => $videos->previousPageUrl(), // 上一页的 URL
+            'next_page' => $videos->nextPageUrl() ? true : false, // 是否有下一页
+            'next_page_url' => $videos->nextPageUrl(), // 下一页的 URL
+            'current_page' => $videos->currentPage(), // 当前页
+            'total_pages' => $videos->lastPage(), // 总页数
+            'pages' => range(1, $videos->lastPage()), // 页码数组
+            'page_url' => array_combine(
+                range(1, $videos->lastPage()),
+                array_map(fn($page) => $videos->url($page), range(1, $videos->lastPage()))
+            ), // 每页的 URL
+        ];
+
+        // 构建导航数据 开始
+        $breadcrumbs = [
+            [
+                'url' => '/',
+                'name' => 'Home',
+            ]
+        ];
+
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => 'Video',
+        ];
+        $breadcrumbs[] = [
+            'url' => '#',
+            'name' => $category->name,
+        ];
+
+        // 渲染模板并传递数据
+        return $this->liquidRenderer->render('videos_categories.liquid', [
+            'category' => $category, // 分类名称
+            'videos' => $videos,           // 分类下的产品
+            'paginator' => $paginator, // 分页信息
+            'breadcrumbs' => $breadcrumbs,
+        ]);
+    }
+
+
+
+    public function detail($slug)
     {
     {
 
 
-        $video = DistVideo::findOrFail($id);
+        $video = DistVideo::where('dist_id', getDistId())->where('slug', $slug)->orWhere('id', $slug)->first();
+
 
 
         // 构建导航数据 开始
         // 构建导航数据 开始
         $breadcrumbs = [
         $breadcrumbs = [
@@ -47,7 +101,7 @@ class VideoController extends Controller
         $category=$video->distVideoCategory;
         $category=$video->distVideoCategory;
 
 
         $breadcrumbs[] = [
         $breadcrumbs[] = [
-            'url' => "/videos/{$category->name}",
+            'url' => '#',
             'name' => $category->name,
             'name' => $category->name,
         ];
         ];
 
 
@@ -56,6 +110,12 @@ class VideoController extends Controller
             'name' => $video->title,
             'name' => $video->title,
         ];
         ];
 
 
-        return $this->liquidRenderer->render('videos.show', ['video' => $video, 'breadcrumbs' => $breadcrumbs]);
+
+        return $this->liquidRenderer->render('videos_detail.liquid',
+            [
+                'video' => $video,
+               // 'csrf_token' => csrf_token(),
+                'breadcrumbs' => $breadcrumbs,
+            ]);
     }
     }
 }
 }

+ 2 - 5
app/Models/DistVideoCategory.php

@@ -5,12 +5,9 @@ namespace App\Models;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
 
 
-class distVideoCategory extends Model implements Sortable
+class distVideoCategory extends Model
 {
 {
-    use HasDateTimeFormatter,
-        ModelTree {
-        ModelTree::boot as treeBoot;
-    }
+
     protected $table = 'dist_video_category';
     protected $table = 'dist_video_category';
     //名称
     //名称
     protected $titleColumn = 'name';
     protected $titleColumn = 'name';

+ 121 - 0
resources/views/liquid_src/1/TechVista/videos_categories.liquid

@@ -0,0 +1,121 @@
+<!DOCTYPE html>
+<html lang="{{site.dist.country_lang }}">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="robots" content="index, follow">
+<meta property="og:locale" content="{{site.dist.country_lang | replace: '-', '_' }}" />
+<meta name="author" content="Mietubl">
+<meta name="description" content="{{ tag.seo_description }}">
+<meta name="keywords" content="{{tag.seo_keywords}}">
+<title>{{tag.seo_title}}</title>
+{% include '_header_css.liquid' %}
+</head>
+<body>
+
+<!-- MAIN WRAPPER -->
+<div class="body-wrap shop-default shop-cards shop-tech">
+    <div id="st-container" class="st-container">
+
+        <div class="st-pusher">
+            <div class="st-content">
+                <div class="st-content-inner">
+                    <!-- HEADER -->
+                    {% include '_header.liquid' %}
+                    <!-- END: HEADER -->
+                    <!-- BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                            <div class="page-title">
+                                <div class="row align-items-center">
+                                    <div class="d-flex justify-content-end col-lg-12 col-12">
+                                        {% for  breadcrumb in breadcrumbs %}
+                                            <h2 class="heading heading-6 text-capitalize strong-500 mb-0">
+                                                <a href="{{ breadcrumb.url }}" class="link text-underline--none">
+                                                    &nbsp;
+                                                    {% if forloop.index == 1 %}
+                                                        <!-- 第一个 breadcrumb 使用 ion-ios-home 图标 -->
+                                                        <i class="ion-ios-home"></i>
+                                                    {% else %}
+                                                        <!-- 其它 breadcrumb 使用 ion-ios-arrow-forward 图标 -->
+                                                        <i class="ion-ios-arrow-forward"></i>
+                                                    {% endif %}
+                                                    {{ breadcrumb.name }}
+                                                </a>
+                                            </h2>
+                                        {% endfor %}
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </section>
+                    <!-- END: BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                            <div class="row align-items-center">
+                                <div class="col-12" >
+                                    <h3 class="heading heading-3 strong-600 text-uppercase mb-0 text-center">{{ tag.name }}</h3>
+                                </div>
+
+                            </div>
+
+                            <div class="row cols-md-space cols-sm-space cols-xs-space">
+
+                                {% for item in videos %}
+                                    <div class="col-lg-4 col-wrapper--spaced-y">
+                                        <div class="card z-depth-2-top">
+                                            <div class="card-image">
+                                                <div class="view view-first">
+                                                    <a href="/videos/{% if item.slug %}{{ item.slug }}{% else %}{{ item.id }}{% endif %}">
+
+                                                        {% if item.cover_image %}
+                                                            <img src="{{ site.image_base_url }}{{ item.cover_image | append: '?x-oss-process=image/resize,m_pad,w_400,h_400'  }}" alt="Cover Image "  >
+                                                        {% else %}
+                                                            <div class="img-center default-image-thumbnail no-image-placeholder-thumbnail">
+                                                                <span>No Image</span>
+                                                            </div>
+                                                        {% endif %}
+
+                                                    </a>
+                                                </div>
+                                            </div>
+
+                                            <div class="card-body">
+                                                <h3 class="heading heading-5 strong-500 mb-0 title-over-flow" >
+                                                    <a href="/videos/{% if item.slug %}{{ item.slug }}{% else %}{{ item.id }}{% endif %}" title="{{ item.title | strip_html }}">{{ item.title | strip_html }}</a>
+                                                </h3>
+                                            </div>
+
+                                            <div class="card-footer">
+                                                <div class="row">
+
+                                                    <div class="col text-right">
+                                                        <ul class="inline-links inline-links--style-2">
+                                                            <li>
+                                                                {{item.post_date }}
+                                                            </li>
+                                                        </ul>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                {% endfor %}
+
+
+
+
+
+                            </div>
+                        </div>
+                    </section>    <!-- FOOTER -->
+                    {% include '_footer.liquid' %}
+                </div>
+            </div>
+        </div><!-- END: st-pusher -->
+    </div><!-- END: st-container -->
+</div><!-- END: body-wrap -->
+<a href="#" class="back-to-top btn-back-to-top"></a>
+{% include '_footer_js.liquid' %}
+</body>
+</html>

+ 147 - 0
resources/views/liquid_src/1/TechVista/videos_detail.liquid

@@ -0,0 +1,147 @@
+<!DOCTYPE html>
+<html lang="{{site.dist.country_lang }}">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="robots" content="index, follow">
+<meta property="og:locale" content="{{site.dist.country_lang | replace: '-', '_' }}" />
+<meta name="author" content="Mietubl">
+<meta name="description" content="{{ page.seo_description }}">
+<meta name="keywords" content="{{page.seo_keywords}}">
+<title>{{page.seo_title}}</title>
+
+{% include '_header_css.liquid' %}
+</head>
+<body>
+
+<!-- MAIN WRAPPER -->
+<div class="body-wrap shop-default shop-cards shop-tech">
+    <div id="st-container" class="st-container">
+        <div class="st-pusher">
+            <div class="st-content">
+                <div class="st-content-inner">
+                    <!-- HEADER -->
+                    {% include '_header.liquid' %}
+                    <!-- END: HEADER -->
+                    <!-- BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                            <div class="page-title">
+                                <div class="row align-items-center">
+                                    <div class="d-flex justify-content-end col-lg-12 col-12">
+                                        {% for  breadcrumb in breadcrumbs %}
+                                            <h2 class="heading heading-6 text-capitalize strong-500 mb-0">
+                                                <a href="{{ breadcrumb.url }}" class="link text-underline--none">
+                                                    &nbsp;
+                                                    {% if forloop.index == 1 %}
+                                                        <!-- 第一个 breadcrumb 使用 ion-ios-home 图标 -->
+                                                        <i class="ion-ios-home"></i>
+                                                    {% else %}
+                                                        <!-- 其它 breadcrumb 使用 ion-ios-arrow-forward 图标 -->
+                                                        <i class="ion-ios-arrow-forward"></i>
+                                                    {% endif %}
+                                                    {{ breadcrumb.name }}
+                                                </a>
+                                            </h2>
+                                        {% endfor %}
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </section>
+                    <!-- END: BREADCRUMB -->
+                    <section class="slice sct-color-1">
+                        <div class="container">
+
+                                    <div class="block block-post">
+                                        <div class="block-body block-post-body">
+                                            <h1>
+                                                {{ video.title | raw }}
+                                            </h1>
+
+
+                                            <div class="d-flex justify-content-center">
+                                                <div style="position: relative; width: 90%; padding-top: 56.25%;"> <!-- 16:9 ratio -->
+                                                    <iframe
+                                                        src="{{ video.video_url | raw }}"
+                                                        title="YouTube video player"
+                                                        frameborder="0"
+                                                        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
+                                                        referrerpolicy="strict-origin-when-cross-origin"
+                                                        allowfullscreen
+                                                        style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
+                                                    ></iframe>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    <!-- Comment form -->
+                                </div>
+                             </div>
+                    </section>
+
+                    {{ page.page_type }}
+                    {% if page.page_type == 0 %}
+                    <section class="slice sct-color-1">
+                        <div class="container">
+                        <div class="pt-5">
+                                <nav aria-label="Product pagination">
+                                    <ul class="pagination pagination--style-2 justify-content-center">
+                                        <!-- Previous Page Link -->
+                                        {% if paginator.previous_page %}
+                                            <li class="page-item">
+                                                <a class="page-link" href="{{ paginator.previous_page_url }}" tabindex="-1">Previous</a>
+                                            </li>
+                                        {% else %}
+                                            <li class="page-item disabled">
+                                                <a class="page-link" href="#" tabindex="-1">Previous</a>
+                                            </li>
+                                        {% endif %}
+
+                                        <!-- Next Page Link -->
+                                        {% if paginator.next_page %}
+                                            <li class="page-item">
+                                                <a class="page-link" href="{{ paginator.next_page_url }}">Next</a>
+                                            </li>
+                                        {% else %}
+                                            <li class="page-item disabled">
+                                                <a class="page-link" href="#">Next</a>
+                                            </li>
+                                        {% endif %}
+                                    </ul>
+                                </nav>
+                            </div>
+                        </div>
+                    </section>
+                    {% endif %}
+
+                    <!-- FOOTER -->
+                    {% include '_footer.liquid' %}
+                </div>
+            </div>
+        </div><!-- END: st-pusher -->
+    </div><!-- END: st-container -->
+</div><!-- END: body-wrap -->
+<a href="#" class="back-to-top btn-back-to-top"></a>
+{% include '_footer_js.liquid' %}
+
+<!-- Isotope -->
+<script src="/static/js/isotope.min.js"></script>
+<script src="/static/js/imagesloaded.pkgd.min.js"></script>
+
+<!-- Deso Slide -->
+<script src="/static/js/jquery.desoslide.min.js"></script>
+<script>
+    $('#slideshow').desoSlide({
+        thumbs: $('#slideshow_thumbs .swiper-slide > a'),
+        thumbEvent: 'click',
+        first: 0,
+        effect: 'none',
+        overlay: 'none',
+        controls: {
+            show: false,
+            keys: false
+        },
+    });
+</script>
+</body>
+</html>

+ 1 - 1
routes/web.php

@@ -37,7 +37,7 @@ Route::prefix('products')->group(function () {
 // 视频路由
 // 视频路由
 Route::prefix('videos')->group(function () {
 Route::prefix('videos')->group(function () {
     Route::get('/', [VideoController::class, 'index'])->name('videos.index');
     Route::get('/', [VideoController::class, 'index'])->name('videos.index');
-    Route::get('/{id}', [VideoController::class, 'show'])->name('videos.show');
+    Route::get('/{id}', [VideoController::class, 'detail'])->name('videos.detail');
     Route::get('/categories/{categoryId}', [VideoController::class, 'category'])->name('videos.category');
     Route::get('/categories/{categoryId}', [VideoController::class, 'category'])->name('videos.category');
 });
 });