laravel-admin-extensions / material-ui

Material-UI extension for laravel-admin
MIT License
94 stars 16 forks source link

Input type image issue #15

Open Rambutantech opened 4 years ago

Rambutantech commented 4 years ago

image and browse button not showing

lixworth commented 4 years ago

I also hava this problem

melty-blood commented 4 years ago

我也遇到了,然后仔细排查觉得应该是 JS初始化的问题!把初始化代码换个地方就行了 这是我改的 位置在:your_app_path/vendor/jxlwqq/material-ui/src/MaterialUIServiceProvider.php

<?php

namespace Jxlwqq\MaterialUI;

use Encore\Admin\Admin;
use Illuminate\Support\ServiceProvider;

class MaterialUIServiceProvider extends ServiceProvider
{
    /**
     * {@inheritdoc}
     */
    public function boot(MaterialUI $extension)
    {
        if (!MaterialUI::boot()) {
            return;
        }

        $vendor_path = 'vendor/laravel-admin-ext/material-ui/';

        if ($this->app->runningInConsole() && $assets = $extension->assets()) {
            $this->publishes(
                [$assets => public_path($vendor_path)],
                'laravel-admin-material-ui'
            );
        }

        Admin::booting(function () use ($vendor_path) {
            $skin = str_replace('skin', 'skin-md', config('admin.skin'));

            $html = <<<HTML_MATERIAL
<script>
    $.material.init()
</script>
HTML_MATERIAL;

            Admin::html($html);
            array_push(
                Admin::$baseCss,
                $vendor_path.'MaterialAdminLTE/dist/css/bootstrap-material-design.min.css',
                $vendor_path.'MaterialAdminLTE/dist/css/ripples.min.css',
                $vendor_path.'MaterialAdminLTE/dist/css/MaterialAdminLTE.min.css',
                $vendor_path.'MaterialAdminLTE/dist/css/skins/'.$skin.'.min.css',
                $vendor_path.'MaterialAdminLTE/dist/css/custom.css'
            );
            array_push(
                Admin::$baseJs,
                // $vendor_path.'MaterialAdminLTE/dist/js/material.min.js',
                // $vendor_path.'MaterialAdminLTE/dist/js/ripples.min.js'
            );

            // Admin::script('$.material.init()');
        });
    }
}

同时修改 admin的文件夹的 bootstrap.php

use Encore\Admin\Facades\Admin;

Admin::headerJs('/vendor/laravel-admin-ext/material-ui/MaterialAdminLTE/dist/js/material.min.js');
Admin::headerJs('/vendor/laravel-admin-ext/material-ui/MaterialAdminLTE/dist/js/ripples.min.js');
jxlwqq commented 4 years ago

@TypeMoon-ACG 非常感谢,方便提个PR吗?

melty-blood commented 4 years ago

@jxlwqq 大哥,PR我还不会提交!!实在抱歉!

jxlwqq commented 4 years ago

@TypeMoon-ACG 好的,我稍后更新下。

melty-blood commented 4 years ago

@TypeMoon-ACG GIT看来的好好学学了!(commit路人党)

1511872373855301

lixworth commented 4 years ago

16