chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: ywxapp<admin@ywxapp.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles;
|
||||
|
||||
use ywxapp\AddonBase;
|
||||
|
||||
/**
|
||||
* 文章CMS插件启动类
|
||||
*/
|
||||
class Addon extends addon
|
||||
{
|
||||
// 插件基本信息
|
||||
public $info = [
|
||||
'name' => 'articles',
|
||||
'title' => '文章CMS',
|
||||
'description' => '完整文章类 CMS 插件:文章、分类、标签、评论',
|
||||
'status' => 1,
|
||||
'author' => 'ywxapp',
|
||||
'version' => '1.0.0',
|
||||
'type' => 1,
|
||||
];
|
||||
|
||||
// 插件安装
|
||||
public function install()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 插件卸载
|
||||
public function uninstall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 插件启用
|
||||
public function enable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 插件禁用
|
||||
public function disable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:31:07
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-13 17:07:28
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\controller\Article.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS前台文章详情 / 搜索 / 评论
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller;
|
||||
|
||||
use think\facade\Db;
|
||||
use addon\articles\model\Article as ArticleModel;
|
||||
use addon\articles\model\ArticleComment;
|
||||
|
||||
class Article extends ArticlesFrontend
|
||||
{
|
||||
public function read($id)
|
||||
{
|
||||
$article = ArticleModel::getDetail((int) $id);
|
||||
if (!$article) {
|
||||
$this->result->error('文章不存在或已删除');
|
||||
}
|
||||
// 浏览量 +1
|
||||
ArticleModel::where('id', $id)->inc('view_count')->update();
|
||||
|
||||
$commentsPage = ArticleComment::getByArticle((int) $id, (int) input('page', 1), 10);
|
||||
$comments = [
|
||||
'data' => $commentsPage->items(),
|
||||
'render' => $commentsPage->render(),
|
||||
];
|
||||
|
||||
$this->view->assign([
|
||||
'article' => $article,
|
||||
'prev' => ArticleModel::prev($article->id, $article->cid),
|
||||
'next' => ArticleModel::next($article->id, $article->cid),
|
||||
'related' => ArticleModel::related($article->id, $article->cid, 5),
|
||||
'hot' => ArticleModel::hot(10),
|
||||
'comments'=> $comments,
|
||||
'nav_active' => $article->cid,
|
||||
]);
|
||||
return $this->fetch('article/detail');
|
||||
}
|
||||
|
||||
// 兼容 route: articles/article/detail/:id
|
||||
public function detail($id)
|
||||
{
|
||||
return $this->read($id);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$keyword = trim(input('keyword', ''));
|
||||
$page = (int) input('page', 1);
|
||||
$list = ArticleModel::listArticles(['keyword' => $keyword], $page, 10);
|
||||
|
||||
$this->view->assign([
|
||||
'keyword' => $keyword,
|
||||
'list' => $list->items(),
|
||||
'total' => $list->total(),
|
||||
'page' => $list->render(),
|
||||
'nav_active' => '',
|
||||
]);
|
||||
return $this->fetch('search/index');
|
||||
}
|
||||
|
||||
public function comment()
|
||||
{
|
||||
if (!$this->auth || !$this->auth->isLogin) {
|
||||
$this->result->error('请先登录后再评论');
|
||||
}
|
||||
$aid = (int) input('aid', 0);
|
||||
$content = trim(input('content', ''));
|
||||
if (!$aid || !$content) {
|
||||
$this->result->error('参数错误');
|
||||
}
|
||||
$uid = $this->auth->info['uid'] ?? 0;
|
||||
ArticleComment::create([
|
||||
'uid' => $uid,
|
||||
'aid' => $aid,
|
||||
'pid' => 0,
|
||||
'content' => $content,
|
||||
'status' => 1,
|
||||
'create_at' => time(),
|
||||
'update_at' => time(),
|
||||
]);
|
||||
ArticleModel::where('id', $aid)->inc('comment_count')->update();
|
||||
$this->result->success('评论成功');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:30:57
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-13 17:38:27
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\controller\ArticlesFrontend.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS前台基类:统一注入侧边栏/分类/标签等共享数据
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller;
|
||||
|
||||
use ywxapp\controller\FrontendBase;
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
use addon\articles\model\ArticleTag;
|
||||
use addon\articles\library\ArticleSchema;
|
||||
|
||||
class ArticlesFrontend extends FrontendBase
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
protected $noNeedVerify = ['*'];
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
// articles 前台页面自带完整 <!DOCTYPE html> 结构,清空 layout_name,
|
||||
// 避免被 common/layout 包裹导致双层 <html>、标签外露、排版错乱。
|
||||
//$this->view->config(['layout_name' => '']);
|
||||
ArticleSchema::ensure();
|
||||
$isLogin = $this->auth && $this->auth->isLogin;
|
||||
$loginUser = $isLogin ? $this->auth->info : null;
|
||||
|
||||
$this->view->assign([
|
||||
'categories' => ArticleCategory::allEnable(),
|
||||
'tags' => ArticleTag::where('delete_at', 0)->order('id', 'desc')->limit(20)->select(),
|
||||
'hot' => Article::hot(10),
|
||||
'is_login' => $isLogin,
|
||||
'member' => $loginUser,
|
||||
'nav_active' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS前台分类列表
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller;
|
||||
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
|
||||
class Category extends ArticlesFrontend
|
||||
{
|
||||
public function index($id)
|
||||
{
|
||||
$category = ArticleCategory::getById((int) $id);
|
||||
if (!$category) {
|
||||
$this->result->error('分类不存在');
|
||||
}
|
||||
$page = (int) input('page', 1);
|
||||
$list = Article::listArticles(['cid' => $id], $page, 10);
|
||||
|
||||
$this->view->assign([
|
||||
'category' => $category,
|
||||
'list' => $list->items(),
|
||||
'page' => $list->render(),
|
||||
'nav_active' => $id,
|
||||
]);
|
||||
return $this->fetch('category/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:31:01
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-10 20:38:46
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\controller\Index.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS前台首页
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller;
|
||||
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
|
||||
class Index extends ArticlesFrontend
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
// dump($this->app->route);die;
|
||||
$page = (int) input('page', 1);
|
||||
$list = Article::listArticles([], $page, 10);
|
||||
|
||||
// 轮播:取推荐或最新的 5 篇
|
||||
$slides = Article::scope('normal')
|
||||
->order('is_top desc, is_recommend desc, create_at desc')
|
||||
->limit(5)
|
||||
->field('id,title,cover_image')
|
||||
->select();
|
||||
|
||||
$this->view->assign([
|
||||
'list' => $list->items(),
|
||||
'page' => $list->render(),
|
||||
'slides' => $slides,
|
||||
'nav_active' => 'index',
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS前台标签列表
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller;
|
||||
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\model\ArticleTag;
|
||||
|
||||
class Tag extends ArticlesFrontend
|
||||
{
|
||||
public function index($id)
|
||||
{
|
||||
$tag = ArticleTag::where('delete_at', 0)->find($id);
|
||||
if (!$tag) {
|
||||
$this->result->error('标签不存在');
|
||||
}
|
||||
$page = (int) input('page', 1);
|
||||
$list = Article::listArticles(['tid' => $id], $page, 10);
|
||||
|
||||
$this->view->assign([
|
||||
'tag' => $tag,
|
||||
'list' => $list->items(),
|
||||
'page' => $list->render(),
|
||||
]);
|
||||
return $this->fetch('tag/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS后台文章管理
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller\backend;
|
||||
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use think\Validate;
|
||||
use ywxapp\controller\BackendBase;
|
||||
use addon\articles\model\Article as ArticleModel;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
use addon\articles\model\ArticleTag;
|
||||
use addon\articles\model\ArticleArticleTag;
|
||||
use addon\articles\library\ArticleSchema;
|
||||
|
||||
class Article extends BackendBase
|
||||
{
|
||||
protected $noNeedVerify = ['*'];
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
ArticleSchema::ensure();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$status = Request::param('status', 'all');
|
||||
$keyword = Request::param('keyword', '');
|
||||
$page = Request::param('page', 1);
|
||||
$limit = Request::param('limit', 15);
|
||||
|
||||
if (Request::isAjax()) {
|
||||
$query = ArticleModel::with(['category']);
|
||||
if ($status !== 'all') {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
if ($keyword) {
|
||||
$query->where('title', 'like', "%{$keyword}%");
|
||||
}
|
||||
$paginator = $query->order('is_top', 'desc')
|
||||
->order('create_at', 'desc')
|
||||
->paginate(['list_rows' => $limit, 'page' => $page]);
|
||||
|
||||
$rows = [];
|
||||
foreach ($paginator->items() as $a) {
|
||||
$rows[] = [
|
||||
'id' => $a->id,
|
||||
'title' => $a->title,
|
||||
'is_top' => $a->is_top,
|
||||
'is_recommend'=> $a->is_recommend,
|
||||
'category' => $a->category->name ?? '-',
|
||||
'status' => $a->status,
|
||||
'view_count' => (int) $a->view_count,
|
||||
'comment_count' => (int) $a->comment_count,
|
||||
'create_at' => $a->create_at,
|
||||
'edit_url' => (string) url('articles/backend.article/edit', ['id' => $a->id]),
|
||||
];
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '', 'count' => $paginator->total(), 'data' => $rows]);
|
||||
}
|
||||
|
||||
return View::fetch('article/index', ['status' => $status, 'keyword' => $keyword]);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
return $this->update(0);
|
||||
}
|
||||
$categories = ArticleCategory::where('delete_at', 0)->where('status', 1)->select();
|
||||
$tags = ArticleTag::where('delete_at', 0)->select();
|
||||
return View::fetch('article/edit', [
|
||||
'article' => null,
|
||||
'categories' => $categories,
|
||||
'tags' => $tags,
|
||||
'articleTags' => [],
|
||||
'tagNamesStr' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
$article = ArticleModel::with(['tags'])->find($id);
|
||||
if (!$article) {
|
||||
return redirect('/articles/backend/article');
|
||||
}
|
||||
$categories = ArticleCategory::where('delete_at', 0)->where('status', 1)->select();
|
||||
$tags = ArticleTag::where('delete_at', 0)->select();
|
||||
$articleTags = $article->tags->column('id');
|
||||
$tagNamesStr = implode(',', $article->tags->column('name'));
|
||||
|
||||
return View::fetch('article/edit', [
|
||||
'article' => $article,
|
||||
'categories' => $categories,
|
||||
'tags' => $tags,
|
||||
'articleTags' => $articleTags,
|
||||
'tagNamesStr' => $tagNamesStr,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id = 0)
|
||||
{
|
||||
$data = Request::post();
|
||||
$id = $id ?: (int) ($data['id'] ?? 0);
|
||||
$data['update_at'] = time();
|
||||
$data['is_top'] = isset($data['is_top']) ? 1 : 0;
|
||||
$data['is_recommend']= isset($data['is_recommend']) ? 1 : 0;
|
||||
|
||||
$validate = new Validate([
|
||||
'title|标题' => 'require|max:255',
|
||||
'content|内容' => 'require',
|
||||
'cid|分类' => 'require|number',
|
||||
]);
|
||||
if (!$validate->check($data)) {
|
||||
return json(['code' => 0, 'msg' => $validate->getError()]);
|
||||
}
|
||||
|
||||
// 处理标签
|
||||
$tagIds = [];
|
||||
if (!empty($data['tags'])) {
|
||||
$tagNames = is_array($data['tags']) ? $data['tags'] : explode(',', $data['tags']);
|
||||
foreach ($tagNames as $name) {
|
||||
$name = trim($name);
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
$tag = ArticleTag::where('delete_at', 0)->where('name', $name)->find()
|
||||
?: ArticleTag::create(['name' => $name, 'alias' => $name, 'create_at' => time(), 'update_at' => time()]);
|
||||
$tagIds[] = $tag->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$article = ArticleModel::find($id);
|
||||
if (!$article) {
|
||||
return json(['code' => 0, 'msg' => '文章不存在']);
|
||||
}
|
||||
$article->save($data);
|
||||
} else {
|
||||
if (empty($data['uid'])) {
|
||||
$data['uid'] = $this->auth->info['uid'] ?? 0;
|
||||
}
|
||||
if (empty($data['author'])) {
|
||||
$data['author'] = $this->auth->info['nickname'] ?? '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$article = ArticleModel::create($data);
|
||||
$id = $article->id;
|
||||
}
|
||||
ArticleArticleTag::syncTags($id, $tagIds);
|
||||
return json(['code' => 1, 'msg' => '保存成功', 'url' => '/articles/backend/article']);
|
||||
}
|
||||
|
||||
public function delete($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$article = ArticleModel::find($id);
|
||||
if ($article) {
|
||||
$article->delete();
|
||||
return json(['code' => 1, 'msg' => '已删除']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '文章不存在']);
|
||||
}
|
||||
|
||||
public function recyclebin()
|
||||
{
|
||||
$page = Request::param('page', 1);
|
||||
$limit = Request::param('limit', 15);
|
||||
if (Request::isAjax()) {
|
||||
$list = ArticleModel::onlyTrashed()
|
||||
->order('delete_at', 'desc')
|
||||
->paginate(['list_rows' => $limit, 'page' => $page]);
|
||||
$rows = array_map(function ($a) {
|
||||
return [
|
||||
'id' => $a->id,
|
||||
'title' => $a->title,
|
||||
'delete_at' => $a->delete_at,
|
||||
];
|
||||
}, $list->items());
|
||||
return json(['code' => 0, 'msg' => '', 'count' => $list->total(), 'data' => $rows]);
|
||||
}
|
||||
return View::fetch('article/recyclebin');
|
||||
}
|
||||
|
||||
public function restore($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$article = ArticleModel::onlyTrashed()->find($id);
|
||||
if ($article) {
|
||||
$article->restore();
|
||||
return json(['code' => 1, 'msg' => '已恢复']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '记录不存在']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS后台分类管理
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace addon\articles\controller\backend;
|
||||
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use think\Validate;
|
||||
use ywxapp\controller\BackendBase;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
use addon\articles\library\ArticleSchema;
|
||||
|
||||
class Category extends BackendBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Summary of needLogin
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedLogin = [];
|
||||
|
||||
/**
|
||||
* Summary of needRight
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedVerify = [];
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
ArticleSchema::ensure();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$page = $this->request->param('page', 1);
|
||||
$size = $this->request->param('size', 15);
|
||||
if ($this->request->isAjax()) {
|
||||
$data = ArticleCategory::paginate([
|
||||
'page' => $page,
|
||||
'list_rows' => $size,
|
||||
]);
|
||||
$this->result->success($data->items());
|
||||
}
|
||||
$this->view->assign('title', '登录');
|
||||
return $this->view->fetch('category/index');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = Request::post();
|
||||
$data['status'] = isset($data['status']) ? 1 : 0;
|
||||
|
||||
$validate = new Validate([
|
||||
'name|名称' => 'require|max:50',
|
||||
'alias|别名' => 'require|max:50',
|
||||
]);
|
||||
if (!$validate->check($data)) {
|
||||
$this->result->error($validate->getError());
|
||||
}
|
||||
ArticleCategory::create($data);
|
||||
$this->result->success();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
$category = ArticleCategory::find($id);
|
||||
if (!$category) {
|
||||
return redirect('/articles/backend/category');
|
||||
}
|
||||
return View::fetch('category/edit', ['category' => $category]);
|
||||
}
|
||||
|
||||
public function update($id = 0)
|
||||
{
|
||||
$data = Request::post();
|
||||
$id = $id ?: (int) ($data['id'] ?? 0);
|
||||
$data['update_at'] = time();
|
||||
$data['status'] = isset($data['status']) ? 1 : 0;
|
||||
|
||||
$validate = new Validate([
|
||||
'name|名称' => 'require|max:50',
|
||||
'alias|别名' => 'require|max:50',
|
||||
]);
|
||||
if (!$validate->check($data)) {
|
||||
return json(['code' => 0, 'msg' => $validate->getError()]);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$category = ArticleCategory::find($id);
|
||||
if (!$category) {
|
||||
return json(['code' => 0, 'msg' => '分类不存在']);
|
||||
}
|
||||
$category->save($data);
|
||||
} else {
|
||||
$data['create_at'] = time();
|
||||
ArticleCategory::create($data);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '保存成功', 'url' => '/articles/backend/category']);
|
||||
}
|
||||
|
||||
public function delete($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$category = ArticleCategory::find($id);
|
||||
if ($category) {
|
||||
if (ArticleCategory::hasArticles($id)) {
|
||||
return json(['code' => 0, 'msg' => '该分类下还有文章,无法删除']);
|
||||
}
|
||||
$category->delete();
|
||||
return json(['code' => 0, 'msg' => '已删除']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '分类不存在']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS后台评论管理
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller\backend;
|
||||
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use ywxapp\controller\BackendBase;
|
||||
use addon\articles\model\ArticleComment;
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\library\ArticleSchema;
|
||||
|
||||
class Comment extends BackendBase
|
||||
{
|
||||
protected $noNeedVerify = ['*'];
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
ArticleSchema::ensure();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$status = Request::param('status', 'all');
|
||||
$keyword = Request::param('keyword', '');
|
||||
$page = Request::param('page', 1);
|
||||
$limit = Request::param('limit', 15);
|
||||
|
||||
if (Request::isAjax()) {
|
||||
$query = ArticleComment::with(['user', 'article']);
|
||||
if ($status !== 'all') {
|
||||
$query->where('status', $status);
|
||||
}
|
||||
if ($keyword) {
|
||||
$query->where('content', 'like', "%{$keyword}%");
|
||||
}
|
||||
$paginator = $query->order('create_at', 'desc')
|
||||
->paginate(['list_rows' => $limit, 'page' => $page]);
|
||||
|
||||
$rows = [];
|
||||
foreach ($paginator->items() as $c) {
|
||||
$rows[] = [
|
||||
'id' => $c->id,
|
||||
'nickname' => $c->user->nickname ?? '游客',
|
||||
'article' => $c->article->title ?? '-',
|
||||
'content' => $c->content,
|
||||
'status' => $c->status,
|
||||
'create_at' => $c->create_at,
|
||||
];
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '', 'count' => $paginator->total(), 'data' => $rows]);
|
||||
}
|
||||
return View::fetch('comment/index', ['status' => $status, 'keyword' => $keyword]);
|
||||
}
|
||||
|
||||
public function audit($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$comment = ArticleComment::find($id);
|
||||
if ($comment) {
|
||||
$comment->status = 1;
|
||||
$comment->save();
|
||||
Article::where('id', $comment->aid)->inc('comment_count')->update();
|
||||
return json(['code' => 1, 'msg' => '审核通过']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '评论不存在']);
|
||||
}
|
||||
|
||||
public function delete($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$comment = ArticleComment::find($id);
|
||||
if ($comment) {
|
||||
$comment->delete();
|
||||
return json(['code' => 1, 'msg' => '已删除']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '评论不存在']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS后台标签管理
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\controller\backend;
|
||||
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use think\Validate;
|
||||
use ywxapp\controller\BackendBase;
|
||||
use addon\articles\model\ArticleTag;
|
||||
use addon\articles\library\ArticleSchema;
|
||||
|
||||
class Tag extends BackendBase
|
||||
{
|
||||
protected $noNeedVerify = ['*'];
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
ArticleSchema::ensure();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (Request::isAjax()) {
|
||||
$list = ArticleTag::where('delete_at', 0)->order('id', 'desc')->select();
|
||||
$rows = array_map(function ($t) {
|
||||
return [
|
||||
'id' => $t->id,
|
||||
'name' => $t->name,
|
||||
'alias' => $t->alias,
|
||||
'description' => $t->description,
|
||||
'create_at' => $t->create_at,
|
||||
'edit_url' => (string) url('articles/backend.tag/edit', ['id' => $t->id]),
|
||||
];
|
||||
}, $list->toArray());
|
||||
return json(['code' => 0, 'msg' => '', 'count' => count($rows), 'data' => $rows]);
|
||||
}
|
||||
return View::fetch('tag/index');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
return $this->update(0);
|
||||
}
|
||||
return View::fetch('tag/edit', ['tag' => null]);
|
||||
}
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
$tag = ArticleTag::find($id);
|
||||
if (!$tag) {
|
||||
return redirect('/articles/backend/tag');
|
||||
}
|
||||
return View::fetch('tag/edit', ['tag' => $tag]);
|
||||
}
|
||||
|
||||
public function update($id = 0)
|
||||
{
|
||||
$data = Request::post();
|
||||
$id = $id ?: (int) ($data['id'] ?? 0);
|
||||
$data['update_at'] = time();
|
||||
$data['alias'] = $data['alias'] ?? $data['name'];
|
||||
|
||||
$validate = new Validate([
|
||||
'name|名称' => 'require|max:50',
|
||||
]);
|
||||
if (!$validate->check($data)) {
|
||||
return json(['code' => 0, 'msg' => $validate->getError()]);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$tag = ArticleTag::find($id);
|
||||
if (!$tag) {
|
||||
return json(['code' => 0, 'msg' => '标签不存在']);
|
||||
}
|
||||
$tag->save($data);
|
||||
} else {
|
||||
$data['create_at'] = time();
|
||||
ArticleTag::create($data);
|
||||
}
|
||||
return json(['code' => 1, 'msg' => '保存成功', 'url' => '/articles/backend/tag']);
|
||||
}
|
||||
|
||||
public function delete($id = 0)
|
||||
{
|
||||
$id = $id ?: (int) Request::post('id', 0);
|
||||
$tag = ArticleTag::find($id);
|
||||
if ($tag) {
|
||||
$tag->delete();
|
||||
return json(['code' => 1, 'msg' => '已删除']);
|
||||
}
|
||||
return json(['code' => 0, 'msg' => '标签不存在']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'articles',
|
||||
'title' => '文章CMS',
|
||||
'description' => '完整文章类 CMS 插件:文章、分类、标签、评论,前台套用 layuiSimpleNews 模板',
|
||||
'status' => 1,
|
||||
'author' => 'ywxapp',
|
||||
'version' => '1.0.0',
|
||||
'type' => 1,
|
||||
'state' => 0,
|
||||
'install_time' => 1786348115,
|
||||
'update_time' => 1786366229,
|
||||
];
|
||||
@@ -0,0 +1,91 @@
|
||||
-- ============================================================
|
||||
-- addon/articles/install.sql —— 文章CMS插件数据表
|
||||
-- 框架约定:插件安装时由 ywxapp\service\AddonService 执行本文件
|
||||
-- (仅允许 CREATE TABLE / INSERT,见 importsql 白名单)。
|
||||
-- 表名须为 __PREFIX__articles_*,与插件名一致。
|
||||
-- 时间字段统一:create_at / update_at / delete_at(int 时间戳,0=未删)
|
||||
-- ============================================================
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__articles_article` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
|
||||
`content` longtext NOT NULL COMMENT '正文',
|
||||
`summary` varchar(500) DEFAULT '' COMMENT '摘要',
|
||||
`cover_image` varchar(255) DEFAULT '' COMMENT '封面图',
|
||||
`uid` int NOT NULL DEFAULT 0 COMMENT '作者ID(member_user.uid)',
|
||||
`author` varchar(50) DEFAULT '' COMMENT '作者名(冗余)',
|
||||
`cid` int NOT NULL DEFAULT 0 COMMENT '分类ID',
|
||||
`status` tinyint(1) DEFAULT 1 COMMENT '状态:1发布 0草稿',
|
||||
`is_top` tinyint(1) DEFAULT 0 COMMENT '是否置顶',
|
||||
`is_recommend` tinyint(1) DEFAULT 0 COMMENT '是否推荐',
|
||||
`view_count` int DEFAULT 0 COMMENT '浏览次数',
|
||||
`comment_count` int DEFAULT 0 COMMENT '评论数',
|
||||
`like_count` int DEFAULT 0 COMMENT '点赞数',
|
||||
`create_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
|
||||
`update_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
|
||||
`delete_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_uid` (`uid`),
|
||||
KEY `idx_cid` (`cid`),
|
||||
KEY `idx_status_create` (`status`,`create_at`),
|
||||
KEY `idx_delete` (`delete_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__articles_category` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '分类名称',
|
||||
`alias` varchar(50) NOT NULL DEFAULT '' COMMENT '分类别名(URL标识)',
|
||||
`description` varchar(255) DEFAULT '' COMMENT '分类描述',
|
||||
`cover` varchar(255) DEFAULT '' COMMENT '分类封面',
|
||||
`sort` int DEFAULT 0 COMMENT '排序权重',
|
||||
`status` tinyint(1) DEFAULT 1 COMMENT '状态',
|
||||
`create_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
|
||||
`update_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
|
||||
`delete_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_alias` (`alias`),
|
||||
KEY `idx_delete` (`delete_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章分类表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__articles_tag` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '标签名称',
|
||||
`alias` varchar(50) NOT NULL DEFAULT '' COMMENT '标签别名',
|
||||
`description` varchar(255) DEFAULT '' COMMENT '标签描述',
|
||||
`create_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
|
||||
`update_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
|
||||
`delete_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_name` (`name`),
|
||||
KEY `idx_delete` (`delete_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章标签表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__articles_article_tag` (
|
||||
`aid` int NOT NULL COMMENT '文章ID',
|
||||
`tid` int NOT NULL COMMENT '标签ID',
|
||||
PRIMARY KEY (`aid`,`tid`) USING BTREE,
|
||||
KEY `idx_tid` (`tid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章标签关联表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__articles_comment` (
|
||||
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uid` int NOT NULL DEFAULT 0 COMMENT '用户ID(member_user.uid)',
|
||||
`aid` int NOT NULL DEFAULT 0 COMMENT '文章ID',
|
||||
`pid` int NOT NULL DEFAULT 0 COMMENT '父评论ID',
|
||||
`content` text NOT NULL COMMENT '评论内容',
|
||||
`status` tinyint(1) DEFAULT 1 COMMENT '状态:1正常 0待审核',
|
||||
`like_count` int DEFAULT 0 COMMENT '点赞数',
|
||||
`ip` varchar(45) DEFAULT '' COMMENT 'IP地址',
|
||||
`user_agent` varchar(255) DEFAULT '' COMMENT '用户代理',
|
||||
`create_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
|
||||
`update_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
|
||||
`delete_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_aid` (`aid`),
|
||||
KEY `idx_pid` (`pid`),
|
||||
KEY `idx_delete` (`delete_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章评论表';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS插件数据表自愈聚合入口
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\library;
|
||||
|
||||
use addon\articles\model\Article;
|
||||
use addon\articles\model\ArticleCategory;
|
||||
use addon\articles\model\ArticleTag;
|
||||
use addon\articles\model\ArticleComment;
|
||||
|
||||
class ArticleSchema
|
||||
{
|
||||
/**
|
||||
* 插件启用/首访时调用,确保全部私有表存在
|
||||
*/
|
||||
public static function ensure(): void
|
||||
{
|
||||
Article::ensureSchema();
|
||||
ArticleCategory::ensureSchema();
|
||||
ArticleTag::ensureSchema();
|
||||
ArticleComment::ensureSchema();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"backend": [
|
||||
{
|
||||
"name": "articles",
|
||||
"title": "文章CMS",
|
||||
"icon": "layui-icon layui-icon-list",
|
||||
|
||||
"sublist": [
|
||||
{
|
||||
"name": "article/index",
|
||||
"title": "文章列表",
|
||||
"route": "articles/backend/article/index"
|
||||
},
|
||||
{
|
||||
"name": "article/index/index",
|
||||
"title": "分类管理",
|
||||
"route": "articles/backend/category/index",
|
||||
"child": [
|
||||
{ "name": "category:add", "title": "新增分类", "type": 4 },
|
||||
{ "name": "category:edit", "title": "编辑分类", "type": 4 },
|
||||
{ "name": "category:delete", "title": "删除分类", "type": 4 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "tag/index",
|
||||
"title": "标签管理",
|
||||
"route": "articles/backend/tag/index"
|
||||
},
|
||||
{
|
||||
"name": "comment/index",
|
||||
"title": "评论管理",
|
||||
"route": "articles/backend/comment/index"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章模型
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\model;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
use ywxapp\model\BaseModel;
|
||||
|
||||
class Article extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'articles_article';
|
||||
protected $deleteTime = 'delete_at';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
// 时间字段为 int 时间戳(与 install.sql 一致),开启自动维护
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
protected $type = [
|
||||
'status' => 'integer',
|
||||
'is_top' => 'integer',
|
||||
'is_recommend' => 'integer',
|
||||
'view_count' => 'integer',
|
||||
'comment_count'=> 'integer',
|
||||
'like_count' => 'integer',
|
||||
];
|
||||
|
||||
// 发布中(未删除、已发布)
|
||||
public function scopeNormal($query)
|
||||
{
|
||||
$query->where('delete_at', 0)->where('status', 1);
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ArticleCategory::class, 'cid', 'id')
|
||||
->bind(['category_name' => 'name', 'category_alias' => 'alias']);
|
||||
}
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(\ywxapp\model\MemberUser::class, 'uid', 'uid')
|
||||
->bind(['author_name' => 'nickname']);
|
||||
}
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->belongsToMany(ArticleTag::class, ArticleArticleTag::class, 'tid', 'aid');
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询(支持分类/标签/关键词)
|
||||
*/
|
||||
public static function listArticles(array $where = [], int $page = 1, int $size = 10, string $order = 'is_top desc, create_at desc')
|
||||
{
|
||||
$query = self::with(['category'])->scope('normal');
|
||||
|
||||
if (!empty($where['cid'])) {
|
||||
$query->where('cid', $where['cid']);
|
||||
}
|
||||
if (!empty($where['tid'])) {
|
||||
$ids = ArticleArticleTag::where('tid', $where['tid'])->column('aid');
|
||||
$query->whereIn('id', $ids ?: [0]);
|
||||
}
|
||||
if (!empty($where['keyword'])) {
|
||||
$kw = $where['keyword'];
|
||||
$query->where(function ($q) use ($kw) {
|
||||
$q->whereLike('title', "%{$kw}%")->whereOr('summary', 'like', "%{$kw}%");
|
||||
});
|
||||
}
|
||||
if (!empty($where['is_recommend'])) {
|
||||
$query->where('is_recommend', 1);
|
||||
}
|
||||
|
||||
return $query->orderRaw($order)->paginate([
|
||||
'list_rows' => $size,
|
||||
'page' => $page,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getDetail(int $id)
|
||||
{
|
||||
return self::with(['category', 'tags', 'author'])
|
||||
->scope('normal')
|
||||
->find($id);
|
||||
}
|
||||
|
||||
public static function prev(int $id, int $cid = 0)
|
||||
{
|
||||
$query = self::scope('normal')->where('id', '<', $id);
|
||||
if ($cid) {
|
||||
$query->where('cid', $cid);
|
||||
}
|
||||
return $query->order('id', 'desc')->field('id,title')->find();
|
||||
}
|
||||
|
||||
public static function next(int $id, int $cid = 0)
|
||||
{
|
||||
$query = self::scope('normal')->where('id', '>', $id);
|
||||
if ($cid) {
|
||||
$query->where('cid', $cid);
|
||||
}
|
||||
return $query->order('id', 'asc')->field('id,title')->find();
|
||||
}
|
||||
|
||||
public static function hot(int $limit = 10)
|
||||
{
|
||||
return self::scope('normal')
|
||||
->order('view_count', 'desc')
|
||||
->limit($limit)
|
||||
->field('id,title,cid,view_count')
|
||||
->select();
|
||||
}
|
||||
|
||||
public static function related(int $id, int $cid = 0, int $limit = 5)
|
||||
{
|
||||
$query = self::scope('normal')->where('id', '<>', $id);
|
||||
if ($cid) {
|
||||
$query->where('cid', $cid);
|
||||
}
|
||||
return $query->order('create_at', 'desc')
|
||||
->limit($limit)
|
||||
->field('id,title,cid')
|
||||
->select();
|
||||
}
|
||||
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
$prefix = self::currentPrefix();
|
||||
self::ensureTableFromInstall($prefix, 'articles_article');
|
||||
self::ensureTableFromInstall($prefix, 'articles_article_tag');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:28:22
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-12 09:42:29
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\model\ArticleArticleTag.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章标签关联模型
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\model;
|
||||
|
||||
use ywxapp\model\BaseModel;
|
||||
use think\model\Pivot;
|
||||
class ArticleArticleTag extends Pivot
|
||||
{
|
||||
protected $name = 'articles_article_tag';
|
||||
public $autoWriteTimestamp = false;
|
||||
|
||||
public static function syncTags(int $aid, array $tagIds): void
|
||||
{
|
||||
self::where('aid', $aid)->delete();
|
||||
$data = array_map(function ($tid) use ($aid) {
|
||||
return ['aid' => $aid, 'tid' => $tid];
|
||||
}, $tagIds);
|
||||
if ($data) {
|
||||
self::insertAll($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:28:14
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-11 00:39:57
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\model\ArticleCategory.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章分类模型
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\model;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
use ywxapp\model\BaseModel;
|
||||
|
||||
class ArticleCategory extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'articles_category';
|
||||
protected $deleteTime = 'delete_at';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
protected $type = [
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany(Article::class, 'cid', 'id');
|
||||
}
|
||||
|
||||
public static function allEnable()
|
||||
{
|
||||
return self::where('delete_at', 0)
|
||||
->where('status', 1)
|
||||
->order('sort', 'asc')
|
||||
->order('id', 'asc')
|
||||
->select();
|
||||
}
|
||||
|
||||
public static function getByAlias(string $alias)
|
||||
{
|
||||
return self::where('delete_at', 0)->where('alias', $alias)->find();
|
||||
}
|
||||
|
||||
public static function getById(int $id)
|
||||
{
|
||||
return self::where('delete_at', 0)->find($id);
|
||||
}
|
||||
|
||||
public static function hasArticles(int $id): bool
|
||||
{
|
||||
return Article::where('delete_at', 0)->where('cid', $id)->count() > 0;
|
||||
}
|
||||
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
$prefix = self::currentPrefix();
|
||||
self::ensureTableFromInstall($prefix, 'articles_category');
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容旧框架 ArticleCategory::tabTree 的树形展开输出
|
||||
* 插件分类为扁平结构(无 parent_id),此处直接按 sort/id 顺序输出带层级前缀的列表。
|
||||
* @param iterable $arr 分类数据集
|
||||
* @param int $pid 兼容参数,保留原签名
|
||||
* @param int $lv 兼容参数,保留原签名
|
||||
*/
|
||||
public static function tabTree($arr, $pid = 0, $lv = 0)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($arr as $item) {
|
||||
$data = is_array($item) ? $item : $item->toArray();
|
||||
$data['lv'] = $lv + 1;
|
||||
$data['title'] = str_repeat('|——', $lv + 1) . ($data['name'] ?? ($data['title'] ?? ''));
|
||||
$result[] = $data;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:28:26
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-15 10:17:49
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\model\ArticleComment.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章评论模型
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\model;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
use ywxapp\model\BaseModel;
|
||||
|
||||
class ArticleComment extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'articles_comment';
|
||||
protected $deleteTime = 'delete_at';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
protected $type = [
|
||||
'pid' => 'integer',
|
||||
'aid' => 'integer',
|
||||
'uid' => 'integer',
|
||||
'status' => 'integer',
|
||||
'like_count'=> 'integer',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\ywxapp\model\MemberUser::class, 'uid', 'uid')
|
||||
->bind(['nickname', 'avatar']);
|
||||
}
|
||||
|
||||
public static function getByArticle(int $aid, int $page = 1, int $size = 10)
|
||||
{
|
||||
return self::with(['user'])
|
||||
->where('delete_at', 0)
|
||||
->where('aid', $aid)
|
||||
->where('status', 1)
|
||||
->order('id', 'asc')
|
||||
->paginate(['list_rows' => $size, 'page' => $page]);
|
||||
}
|
||||
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
$prefix = self::currentPrefix();
|
||||
self::ensureTableFromInstall($prefix, 'articles_comment');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章标签模型
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\articles\model;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
use ywxapp\model\BaseModel;
|
||||
|
||||
class ArticleTag extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'articles_tag';
|
||||
protected $deleteTime = 'delete_at';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
protected $type = [];
|
||||
|
||||
public static function getByAlias(string $alias)
|
||||
{
|
||||
return self::where('delete_at', 0)->where('alias', $alias)->find();
|
||||
}
|
||||
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
$prefix = self::currentPrefix();
|
||||
self::ensureTableFromInstall($prefix, 'articles_tag');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||||
* @Date: 2026-08-10 15:26:18
|
||||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||||
* @LastEditTime: 2026-08-15 10:14:11
|
||||
* @Description:
|
||||
* @FilePath: \ywxapp_dev\addon\articles\route\app.php
|
||||
* @CustomString: Copyright (c) 2026 YwxApp
|
||||
*/
|
||||
// +----------------------------------------------------------------------
|
||||
// | 文章CMS插件路由:相对路由,由 AppService::loadAddonRoutes 统一补 articles 前缀
|
||||
// | 约定:不要用 Route::group('articles') 再包一层(外层已补前缀,会双重前缀)
|
||||
// +----------------------------------------------------------------------
|
||||
use think\facade\Route;
|
||||
|
||||
// 前台(相对规则,由外层 Route::group('articles') 统一补全前缀,url() 用 articles/xxx/index 生成)
|
||||
Route::get('index/index', 'addon\articles\controller\Index@index');
|
||||
Route::get('read/:id', 'addon\articles\controller\Article@read');
|
||||
Route::get('article/detail/:id', 'addon\articles\controller\Article@detail');
|
||||
Route::get('category/index', 'addon\articles\controller\Category@index');
|
||||
Route::get('category/:id', 'addon\articles\controller\Category@index');
|
||||
Route::get('tag/index', 'addon\articles\controller\Tag@index');
|
||||
Route::get('tag/:id', 'addon\articles\controller\Tag@index');
|
||||
Route::get('search/index', 'addon\articles\controller\Article@search');
|
||||
Route::post('article/comment', 'addon\articles\controller\Article@comment');
|
||||
|
||||
// 后台(直接把 backend/ 写进 rule 路径,避免嵌套 Route::group('backend') 产生的歧义)
|
||||
// 实测结论:无论用嵌套 Route::group('backend') 还是把 backend 写进 rule 路径,
|
||||
// loadAddonRoutes 的外层 Route::group('articles') 都会把 backend 层级拼成「带点」形式
|
||||
// → 真实 URL 固定为 /articles/backend.category/index.html(斜杠形式恒 404)。
|
||||
// 故后台 URL 统一用带点,menu.json 的 jump 与视图 {:url('articles/backend.xxx/yyy')} 均须用带点。
|
||||
// 注意:不能用 wxchat 的 ->prefix('backend/') 写法——articles 后台控制器在 controller/backend/ 子目录,
|
||||
// prefix 会让 TP 解析成 backend/backend/Category 导致 500(实测)。
|
||||
|
||||
|
||||
|
||||
|
||||
Route::group('backend', function () {
|
||||
Route::get('article/index', 'Article/index');
|
||||
Route::any('article/save', 'Article/save');
|
||||
Route::get('article/edit', 'Article/edit');
|
||||
Route::post('article/update', 'Article/update');
|
||||
Route::post('article/delete', 'Article/delete');
|
||||
Route::post('article/recyclebin', 'Article/recyclebin');
|
||||
Route::post('article/restore', 'Article/restore');
|
||||
|
||||
Route::get('tag/index', 'Tag/index');
|
||||
Route::any('tag/save', 'Tag/save');
|
||||
Route::get('tag/edit', 'Tag/edit');
|
||||
Route::post('tag/update', 'Tag/update');
|
||||
Route::post('tag/delete', 'Tag/delete');
|
||||
|
||||
Route::get('comment/index', 'Comment/index');
|
||||
Route::post('comment/audit', 'Comment/audit');
|
||||
Route::post('comment/delete', 'Comment/delete');
|
||||
|
||||
Route::get('category/index', 'Category/index');
|
||||
Route::any('category/save', 'Category/save');
|
||||
Route::get('category/edit', 'Category/edit');
|
||||
Route::post('category/update', 'Category/update');
|
||||
Route::post('category/delete', 'Category/delete');
|
||||
|
||||
})->layer('backend');;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">编辑文章</div>
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" id="form">
|
||||
<input type="hidden" name="id" value="{$article.id|default=0}">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标题</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" value="{$article.title|default=''}" class="layui-input" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="cid" lay-verify="required">
|
||||
<option value="">请选择分类</option>
|
||||
{volist name='categories' id='c'}
|
||||
<option value="{$c.id}" {if isset($article['cid']) && $article['cid'] == $c['id']}selected{/if}>{$c.name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
<label class="layui-form-label">标签</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="tags" value="{$tagNamesStr|default=''}" class="layui-input" placeholder="逗号分隔">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">封面图</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="cover_image" id="cover_image" value="{$article.cover_image|default=''}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">摘要</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="summary" class="layui-textarea">{$article.summary|default=''}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">正文</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="content" name="content" style="display:none;">{$article.content|default=''}</textarea>
|
||||
<script id="editor" type="text/plain" style="width:100%;height:420px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="status" value="1" {if isset($article['status']) ? $article['status'] : 1}checked{/if} title="发布" lay-skin="switch">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="is_top" value="1" {if isset($article['is_top']) ? $article['is_top'] : 0}checked{/if} title="置顶">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="is_recommend" value="1" {if isset($article['is_recommend']) ? $article['is_recommend'] : 0}checked{/if} title="推荐">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<a href="{:url('articles/backend.article/index')}" class="layui-btn layui-btn-primary">返回</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/assets/library/ueditor/ueditor.config.js"></script>
|
||||
<script src="/assets/library/ueditor/ueditor.all.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
var form = layui.form, $ = layui.jquery;
|
||||
|
||||
var ue = UE.getEditor('editor', {
|
||||
UEDITOR_HOME_URL: '/assets/library/ueditor/',
|
||||
serverUrl: '/ueditor'
|
||||
});
|
||||
ue.ready(function () {
|
||||
var c = $('#content').val();
|
||||
if (c) { ue.setContent(c); }
|
||||
});
|
||||
|
||||
form.on('submit(save)', function (data) {
|
||||
data.field.content = ue.getContent();
|
||||
$.ajax({
|
||||
url: "{:url('articles/backend.article/update')}",
|
||||
type: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function (r) {
|
||||
layer.msg(r.msg);
|
||||
if (r.code) { setTimeout(function () { location.href = r.url || "{:url('articles/backend.article/index')}"; }, 800); }
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,76 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">文章管理</div>
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" lay-filter="search">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<select name="status">
|
||||
<option value="all">全部状态</option>
|
||||
<option value="1">已发布</option>
|
||||
<option value="0">草稿</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" placeholder="标题关键词" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">搜索</button>
|
||||
<a href="{:url('articles/backend.article/save')}" class="layui-btn layui-btn-normal">新建文章</a>
|
||||
<a href="{:url('articles/backend.article/recyclebin')}" class="layui-btn layui-btn-primary">回收站</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="layui-table" id="table" lay-filter="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['table', 'form'], function () {
|
||||
var table = layui.table, form = layui.form, $ = layui.jquery;
|
||||
var tableIns = table.render({
|
||||
elem: '#table',
|
||||
url: "{:url('articles/backend.article/index')}",
|
||||
method: 'post',
|
||||
where: { status: 'all' },
|
||||
page: true,
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', width: 70 },
|
||||
{ field: 'title', title: '标题', minWidth: 200 },
|
||||
{ field: 'category', title: '分类', width: 100 },
|
||||
{ field: 'is_top', title: '置顶', width: 70, templet: function (d) { return d.is_top ? '是' : ''; } },
|
||||
{ field: 'is_recommend', title: '推荐', width: 70, templet: function (d) { return d.is_recommend ? '是' : ''; } },
|
||||
{ field: 'status', title: '状态', width: 80, templet: function (d) { return d.status ? '<span class="layui-badge layui-bg-green">发布</span>' : '<span class="layui-badge">草稿</span>'; } },
|
||||
{ field: 'view_count', title: '浏览', width: 80 },
|
||||
{ field: 'comment_count', title: '评论', width: 80 },
|
||||
{ field: 'create_at', title: '创建时间', width: 170 },
|
||||
{ title: '操作', width: 140, toolbar: '#toolbar' }
|
||||
]]
|
||||
});
|
||||
|
||||
form.on('submit(search)', function (data) {
|
||||
tableIns.reload({ where: data.field, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
|
||||
table.on('tool(table)', function (obj) {
|
||||
if (obj.event === 'edit') {
|
||||
location.href = obj.data.edit_url;
|
||||
} else if (obj.event === 'del') {
|
||||
layer.confirm('确认删除该文章?', function () {
|
||||
$.post("{:url('articles/backend.article/delete')}", { id: obj.data.id }, function (r) {
|
||||
layer.msg(r.msg);
|
||||
if (r.code) { obj.del(); }
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,37 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">回收站</div>
|
||||
<div class="layui-card-body">
|
||||
<table class="layui-table" id="table" lay-filter="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="restore">恢复</a>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['table'], function () {
|
||||
var table = layui.table;
|
||||
var tableIns = table.render({
|
||||
elem: '#table',
|
||||
url: "{:url('articles/backend.article/recyclebin')}",
|
||||
method: 'post',
|
||||
page: true,
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', width: 70 },
|
||||
{ field: 'title', title: '标题', minWidth: 200 },
|
||||
{ field: 'delete_at', title: '删除时间', width: 170 },
|
||||
{ title: '操作', width: 90, toolbar: '#toolbar' }
|
||||
]]
|
||||
});
|
||||
table.on('tool(table)', function (obj) {
|
||||
if (obj.event === 'restore') {
|
||||
$.post("{:url('articles/backend.article/restore')}", { id: obj.data.id }, function (r) {
|
||||
layer.msg(r.msg); if (r.code) { obj.del(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">编辑分类</div>
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" id="form">
|
||||
<input type="hidden" name="id" value="{$category.id|default=0}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block"><input type="text" name="name" value="{$category.name|default=''}" class="layui-input" lay-verify="required"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">别名</label>
|
||||
<div class="layui-input-block"><input type="text" name="alias" value="{$category.alias|default=''}" class="layui-input" lay-verify="required"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block"><input type="text" name="description" value="{$category.description|default=''}" class="layui-input"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">封面</label>
|
||||
<div class="layui-input-block"><input type="text" name="cover" value="{$category.cover|default=''}" class="layui-input"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-inline"><input type="number" name="sort" value="{$category.sort|default=0}" class="layui-input"></div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="status" value="1" {if isset($category) && $category.status}checked{/if} title="启用" lay-skin="switch">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<a href="{:url('articles/backend.category/index')}" class="layui-btn layui-btn-primary">返回</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
var form = layui.form, $ = layui.jquery;
|
||||
form.on('submit(save)', function (data) {
|
||||
$.post("{:url('articles/backend.category/update')}", data.field, function (r) {
|
||||
layer.msg(r.msg); if (r.code) { setTimeout(function () { location.href = r.url; }, 800); }
|
||||
}, 'json');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,96 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">分类管理</div>
|
||||
<div class="layui-card-body">
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 表格顶部工具条 -->
|
||||
<script type="text/html" id="toolbar">
|
||||
<div class="layui-btn-group">
|
||||
<a
|
||||
class="layui-btn layui-btn-sm layui-btn-primary"
|
||||
title="新建分类"
|
||||
lay-event="create"
|
||||
data-perm="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 表格数据工具条 -->
|
||||
<script type="text/html" id="action">
|
||||
<div class="layui-btn-group">
|
||||
<a
|
||||
class="layui-btn layui-btn-sm layui-btn-primary"
|
||||
title="编辑分类"
|
||||
lay-event="edit"
|
||||
data-perm="edit"
|
||||
><i class="layui-icon layui-icon-edit"></i>
|
||||
</a>
|
||||
{{# if(d.id > 1) { }}
|
||||
<a
|
||||
class="layui-btn layui-btn-sm layui-btn-primary"
|
||||
title="删除分类"
|
||||
lay-event="delete"
|
||||
data-perm="delete"
|
||||
><i class="layui-icon layui-icon-delete"></i>
|
||||
</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 数据状态 -->
|
||||
<script type="text/html" id="statusTpl">
|
||||
{{# if(d.status == 1) { }}
|
||||
<span class="layui-badge layui-bg-green">启用</span>
|
||||
{{# } else { }}
|
||||
<span class="layui-badge layui-bg-orange">禁用</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 添加/编辑数据表单 -->
|
||||
<script type="text/html" id="dataFormTpl">
|
||||
<form class="layui-form layui-form-pane" lay-filter="category-form" id="category-form">
|
||||
<input type="hidden" name="id" value="{{d.id||''}}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input" value="{{d.name||''}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">别名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="alias" required lay-verify="required" placeholder="请输入分类别名(英文标识)" autocomplete="off" class="layui-input" value="{{d.alias||''}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="description" placeholder="请输入分类描述" class="layui-textarea">{{d.description||''}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" placeholder="数字越小越靠前" autocomplete="off" class="layui-input" value="{{d.sort||0}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="启用" {{ d.status==undefined || d.status==1 ? 'checked' : '' }}>
|
||||
<input type="radio" name="status" value="0" title="禁用" {{ d.status==0 ? 'checked' : '' }}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<button class="layui-btn" lay-submit lay-filter="category-form-submit" id="category-form-submit">提交</button>
|
||||
</div>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['category'], function () {});
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">评论管理</div>
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" lay-filter="search">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<select name="status">
|
||||
<option value="all">全部</option>
|
||||
<option value="1">已审核</option>
|
||||
<option value="0">待审核</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" name="keyword" placeholder="评论内容" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table class="layui-table" id="table" lay-filter="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="audit">审核</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['table', 'form'], function () {
|
||||
var table = layui.table, form = layui.form;
|
||||
var tableIns = table.render({
|
||||
elem: '#table',
|
||||
url: "{:url('articles/backend.comment/index')}",
|
||||
method: 'post',
|
||||
where: { status: 'all' },
|
||||
page: true,
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', width: 70 },
|
||||
{ field: 'nickname', title: '用户', width: 120 },
|
||||
{ field: 'article', title: '文章', minWidth: 160 },
|
||||
{ field: 'content', title: '内容', minWidth: 200 },
|
||||
{ field: 'status', title: '状态', width: 90, templet: function (d) { return d.status ? '已审核' : '待审'; } },
|
||||
{ field: 'create_at', title: '时间', width: 170 },
|
||||
{ title: '操作', width: 140, toolbar: '#toolbar' }
|
||||
]]
|
||||
});
|
||||
form.on('submit(search)', function (data) {
|
||||
tableIns.reload({ where: data.field, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
table.on('tool(table)', function (obj) {
|
||||
if (obj.event === 'audit') {
|
||||
$.post("{:url('articles/backend.comment/audit')}", { id: obj.data.id }, function (r) { layer.msg(r.msg); if (r.code) { obj.update({ status: '已审核' }); } });
|
||||
} else if (obj.event === 'del') {
|
||||
layer.confirm('确认删除该评论?', function () {
|
||||
$.post("{:url('articles/backend.comment/delete')}", { id: obj.data.id }, function (r) { layer.msg(r.msg); if (r.code) obj.del(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">编辑标签</div>
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" id="form">
|
||||
<input type="hidden" name="id" value="{$tag.id|default=0}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block"><input type="text" name="name" value="{$tag.name|default=''}" class="layui-input" lay-verify="required"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">别名</label>
|
||||
<div class="layui-input-block"><input type="text" name="alias" value="{$tag.alias|default=''}" class="layui-input"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block"><input type="text" name="description" value="{$tag.description|default=''}" class="layui-input"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<a href="{:url('articles/backend.tag/index')}" class="layui-btn layui-btn-primary">返回</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
var form = layui.form, $ = layui.jquery;
|
||||
form.on('submit(save)', function (data) {
|
||||
$.post("{:url('articles/backend.tag/update')}", data.field, function (r) {
|
||||
layer.msg(r.msg); if (r.code) { setTimeout(function () { location.href = r.url; }, 800); }
|
||||
}, 'json');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,43 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">标签管理 <a href="{:url('articles/backend.tag/save')}" class="layui-btn layui-btn-sm layui-btn-normal" style="float:right;margin-top:8px;">新建标签</a></div>
|
||||
<div class="layui-card-body">
|
||||
<table class="layui-table" id="table" lay-filter="table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['table'], function () {
|
||||
var table = layui.table;
|
||||
table.render({
|
||||
elem: '#table',
|
||||
url: "{:url('articles/backend.tag/index')}",
|
||||
method: 'post',
|
||||
page: false,
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', width: 70 },
|
||||
{ field: 'name', title: '名称', width: 150 },
|
||||
{ field: 'alias', title: '别名', width: 150 },
|
||||
{ field: 'description', title: '描述', minWidth: 180 },
|
||||
{ field: 'create_at', title: '创建时间', width: 170 },
|
||||
{ title: '操作', width: 140, toolbar: '#toolbar' }
|
||||
]]
|
||||
});
|
||||
table.on('tool(table)', function (obj) {
|
||||
if (obj.event === 'edit') { location.href = obj.data.edit_url; }
|
||||
else if (obj.event === 'del') {
|
||||
layer.confirm('确认删除该标签?', function () {
|
||||
$.post("{:url('articles/backend.tag/delete')}", { id: obj.data.id }, function (r) {
|
||||
layer.msg(r.msg); if (r.code) { obj.del(); }
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,190 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{$article.title} - 文章CMS</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/articles/css/main.css">
|
||||
</head>
|
||||
<body class="micronews">
|
||||
<div class="micronews-header-wrap">
|
||||
<div class="micronews-header w1000 layui-clear">
|
||||
<h1 class="logo">
|
||||
<a href="{:url('articles/index/index')}">
|
||||
<img src="/static/articles/img/LOGO.png" alt="logo">
|
||||
<span class="layui-hide">LOGO</span>
|
||||
</a>
|
||||
</h1>
|
||||
<p class="nav">
|
||||
<a href="{:url('articles/index/index')}" {eq name='nav_active' value='index'}class="active"{/eq}>最新</a>
|
||||
{volist name='categories' id='c'}
|
||||
<a href="{:url('articles/category/index', ['id'=>$c.id])}" {eq name='nav_active' value='$c.id'}class="active"{/eq}>{$c.name}</a>
|
||||
{/volist}
|
||||
</p>
|
||||
<div class="search-bar">
|
||||
<form class="layui-form" action="{:url('articles/search/index')}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keyword" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
|
||||
<button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
|
||||
</div>
|
||||
</div>-
|
||||
</form>
|
||||
</div>
|
||||
<div class="login">
|
||||
{if $is_login}
|
||||
<a href="{:url('member/index/index')}"><img src="{:isset($member['avatar']) && $member['avatar'] ? $member['avatar'] : '/static/articles/img/header.png'}" style="width: 36px; height: 36px;"></a>
|
||||
{else/}
|
||||
<a href="{:url('member/login/index')}">登录</a>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="menu-icon">
|
||||
<i class="layui-icon layui-icon-more-vertical"></i>
|
||||
</div>
|
||||
<div class="mobile-nav">
|
||||
<ul class="layui-nav" lay-filter="">
|
||||
<li class="layui-nav-item {eq name='nav_active' value='index'}layui-this{/eq}"><a href="{:url('articles/index/index')}">最新</a></li>
|
||||
{volist name='categories' id='c'}
|
||||
<li class="layui-nav-item {eq name='nav_active' value='$c.id'}layui-this{/eq}"><a href="{:url('articles/category/index', ['id'=>$c.id])}">{$c.name}</a></li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-container micronews-details-container w1000">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md8">
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<h3>{$article.title}</h3>
|
||||
<div class="b-txt">
|
||||
<span class="label">{$article.category_name|default='未分类'}</span>
|
||||
<span class="icon">
|
||||
<i class="layui-icon layui-icon-radio"></i>
|
||||
<b>{$article.view_count}</b>人
|
||||
</span>
|
||||
<a href="#message">
|
||||
<span class="icon message">
|
||||
<i class="layui-icon layui-icon-dialogue"></i>
|
||||
<b>{$article.comment_count}</b>条
|
||||
</span>
|
||||
</a>
|
||||
<span class="icon time">
|
||||
<i class="layui-icon layui-icon-log"></i>
|
||||
{$article.create_at}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="article">
|
||||
{$article.content|raw}
|
||||
</div>
|
||||
<div class="leave-message" id="message">
|
||||
<div class="tit-box">
|
||||
<span class="tit">网友跟帖</span>
|
||||
<span class="num"><b>{$article.comment_count}</b>条</span>
|
||||
</div>
|
||||
<div class="content-box">
|
||||
<div class="tear-box">
|
||||
<a href="#"><img src="/static/articles/img/header_img1.png"></a>
|
||||
<form class="layui-form">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<div class="layui-input-block">
|
||||
<textarea id="onInput" placeholder="请输入内容" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block" style="text-align: right;">
|
||||
<div class="message-text">
|
||||
<div class="txt"></div>
|
||||
</div>
|
||||
<button type="button" class="layui-btn micronews-details-Publish">发表</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="ulCommentList">
|
||||
{volist name='comments.data' id='cm'}
|
||||
<div class="liCont">
|
||||
<a href="#"><img src="/static/articles/img/header_img1.png"></a>
|
||||
<div class="item-cont">
|
||||
<div class="cont">
|
||||
<p><span class="name">{$cm.nickname|default='游客'}</span><span class="time">{$cm.create_at}</span></p>
|
||||
<p class="text">{$cm.content}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
<div class="page-wrap">{$comments.render|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="popular-info popular-info-tog">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<h3>资讯推荐</h3>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="list-box">
|
||||
{volist name='related' id='r'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$r.id])}">{$r.title}</a>
|
||||
</li>
|
||||
{/volist}
|
||||
{volist name='hot' id='h'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$h.id])}">{$h.title}</a>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-footer-wrap">
|
||||
<div class="micronews-footer w1000">
|
||||
<div class="ft-nav">
|
||||
<a href="#">关于我们</a>
|
||||
<a href="#">合作伙伴</a>
|
||||
<a href="#">广告服务</a>
|
||||
<a href="#">常见问题</a>
|
||||
</div>
|
||||
<div class="Copyright">
|
||||
<span>Copyright </span> ©<span>文章CMS </span><span>Powered by YwxApp</span>
|
||||
</div>
|
||||
<div class="f-icon">
|
||||
<a href="#" class="w-icon">
|
||||
<img src="/static/articles/img/wechat_ic.png">
|
||||
</a>
|
||||
<a href="#" class="wb-icon">
|
||||
<img src="/static/articles/img/qq_ic.png">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/assets/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/assets/ywxapp/ywxapp.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: '/assets/layui/js/'
|
||||
}).use('index', function () {
|
||||
var index = layui.index;
|
||||
index.EnterMessage();
|
||||
index.seachBtn();
|
||||
index.onInput();
|
||||
index.arrowutil();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{$category.name|default='分类'} - 文章CMS</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/articles/css/main.css">
|
||||
</head>
|
||||
<body class="micronews">
|
||||
<div class="micronews-header-wrap">
|
||||
<div class="micronews-header w1000 layui-clear">
|
||||
<h1 class="logo">
|
||||
<a href="{:url('articles/index/index')}">
|
||||
<img src="/static/articles/img/LOGO.png" alt="logo">
|
||||
<span class="layui-hide">LOGO</span>
|
||||
</a>
|
||||
</h1>
|
||||
<p class="nav">
|
||||
<a href="{:url('articles/index/index')}" {eq name='nav_active' value='index'}class="active"{/eq}>最新</a>
|
||||
{volist name='categories' id='c'}
|
||||
<a href="{:url('articles/category/index', ['id'=>$c.id])}" {eq name='nav_active' value='$c.id'}class="active"{/eq}>{$c.name}</a>
|
||||
{/volist}
|
||||
</p>
|
||||
<div class="search-bar">
|
||||
<form class="layui-form" action="{:url('articles/search/index')}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keyword" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
|
||||
<button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="login">
|
||||
{if $is_login}
|
||||
<a href="{:url('member/index/index')}"><img src="{:isset($member['avatar']) && $member['avatar'] ? $member['avatar'] : '/static/articles/img/header.png'}" style="width: 36px; height: 36px;"></a>
|
||||
{else/}
|
||||
<a href="{:url('member/login/index')}">登录</a>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="menu-icon">
|
||||
<i class="layui-icon layui-icon-more-vertical"></i>
|
||||
</div>
|
||||
<div class="mobile-nav">
|
||||
<ul class="layui-nav" lay-filter="">
|
||||
<li class="layui-nav-item {eq name='nav_active' value='index'}layui-this{/eq}"><a href="{:url('articles/index/index')}">最新</a></li>
|
||||
{volist name='categories' id='c'}
|
||||
<li class="layui-nav-item {eq name='nav_active' value='$c.id'}layui-this{/eq}"><a href="{:url('articles/category/index', ['id'=>$c.id])}">{$c.name}</a></li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-container w1000">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md8">
|
||||
<div class="main">
|
||||
<div class="list-item" id="LAY_demo2">
|
||||
{volist name='list' id='vo'}
|
||||
<div class="item">
|
||||
{if isset($vo['cover_image']) && $vo['cover_image']}
|
||||
<a href="{:url('articles/Article/read', ['id'=>$vo.id])}">
|
||||
<img src="{$vo.cover_image}">
|
||||
</a>
|
||||
{/if}
|
||||
<div class="item-info">
|
||||
<h4><a href="{:url('articles/Article/read', ['id'=>$vo.id])}">{$vo.title}</a></h4>
|
||||
<div class="b-txt">
|
||||
<span class="label">{$vo.category_name|default='未分类'}</span>
|
||||
<span class="icon message">
|
||||
<i class="layui-icon layui-icon-dialogue"></i>
|
||||
{$vo.comment_count|default=0}条
|
||||
</span>
|
||||
<span class="icon time">
|
||||
<i class="layui-icon layui-icon-log"></i>
|
||||
{$vo.create_at}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
<div class="page-wrap">{$page|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="popular-info">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<h3>热门资讯</h3>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="list-box">
|
||||
{volist name='hot' id='h'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$h.id])}">{$h.title}</a><i class="heat-icon"></i>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-footer-wrap">
|
||||
<div class="micronews-footer w1000">
|
||||
<div class="ft-nav">
|
||||
<a href="#">关于我们</a>
|
||||
<a href="#">合作伙伴</a>
|
||||
<a href="#">广告服务</a>
|
||||
<a href="#">常见问题</a>
|
||||
</div>
|
||||
<div class="Copyright">
|
||||
<span>Copyright </span> ©<span>文章CMS </span><span>Powered by YwxApp</span>
|
||||
</div>
|
||||
<div class="f-icon">
|
||||
<a href="#" class="w-icon">
|
||||
<img src="/static/articles/img/wechat_ic.png">
|
||||
</a>
|
||||
<a href="#" class="wb-icon">
|
||||
<img src="/static/articles/img/qq_ic.png">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/assets/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/assets/ywxapp/ywxapp.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: '/assets/layui/js/'
|
||||
}).use('index', function () {
|
||||
var index = layui.index;
|
||||
index.seachBtn();
|
||||
index.arrowutil();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,159 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>文章CMS - 资讯中心</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/articles/css/main.css">
|
||||
</head>
|
||||
<body class="micronews">
|
||||
<div class="micronews-header-wrap">
|
||||
<div class="micronews-header w1000 layui-clear">
|
||||
<h1 class="logo">
|
||||
<a href="{:url('articles/index/index')}">
|
||||
<img src="/static/articles/img/LOGO.png" alt="logo">
|
||||
<span class="layui-hide">LOGO</span>
|
||||
</a>
|
||||
</h1>
|
||||
<p class="nav">
|
||||
<a href="{:url('articles/index/index')}" {eq name='nav_active' value='index'}class="active"{/eq}>最新</a>
|
||||
{volist name='categories' id='c'}
|
||||
<a href="{:url('articles/category/index', ['id'=>$c.id])}" {eq name='nav_active' value='$c.id'}class="active"{/eq}>{$c.name}</a>
|
||||
{/volist}
|
||||
</p>
|
||||
<div class="search-bar">
|
||||
<form class="layui-form" action="{:url('articles/search/index')}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keyword" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
|
||||
<button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="login">
|
||||
{if $is_login}
|
||||
<a href="{:url('member/index/index')}"><img src="{:isset($member['avatar']) && $member['avatar'] ? $member['avatar'] : '/static/articles/img/header.png'}" style="width: 36px; height: 36px;"></a>
|
||||
{else/}
|
||||
<a href="{:url('member/login/index')}">登录</a>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="menu-icon">
|
||||
<i class="layui-icon layui-icon-more-vertical"></i>
|
||||
</div>
|
||||
<div class="mobile-nav">
|
||||
<ul class="layui-nav" lay-filter="">
|
||||
<li class="layui-nav-item {eq name='nav_active' value='index'}layui-this{/eq}"><a href="{:url('articles/index/index')}">最新</a></li>
|
||||
{volist name='categories' id='c'}
|
||||
<li class="layui-nav-item {eq name='nav_active' value='$c.id'}layui-this{/eq}"><a href="{:url('articles/category/index', ['id'=>$c.id])}">{$c.name}</a></li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-fluid micronews-banner w1000">
|
||||
<div class="layui-carousel imgbox" id="micronews-carouse">
|
||||
<div carousel-item>
|
||||
{volist name='slides' id='s'}
|
||||
<div>
|
||||
<p class="title">{$s.title}</p>
|
||||
<a href="{:url('articles/Article/read', ['id'=>$s.id])}"><img src="{$s.cover_image}"></a>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-container w1000">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md8">
|
||||
<div class="main">
|
||||
<div class="list-item" id="LAY_demo2">
|
||||
{volist name='list' id='vo'}
|
||||
<div class="item">
|
||||
{if isset($vo['cover_image']) && $vo['cover_image']}
|
||||
<a href="{:url('articles/Article/read', ['id'=>$vo.id])}">
|
||||
<img src="{$vo.cover_image}">
|
||||
</a>
|
||||
{/if}
|
||||
<div class="item-info">
|
||||
<h4><a href="{:url('articles/Article/read', ['id'=>$vo.id])}">{$vo.title}</a></h4>
|
||||
<div class="b-txt">
|
||||
<span class="label">{$vo.category_name|default='未分类'}</span>
|
||||
<span class="icon message">
|
||||
<i class="layui-icon layui-icon-dialogue"></i>
|
||||
{$vo.comment_count|default=0}条
|
||||
</span>
|
||||
<span class="icon time">
|
||||
<i class="layui-icon layui-icon-log"></i>
|
||||
{$vo.create_at}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
<div class="page-wrap">{$page|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="popular-info">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<h3>热门资讯</h3>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="list-box">
|
||||
{volist name='hot' id='h'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$h.id])}">{$h.title}</a><i class="heat-icon"></i>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-footer-wrap">
|
||||
<div class="micronews-footer w1000">
|
||||
<div class="ft-nav">
|
||||
<a href="#">关于我们</a>
|
||||
<a href="#">合作伙伴</a>
|
||||
<a href="#">广告服务</a>
|
||||
<a href="#">常见问题</a>
|
||||
</div>
|
||||
<div class="Copyright">
|
||||
<span>Copyright </span> ©<span>文章CMS </span><span>Powered by YwxApp</span>
|
||||
</div>
|
||||
<div class="f-icon">
|
||||
<a href="#" class="w-icon">
|
||||
<img src="/static/articles/img/wechat_ic.png">
|
||||
</a>
|
||||
<a href="#" class="wb-icon">
|
||||
<img src="/static/articles/img/qq_ic.png">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/assets/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/assets/ywxapp/ywxapp.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: '/assets/layui/js/'
|
||||
}).use('index', function () {
|
||||
var index = layui.index;
|
||||
index.banner();
|
||||
index.seachBtn();
|
||||
index.arrowutil();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,146 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>搜索:{$keyword|default=''} - 文章CMS</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/articles/css/main.css">
|
||||
</head>
|
||||
<body class="micronews">
|
||||
<div class="micronews-header-wrap">
|
||||
<div class="micronews-header w1000 layui-clear">
|
||||
<h1 class="logo">
|
||||
<a href="{:url('articles/index/index')}">
|
||||
<img src="/static/articles/img/LOGO.png" alt="logo">
|
||||
<span class="layui-hide">LOGO</span>
|
||||
</a>
|
||||
</h1>
|
||||
<p class="nav">
|
||||
<a href="{:url('articles/index/index')}" {eq name='nav_active' value='index'}class="active"{/eq}>最新</a>
|
||||
{volist name='categories' id='c'}
|
||||
<a href="{:url('articles/category/index', ['id'=>$c.id])}" {eq name='nav_active' value='$c.id'}class="active"{/eq}>{$c.name}</a>
|
||||
{/volist}
|
||||
</p>
|
||||
<div class="search-bar">
|
||||
<form class="layui-form" action="{:url('articles/search/index')}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keyword" value="{$keyword|default=''}" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
|
||||
<button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="login">
|
||||
{if $is_login}
|
||||
<a href="{:url('member/index/index')}"><img src="{:isset($member['avatar']) && $member['avatar'] ? $member['avatar'] : '/static/articles/img/header.png'}" style="width: 36px; height: 36px;"></a>
|
||||
{else/}
|
||||
<a href="{:url('member/index/login')}">登录</a>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="menu-icon">
|
||||
<i class="layui-icon layui-icon-more-vertical"></i>
|
||||
</div>
|
||||
<div class="mobile-nav">
|
||||
<ul class="layui-nav" lay-filter="">
|
||||
<li class="layui-nav-item {eq name='nav_active' value='index'}layui-this{/eq}"><a href="{:url('articles/index/index')}">最新</a></li>
|
||||
{volist name='categories' id='c'}
|
||||
<li class="layui-nav-item {eq name='nav_active' value='$c.id'}layui-this{/eq}"><a href="{:url('articles/category/index', ['id'=>$c.id])}">{$c.name}</a></li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-container w1000">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md8">
|
||||
<div class="main micronews-search-container">
|
||||
<h3>“{$keyword|default=''}” 共有 <b>{$total|default=0}</b> 条搜索结果</h3>
|
||||
<div class="list-item" id="LAY_demo2">
|
||||
{volist name='list' id='vo'}
|
||||
<div class="item">
|
||||
{if isset($vo['cover_image']) && $vo['cover_image']}
|
||||
<a href="{:url('articles/Article/read', ['id'=>$vo.id])}">
|
||||
<img src="{$vo.cover_image}">
|
||||
</a>
|
||||
{/if}
|
||||
<div class="item-info">
|
||||
<h4><a href="{:url('articles/Article/read', ['id'=>$vo.id])}">{$vo.title}</a></h4>
|
||||
<div class="b-txt">
|
||||
<span class="label">{$vo.category_name|default='未分类'}</span>
|
||||
<span class="icon message">
|
||||
<i class="layui-icon layui-icon-dialogue"></i>
|
||||
{$vo.comment_count|default=0}条
|
||||
</span>
|
||||
<span class="icon time">
|
||||
<i class="layui-icon layui-icon-log"></i>
|
||||
{$vo.create_at}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
<div class="page-wrap">{$page|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="popular-info">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<h3>热门资讯</h3>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="list-box">
|
||||
{volist name='hot' id='h'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$h.id])}">{$h.title}</a><i class="heat-icon"></i>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-footer-wrap">
|
||||
<div class="micronews-footer w1000">
|
||||
<div class="ft-nav">
|
||||
<a href="#">关于我们</a>
|
||||
<a href="#">合作伙伴</a>
|
||||
<a href="#">广告服务</a>
|
||||
<a href="#">常见问题</a>
|
||||
</div>
|
||||
<div class="Copyright">
|
||||
<span>Copyright </span> ©<span>文章CMS </span><span>Powered by YwxApp</span>
|
||||
</div>
|
||||
<div class="f-icon">
|
||||
<a href="#" class="w-icon">
|
||||
<img src="/static/articles/img/wechat_ic.png">
|
||||
</a>
|
||||
<a href="#" class="wb-icon">
|
||||
<img src="/static/articles/img/qq_ic.png">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/assets/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/assets/ywxapp/ywxapp.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: '/assets/layui/js/'
|
||||
}).use('index', function () {
|
||||
var index = layui.index;
|
||||
index.seachBtn();
|
||||
index.arrowutil();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{$tag.name|default='标签'} - 文章CMS</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/articles/css/main.css">
|
||||
</head>
|
||||
<body class="micronews">
|
||||
<div class="micronews-header-wrap">
|
||||
<div class="micronews-header w1000 layui-clear">
|
||||
<h1 class="logo">
|
||||
<a href="{:url('articles/index/index')}">
|
||||
<img src="/static/articles/img/LOGO.png" alt="logo">
|
||||
<span class="layui-hide">LOGO</span>
|
||||
</a>
|
||||
</h1>
|
||||
<p class="nav">
|
||||
<a href="{:url('articles/index/index')}" {eq name='nav_active' value='index'}class="active"{/eq}>最新</a>
|
||||
{volist name='categories' id='c'}
|
||||
<a href="{:url('articles/category/index', ['id'=>$c.id])}" {eq name='nav_active' value='$c.id'}class="active"{/eq}>{$c.name}</a>
|
||||
{/volist}
|
||||
</p>
|
||||
<div class="search-bar">
|
||||
<form class="layui-form" action="{:url('articles/search/index')}">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="keyword" placeholder="搜索你要的内容" autocomplete="off" class="layui-input">
|
||||
<button class="layui-btn search-btn" formnovalidate><i class="layui-icon layui-icon-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="login">g
|
||||
{if $is_login}
|
||||
<a href="{:url('member/index/index')}"><img src="{:isset($member['avatar']) && $member['avatar'] ? $member['avatar'] : '/static/articles/img/header.png'}" style="width: 36px; height: 36px;"></a>
|
||||
{else/}
|
||||
<a href="{:url('member/login/index')}">登录</a>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="menu-icon">
|
||||
<i class="layui-icon layui-icon-more-vertical"></i>
|
||||
</div>
|
||||
<div class="mobile-nav">
|
||||
<ul class="layui-nav" lay-filter="">
|
||||
<li class="layui-nav-item {eq name='nav_active' value='index'}layui-this{/eq}"><a href="{:url('articles/index/index')}">最新</a></li>
|
||||
{volist name='categories' id='c'}
|
||||
<li class="layui-nav-item {eq name='nav_active' value='$c.id'}layui-this{/eq}"><a href="{:url('articles/category/index', ['id'=>$c.id])}">{$c.name}</a></li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-container w1000">
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md8">
|
||||
<div class="main">
|
||||
<div class="list-item" id="LAY_demo2">
|
||||
{volist name='list' id='vo'}
|
||||
<div class="item">
|
||||
{if isset($vo['cover_image']) && $vo['cover_image']}
|
||||
<a href="{:url('articles/Article/read', ['id'=>$vo.id])}">
|
||||
<img src="{$vo.cover_image}">
|
||||
</a>
|
||||
{/if}
|
||||
<div class="item-info">
|
||||
<h4><a href="{:url('articles/Article/read', ['id'=>$vo.id])}">{$vo.title}</a></h4>
|
||||
<div class="b-txt">
|
||||
<span class="label">{$vo.category_name|default='未分类'}</span>
|
||||
<span class="icon message">
|
||||
<i class="layui-icon layui-icon-dialogue"></i>
|
||||
{$vo.comment_count|default=0}条
|
||||
</span>
|
||||
<span class="icon time">
|
||||
<i class="layui-icon layui-icon-log"></i>
|
||||
{$vo.create_at}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
<div class="page-wrap">{$page|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="popular-info">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<h3>热门资讯</h3>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<ul class="list-box">
|
||||
{volist name='hot' id='h'}
|
||||
<li class="list">
|
||||
<a href="{:url('articles/Article/read', ['id'=>$h.id])}">{$h.title}</a><i class="heat-icon"></i>
|
||||
</li>
|
||||
{/volist}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="micronews-footer-wrap">
|
||||
<div class="micronews-footer w1000">
|
||||
<div class="ft-nav">
|
||||
<a href="#">关于我们</a>
|
||||
<a href="#">合作伙伴</a>
|
||||
<a href="#">广告服务</a>
|
||||
<a href="#">常见问题</a>
|
||||
</div>
|
||||
<div class="Copyright">
|
||||
<span>Copyright </span> ©<span>文章CMS </span><span>Powered by YwxApp</span>
|
||||
</div>
|
||||
<div class="f-icon">
|
||||
<a href="#" class="w-icon">
|
||||
<img src="/static/articles/img/wechat_ic.png">
|
||||
</a>
|
||||
<a href="#" class="wb-icon">
|
||||
<img src="/static/articles/img/qq_ic.png">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/assets/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/assets/ywxapp/ywxapp.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: '/assets/layui/js/'
|
||||
}).use('index', function () {
|
||||
var index = layui.index;
|
||||
index.seachBtn();
|
||||
index.arrowutil();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user