1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
vine_liutk 9489c3ea3a 添加友情链接样式 2023-03-20 16:19:28 +08:00
vine_liutk c7c3c9cd39 添加图片管理样式 2023-03-20 15:59:08 +08:00
vine_liutk 7adb8316e1 添加文章管理样式 2023-03-20 15:35:19 +08:00
23 changed files with 659 additions and 4 deletions

View File

@ -9,10 +9,10 @@ class Components extends BaseRenderer {
/**
* 父级选择器
*/
public function parentControl($apiUrl = '', $name ='parent_id', $labelField = 'name', $valueField = 'id')
public function parentControl($apiUrl = '', $name ='parent_id', $label ='父级', $labelField = 'name', $valueField = 'id')
{
return amisMake()->TreeSelectControl()
->name($name)->label('父级')
->name($name)->label($label)
->showIcon(false)
->labelField($labelField)
->valueField($valueField)
@ -23,7 +23,10 @@ class Components extends BaseRenderer {
* 排序字段
*/
public function sortControl($name ='sort', $label = '排序'){
return amisMake()->NumberControl()->name($name)->label($label)->min(0);
return amisMake()->NumberControl()
->name($name)->label($label)
->value(0)
->min(0);
}
/**

View File

@ -0,0 +1,62 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\ArticleCategoryService;
use App\Admin\Components;
class ArticleCategoryController extends AdminController
{
protected string $serviceName = ArticleCategoryService::class;
protected string $pageTitle = '文章分类';//待完善-todo
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('name')->label('名称'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('name')->label('名称')->required(true),
amisMake()->ImageControl()->name('icon')->label('icon')->autoUpload(true),
Components::make()->parentControl(),
Components::make()->sortControl(),
amisMake()->SwitchControl()->name('is_enable')->label('显示'),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('name')->label('名称'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
public function getTreeList(Request $request){
return $this->service->getTree();
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\ArticleService;
use App\Admin\Components;
class ArticleController extends AdminController
{
protected string $serviceName = ArticleService::class;
protected string $pageTitle = '文章管理';//待完善-todo
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true, 'lg'),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('title')->label('标题'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true, 'lg'),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('title')->label('标题')->required(true),
TextControl::make()->name('sub_title')->label('副标题'),
\amisMake()->ImageControl()->name('cover')->label('封面')->autoUpload(true),
Components::make()->parentControl('', 'category_id', '分类'),
Components::make()->fuEditorControl(),
Components::make()->sortControl(),
\amisMake()->DateTimeControl()->name('published_at')->label('发布时间')->description('*不填写则默认为创建时间'),
\amisMake()->SwitchControl()->name('is_enable')->label('显示'),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('title')->label('标题'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\BannerService;
use App\Admin\Components;
class BannerController extends AdminController
{
protected string $serviceName = BannerService::class;
protected string $pageTitle = '图片管理';//待完善-todo
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('name')->label('名称'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('name')->label('名称')->required(true),
\amisMake()->ImageControl()->name('picture')->label('图片')->autoUpload(true),
Components::make()->parentControl('', 'place_id', '位置'),
Components::make()->sortControl(),
\amisMake()->DateTimeControl()->name('published_at')->label('发布时间')->description('*不填写则默认为创建时间'),
\amisMake()->SwitchControl()->name('is_enable')->label('显示'),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('name')->label('名称'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\BannerPlaceService;
class BannerPlaceController extends AdminController
{
protected string $serviceName = BannerPlaceService::class;
protected string $pageTitle = '图片位置';//待完善-todo
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('name')->label('名称'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('name')->label('名称')->required(true),
TextControl::make()->name('key')->label('KEY')->required(true),
\amisMake()->SwitchControl()->name('is_enable')->label('显示'),
TextControl::make()->name('remark')->label('备注'),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('name')->label('名称'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\TableColumn;
use Slowlyo\OwlAdmin\Renderers\TextControl;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Services\Admin\FriendLinkService;
use App\Admin\Components;
class FriendLinkController extends AdminController
{
protected string $serviceName = FriendLinkService::class;
protected string $pageTitle = '友情链接';//待完善-todo
public function list(): Page
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->headerToolbar([
$this->createButton(true),
...$this->baseHeaderToolBar(),
])
->columns([
TableColumn::make()->name('id')->label('ID')->sortable(true),
TableColumn::make()->name('name')->label('名称'),
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
$this->rowActions(true),
]);
return $this->baseList($crud);
}
public function form(): Form
{
return $this->baseForm()->body([
TextControl::make()->name('name')->label('名称'),
TextControl::make()->name('path')->label('链接')->required(true),
amisMake()->ImageControl()->name('icon')->label('icon')->autoUpload(true),
Components::make()->sortControl(),
amisMake()->SwitchControl()->name('is_recommend')->label('推荐'),
amisMake()->SwitchControl()->name('is_enable')->label('显示'),
]);
}
public function detail(): Form
{
return $this->baseDetail()->body([
TextControl::make()->static(true)->name('id')->label('ID'),
TextControl::make()->static(true)->name('name')->label('名称'),
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
]);
}
}

View File

@ -18,6 +18,16 @@ Route::group([
//公告管理
$router->resource('admin-notices', \App\Admin\Controllers\AdminNoticeController::class);
//文章分类
$router->resource('article-categories', \App\Admin\Controllers\ArticleCategoryController::class);
//文章管理
$router->resource('articles', \App\Admin\Controllers\ArticleController::class);
//图片位置
$router->resource('banner-places', \App\Admin\Controllers\BannerPlaceController::class);
//图片管理
$router->resource('banners', \App\Admin\Controllers\BannerController::class);
//友情链接
$router->resource('friend-links', \App\Admin\Controllers\FriendLinkController::class);
$router->resource('keywords', \App\Admin\Controllers\KeywordController::class);

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use EloquentFilter\Filterable;
class Article extends Model
{
use HasFactory;
use Filterable;
protected $fillable = [];
protected function serializeDate(\DateTimeInterface $date){
return $date->format('Y-m-d H:i:s');
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use EloquentFilter\Filterable;
class ArticleCategory extends Model
{
use HasFactory;
use Filterable;
protected $fillable = [];
protected function serializeDate(\DateTimeInterface $date){
return $date->format('Y-m-d H:i:s');
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Banner extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BannerPlace extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FriendLink extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Services\Admin;
use App\Models\ArticleCategory;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method ArticleCategory getModel()
* @method ArticleCategory|\Illuminate\Database\Query\Builder query()
*/
class ArticleCategoryService extends AdminService
{
protected string $modelName = ArticleCategory::class;
public function getTree()
{
$list = $this->query()->orderByDesc('sort')->get()->toArray();
return array2tree($list);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\Article;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method Article getModel()
* @method Article|\Illuminate\Database\Query\Builder query()
*/
class ArticleService extends AdminService
{
protected string $modelName = Article::class;
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\BannerPlace;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method BannerPlace getModel()
* @method BannerPlace|\Illuminate\Database\Query\Builder query()
*/
class BannerPlaceService extends AdminService
{
protected string $modelName = BannerPlace::class;
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\Banner;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method Banner getModel()
* @method Banner|\Illuminate\Database\Query\Builder query()
*/
class BannerService extends AdminService
{
protected string $modelName = Banner::class;
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Admin;
use App\Models\FriendLink;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method FriendLink getModel()
* @method FriendLink|\Illuminate\Database\Query\Builder query()
*/
class FriendLinkService extends AdminService
{
protected string $modelName = FriendLink::class;
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('article_categories', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('名称');
$table->string('icon')->nullable()->comment('图标');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
$table->unsignedInteger('sort')->default(0)->comment('排序');
$table->unsignedBigInteger('parent_id')->default(0)->comment('上级ID');
$table->unsignedInteger('level')->default(1)->comment('层级');
$table->string('path')->default('-')->comment('所有的父级ID');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('article_categories');
}
};

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('sub_title')->nullable()->comment('副标题');
$table->unsignedBigInteger('category_id')->nullable()->comment('文章分类');
$table->text('content')->nullable()->comment('文章内容');
$table->timestamp('published_at')->nullable()->comment('发布时间');
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐开关');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
$table->unsignedInteger('sort')->default(0)->comment('排序');
//可能用到的额外字段
$table->string('cover')->nullable()->comment('封面');
$table->string('author')->nullable()->comment('作者/来源');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('articles');
}
};

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('banner_places', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('key');
$table->unsignedInteger('height')->nullable()->comment('高:px');
$table->unsignedInteger('width')->nullable()->comment('宽:px');
$table->string('remark')->nullable()->comment('备注');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('banner_places');
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('banners', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('picture');
$table->unsignedBigInteger('place_id')->nullable()->comment('位置');
$table->timestamp('published_at')->nullable()->comment('发布时间');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
$table->unsignedInteger('sort')->default(0)->comment('排序');
$table->text('link_config')->nullable()->comment('跳转配置');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('banners');
}
};

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('friend_links', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('icon')->nullable()->comment('图标');
$table->string('path');
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐开关');
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
$table->unsignedInteger('sort')->default(0)->comment('排序');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('friend_links');
}
};

View File

@ -25,7 +25,7 @@ class AdminMenuSeeder extends Seeder
['title' => '公告管理', 'icon' => 'icon-park:volume-notice', 'url' => '/admin-notices'],
['title' => '文章分类', 'icon' => 'icon-park:book-one', 'url' => '/article-categories'],
['title' => '文章管理', 'icon' => 'icon-park:file-search', 'url' => '/articles'],
['title' => '图片位置', 'icon' => 'icon-park:graphic-design-two', 'url' => '/banner-addresses'],
['title' => '图片位置', 'icon' => 'icon-park:graphic-design-two', 'url' => '/banner-places'],
['title' => '图片管理', 'icon' => 'icon-park:picture-album', 'url' => '/banners'],
]
],