parent
526827ff64
commit
370364002b
|
|
@ -90,6 +90,7 @@ class PluginController extends Controller
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param $code
|
* @param $code
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $code)
|
public function update(Request $request, $code)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,13 @@ class PluginResource extends JsonResource
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'version' => $this->version,
|
'version' => $this->version,
|
||||||
|
'dir_name' => $this->dirName,
|
||||||
'path' => $this->path,
|
'path' => $this->path,
|
||||||
'code' => $this->code,
|
'code' => $this->code,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'type_format' => trans('admin/plugin.' . $this->type),
|
'type_format' => trans('admin/plugin.' . $this->type),
|
||||||
'icon' => $this->icon,
|
'icon' => plugin_resize($this->code, $this->icon),
|
||||||
'author' => $this->author,
|
'author' => $this->author,
|
||||||
'status' => $this->getStatus(),
|
'status' => $this->getStatus(),
|
||||||
'installed' => $this->getInstalled(),
|
'installed' => $this->getInstalled(),
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,39 @@ function time_format($datetime = null)
|
||||||
return date($format);
|
return date($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取插件根目录
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function plugin_path(string $path = ''): string
|
||||||
|
{
|
||||||
|
return base_path('plugins') . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件图片缩放
|
||||||
|
*
|
||||||
|
* @param $pluginCode
|
||||||
|
* @param $image
|
||||||
|
* @param int $width
|
||||||
|
* @param int $height
|
||||||
|
* @return mixed|void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function plugin_resize($pluginCode, $image, int $width = 100, int $height = 100)
|
||||||
|
{
|
||||||
|
$plugin = app('plugin')->getPlugin($pluginCode);
|
||||||
|
if (Str::startsWith($image, 'http')) {
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
$pluginDirName = $plugin->getDirname();
|
||||||
|
return (new \Beike\Services\ImageService($image))->setPluginDirName($pluginDirName)->resize($width, $height);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图片缩放
|
* 图片缩放
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class Manager
|
||||||
$plugin->setColumns();
|
$plugin->setColumns();
|
||||||
|
|
||||||
if ($plugins->has($plugin->code)) {
|
if ($plugins->has($plugin->code)) {
|
||||||
throw new \Exception("有重名插件:" . $plugin->code);
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$plugins->put($plugin->code, $plugin);
|
$plugins->put($plugin->code, $plugin);
|
||||||
|
|
@ -123,10 +123,10 @@ class Manager
|
||||||
public function getPluginOrFail($code): ?Plugin
|
public function getPluginOrFail($code): ?Plugin
|
||||||
{
|
{
|
||||||
$plugin = $this->getPlugin($code);
|
$plugin = $this->getPlugin($code);
|
||||||
$plugin->handleLabel();
|
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
throw new \Exception('无效的插件');
|
throw new \Exception('无效的插件');
|
||||||
}
|
}
|
||||||
|
$plugin->handleLabel();
|
||||||
return $plugin;
|
return $plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,9 +201,9 @@ class Plugin implements Arrayable, \ArrayAccess
|
||||||
*/
|
*/
|
||||||
public function getColumnView(): string
|
public function getColumnView(): string
|
||||||
{
|
{
|
||||||
$viewFile = $this->getPath() . '/Views/columns.blade.php';
|
$viewFile = $this->getPath() . '/Views/admin/config.blade.php';
|
||||||
if (file_exists($viewFile)) {
|
if (file_exists($viewFile)) {
|
||||||
return "{$this->dirName}::columns";
|
return "{$this->dirName}::admin.config";
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,33 @@ class ImageService
|
||||||
public function __construct($image)
|
public function __construct($image)
|
||||||
{
|
{
|
||||||
$this->image = $image ?: self::PLACEHOLDER_IMAGE;
|
$this->image = $image ?: self::PLACEHOLDER_IMAGE;
|
||||||
if (!is_file($image)) {
|
$this->imagePath = public_path($this->image);
|
||||||
$this->image = self::PLACEHOLDER_IMAGE;
|
|
||||||
}
|
|
||||||
$imagePath = public_path($this->image);
|
|
||||||
$this->imagePath = $imagePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置插件目录名称
|
||||||
|
* @param $dirName
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPluginDirName($dirName): static
|
||||||
|
{
|
||||||
|
$originImage = $this->image;
|
||||||
|
if ($this->image == self::PLACEHOLDER_IMAGE) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->imagePath = plugin_path("{$dirName}/Static") . $originImage;
|
||||||
|
if (file_exists($this->imagePath)) {
|
||||||
|
$this->image = strtolower('plugin/' . $dirName . $originImage);
|
||||||
|
} else {
|
||||||
|
$this->image = self::PLACEHOLDER_IMAGE;
|
||||||
|
$this->imagePath = public_path($this->image);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成并获取缩略图
|
* 生成并获取缩略图
|
||||||
* @param int $width
|
* @param int $width
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ use Beike\Plugin\Manager;
|
||||||
use Beike\Models\AdminUser;
|
use Beike\Models\AdminUser;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class PluginServiceProvider extends ServiceProvider
|
class PluginServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +50,11 @@ class PluginServiceProvider extends ServiceProvider
|
||||||
$this->bootPlugin($plugin);
|
$this->bootPlugin($plugin);
|
||||||
$this->loadRoutes($pluginCode);
|
$this->loadRoutes($pluginCode);
|
||||||
$this->loadTranslations($pluginCode);
|
$this->loadTranslations($pluginCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$allPlugins = $manager->getPlugins();
|
||||||
|
foreach ($allPlugins as $plugin) {
|
||||||
|
$pluginCode = $plugin->getDirname();
|
||||||
$this->loadViews($pluginCode);
|
$this->loadViews($pluginCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "首页菜单添加最新商品列表功能",
|
"description": "首页菜单添加最新商品列表功能",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.0",
|
||||||
"icon": "https://via.placeholder.com/100x100.png/aabbcc?text=MENU",
|
"icon": "",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "成都光大网络科技有限公司",
|
"name": "成都光大网络科技有限公司",
|
||||||
"email": "yangjin@beikeshop.com"
|
"email": "yangjin@beikeshop.com"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "PayPal 支付 <a href='https://developer.paypal.com/' target='_blank'>PayPal Developer</a>",
|
"description": "PayPal 支付 <a href='https://developer.paypal.com/' target='_blank'>PayPal Developer</a>",
|
||||||
"type": "payment",
|
"type": "payment",
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.0",
|
||||||
"icon": "plugin/paypal/image/logo.png",
|
"icon": "/image/logo.png",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "成都光大网络科技有限公司",
|
"name": "成都光大网络科技有限公司",
|
||||||
"email": "yangjin@beikeshop.com"
|
"email": "yangjin@beikeshop.com"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
@extends('admin::layouts.master')
|
||||||
|
|
||||||
|
@section('title', __('admin/plugin.plugins_show'))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h6 class="border-bottom pb-3 mb-4">{{ $plugin->name }}</h6>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<x-admin-alert type="success" msg="{{ session('success') }}" class="mt-4"/>
|
||||||
|
@endif
|
||||||
|
<form class="needs-validation" novalidate action="{{ admin_route('plugins.update', [$plugin->code]) }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
{{ method_field('put') }}
|
||||||
|
|
||||||
|
这里是social配置模板
|
||||||
|
|
||||||
|
<x-admin::form.row title="">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg mt-4">{{ __('common.submit') }}</button>
|
||||||
|
</x-admin::form.row>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"code": "social",
|
||||||
|
"name": "Social",
|
||||||
|
"description": "第三方登录(包括微信、QQ、微博、Google、Facebook)",
|
||||||
|
"type": "social",
|
||||||
|
"version": "v1.0.0",
|
||||||
|
"icon": "/image/logo.png",
|
||||||
|
"author": {
|
||||||
|
"name": "成都光大网络科技有限公司",
|
||||||
|
"email": "yangjin@beikeshop.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "Stripe 支付 <a href='https://stripe.com/' target='_blank'>Stripe</a>",
|
"description": "Stripe 支付 <a href='https://stripe.com/' target='_blank'>Stripe</a>",
|
||||||
"type": "payment",
|
"type": "payment",
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.0",
|
||||||
"icon": "plugin/stripe/image/logo.png",
|
"icon": "/image/logo.png",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "成都光大网络科技有限公司",
|
"name": "成都光大网络科技有限公司",
|
||||||
"email": "yangjin@beikeshop.com"
|
"email": "yangjin@beikeshop.com"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
@extends('errors::minimal')
|
@extends('admin::layouts.master')
|
||||||
|
|
||||||
@section('title', __('Server Error'))
|
@section('title', __('Server Error'))
|
||||||
@section('code', '500')
|
@section('code', '500')
|
||||||
@section('message', __('Server Error'))
|
@section('message', __('Server Error'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{{--@extends('admin::layouts.master')--}}
|
||||||
|
{{----}}
|
||||||
|
{{--@section('title', __('admin/common.forbidden'))--}}
|
||||||
|
{{--@section('code', '403')--}}
|
||||||
|
{{--@section('content', __('admin/common.has_no_permission'))--}}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ return [
|
||||||
|
|
||||||
'shipping' => 'Shipping',
|
'shipping' => 'Shipping',
|
||||||
'payment' => 'Payment',
|
'payment' => 'Payment',
|
||||||
|
'social' => 'Social',
|
||||||
'total' => 'Total',
|
'total' => 'Total',
|
||||||
'view' => 'View',
|
'view' => 'View',
|
||||||
'social' => 'Social',
|
'social' => 'Social',
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ return [
|
||||||
|
|
||||||
'shipping' => '配送方式',
|
'shipping' => '配送方式',
|
||||||
'payment' => '支付方式',
|
'payment' => '支付方式',
|
||||||
|
'social' => '社交网络',
|
||||||
'total' => '订单计算',
|
'total' => '订单计算',
|
||||||
'view' => '页面修改',
|
'view' => '页面修改',
|
||||||
'social' => '第三方登录',
|
'social' => '第三方登录',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue