mirror of https://github.com/1099438829/apeblog
增加主题修改
This commit is contained in:
parent
328c4f2186
commit
83671b171a
|
|
@ -19,6 +19,11 @@ use think\facade\Route as Url;
|
|||
*/
|
||||
class Category extends AuthController
|
||||
{
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->model = new aModel();
|
||||
}
|
||||
/**
|
||||
* 分类
|
||||
* @return string
|
||||
|
|
@ -57,31 +62,25 @@ class Category extends AuthController
|
|||
{
|
||||
$data = Util::postMore([
|
||||
['title',''],
|
||||
['en_title',''],
|
||||
['pid',0],
|
||||
['title_en',''],
|
||||
['module',''],
|
||||
['controller',''],
|
||||
['action',''],
|
||||
['params',''],
|
||||
['rank',0],
|
||||
['is_menu',1],
|
||||
['status',1]
|
||||
['type',''],
|
||||
['sort',''],
|
||||
['meta_title',''],
|
||||
['keywords',''],
|
||||
['description',0],
|
||||
['link_str',1],
|
||||
['display',1]
|
||||
]);
|
||||
if ($data['name'] == "") return app("json")->fail("权限名称不能为空");
|
||||
if ($data['pid'] == "") return app("json")->fail("上级归属不能为空");
|
||||
if ($data['module'] == "") return app("json")->fail("模块名不能为空");
|
||||
if ($data['controller'] == "") return app("json")->fail("控制器名不能为空");
|
||||
if ($data['action'] == "") return app("json")->fail("方法名不能为空");
|
||||
$data['path'] = '/'.$data['module'].'/'.$data['controller'].'/'.$data['action'];
|
||||
if ($data['title'] == "") return app("json")->fail("分类名称不能为空");
|
||||
if ($id=="")
|
||||
{
|
||||
$data['create_user'] = $this->adminId;
|
||||
$data['create_time'] = time();
|
||||
$res = aModel::insert($data);
|
||||
$model = new aModel();
|
||||
$res = $model->save($data);
|
||||
}else
|
||||
{
|
||||
$data['update_user'] = $this->adminId;
|
||||
$data['update_time'] = time();
|
||||
$res = aModel::update($data,['id'=>$id]);
|
||||
}
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ class SystemConfig extends AuthController
|
|||
$data['update_time'] = time();
|
||||
$res = cModel::update($data,['id'=>$id]);
|
||||
}
|
||||
//修改完需要更新缓存
|
||||
cache('systemConfig',null);//清除缓存
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\SystemConfig as cModel;
|
||||
use app\Request;
|
||||
use app\admin\services\UtilService as Util;
|
||||
|
||||
/**
|
||||
* Class Theme
|
||||
* @package app\admin\controller\system
|
||||
* @author 李玉坤
|
||||
* @date 2021-02-15 23:20
|
||||
*/
|
||||
class Theme extends AuthController
|
||||
{
|
||||
/**
|
||||
* 主题列表
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @author 李玉坤
|
||||
* @date 2021-02-17 11:40
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$themeList = [];
|
||||
// 寻找有多少主题
|
||||
$themeDir = public_path('template/');
|
||||
$defaultTheme = system_config('web_template');
|
||||
if($dh = opendir($themeDir)){
|
||||
while (($file = readdir($dh)) !== false){
|
||||
if((is_dir($themeDir."/".$file)) && $file!="." && $file!=".."){
|
||||
$themeInfoFile = $themeDir."/".$file.'/info.json';
|
||||
if(!file_exists($themeInfoFile)){
|
||||
//主题信息不存在则跳过
|
||||
continue;
|
||||
}
|
||||
$info = json_decode(file_get_contents($themeInfoFile),true);
|
||||
unset($themeInfoFile);
|
||||
$info['root_dir'] = $themeDir."/".$file.'/';
|
||||
$info['dir_name'] = $file;
|
||||
$info['preview_file'] = file_cdn($themeDir."/".$file.'/'. $info['preview_file']);
|
||||
$info['is_default'] = $file == $defaultTheme?1:0;//检查是不是默认主题
|
||||
$themeList[] = $info;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
$this->assign("theme_list",$themeList);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新主题
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @author 李玉坤
|
||||
* @date 2021-02-17 11:40
|
||||
*/
|
||||
public function change_theme()
|
||||
{
|
||||
$data = Util::postMore([
|
||||
['value',''],
|
||||
]);
|
||||
if ($data['value'] == "") return app("json")->fail("主题不能为空");
|
||||
$res = cModel::update($data,['form_name'=>'web_template']);
|
||||
cache('systemConfig',null);//清除缓存
|
||||
return $res ? app("json")->success("操作成功",'code') : app("json")->fail("操作失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>基本样式</h4>
|
||||
<h4>添加文章</h4>
|
||||
<ul class="card-actions">
|
||||
<li>
|
||||
<button type="button" data-toggle="tooltip" title="" data-original-title="返回" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>添加文章 - {:system_config("title")}后台管理系统</title>
|
||||
<title>编辑文章 - {:system_config("title")}后台管理系统</title>
|
||||
{include file="public/header" /}
|
||||
<!--标签插件-->
|
||||
<link rel="stylesheet" href="__ADMIN_PATH__js/jquery-tags-input/jquery.tagsinput.min.css">
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>基本样式</h4>
|
||||
<h4>编辑文章</h4>
|
||||
<ul class="card-actions">
|
||||
<li>
|
||||
<button type="button" data-toggle="tooltip" title="" data-original-title="返回" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>基本样式</h4>
|
||||
<h4>添加分类</h4>
|
||||
<ul class="card-actions">
|
||||
<li>
|
||||
<button type="button" data-toggle="tooltip" title="" data-original-title="返回" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
<label for="pid">上级分类</label>
|
||||
<div class="form-controls">
|
||||
<select name="pid" id="pid" class="form-control">
|
||||
<option value="0">请选择</option>
|
||||
<option value="">请选择</option>
|
||||
{volist name="category" id="vo"}
|
||||
<option value="{$vo.id}" {notempty name="pid"}{if $vo.id == $pid}selected{/if}{/notempty}>{$vo.html}{$vo.title}</option>
|
||||
{/volist}
|
||||
|
|
@ -48,11 +48,11 @@
|
|||
<div class="form-group col-md-12">
|
||||
<label for="pid">属性</label>
|
||||
<div class="form-controls">
|
||||
<select name="pid" class="form-control">
|
||||
<option value="0">请选择</option>
|
||||
<option value="1">列表</option>
|
||||
<option value="2">单页</option>
|
||||
<option value="3">外联</option>
|
||||
<select name="type" class="form-control">
|
||||
<option value="">请选择</option>
|
||||
<option value="0">列表</option>
|
||||
<option value="1">单页</option>
|
||||
<option value="2">外联</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -177,6 +177,11 @@
|
|||
throw "分类名称不能为空";
|
||||
}
|
||||
break;
|
||||
case 'type':
|
||||
if (!item.value) {
|
||||
throw "请选择属性";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
lightyear.notify(error, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
|
|
@ -188,8 +193,8 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/article/index';},2000)}
|
||||
$.post(url="/admin/category/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/category/index';},2000)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>添加文章 - {:system_config("title")}后台管理系统</title>
|
||||
<title>修改分类 - {:system_config("title")}后台管理系统</title>
|
||||
{include file="public/header" /}
|
||||
<!--标签插件-->
|
||||
<link rel="stylesheet" href="__ADMIN_PATH__js/jquery-tags-input/jquery.tagsinput.min.css">
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>基本样式</h4>
|
||||
<h4>修改分类</h4>
|
||||
<ul class="card-actions">
|
||||
<li>
|
||||
<button type="button" data-toggle="tooltip" title="" data-original-title="返回" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||
|
|
@ -49,10 +49,9 @@
|
|||
<label>属性</label>
|
||||
<div class="form-controls">
|
||||
<select name="type" class="form-control">
|
||||
<option value="0" {if 0== $info.type}selected{/if}>请选择</option>
|
||||
<option value="1" {if 1== $info.type}selected{/if}>列表</option>
|
||||
<option value="2" {if 2== $info.type}selected{/if}>单页</option>
|
||||
<option value="3" {if 3== $info.type}selected{/if}>外联</option>
|
||||
<option value="0" {if 1== $info.type}selected{/if}>列表</option>
|
||||
<option value="1" {if 2== $info.type}selected{/if}>单页</option>
|
||||
<option value="2" {if 3== $info.type}selected{/if}>外联</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -177,6 +176,11 @@
|
|||
throw "分类名称不能为空";
|
||||
}
|
||||
break;
|
||||
case 'type':
|
||||
if (!item.value) {
|
||||
throw "请选择属性";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
lightyear.notify(error, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
|
|
@ -188,8 +192,8 @@
|
|||
if (!checkResult) {
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/article/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/article/index';},2000)}
|
||||
$.post(url="/admin/category/save",$('.add-form').serialize(),function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.href='/admin/category/index';},2000)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
btnClass: 'btn-primary',
|
||||
action: function(){
|
||||
$.post(url="/admin/category/del",data={"id":row.id},function (res) {
|
||||
if (res.status == 200) {parent.lightyear.notify('删除成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$(".tree-table").bootstrapTable('refresh');}
|
||||
if (res.status == 200) {parent.lightyear.notify('删除成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$("#tree-table").bootstrapTable('refresh');}
|
||||
else parent.lightyear.notify('删除失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@
|
|||
data: {field: field, value: newstate},
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
if (res.status == 200) {parent.lightyear.notify('修改成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$(".tree-table").bootstrapTable('refresh');}
|
||||
if (res.status == 200) {parent.lightyear.notify('修改成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$("#tree-table").bootstrapTable('refresh');}
|
||||
else parent.lightyear.notify('修改失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
},
|
||||
error: function () {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>主题管理 - {:system_config("title")}后台管理系统</title>
|
||||
{include file="public/header" /}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid p-t-15">
|
||||
<div class="row">
|
||||
{notempty name="theme_list"}
|
||||
{volist name="theme_list" id="vo"}
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-header"><h4>{$vo.title}</h4></div>
|
||||
<div class="card-body clearfix lyear-uploads-pic">
|
||||
<figure>
|
||||
<img src="{$vo.preview_file}" alt="{$vo.title}">
|
||||
<figcaption class="pic-tool">
|
||||
{if !$vo.is_default}
|
||||
<a class="btn btn-round btn-square btn-primary btn-set" data-value="{$vo.dir_name}" href="#!" title="启用"><i class="mdi mdi-settings"></i></a>
|
||||
{/if}
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/volist}
|
||||
{else /}
|
||||
<div class="col-md-12"><span>暂无主题</span></div>
|
||||
{/notempty}
|
||||
</div>
|
||||
</div>
|
||||
{include file="public/footer"/}
|
||||
<script type="text/javascript">
|
||||
$(".btn-set").click(function () {
|
||||
let value = $(this).data('value');
|
||||
// 检验不通过终止执行
|
||||
if (!value) {
|
||||
lightyear.notify('主题值不能为空', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
return false;
|
||||
}
|
||||
$.post(url="/admin/theme/change_theme",{value:value},function (res) {
|
||||
if (res.code == 200) {lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');setTimeout(function () {location.reload();},2000)}
|
||||
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||
});
|
||||
return true;
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -155,6 +155,7 @@ if (!function_exists('file_cdn'))
|
|||
//是网址开头的不处理
|
||||
return $path;
|
||||
}
|
||||
$path = str_replace(public_path(),'',$path);
|
||||
if (!(substr($path, 0,1) == '/')){
|
||||
//统一路径
|
||||
$path = '/'.$path;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"title":"默认主题",
|
||||
"author":"MonkeyCode",
|
||||
"demo_url":"http://default.lcm.wang/",
|
||||
"category_type":[
|
||||
{
|
||||
"默认列表":"list_default.html"
|
||||
},
|
||||
{
|
||||
"两排列表":"list_double.html"
|
||||
}
|
||||
],
|
||||
"article_type":[
|
||||
{
|
||||
"普通文章":"page.html"
|
||||
},
|
||||
{
|
||||
"关于我们":"page_about.html"
|
||||
},
|
||||
{
|
||||
"产品文章":"page_product.html"
|
||||
}
|
||||
],
|
||||
"info_file":"全部都是可视化的 没什么可说明的",
|
||||
"update_url":"http://www.lcm.wang/",
|
||||
"preview_file":"preview.jpg",
|
||||
"versions":"1.0"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 559 KiB |
|
|
@ -22,7 +22,6 @@
|
|||
}
|
||||
],
|
||||
"info_file":"全部都是可视化的 没什么可说明的",
|
||||
"set_file":"set.php",
|
||||
"update_url":"http://www.lcm.wang/",
|
||||
"preview_file":"preview.jpg",
|
||||
"versions":"1.0"
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
这里是教你如何设置主题
|
||||
Loading…
Reference in New Issue