如何更改 Laravel 8 中的 Jetstream 徽标?

How to change Jetstream logo in Laravel 8?

我使用 Jetstream 身份验证安装了 Laravel 8。现在我想更改登录组件,特别是徽标。这些组件放在哪里?

我找到了这个,请按照以下步骤操作。

您可以运行下面的命令来发布资产。

php artisan vendor:publish --tag=jetstream-views

之后文件将在文件夹 resources/views/vendor/jetstream/components

下可用

安装教程里有答案

https://jetstream.laravel.com/1.x/installation.html#application-logo

php artisan vendor:publish --tag=jetstream-views

Livewire

Next, you should customize the SVGs located in the resources/views/vendor/jetstream/components/application-logo.blade.php, resources/views/vendor/jetstream/components/authentication-card-logo.blade.php, and resources/views/vendor/jetstream/components/application-mark.blade.php components.

惯性

Next, you should customize the SVGs located in resources/views/vendor/jetstream/components/authentication-card-logo.blade.php, resources/js/Jetstream/ApplicationLogo.vue, and resources/js/Jetstream/ApplicationMark.vue. After customizing these components, you should rebuild your assets:

如果您想在数据库中获取徽标。

您需要先运行 php artisan vendor:publish --tag=jetstream-views 这个命令。之后,你需要获取 resources\views\auth\login.blade.php 并将这个 <x-jet-authentication-card-logo /> 替换为你自己的组件!

你可以这样做 运行 这个命令 php artisan make:component AppLogo 并创建你自己的组件。

<?php

namespace App\View\Components;

use App\Models\GeneralSettings;
use Illuminate\View\Component;

class AppLogo extends Component
{
    public $logo;

    public function __construct()
    {
        $this->logo = GeneralSettings::first()->favicon;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|string
     */
    public function render()
    {
        return view('components.home.app-logo');
    }
}

之后您需要像那样编辑 resources\views\components\home\app-logo.blade.php 文件;

<div>
    <img src="{{$logo}}">
</div>

之后,您需要获取 resources\views\auth\login.blade.php 并将此 <x-jet-authentication-card-logo /> 替换为您自己的组件!就那样<x-applogo />

结果就是这样;

<x-guest-layout>
    <x-jet-authentication-card>
        <x-slot name="logo">
{{--            <x-jet-authentication-card-logo />--}}
            <x-applogo />
        </x-slot>

        <x-jet-validation-errors class="mb-4" />
....

只需添加您自己的 html.

这样做,

<x-slot name="logo">
    <img src="{{ url('logo.png') }}" />
</x-slot>

更改 Laravel 8 中的 Jetstream 徽标。 您必须完成 3 个步骤

  • 1.first运行这条命令生成组件
    php artisan vendor:publish --tag=jetstream-views 这将生成视图 [\vendor\laravel\jetstream\resources\views] To
    [\resources\views\vendor\jetstream]
  • 2.Open \resources\views\vendor\jetstream 并移动到认证卡-logo.blade
  • 3.Crate 您的 Svg 图片来自 https://www.w3schools.com/graphics/svg_intro.asp 或下载 免于 1: https://freesvg.org 我也通过以下方式更改了我的徽标 这个