mirror of
https://github.com/cjango/dcat-vue.git
synced 2025-12-06 22:40:03 +08:00
一些优化
This commit is contained in:
@@ -6,6 +6,7 @@ use Dcat\Admin\Extend\ServiceProvider;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Weiwait\DcatVue\Field\DateRange;
|
||||
use Weiwait\DcatVue\Field\File;
|
||||
use Weiwait\DcatVue\Field\Image;
|
||||
use Weiwait\DcatVue\Field\MultipleFile;
|
||||
@@ -35,15 +36,14 @@ class DcatVueServiceProvider extends ServiceProvider
|
||||
$this->hackConfigs();
|
||||
|
||||
// Form::extend('vue', Vue::class);
|
||||
Form::extend('file', File::class);
|
||||
Form::extend('multipleFile', MultipleFile::class);
|
||||
Form::extend('image', Image::class);
|
||||
Form::extend('multipleImage', MultipleImage::class);
|
||||
Form::extend('tags', Tag::class);
|
||||
Form::extend('vFile', File::class);
|
||||
Form::extend('vMultipleFile', MultipleFile::class);
|
||||
Form::extend('vImage', Image::class);
|
||||
Form::extend('vMultipleImage', MultipleImage::class);
|
||||
Form::extend('vTags', Tag::class);
|
||||
// Form::extend('dateRange', DateRange::class);
|
||||
|
||||
Admin::asset()->css(Admin::asset()->getAlias('@weiwait.dcat-vue')['css']);
|
||||
|
||||
$this->publishable();
|
||||
}
|
||||
|
||||
public function settingForm()
|
||||
@@ -92,6 +92,8 @@ class DcatVueServiceProvider extends ServiceProvider
|
||||
]);
|
||||
|
||||
config()->set('filesystems.default', FilesystemConfig::get('disk', config('filesystems.default')));
|
||||
|
||||
config()->set('admin.auth.except', array_merge((array)config('admin.auth.except'), ['weiwait*']));
|
||||
});
|
||||
|
||||
Event::listen('admin:booted', function () {
|
||||
|
||||
73
src/Field/DateRange.php
Normal file
73
src/Field/DateRange.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Weiwait\DcatVue\Field;
|
||||
|
||||
use Dcat\Admin\Form\Field;
|
||||
use Dcat\Admin\Support\Helper;
|
||||
|
||||
class DateRange extends Field\DateRange
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
|
||||
public function render()
|
||||
{
|
||||
/****************************** parent ************************************/
|
||||
|
||||
$this->options['locale'] = config('app.locale');
|
||||
|
||||
$this->addVariables(['options' => $this->options]);
|
||||
|
||||
/****************************** field ************************************/
|
||||
|
||||
if (!$this->shouldRender()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->setDefaultClass();
|
||||
|
||||
$this->callComposing();
|
||||
|
||||
$this->withScript();
|
||||
|
||||
/****************************** custom ************************************/
|
||||
|
||||
$this->withProvides();
|
||||
|
||||
$this->addVariables([
|
||||
'provides' => $this->variables(),
|
||||
]);
|
||||
|
||||
return view($this->view(), $this->variables());
|
||||
}
|
||||
|
||||
protected function formatAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
protected function withProvides()
|
||||
{
|
||||
$this->addVariables([
|
||||
'component' => 'DateRange',
|
||||
]);
|
||||
}
|
||||
|
||||
public function max(int $max): self
|
||||
{
|
||||
$this->addVariables(['max' => $max]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function disableDates(array $dates): self
|
||||
{
|
||||
$datesObj = [];
|
||||
foreach ($dates as $item) {
|
||||
$datesObj[] = ['start' => $item[0], 'end' => $item[1] ?? null];
|
||||
}
|
||||
|
||||
$this->addVariables(['disableDates' => $datesObj]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||
|
||||
class File extends Field\File
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::file';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
protected string $disk;
|
||||
|
||||
protected function prepareInputValue($file)
|
||||
|
||||
@@ -8,7 +8,7 @@ use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||
|
||||
class Image extends Field\Image
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::file';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
protected string $disk;
|
||||
|
||||
protected function prepareInputValue($file)
|
||||
|
||||
@@ -7,7 +7,7 @@ use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||
|
||||
class MultipleFile extends Field\MultipleFile
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::file';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
protected string $disk;
|
||||
|
||||
protected function prepareInputValue($file): array
|
||||
|
||||
@@ -8,7 +8,7 @@ use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||
|
||||
class MultipleImage extends Field\MultipleImage
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::file';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
protected string $disk;
|
||||
|
||||
protected function prepareInputValue($file)
|
||||
|
||||
@@ -7,7 +7,7 @@ use Dcat\Admin\Support\Helper;
|
||||
|
||||
class Tag extends Field\Tags
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::tag';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
|
||||
public function render()
|
||||
{
|
||||
@@ -31,8 +31,6 @@ class Tag extends Field\Tags
|
||||
'keyAsValue' => $this->keyAsValue,
|
||||
]);
|
||||
|
||||
/****************************** end parent ************************************/
|
||||
|
||||
/****************************** field ************************************/
|
||||
|
||||
if (!$this->shouldRender()) {
|
||||
@@ -45,7 +43,7 @@ class Tag extends Field\Tags
|
||||
|
||||
$this->withScript();
|
||||
|
||||
/****************************** end field ************************************/
|
||||
/****************************** custom ************************************/
|
||||
|
||||
$this->withProvides();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use Dcat\Admin\Widgets\Checkbox as WidgetCheckbox;
|
||||
|
||||
class Vue extends Field\Checkbox
|
||||
{
|
||||
protected $view = 'weiwait.dcat-vue::index';
|
||||
protected $view = 'weiwait.dcat-vue::common';
|
||||
|
||||
protected array $watch = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user