mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
完成资讯主题
This commit is contained in:
@@ -1,47 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace app;
|
||||
|
||||
use app\model\UploadFiles as AppUploadFiles;
|
||||
use think\facade\Filesystem;
|
||||
use think\facade\Config;
|
||||
|
||||
class UploadFiles
|
||||
class UploadFiles
|
||||
{
|
||||
|
||||
public static function add()
|
||||
{
|
||||
return new AppUploadFiles();
|
||||
public static function add()
|
||||
{
|
||||
return new AppUploadFiles();
|
||||
}
|
||||
|
||||
public static function create($data, $allowFiled = [], $replace = false)
|
||||
{
|
||||
return AppUploadFiles::create($data, $allowFiled, $replace);
|
||||
}
|
||||
|
||||
public static function use($save_name)
|
||||
{
|
||||
return AppUploadFiles::where('save_name', $save_name)->update([
|
||||
'used_time' => time(),
|
||||
'status' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
public static function delete($save_name)
|
||||
{
|
||||
return AppUploadFiles::where('save_name', $save_name)->update([
|
||||
'delete_time' => time(),
|
||||
'status' => 2
|
||||
]);
|
||||
}
|
||||
|
||||
public static function clear($id)
|
||||
{
|
||||
$model_file = AppUploadFiles::withTrashed()->find($id);
|
||||
|
||||
$model_file->clear_time = time();
|
||||
$model_file->status = 3;
|
||||
|
||||
$model_file->save();
|
||||
|
||||
return Filesystem::delete($model_file->getData('save_name'));
|
||||
}
|
||||
|
||||
public static function save(Request $request)
|
||||
{
|
||||
|
||||
$type = $request->param('type');
|
||||
if (empty($type)) {
|
||||
return json_message('缺少类型参数');
|
||||
}
|
||||
|
||||
public static function create($data,$allowFiled = [],$replace = false)
|
||||
{
|
||||
return AppUploadFiles::create($data,$allowFiled,$replace);
|
||||
$file = request()->file('file');
|
||||
|
||||
$file_extension = $file->extension();
|
||||
|
||||
if ($file_extension == 'php') {
|
||||
return json_message('上传文件异常');
|
||||
}
|
||||
|
||||
public static function use($save_name)
|
||||
{
|
||||
return AppUploadFiles::where('save_name',$save_name)->update([
|
||||
'used_time'=>time(),
|
||||
'status'=>1
|
||||
]);
|
||||
$file_path = $file->getRealPath();
|
||||
|
||||
$file_content = file_get_contents($file_path);
|
||||
|
||||
if (strpos($file_content, '<?php') !== false) {
|
||||
return json_message('上传文件异常');
|
||||
}
|
||||
|
||||
public static function delete($save_name)
|
||||
{
|
||||
return AppUploadFiles::where('save_name',$save_name)->update([
|
||||
'delete_time'=>time(),
|
||||
'status'=>2
|
||||
]);
|
||||
if (empty($file)) {
|
||||
return json_message('上传失败');
|
||||
}
|
||||
|
||||
public static function clear($id)
|
||||
{
|
||||
$model_file = AppUploadFiles::withTrashed()->find($id);
|
||||
|
||||
$model_file->clear_time = time();
|
||||
$model_file->status = 3;
|
||||
|
||||
$model_file->save();
|
||||
|
||||
return Filesystem::delete($model_file->getData('save_name'));
|
||||
$dir_name = $request->param('dir', 'data');
|
||||
$model_file = UploadFiles::add();
|
||||
$model_file->file_name = $file->getOriginalName();
|
||||
$model_file->mime_type = $file->getOriginalMime();
|
||||
$model_file->ext_name = $file->extension();
|
||||
$model_file->file_size = $file->getSize();
|
||||
$model_file->file_md5 = $file->md5();
|
||||
$model_file->file_sha1 = $file->sha1();
|
||||
$model_file->create_time = time();
|
||||
$model_file->type = $type;
|
||||
try {
|
||||
$model_file->save_name = Filesystem::putFile('upload/' . $dir_name, $file, 'uniqid');
|
||||
$model_file->save();
|
||||
return json_message($model_file->append(['src'])->toArray());
|
||||
} catch (\Throwable $th) {
|
||||
return json_message($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,100 +9,102 @@ use think\Request;
|
||||
|
||||
class File extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
|
||||
$type = $this->request->param('type',1);
|
||||
$status = $this->request->param('status','');
|
||||
$type = $this->request->param('type', 1);
|
||||
$status = $this->request->param('status', '');
|
||||
|
||||
$model_list = UploadFiles::withTrashed()->where('type',$type)->order('id desc');
|
||||
$model_list = UploadFiles::withTrashed()->where('type', $type)->order('id desc');
|
||||
|
||||
if($status != ''){
|
||||
$model_list->where('status',$status);
|
||||
}
|
||||
|
||||
$list = $model_list->paginate();
|
||||
View::assign('list',$list);
|
||||
|
||||
return View::fetch();
|
||||
if ($status != '') {
|
||||
$model_list->where('status', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
$list = $model_list->paginate();
|
||||
View::assign('list', $list);
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
return AppUploadFiles::save($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function clear($id)
|
||||
{
|
||||
AppUploadFiles::clear($id);
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
return json_message();
|
||||
}
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function clear($id)
|
||||
{
|
||||
AppUploadFiles::clear($id);
|
||||
|
||||
return json_message();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,111 +10,69 @@ use app\UploadFiles as AppUploadFiles;
|
||||
|
||||
class Files extends BaseController
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$type = $request->param('type');
|
||||
if(empty($type)){
|
||||
return json_message('缺少类型参数');
|
||||
}
|
||||
|
||||
$file = request()->file('file');
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
return AppUploadFiles::save($request);
|
||||
}
|
||||
|
||||
$file_extension = $file->extension();
|
||||
|
||||
if($file_extension == 'php'){
|
||||
return json_message('上传文件异常');
|
||||
}
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
$file_path = $file->getRealPath();
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
$file_content = file_get_contents($file_path);
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
if(strpos($file_content,'<?php') !== false){
|
||||
return json_message('上传文件异常');
|
||||
}
|
||||
|
||||
if(empty($file)){
|
||||
return json_message('上传失败');
|
||||
}
|
||||
|
||||
$dir_name = $request->param('dir','data');
|
||||
$model_file = AppUploadFiles::add();
|
||||
$model_file->file_name = $file->getOriginalName();
|
||||
$model_file->mime_type = $file->getOriginalMime();
|
||||
$model_file->ext_name = $file->extension();
|
||||
$model_file->file_size = $file->getSize();
|
||||
$model_file->file_md5 = $file->md5();
|
||||
$model_file->file_sha1 = $file->sha1();
|
||||
$model_file->create_time = time();
|
||||
$model_file->type = $type;
|
||||
try {
|
||||
$model_file->save_name = Filesystem::putFile('upload/'.$dir_name,$file,'uniqid');
|
||||
$model_file->save();
|
||||
return json_message($model_file->append(['src'])->toArray());
|
||||
} catch (\Throwable $th) {
|
||||
return json_message($th->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\BaseController as AppBaseController;
|
||||
@@ -9,38 +10,58 @@ use think\helper\Str;
|
||||
class BaseController extends AppBaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 是否使用多模板
|
||||
* 仅当名称为空或者指定名称有效,
|
||||
* 使用跨应用,跨控制器,引用模板路径的写法时无效
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isUseTpls = true;
|
||||
/**
|
||||
* 是否使用多模板
|
||||
* 仅当名称为空或者指定名称有效,
|
||||
* 使用跨应用,跨控制器,引用模板路径的写法时无效
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $isUseTpls = true;
|
||||
|
||||
public function assign($template,$value)
|
||||
{
|
||||
return View::assign($template,$value);
|
||||
}
|
||||
protected $indexTplName = '';
|
||||
protected $indexTplMethod = '';
|
||||
protected $indexTplMethodCurrentAction = '';
|
||||
|
||||
public function fetch($template = '',$vars = [])
|
||||
{
|
||||
if($this->isUseTpls && strpos($template,'@') === false && stripos($template,'/') === false){
|
||||
|
||||
if($template === ''){
|
||||
$config_auto_rule = Config::get('view.auto_rule');
|
||||
if (2 == $config_auto_rule) {
|
||||
$template = $this->request->action(true);
|
||||
} elseif (3 == $config_auto_rule) {
|
||||
$template = $this->request->action();
|
||||
} else {
|
||||
$template = Str::snake($this->request->action());
|
||||
}
|
||||
}
|
||||
return View::fetch(get_system_config('index_tpl_name').$template,$vars);
|
||||
}else{
|
||||
return View::fetch($template,$vars);
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->indexTplName = get_system_config('index_tpl_name');
|
||||
|
||||
$this->indexTplMethod = '__'.Str::camel($this->indexTplName);
|
||||
|
||||
$this->indexTplMethodCurrentAction = $this->indexTplMethod.Str::studly($this->request->action());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function assign($template, $value)
|
||||
{
|
||||
return View::assign($template, $value);
|
||||
}
|
||||
|
||||
public function fetch($template = '', $vars = [])
|
||||
{
|
||||
if ($this->isUseTpls && strpos($template, '@') === false && stripos($template, '/') === false) {
|
||||
|
||||
if ($template === '') {
|
||||
$config_auto_rule = Config::get('view.auto_rule');
|
||||
if (2 == $config_auto_rule) {
|
||||
$template = $this->request->action(true);
|
||||
} elseif (3 == $config_auto_rule) {
|
||||
$template = $this->request->action();
|
||||
} else {
|
||||
$template = Str::snake($this->request->action());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return View::fetch($this->indexTplName . $template, $vars);
|
||||
} else {
|
||||
return View::fetch($template, $vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\model\Category;
|
||||
use app\model\Nav;
|
||||
use think\facade\View;
|
||||
use think\helper\Str;
|
||||
|
||||
class Common extends BaseController
|
||||
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);
|
||||
$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_friend_url = Nav::where('type', 2)->order('sort asc')->where('status', 1)->select();
|
||||
View::assign('list_nav_friend_url', $list_nav_friend_url);
|
||||
|
||||
if (!empty($this->indexTplMethod)) {
|
||||
|
||||
if (method_exists($this, $this->indexTplMethod)) {
|
||||
$this->{$this->indexTplMethod}();
|
||||
}
|
||||
|
||||
}
|
||||
if (!empty($this->indexTplMethodCurrentAction)) {
|
||||
|
||||
if (method_exists($this, $this->indexTplMethodCurrentAction)) {
|
||||
$this->{$this->indexTplMethodCurrentAction}();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function __easyBlue()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
public function __articles()
|
||||
{
|
||||
$list_category_first_level = Category::where('level', 1)->where('status', 1)->select();
|
||||
$this->assign('list_category_first_level', $list_category_first_level);
|
||||
$list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->select();
|
||||
View::assign('list_nav_more', $list_nav_more);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,86 +2,126 @@
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use think\facade\View;
|
||||
use app\model\Category;
|
||||
use app\model\Post;
|
||||
use app\model\PostCategory;
|
||||
use think\Request;
|
||||
|
||||
class Index extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
|
||||
return $this->fetch();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function __articlesIndex()
|
||||
{
|
||||
|
||||
$sub_category = [];
|
||||
|
||||
if(!empty($this->request->param('category_id'))){
|
||||
$sub_category = Category::where('pid',$this->request->param('category_id'))->select();
|
||||
|
||||
if(empty($this->request->param('sub_category_id'))){
|
||||
$categorys = [$this->request->param('category_id')];
|
||||
|
||||
$categorys = array_merge($categorys,array_column((array)Category::getListLevel($this->request->param('category_id')),'id'));
|
||||
|
||||
$categorys_where = PostCategory::whereIn('category_id',$categorys);
|
||||
|
||||
$model_post = Post::hasWhere('categorys',$categorys_where)->where('status',1)->order('id desc');
|
||||
}else{
|
||||
$model_post = Post::hasWhere('categorys',['category_id'=>$this->request->param('sub_category_id')])->where('status',1)->order('id desc');
|
||||
|
||||
}
|
||||
}else{
|
||||
|
||||
$model_post = Post::where('status',1)->order('id desc');
|
||||
}
|
||||
|
||||
$keywords = $this->request->param('keywords');
|
||||
|
||||
if(!empty($keywords)){
|
||||
$model_post->whereLike('title|desc',"%$keywords%");
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
$list_post = $model_post->paginate();
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
$this->assign('sub_category',$sub_category);
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
$this->assign('list_post',$list_post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,41 @@ class Category extends Model
|
||||
{
|
||||
//
|
||||
|
||||
public static function getListLevel()
|
||||
{
|
||||
$model_list = Category::select();
|
||||
public static $allCategory = [];
|
||||
|
||||
// return $model_list;
|
||||
return array2level($model_list,0,0);
|
||||
|
||||
/**
|
||||
* 获取指定id下的所有分类
|
||||
*
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public static function getListLevel($id = '')
|
||||
{
|
||||
|
||||
if(empty(self::$allCategory)){
|
||||
|
||||
$model_list = Category::select();
|
||||
self::$allCategory = array2level($model_list,0,0);
|
||||
}
|
||||
|
||||
if(!empty($id)){
|
||||
$list = [];
|
||||
$in_category = [$id];
|
||||
foreach (self::$allCategory as $category) {
|
||||
if(in_array($category->pid,$in_category)){
|
||||
$list[] = $category;
|
||||
$in_category[] = $category->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
return self::$allCategory;
|
||||
}
|
||||
|
||||
|
||||
public function getTitleImgAttr($value)
|
||||
{
|
||||
|
||||
|
||||
@@ -113,6 +113,10 @@ class Post extends Model
|
||||
{
|
||||
return json_encode($value);
|
||||
}
|
||||
public function setContentHtmlAttr($value)
|
||||
{
|
||||
return trim($value);
|
||||
}
|
||||
|
||||
public function getContentAttr($value)
|
||||
{
|
||||
|
||||
130
public/static/css/index.articles.css
Normal file
130
public/static/css/index.articles.css
Normal file
@@ -0,0 +1,130 @@
|
||||
.main-container{
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.nav-left-container{
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.nav-left-list{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-left-list a{
|
||||
display: block;
|
||||
padding: 10px 15px;
|
||||
border-radius: 5px;
|
||||
margin: 5px 40px;
|
||||
}
|
||||
|
||||
.nav-left-list a:hover,.nav-left-list a.current{
|
||||
background-color: #6699CC;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.logo{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo img{
|
||||
max-width: 60%;
|
||||
}
|
||||
|
||||
.session{
|
||||
margin-top: 15px;
|
||||
background-color: #99CCFF;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.session.border{
|
||||
border-top: 2px solid #6699CC;
|
||||
}
|
||||
|
||||
.session .header{
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #036;
|
||||
}
|
||||
|
||||
.search-container{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
|
||||
.layui-btn{
|
||||
background-color: #6699CC;
|
||||
}
|
||||
|
||||
.nav-more-list a{
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
color: #036;
|
||||
margin-right: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.session .info p{
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
#banner img{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tab-list{
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin-top: 15px;
|
||||
font-size: 16px;
|
||||
|
||||
}
|
||||
|
||||
.tab-list a{
|
||||
margin-right: 15px;
|
||||
border-bottom: 2px solid transparent;
|
||||
padding-bottom: 10px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tab-list a.current{
|
||||
border-color: #6699CC;
|
||||
}
|
||||
|
||||
|
||||
.post-item{
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin-top: 15px;
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.post-item .poster{
|
||||
width: 160px;
|
||||
height: 100px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.post-item .info .title{
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.post-item .info .plus-info{
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.nodata{
|
||||
|
||||
margin: 60px auto;
|
||||
display: block;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.content-container .title{
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
BIN
public/static/images/nodata.png
Normal file
BIN
public/static/images/nodata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
@@ -110,7 +110,7 @@
|
||||
|
||||
var uploadSiteLogo = croppers.render({
|
||||
elem: '.upload-admin-avatar',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 2,
|
||||
dir: 'admin_avatar'
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
var uploadSiteLogo = croppers.render({
|
||||
elem:'.upload-admin-avatar',
|
||||
url:'{:url("api/Files/save")}',
|
||||
url:'{:url("File/save")}',
|
||||
data:{
|
||||
type:2,
|
||||
dir:'admin_avatar'
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
var uploadSiteLogo = croppers.render({
|
||||
elem: '.upload-admin-avatar',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 2,
|
||||
dir: 'admin_avatar'
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
|
||||
upload.render({
|
||||
elem: '.upload-title-img',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
|
||||
upload.render({
|
||||
elem: '.upload-title-img',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
|
||||
@@ -37,6 +37,23 @@
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
{if get_system_config('index_tpl_name') == 'articles_' }
|
||||
|
||||
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||
<li class="layui-nav-item layui-nav-itemed">
|
||||
<a class="" href="javascript:;">资讯头条</a>
|
||||
<dl class="layui-nav-child">
|
||||
|
||||
<dd class="left-nav-item" data-name="easy_blue"><a href="{:url('System/easyBlue')}">一般参数</a></dd>
|
||||
|
||||
<dd class="left-nav-item" data-name="pc-nav-6">
|
||||
<a href="{:url('Nav/index',['type'=>8,'show_img'=>0,'show_target'=>1])}">更多导航</a>
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||
<li class="layui-nav-item layui-nav-itemed">
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
var uploadTitleImg = upload.render({
|
||||
elem: '.upload',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 6,
|
||||
dir: 'nav'
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
var uploadTitleImg = upload.render({
|
||||
elem: '.upload',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 6,
|
||||
dir: 'nav'
|
||||
|
||||
@@ -298,7 +298,7 @@
|
||||
|
||||
upload.render({
|
||||
elem: '.ql-image',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
@@ -315,7 +315,7 @@
|
||||
})
|
||||
upload.render({
|
||||
elem: '.upload-poster',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
|
||||
@@ -305,7 +305,7 @@
|
||||
|
||||
upload.render({
|
||||
elem: '.ql-image',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
@@ -322,7 +322,7 @@
|
||||
})
|
||||
upload.render({
|
||||
elem: '.upload-poster',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
var uploadSiteLogo = upload.render({
|
||||
elem: '.ql-image',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
var uploadSiteLogo = upload.render({
|
||||
elem: '.upload-site-logo',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 1,
|
||||
dir: 'site_logo'
|
||||
@@ -199,7 +199,7 @@
|
||||
})
|
||||
var uploadSiteLogo = upload.render({
|
||||
elem: '.upload-site-qrcode',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 1,
|
||||
dir: 'site_logo'
|
||||
@@ -217,7 +217,7 @@
|
||||
})
|
||||
var uploadSiteLogo = upload.render({
|
||||
elem: '.upload-site-fovicon',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 1,
|
||||
dir: 'site_logo'
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
var uploadSiteLogo = croppers.render({
|
||||
elem: '.upload-admin-avatar',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 3,
|
||||
dir: 'user_avatar'
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
|
||||
var uploadSiteLogo = croppers.render({
|
||||
elem: '.upload-admin-avatar',
|
||||
url: '{:url("api/Files/save")}',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 3,
|
||||
dir: 'user_avatar'
|
||||
|
||||
19
view/index/common/_articles_left.html
Normal file
19
view/index/common/_articles_left.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="layui-col-md2">
|
||||
<div class="logo">
|
||||
<a href="{:url('Index/index')}">
|
||||
<img src="{:get_source_link(get_system_config('site_logo'))}" alt="">
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-left-container">
|
||||
<div class="nav-left-list">
|
||||
<a href="{:url('Index/index')}" {eq name='$Request.param.category_id|default=0' value='0'} class="current" {/eq}>全部</a>
|
||||
{volist name='list_header_nav' id='nav'}
|
||||
<a href="{$nav.value}" >{$nav.title}</a>
|
||||
{/volist}
|
||||
{volist name='list_category_first_level' id='category'}
|
||||
<a href="{:url('Index/index',['category_id'=>$category.id])}" {eq name='$Request.param.category_id|default=0' value='$category.id'} class="current"{/eq} >{$category.title}</a>
|
||||
{/volist}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
3
view/index/common/_articles_require.html
Normal file
3
view/index/common/_articles_require.html
Normal file
@@ -0,0 +1,3 @@
|
||||
{include file='common/_require'/}
|
||||
|
||||
<link rel="stylesheet" href="/static/css/index.articles.css">
|
||||
52
view/index/common/_articles_right.html
Normal file
52
view/index/common/_articles_right.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="layui-col-md3">
|
||||
<div class="session">
|
||||
<form action="{:url('Index/index')}" class="layui-form">
|
||||
<div class="search-container">
|
||||
{volist name='$Request.param' id='request'}
|
||||
{neq name='$key' value='keywords'}
|
||||
<input type="hidden" name="{$key}" value="{$request}">
|
||||
{/neq}
|
||||
{/volist}
|
||||
<input type="text" name="keywords" value="{$Request.param.keywords}" placeholder="搜索文章" class="layui-input">
|
||||
<button class="layui-btn">搜索</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="session border">
|
||||
<div class="header">
|
||||
更多
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="nav-more-list">
|
||||
{volist name='list_nav_more' id='nav'}
|
||||
|
||||
<a href="{$nav.value}" target="{$nav.target}">{$nav.title}</a>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="session border">
|
||||
<div class="header">
|
||||
友情链接
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="nav-more-list">
|
||||
{volist name='list_nav_friend_url' id='nav'}
|
||||
|
||||
<a href="{$nav.value}" target="{$nav.target}">{$nav.title}</a>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="session">
|
||||
<div class="info">
|
||||
|
||||
<p>{:get_system_config('site_copyright')}</p>
|
||||
|
||||
<p>举报邮箱:{:get_system_config('stie_contact_email')}</p>
|
||||
|
||||
<p> <a href="http://www.beian.miit.gov.cn/">{:get_system_config('site_beian')}</a> </p>
|
||||
<p> <a href="{:get_system_config('site_safe_beian_url')}"><img src="/static/images/ghs.png" alt="" style="margin-right: 10px;">{:get_system_config('site_safe_beian')}</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
21
view/index/common/tpl_articles.html
Normal file
21
view/index/common/tpl_articles.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{:get_system_config('site_name')}</title>
|
||||
{include file='common/_articles_require'/}
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-container main-container">
|
||||
<div class="layui-row layui-col-space4">
|
||||
{include file='common/_articles_left'/}
|
||||
<div class="layui-col-md7">
|
||||
|
||||
</div>
|
||||
{include file='common/_articles_right'/}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
96
view/index/index/articles_index.html
Normal file
96
view/index/index/articles_index.html
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{:get_system_config('site_name')}</title>
|
||||
{include file='common/_articles_require'/}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="layui-container main-container">
|
||||
<div class="layui-row layui-col-space4">
|
||||
{include file='common/_articles_left'/}
|
||||
<div class="layui-col-md7">
|
||||
{eq name='$Request.param.category_id|default="0"' value='0'}
|
||||
|
||||
<div>
|
||||
<div class="layui-carousel" id="banner">
|
||||
<div carousel-item>
|
||||
{volist name='list_nav_slide' id='nav'}
|
||||
|
||||
<a href="{$nav.value|default='javascript:;'}" target="{$nav.target}">
|
||||
<img src="{$nav.img}">
|
||||
<div class="panel">
|
||||
<p class="title">{$nav.title}</p>
|
||||
<p>{$nav.desc}</p>
|
||||
</div>
|
||||
</a>
|
||||
{/volist}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/eq}
|
||||
|
||||
{notempty name='$sub_category'}
|
||||
<div class="tab-list">
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id])}" {eq name='$Request.param.sub_category_id|default=0' value='0'} class="current" {/eq}>全部</a>
|
||||
{volist name='$sub_category' id='category'}
|
||||
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id,'sub_category_id'=>$category.id])}" {eq name='$Request.param.sub_category_id|default=0' value='$category.id'} class="current" {else/}{/eq}>{$category.title}</a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
<div class="post-container">
|
||||
<div class="post-list">
|
||||
{volist name='list_post' id='post'}
|
||||
|
||||
<a href="{:url('Post/read',['id'=>$post.id])}" class="post-item" onmouseover="$(this).find('.poster').addClass('layui-anim-scale')" onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')" >
|
||||
{notempty name='$post->getData("poster")'}
|
||||
|
||||
<div class="poster layui-anim" style="background-image: url('{$post.poster}');"></div>
|
||||
{/notempty}
|
||||
|
||||
<div class="info">
|
||||
<div class="title">{$post.title}</div>
|
||||
<div class="plus-info">
|
||||
<span>{$post.hits}访问</span>
|
||||
<span>{$post.comment_count}评论</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</a>
|
||||
{/volist}
|
||||
{empty name='list_post'}
|
||||
|
||||
<img class="nodata" src="/static/images/nodata.png" alt="">
|
||||
{/empty}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file='common/_articles_right'/}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
layui.use('carousel', function () {
|
||||
var carousel = layui.carousel;
|
||||
//建造实例
|
||||
carousel.render({
|
||||
elem: '#banner'
|
||||
, width: '100%' //设置容器宽度
|
||||
, arrow: 'always' //始终显示箭头
|
||||
//,anim: 'updown' //切换动画方式
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
33
view/index/post/articles_read.html
Normal file
33
view/index/post/articles_read.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{:get_system_config('site_name')}</title>
|
||||
{include file='common/_articles_require'/}
|
||||
<link rel="stylesheet" href="/static/lib/quill/quill.snow.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-container main-container">
|
||||
<div class="layui-row layui-col-space4">
|
||||
{include file='common/_articles_left'/}
|
||||
<div class="layui-col-md7">
|
||||
<div class="content-container">
|
||||
|
||||
<div class="title">
|
||||
{$post.title}
|
||||
</div>
|
||||
<div class="info">
|
||||
<span>{$post->publish_time_text}</span>
|
||||
</div>
|
||||
<div class="ql-snow">
|
||||
<div class="ql-editor">{$post->content_html|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file='common/_articles_right'/}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user