mirror of https://github.com/1099438829/apeblog
更新主题读取和支持page单独访问
This commit is contained in:
parent
8e185ca1a9
commit
bc41c2430d
|
|
@ -152,8 +152,8 @@ if (!function_exists('get_tree_list')) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('get_theme_list')) {
|
if (!function_exists('get_template_list')) {
|
||||||
function get_theme_list($type = ''): array
|
function get_template_list($type = ''): array
|
||||||
{
|
{
|
||||||
$themeList = [];
|
$themeList = [];
|
||||||
$themeDir = public_path('template') . system_config('web_template') . '/pc/' . $type;
|
$themeDir = public_path('template') . system_config('web_template') . '/pc/' . $type;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Page extends AuthController
|
||||||
['is_recommend', 0],
|
['is_recommend', 0],
|
||||||
['is_top', 0],
|
['is_top', 0],
|
||||||
['is_hot', 0],
|
['is_hot', 0],
|
||||||
['theme', ''],
|
['template', ''],
|
||||||
['link_str', ''],
|
['link_str', ''],
|
||||||
['cover_path', ''],
|
['cover_path', ''],
|
||||||
['display', 1],
|
['display', 1],
|
||||||
|
|
@ -98,7 +98,7 @@ class Page extends AuthController
|
||||||
['uid', $this->adminId],
|
['uid', $this->adminId],
|
||||||
]);
|
]);
|
||||||
if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
|
if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
|
||||||
if ($data['theme'] == "") return app("json")->fail("文章模板不能为空");
|
if ($data['template'] == "") return app("json")->fail("文章模板不能为空");
|
||||||
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
|
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
|
||||||
$model = new Document();
|
$model = new Document();
|
||||||
$res = $model->updateInfo($data, Data::DOCUMENT_TYPE_PAGE);
|
$res = $model->updateInfo($data, Data::DOCUMENT_TYPE_PAGE);
|
||||||
|
|
@ -130,21 +130,18 @@ class Page extends AuthController
|
||||||
* @author 木子的忧伤
|
* @author 木子的忧伤
|
||||||
* @date 2021-03-10 14:46
|
* @date 2021-03-10 14:46
|
||||||
*/
|
*/
|
||||||
public function add()
|
public function add(): string
|
||||||
{
|
{
|
||||||
// 获取页面模板列表
|
// 获取页面模板列表
|
||||||
$this->getThemeList();
|
$templateList = get_template_list(Data::DOCUMENT_TYPE_PAGE);
|
||||||
$themeList = get_theme_list(Data::DOCUMENT_TYPE_PAGE);
|
$this->assign("template_list", $templateList);
|
||||||
$this->assign("theme_list", $themeList);
|
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑页
|
* 编辑页
|
||||||
* @return string|void
|
* @return string|void
|
||||||
* @throws DataNotFoundException
|
* @throws \Exception
|
||||||
* @throws DbException
|
|
||||||
* @throws ModelNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
|
|
@ -159,8 +156,8 @@ class Page extends AuthController
|
||||||
$this->error('数据不存在');
|
$this->error('数据不存在');
|
||||||
}
|
}
|
||||||
// 获取页面模板列表
|
// 获取页面模板列表
|
||||||
$themeList = get_theme_list(Data::DOCUMENT_TYPE_PAGE);
|
$templateList = get_template_list(Data::DOCUMENT_TYPE_PAGE);
|
||||||
$this->assign("theme_list", $themeList);
|
$this->assign("template_list", $templateList);
|
||||||
$this->assign("info", $info);
|
$this->assign("info", $info);
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@
|
||||||
<div class="col-xs-4">
|
<div class="col-xs-4">
|
||||||
<label>展示模板</label>
|
<label>展示模板</label>
|
||||||
<div class="form-group form-controls">
|
<div class="form-group form-controls">
|
||||||
<select name="theme" id="theme" class="form-control">
|
<select name="template" id="template" class="form-control">
|
||||||
<option value="0">请选择</option>
|
<option value="0">请选择</option>
|
||||||
{volist name="theme_list" id="vo"}
|
{volist name="template_list" id="vo"}
|
||||||
<option value="{$vo}">{$vo}</option>
|
<option value="{$vo}">{$vo}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@
|
||||||
<div class="col-xs-4">
|
<div class="col-xs-4">
|
||||||
<label>展示模板</label>
|
<label>展示模板</label>
|
||||||
<div class="form-group form-controls">
|
<div class="form-group form-controls">
|
||||||
<select name="theme" id="theme" class="form-control">
|
<select name="template" id="template" class="form-control">
|
||||||
<option value="0">请选择</option>
|
<option value="0">请选择</option>
|
||||||
{volist name="theme_list" id="vo"}
|
{volist name="template_list" id="vo"}
|
||||||
<option value="{$vo}" {if $vo == $info.theme}selected{/if}>{$vo}</option>
|
<option value="{$vo}" {if $vo == $info.template}selected{/if}>{$vo}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,15 @@ class Index extends Base
|
||||||
$article['position'] = '<a href="/">首页</a><span>></span>';
|
$article['position'] = '<a href="/">首页</a><span>></span>';
|
||||||
//更新浏览次数
|
//更新浏览次数
|
||||||
$documentModel->where('id', $article['id'])->inc('view')->update();
|
$documentModel->where('id', $article['id'])->inc('view')->update();
|
||||||
$template = Data::DOCUMENT_TYPE_PAGE . '/' . ($article['theme'] ?: 'detail.html');
|
$template = Data::DOCUMENT_TYPE_PAGE . '/' . ($article['template'] ?: 'index.html');
|
||||||
$templateFile = config('view.view_path') . $template;
|
$templateFile = config('view.view_path') . $template;
|
||||||
if (!is_file($templateFile)) {
|
if (!is_file($templateFile)) {
|
||||||
$this->error('模板文件不存在!');
|
//配置的模版文件不存在则走默认模版
|
||||||
|
$template = Data::DOCUMENT_TYPE_PAGE . '/' . 'index.html';
|
||||||
|
$templateFile = config('view.view_path') . $template;
|
||||||
|
if (!is_file($templateFile)){
|
||||||
|
$this->error('模板文件不存在!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$article['category_title'] = "单页";
|
$article['category_title'] = "单页";
|
||||||
//判断SEO 为空则取系统
|
//判断SEO 为空则取系统
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,6 @@ Route::get('think', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('hello/:name', 'index/hello');
|
Route::get('hello/:name', 'index/hello');
|
||||||
Route::rule('/sitemap.xml', 'index/sitemap');
|
Route::rule('/sitemap.xml', 'index/sitemap');
|
||||||
|
//单页面访问
|
||||||
|
Route::get('page/:id', 'page/index');
|
||||||
|
|
@ -334,7 +334,7 @@ CREATE TABLE `ape_document` (
|
||||||
`category_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属分类',
|
`category_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '所属分类',
|
||||||
`cover_path` varchar(255) NOT NULL DEFAULT '' COMMENT '封面',
|
`cover_path` varchar(255) NOT NULL DEFAULT '' COMMENT '封面',
|
||||||
`type` varchar(50) NOT NULL DEFAULT 'article' COMMENT '内容类型',
|
`type` varchar(50) NOT NULL DEFAULT 'article' COMMENT '内容类型',
|
||||||
`theme` varchar(40) NOT NULL DEFAULT '' COMMENT '主题模板',
|
`template` varchar(40) NOT NULL DEFAULT '' COMMENT '主题模板',
|
||||||
`is_recommend` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否推荐',
|
`is_recommend` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否推荐',
|
||||||
`is_top` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否置顶',
|
`is_top` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否置顶',
|
||||||
`is_hot` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否热门',
|
`is_hot` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否热门',
|
||||||
|
|
@ -362,7 +362,7 @@ CREATE TABLE `ape_document` (
|
||||||
-- Records of ape_document
|
-- Records of ape_document
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO `ape_document` (`id`, `alias`, `uid`, `author`, `title`, `category_id`, `cover_path`, `type`, `theme`, `is_recommend`, `is_top`, `is_hot`, `link_str`, `is_jump`, `display`, `view`, `tags`, `abstract`, `keywords`, `description`, `sort`, `create_date`, `create_time`, `update_time`, `status`, `password`) VALUES (1, 'about', 1, '超级管理员', '关于博客', 0, '/storage/image/20220710/a5059baa808c46f83674cb5dbcae8dc5.png', 'page', 'article.html', 0, 0, 0, '', 0, 1, 570, '源码云', '关于源码云博客', '关于小站,源码云,源码云博客,关于源码云博客', '关于源码云博客', 99, '2022-07-10', 1657464428, 1657464428, 1, '');
|
INSERT INTO `ape_document` (`id`, `alias`, `uid`, `author`, `title`, `category_id`, `cover_path`, `type`, `template`, `is_recommend`, `is_top`, `is_hot`, `link_str`, `is_jump`, `display`, `view`, `tags`, `abstract`, `keywords`, `description`, `sort`, `create_date`, `create_time`, `update_time`, `status`, `password`) VALUES (1, 'about', 1, '超级管理员', '关于博客', 0, '/storage/image/20220710/a5059baa808c46f83674cb5dbcae8dc5.png', 'page', 'article.html', 0, 0, 0, '', 0, 1, 570, '源码云', '关于源码云博客', '关于小站,源码云,源码云博客,关于源码云博客', '关于源码云博客', 99, '2022-07-10', 1657464428, 1657464428, 1, '');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue