mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 02:52:49 +08:00
开始官网模板
This commit is contained in:
@@ -54,9 +54,9 @@ class Nav extends Common
|
||||
|
||||
return $this->success('添加成功', url('index',[
|
||||
'type'=>$request->param('type',1),
|
||||
'show_img'=>$request->param('show_img'),
|
||||
'show_target'=>$request->param('show_target'),
|
||||
'show_xcx'=>$request->param('show_xcx'),
|
||||
'show_img'=>$request->param('show_img',0),
|
||||
'show_target'=>$request->param('show_target',0),
|
||||
'show_xcx'=>$request->param('show_xcx',0),
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ class Nav extends Common
|
||||
$model_nav->save($post_data);
|
||||
|
||||
return $this->success('保存成功', url('index',[
|
||||
'type'=>$model_nav->getData('type'),
|
||||
'show_img'=>$request->param('show_img'),
|
||||
'show_target'=>$request->param('show_target'),
|
||||
'show_xcx'=>$request->param('show_xcx'),
|
||||
'type'=>$model_nav->getData('type',1),
|
||||
'show_img'=>$request->param('show_img',0),
|
||||
'show_target'=>$request->param('show_target',0),
|
||||
'show_xcx'=>$request->param('show_xcx',0),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Post extends Common
|
||||
{
|
||||
//
|
||||
|
||||
$list = ModelPost::order('id desc')->paginate();
|
||||
$list = ModelPost::with(['categorys.category','tags.tag'])->order('id desc')->paginate();
|
||||
|
||||
View::assign('list', $list);
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ class System extends Common
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
public function easyBlue()
|
||||
{
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
@@ -54,6 +54,10 @@ function get_system_config($name = '', $default = '')
|
||||
|
||||
function get_source_link($url)
|
||||
{
|
||||
|
||||
if(empty($url)){
|
||||
$url = '/static/images/avatar.jpeg';
|
||||
}
|
||||
if (strpos($url, '/') === 0) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
93
app/index/controller/Category.php
Normal file
93
app/index/controller/Category.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\model\Category as ModelCategory;
|
||||
use think\Request;
|
||||
|
||||
class Category extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
|
||||
$model_category = ModelCategory::with('posts.post')->find($id);
|
||||
|
||||
$this->assign('category',$model_category);
|
||||
|
||||
return $this->fetch('read'.$model_category->tpl_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
25
app/index/controller/Common.php
Normal file
25
app/index/controller/Common.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\model\Nav;
|
||||
use think\facade\View;
|
||||
|
||||
class Common extends BaseController
|
||||
{
|
||||
public function initialize()
|
||||
{
|
||||
|
||||
parent::initialize();
|
||||
|
||||
$list_header_nav = Nav::where('type',1)->order('sort asc')->where('status',1)->select();
|
||||
View::assign('list_header_nav',$list_header_nav);
|
||||
$list_nav_slide = Nav::where('type',3)->order('sort asc')->where('status',1)->select();
|
||||
View::assign('list_nav_slide',$list_nav_slide);
|
||||
$list_nav_index_block_1 = Nav::where('type',6)->order('sort asc')->where('status',1)->select();
|
||||
View::assign('list_nav_index_block_1',$list_nav_index_block_1);
|
||||
$list_nav_index_block_2 = Nav::where('type',7)->order('sort asc')->where('status',1)->select();
|
||||
View::assign('list_nav_index_block_2',$list_nav_index_block_2);
|
||||
$list_nav_friend_url = Nav::where('type',2)->order('sort asc')->where('status',1)->select();
|
||||
View::assign('list_nav_friend_url',$list_nav_friend_url);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace app\index\controller;
|
||||
use think\facade\View;
|
||||
use think\Request;
|
||||
|
||||
class Index extends BaseController
|
||||
class Index extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
@@ -16,9 +16,7 @@ class Index extends BaseController
|
||||
{
|
||||
//
|
||||
|
||||
dump($this->request->action());
|
||||
|
||||
return $this->fetch('');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,4 +20,48 @@ class Category extends Model
|
||||
// return $model_list;
|
||||
return array2level($model_list,0,0);
|
||||
}
|
||||
|
||||
public function getTitleImgAttr($value)
|
||||
{
|
||||
|
||||
return get_source_link($value);
|
||||
}
|
||||
|
||||
public function posts()
|
||||
{
|
||||
return $this->hasMany(PostCategory::class,'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回的对应的post的模型
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getPostsModelListAttr()
|
||||
{
|
||||
$list_post_category = $this->getAttr('posts');
|
||||
|
||||
$list_post = [];
|
||||
|
||||
foreach ($list_post_category as $list_post_category) {
|
||||
array_push($list_post,$list_post_category->post);
|
||||
}
|
||||
|
||||
return $list_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回的对应post的数据,性能比模型要高.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getPostsListAttr()
|
||||
{
|
||||
$list_post_category = $this->getAttr('posts');
|
||||
|
||||
$list_post = array_column($list_post_category->append(['post'])->toArray(),'post');
|
||||
|
||||
return $list_post;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
@@ -10,9 +11,19 @@ use think\Model;
|
||||
*/
|
||||
class Nav extends Model
|
||||
{
|
||||
//
|
||||
public function getImgAttr($value)
|
||||
{
|
||||
return get_source_link($value);
|
||||
}
|
||||
|
||||
public static $statusName = [
|
||||
0=>'不显示',
|
||||
1=>'显示'
|
||||
];
|
||||
//
|
||||
public function getImgAttr($value)
|
||||
{
|
||||
return get_source_link($value);
|
||||
}
|
||||
|
||||
public function getStatusNameAttr()
|
||||
{
|
||||
return self::$statusName[$this->getData('status')];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,39 @@ class Post extends Model
|
||||
return $this->hasMany(PostTag::class,'post_id');
|
||||
}
|
||||
|
||||
public function getCategorysListAttr()
|
||||
{
|
||||
$list_post_categorys = $this->getAttr('categorys');
|
||||
|
||||
$list = array_column($list_post_categorys->append(['category'])->toArray(),'category');
|
||||
|
||||
$list = array2level($list,0,0);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getTagsListAttr()
|
||||
{
|
||||
$list_post_tags = $this->getAttr('tags');
|
||||
|
||||
$list = array_column($list_post_tags->append(['tag'])->toArray(),'tag');
|
||||
|
||||
$list = array2level($list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getDescShortAttr()
|
||||
{
|
||||
$desc = $this->getData('desc');
|
||||
|
||||
if(strlen($desc) > 100){
|
||||
$desc = mb_substr($desc,0,100).'...';
|
||||
}
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
public function getStatusNameAttr()
|
||||
{
|
||||
return self::$stausNameList[$this->getData('status')];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
@@ -10,5 +11,14 @@ use think\Model;
|
||||
*/
|
||||
class PostCategory extends Model
|
||||
{
|
||||
//
|
||||
//
|
||||
public function post()
|
||||
{
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class,'category_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
@@ -10,5 +11,14 @@ use think\Model;
|
||||
*/
|
||||
class PostTag extends Model
|
||||
{
|
||||
//
|
||||
//
|
||||
public function tag()
|
||||
{
|
||||
return $this->belongsTo(Tag::class,'tag_id');
|
||||
}
|
||||
|
||||
public function post()
|
||||
{
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user