diff --git a/app/Admin/Components.php b/app/Admin/Components.php
index 51a1dd5..d631b1b 100644
--- a/app/Admin/Components.php
+++ b/app/Admin/Components.php
@@ -6,48 +6,50 @@ use App\Models\Keyword;
use Slowlyo\OwlAdmin\Renderers\BaseRenderer;
use Slowlyo\OwlAdmin\Renderers\WangEditor;
-class Components extends BaseRenderer {
-
+class Components extends BaseRenderer
+{
/**
* 父级选择器
*/
- public function parentControl($apiUrl = null, $name ='parent_id', $label = null, $labelField = 'name', $valueField = 'id')
+ public function parentControl($apiUrl = null, $name = 'parent_id', $label = null, $labelField = 'name', $valueField = 'id')
{
return amisMake()->TreeSelectControl()->source($apiUrl)
- ->name($name)->label($label ?? __('admin.components.parent_select'))
- ->showIcon(false)
- ->labelField($labelField)
- ->valueField($valueField);
+ ->name($name)->label($label ?? __('admin.components.parent_select'))
+ ->showIcon(false)
+ ->labelField($labelField)
+ ->valueField($valueField);
}
/**
* 排序字段
*/
- public function sortControl($name ='sort', $label = null){
+ public function sortControl($name = 'sort', $label = null)
+ {
return amisMake()->NumberControl()
- ->name($name)->label($label ?? __('admin.components.order'))
- ->displayMode('enhance')
- ->value(0)
- ->min(0);
+ ->name($name)->label($label ?? __('admin.components.order'))
+ ->displayMode('enhance')
+ ->value(0)
+ ->min(0);
}
/**
* 2位小数输入框
*/
- public function decimalControl($name ='decimal', $label = null){
+ public function decimalControl($name = 'decimal', $label = null)
+ {
return amisMake()->NumberControl()
- ->name($name)->label($label ?? __('admin.components.decimal'))
- ->kilobitSeparator(true)
- ->percision(2)
- ->step(0.01)
- ->value(0.00)
- ->min(0);
+ ->name($name)->label($label ?? __('admin.components.decimal'))
+ ->kilobitSeparator(true)
+ ->percision(2)
+ ->step(0.01)
+ ->value(0.00)
+ ->min(0);
}
/**
* 富文本编辑器
*/
- public function fuEditorControl($name ='content', $label = null, $height = 530)
+ public function fuEditorControl($name = 'content', $label = null, $height = 530)
{
return WangEditor::make()
->name($name)->label($label ?? __('admin.components.content'))
@@ -58,7 +60,8 @@ class Components extends BaseRenderer {
/**
* 开关
*/
- public function enableControl($name = 'is_enable', $label= null, $mode = 'horizontal'){
+ public function enableControl($name = 'is_enable', $label = null, $mode = 'horizontal')
+ {
return amisMake()->SwitchControl()
->name($name)->label($label ?? __('admin.components.status'))
->mode($mode)
@@ -68,39 +71,44 @@ class Components extends BaseRenderer {
/**
* 图片上传
*/
- public function imageControl($name, $label){
+ public function imageControl($name, $label)
+ {
return amis()->ImageControl($name, $label)
->joinValues(false)
- ->autoUpload(true)->maxSize('5*1024*1024');//不能大于5M
+ ->autoUpload(true)->maxSize('5*1024*1024'); //不能大于5M
}
/**
* 图片上传,带裁剪
*/
- public function cropImageControl($name, $label, $aspectRatio = null){
+ public function cropImageControl($name, $label, $aspectRatio = null)
+ {
$cropImage = amis()->ImageControl($name, $label)->joinValues(false);
// if($aspectRatio){
- $cropImage->crop([
- 'aspectRatio' => $aspectRatio ?? 1
- ]);
+ $cropImage->crop([
+ 'aspectRatio' => $aspectRatio ?? 1,
+ ]);
// }
$cropImage->autoUpload(true);
+
return $cropImage;
}
/**
* 普通文件上传
*/
- public function fileControl($name, $label, $accept = '.txt', $multiple = false){
+ public function fileControl($name, $label, $accept = '.txt', $multiple = false)
+ {
return amis()->FileControl($name, $label ?? __('admin.components.files'))
->multiple($multiple)
->joinValues(false)
->useChunk(false)
- ->maxSize(20*1024*1024)
+ ->maxSize(20 * 1024 * 1024)
->accept($accept);
}
- public function chunkFileControl($name, $label, $accept = '*', $multiple = false){
+ public function chunkFileControl($name, $label, $accept = '*', $multiple = false)
+ {
return amis()->FileControl($name, $label ?? __('admin.components.files'))
->multiple($multiple)
->joinValues(false)
@@ -114,25 +122,28 @@ class Components extends BaseRenderer {
/**
* 标签选择
*/
- public function keywordsTagControl($name = 'tags', $label= null, $pKey = null){
+ public function keywordsTagControl($name = 'tags', $label = null, $pKey = null)
+ {
return amisMake()->TagControl()
->name($name)->label($label ?? __('admin.components.tag'))
->maxTagLength(0)
->options(Keyword::where('parent_key', $pKey)->pluck('name', 'id')->toArray());
}
- public function keywordsTag($label = null, $color = null){
- if($color){
+ public function keywordsTag($label = null, $color = null)
+ {
+ if ($color) {
$tag = amisMake()->Tag()->label($label ?? __('admin.components.tag'))
- ->displayMode('rounded')->style([
+ ->displayMode('rounded')->style([
'color' => '#fff',
- 'backgroundColor' =>$color,
- 'borderColor' => $color
+ 'backgroundColor' => $color,
+ 'borderColor' => $color,
]);
- }else{
+ } else {
$tag = amisMake()->Tag()->label($label ?? __('admin.components.tag'))
- ->displayMode('rounded')->color('inactive');
+ ->displayMode('rounded')->color('inactive');
}
+
return $tag;
}
@@ -140,36 +151,37 @@ class Components extends BaseRenderer {
* 生成统计图config
* 折线图或者柱状图
*/
- public function chartLineBarConfig($title = null, array $x , array $y){
+ public function chartLineBarConfig($title, array $x, array $y)
+ {
$yAxisData = [];
$seriesData = [];
$color = [];
- if(!isset($y[0])){
+ if (! isset($y[0])) {
$_y = $y;
- $y = [0=>$_y];
+ $y = [0 => $_y];
}
$i = 0;
$tips = '{b0}';
- foreach($y as $item) {
+ foreach ($y as $item) {
//调色盘
$color[] = $item['color'];
//tips
- $tips.= '
{a'.$i.'}: {c'.$i.'}'.($item['unit'] ?? '');
+ $tips .= '
{a'.$i.'}: {c'.$i.'}'.($item['unit'] ?? '');
//纵坐标
$yAxisData[] = [
- 'name'=>($item['unit'] ?? ''),
- 'type' =>'value',
+ 'name' => ($item['unit'] ?? ''),
+ 'type' => 'value',
'axisTick' => true,
'alignTicks' => true,
'axisLine' => [
'show' => true,
'lineStyle' => [
- 'color' => $item['color'] ?? ''
- ]
+ 'color' => $item['color'] ?? '',
+ ],
+ ],
+ 'axisLabel' => [
+ 'formatter' => '{value} ',
],
- 'axisLabel'=> [
- 'formatter'=>'{value} '
- ]
];
//数据
$_series = [
@@ -178,16 +190,16 @@ class Components extends BaseRenderer {
'type' => $item['type'] ?? 'line',
'yAxisIndex' => $i,
];
- switch($item['type']){
+ switch ($item['type']) {
case 'line':
$_series = array_merge($_series, [
- 'smooth'=> true,
- 'symbol'=> 'none',
+ 'smooth' => true,
+ 'symbol' => 'none',
'lineStyle' => [
- 'color' => $item['color'] ?? ''
+ 'color' => $item['color'] ?? '',
],
'areaStyle' => [
- 'color' => $item['color'] ?? ''
+ 'color' => $item['color'] ?? '',
],
]);
break;
@@ -201,14 +213,14 @@ class Components extends BaseRenderer {
}
return [
- 'color' => $color,
+ 'color' => $color,
'title' => [
'text' => $title,
],
- "tooltip" => [//提示
- 'trigger'=>'axis',//坐标轴触发
+ 'tooltip' => [//提示
+ 'trigger' => 'axis', //坐标轴触发
'axisPointer' => [
- 'type' => 'cross'
+ 'type' => 'cross',
],
// 'formatter' => $tips
],
@@ -221,21 +233,22 @@ class Components extends BaseRenderer {
'data' => $x,
],
'yAxis' => $yAxisData,
- 'series' => $seriesData
+ 'series' => $seriesData,
];
}
-
+
/**
* 散点图
*/
- public function chartScatterConfig($title = null, array $x , array $y, array $yData = null){
+ public function chartScatterConfig($title, array $x, array $y, ?array $yData = null)
+ {
$yAxisData = [];
$seriesData = [];
$color = [];
- if($yData){
+ if ($yData) {
$yAxisData = [
- 'type' =>'category',
+ 'type' => 'category',
// 'splitLine'=>[
// 'show'=>true,
// 'lineStyle'=>[
@@ -243,23 +256,23 @@ class Components extends BaseRenderer {
// ]
// ],
'axisTick' => [
- 'alignWithLabel'=>true
+ 'alignWithLabel' => true,
],
- 'data'=> $yData
+ 'data' => $yData,
];
}
-
+
$seriesData = $y;
-
+
return [
- 'color' => $color,
+ 'color' => $color,
'title' => [
'text' => $title,
],
- "tooltip" => [//提示
- 'trigger'=>'axis',//坐标轴触发
+ 'tooltip' => [//提示
+ 'trigger' => 'axis', //坐标轴触发
'axisPointer' => [
- 'type' => 'cross'
+ 'type' => 'cross',
],
],
'xAxis' => [
@@ -267,7 +280,7 @@ class Components extends BaseRenderer {
'data' => $x,
],
'yAxis' => $yAxisData,
- 'series' => $seriesData
+ 'series' => $seriesData,
];
}
@@ -275,7 +288,8 @@ class Components extends BaseRenderer {
* 生成饼状图config
* -todo
*/
- public function chartPieConfig(){
- return ;
+ public function chartPieConfig()
+ {
+
}
-}
\ No newline at end of file
+}
diff --git a/app/Admin/Controllers/AdController.php b/app/Admin/Controllers/AdController.php
index b665279..5bd08cc 100644
--- a/app/Admin/Controllers/AdController.php
+++ b/app/Admin/Controllers/AdController.php
@@ -31,14 +31,14 @@ class AdController extends AdminController
->filter($this->baseFilter()->labelWidth('80px')->body([
amis()->GroupControl()->mode('horizontal')->body([
amis()->TextControl('id', __('admin.ads.id'))
- ->placeholder(__('admin.id')),
+ ->placeholder(__('admin.id')),
amis()->TextControl('remark', __('admin.ads.remark'))
- ->placeholder(__('admin.ads.remark')),
+ ->placeholder(__('admin.ads.remark')),
Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=banner_address&has_owner=0'), 'address', __('admin.ads.address'), 'name', 'key'),
amis()->SelectControl('enable', __('admin.ads.is_enable'))
- ->options([
- 1=>'开启',0=>'关闭'
- ]),
+ ->options([
+ 1 => '开启', 0 => '关闭',
+ ]),
]),
amis()->GroupControl()->mode('horizontal')->body([
amis()->InputDatetimeRange()->label(__('admin.ads.published_at'))->name('published_at'),
@@ -54,14 +54,14 @@ class AdController extends AdminController
amis()->NumberControl()->min(0)->saveImmediately(true)
),
amis()->TableColumn('resource', __('admin.ads.resource'))->type('image')->height('50px')->width('150px')->enlargeAble(true),
- amis()->TableColumn('remark', __('admin.ads.remark')),
+ amis()->TableColumn('remark', __('admin.ads.remark')),
amis()->TableColumn('published_at', __('admin.ads.published_at'))->remark(__('admin.ads.published_at_remark')),
amis()->TableColumn('is_enable', __('admin.ads.is_enable'))->type('switch'),
- amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
+ amis()->TableColumn('created_at', __('admin.created_at'))->type('datetime')->sortable(true),
Operation::make()->label(__('admin.actions'))->buttons([
$this->rowEditButton(),
$this->rowDeleteButton(),
- ])
+ ]),
]);
return $this->baseList($crud);
@@ -71,7 +71,7 @@ class AdController extends AdminController
{
return $this->baseForm()->body([
Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=banner_address&has_owner=0'), 'address', __('admin.ads.address'), 'name', 'key')->required(true),
- Components::make()->imageControl('resource', __('admin.ads.resource'))->required(true),
+ Components::make()->imageControl('resource', __('admin.ads.resource'))->required(true),
amis()->TextControl('remark', __('admin.ads.remark')),
Components::make()->sortControl('sort', __('admin.ads.sort')),
amis()->DateTimeControl('published_at', __('admin.ads.published_at'))->format('YYYY-MM-DD HH:mm:ss')->description(__('admin.ads.published_at_remark')),
@@ -90,8 +90,8 @@ class AdController extends AdminController
{
return $this->baseDetail()->body([
amis()->TextControl('id', 'ID')->static(),
- amis()->TextControl('created_at', __('admin.created_at'))->static(),
- amis()->TextControl('updated_at', __('admin.updated_at'))->static()
+ amis()->TextControl('created_at', __('admin.created_at'))->static(),
+ amis()->TextControl('updated_at', __('admin.updated_at'))->static(),
]);
}
}
diff --git a/app/Admin/Controllers/AdminRoleController.php b/app/Admin/Controllers/AdminRoleController.php
index 5fe8ea2..363b1aa 100644
--- a/app/Admin/Controllers/AdminRoleController.php
+++ b/app/Admin/Controllers/AdminRoleController.php
@@ -2,8 +2,8 @@
namespace App\Admin\Controllers;
-use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Controllers\AdminRoleController as AdminRoleBaseController;
+use Slowlyo\OwlAdmin\Renderers\Page;
class AdminRoleController extends AdminRoleBaseController
{
@@ -38,13 +38,13 @@ class AdminRoleController extends AdminRoleBaseController
]);
return $this->baseList($crud)->css([
- '.tree-full' => [
+ '.tree-full' => [
'overflow' => 'hidden !important',
],
'.cxd-TreeControl > .cxd-Tree' => [
- 'height' => '100% !important',
+ 'height' => '100% !important',
'max-height' => '100% !important',
],
]);
}
-}
\ No newline at end of file
+}
diff --git a/app/Admin/Controllers/AdminUserController.php b/app/Admin/Controllers/AdminUserController.php
index f4b1fd2..714d20a 100644
--- a/app/Admin/Controllers/AdminUserController.php
+++ b/app/Admin/Controllers/AdminUserController.php
@@ -83,8 +83,8 @@ class AdminUserController extends AdminController
amisMake()->Dialog()->title(__('admin.admin_user.edit_password'))->body([
amisMake()->Form()->title('')
->api([
- 'method'=>'PUT',
- 'url'=> admin_url('system/admin_users/$id')
+ 'method' => 'PUT',
+ 'url' => admin_url('system/admin_users/$id'),
])
->body([
amisMake()->TextControl('id')->value('${id}')->hidden(true),
diff --git a/app/Admin/Controllers/ArticleController.php b/app/Admin/Controllers/ArticleController.php
index d171cab..dfb541a 100644
--- a/app/Admin/Controllers/ArticleController.php
+++ b/app/Admin/Controllers/ArticleController.php
@@ -4,7 +4,6 @@ namespace App\Admin\Controllers;
use App\Admin\Components;
use App\Admin\Services\ArticleService;
-use App\Casts\Storage;
use App\Models\Keyword;
use App\Traits\CustomActionTrait;
use Slowlyo\OwlAdmin\Admin;
@@ -15,9 +14,10 @@ use Slowlyo\OwlAdmin\Renderers\Page;
class ArticleController extends AdminController
{
use CustomActionTrait;
+
protected string $serviceName = ArticleService::class;
- public function list():Page
+ public function list(): Page
{
$crud = $this->baseCRUD()->tableLayout('fixed')
->headerToolbar([
@@ -27,9 +27,9 @@ class ArticleController extends AdminController
->filter($this->baseFilter()->body([
amis()->GroupControl()->mode('horizontal')->body([
amis()->TextControl('id', __('admin.articles.id'))
- ->placeholder(__('admin.id')),
+ ->placeholder(__('admin.id')),
amis()->TextControl('title', __('admin.articles.title'))
- ->placeholder(__('admin.articles.title')),
+ ->placeholder(__('admin.articles.title')),
Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=article_category&has_owner=0'), 'category', __('admin.articles.category'), 'name', 'key'),
Components::make()->keywordsTagControl('t_ids', __('admin.articles.tags'), 'article_tag'),
]),
@@ -37,12 +37,12 @@ class ArticleController extends AdminController
amis()->SelectControl('enable', __('admin.articles.is_enable'))
->columnRatio(3)
->options([
- 1=>'开启',0=>'关闭'
+ 1 => '开启', 0 => '关闭',
]),
amis()->SelectControl('recommend', __('admin.articles.is_recommend'))
->columnRatio(3)
->options([
- 1=>'开启',0=>'关闭'
+ 1 => '开启', 0 => '关闭',
]),
amis()->InputDatetimeRange()->label(__('admin.articles.published_at'))->name('published_at'),
]),
@@ -56,7 +56,7 @@ class ArticleController extends AdminController
'position' => 'top-left',
'badgeLevel' => 'danger',
'visibleOn' => '${is_recommend > 0}',
- 'size' => 15
+ 'size' => 15,
])
->columns([
amis()->TableColumn('id', __('admin.id'))->sortable(true),
@@ -73,7 +73,7 @@ class ArticleController extends AdminController
amis()->Operation()->label(__('admin.actions'))->buttons([
$this->rowEditTypeButton('drawer', 'xl'),
$this->rowDeleteButton(),
- ])
+ ]),
]);
return $this->baseList($crud);
@@ -84,10 +84,10 @@ class ArticleController extends AdminController
return $this->baseForm()->panelClassName('px-0')->body([
amis()->Grid()->columns([
amis()->Wrapper()->body([
- amis()->TextControl('title', __('admin.articles.title'))->required(true),
+ amis()->TextControl('title', __('admin.articles.title'))->required(true),
Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=article_category&has_owner=0'), 'category', __('admin.articles.category'), 'name', 'key'),
Components::make()->keywordsTagControl('t_ids', __('admin.articles.tags'), 'article_tag'),
- Components::make()->cropImageControl('cover', __('admin.articles.cover')),
+ Components::make()->cropImageControl('cover', __('admin.articles.cover')),
Components::make()->sortControl('sort', __('admin.articles.sort')),
amis()->DateTimeControl('published_at', __('admin.articles.published_at'))->format('YYYY-MM-DD HH:mm:ss')->description(__('admin.articles.published_at_remark')),
amis()->SwitchControl('is_enable', __('admin.articles.is_enable'))->value(false),
@@ -96,7 +96,7 @@ class ArticleController extends AdminController
])->md(4),
amis()->Wrapper()->body([
Components::make()->fuEditorControl('content', __('admin.articles.content')),
- ])->md(8)
+ ])->md(8),
]),
]);
}
@@ -105,5 +105,4 @@ class ArticleController extends AdminController
{
return $this->baseDetail()->body([]);
}
-
}
diff --git a/app/Admin/Controllers/AuthController.php b/app/Admin/Controllers/AuthController.php
index b1a2068..8aa1c5b 100644
--- a/app/Admin/Controllers/AuthController.php
+++ b/app/Admin/Controllers/AuthController.php
@@ -2,19 +2,19 @@
namespace App\Admin\Controllers;
-use Slowlyo\OwlAdmin\Admin;
use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Validator;
-use Symfony\Component\HttpFoundation\Response;
-use Slowlyo\OwlAdmin\Controllers\AuthController as AdminAuthController;
use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Validator;
+use Slowlyo\OwlAdmin\Admin;
+use Slowlyo\OwlAdmin\Controllers\AuthController as AdminAuthController;
+use Symfony\Component\HttpFoundation\Response;
class AuthController extends AdminAuthController
{
public function login(Request $request)
{
if (Admin::config('admin.auth.login_captcha')) {
- if (!$request->has('captcha')) {
+ if (! $request->has('captcha')) {
return $this->response()->fail(__('admin.required', ['attribute' => __('admin.captcha')]));
}
@@ -28,8 +28,8 @@ class AuthController extends AdminAuthController
'username' => 'required',
'password' => 'required',
], [
- 'username' . '.required' => __('admin.required', ['attribute' => __('admin.username')]),
- 'password.required' => __('admin.required', ['attribute' => __('admin.password')]),
+ 'username'.'.required' => __('admin.required', ['attribute' => __('admin.username')]),
+ 'password.required' => __('admin.required', ['attribute' => __('admin.password')]),
]);
if ($validator->fails()) {
@@ -37,15 +37,16 @@ class AuthController extends AdminAuthController
}
$adminModel = Admin::adminUserModel();
- $user = $adminModel::query()->where('username', $request->username)->first();
+ $user = $adminModel::query()->where('username', $request->username)->first();
- if($user && $user->lock){
+ if ($user && $user->lock) {
abort(Response::HTTP_BAD_REQUEST, '您的账号已被锁定,需要联系超级管理员解锁。');
- }else{
+ } else {
if ($user && Hash::check($request->password, $user->password)) {
$module = Admin::currentModule(true);
- $prefix = $module ? $module . '.' : '';
- $token = $user->createToken($prefix . 'admin')->plainTextToken;
+ $prefix = $module ? $module.'.' : '';
+ $token = $user->createToken($prefix.'admin')->plainTextToken;
+
return $this->response()->success(compact('token'), __('admin.login_successful'));
}
diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php
index 573d726..34bf37b 100644
--- a/app/Admin/Controllers/HomeController.php
+++ b/app/Admin/Controllers/HomeController.php
@@ -3,17 +3,17 @@
namespace App\Admin\Controllers;
use Illuminate\Http\JsonResponse;
-use Slowlyo\OwlAdmin\Renderers\Card;
-use Slowlyo\OwlAdmin\Renderers\Flex;
-use Slowlyo\OwlAdmin\Renderers\Html;
-use Slowlyo\OwlAdmin\Renderers\Grid;
-use Slowlyo\OwlAdmin\Renderers\Chart;
-use Slowlyo\OwlAdmin\Renderers\Image;
-use Slowlyo\OwlAdmin\Renderers\Action;
-use Slowlyo\OwlAdmin\Renderers\Custom;
-use Slowlyo\OwlAdmin\Renderers\Wrapper;
use Illuminate\Http\Resources\Json\JsonResource;
use Slowlyo\OwlAdmin\Controllers\AdminController;
+use Slowlyo\OwlAdmin\Renderers\Action;
+use Slowlyo\OwlAdmin\Renderers\Card;
+use Slowlyo\OwlAdmin\Renderers\Chart;
+use Slowlyo\OwlAdmin\Renderers\Custom;
+use Slowlyo\OwlAdmin\Renderers\Flex;
+use Slowlyo\OwlAdmin\Renderers\Grid;
+use Slowlyo\OwlAdmin\Renderers\Html;
+use Slowlyo\OwlAdmin\Renderers\Image;
+use Slowlyo\OwlAdmin\Renderers\Wrapper;
class HomeController extends AdminController
{
@@ -47,7 +47,7 @@ class HomeController extends AdminController
return Card::make()
->className('h-full clear-card-mb')
->body(
- Custom::make()->html(<<html(<<<'HTML'