diff --git a/app/common.php b/app/common.php index c6d1fde..9d0d82d 100644 --- a/app/common.php +++ b/app/common.php @@ -44,12 +44,29 @@ function get_system_config($name, $key = '') if ($key == '') { return $config; } else { - if ($config[$key]) { + if (isset($config[$key])) { return $config[$key]; } + else{ + return ''; + } } } +//设置系统配置 +function set_system_config($name, $key, $value='') +{ + $config = []; + $conf = Db::name('config')->where('name', $name)->find(); + if ($conf['content']) { + $config = unserialize($conf['content']); + } + $config[$key] = $value; + set_cache('system_config' . $name, $config); + $content = serialize($config); + Db::name('config')->where('name', $name)->update(['content'=>$content]); +} + //读取文件配置 function get_config($key) diff --git a/app/home/controller/Index.php b/app/home/controller/Index.php index e7623a6..16e5b30 100644 --- a/app/home/controller/Index.php +++ b/app/home/controller/Index.php @@ -84,6 +84,7 @@ class Index extends BaseController \think\facade\Cache::tag('adminMenu')->set('menu' . $admin['id'], $list); } View::assign('menu', $list); + View::assign('theme', get_system_config('other','theme')); return View(); } } @@ -199,4 +200,17 @@ class Index extends BaseController return view(); } } + + //设置theme + public function set_theme() + { + if (request()->isAjax()) { + $param = get_params(); + set_system_config('other','theme',$param['theme']); + return to_assign(); + } + else{ + return to_assign(1,'操作错误'); + } + } } diff --git a/app/home/view/conf/other.html b/app/home/view/conf/other.html index fdb41f1..06e178d 100644 --- a/app/home/view/conf/other.html +++ b/app/home/view/conf/other.html @@ -5,6 +5,16 @@
系统主题 | ++ {empty name="$config.theme"} + + + {else/} + + + {/empty} + | 开发者 | diff --git a/app/home/view/index/index.html b/app/home/view/index/index.html index 5a5cb5f..f67914d 100644 --- a/app/home/view/index/index.html +++ b/app/home/view/index/index.html @@ -24,13 +24,18 @@ - |