更新代码
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use think\facade\Db;
|
||||
|
||||
class Database extends Admin{
|
||||
|
||||
@@ -16,8 +17,11 @@ class Database extends Admin{
|
||||
* @title 数据备份
|
||||
*/
|
||||
public function export(){
|
||||
$list = Db::query('SHOW TABLE STATUS');
|
||||
$list = array_map('array_change_key_case', $list);
|
||||
|
||||
$this->data['data'] = array(
|
||||
'list' => array()
|
||||
'list' => $list
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
@@ -25,8 +29,41 @@ class Database extends Admin{
|
||||
* @title 数据导入
|
||||
*/
|
||||
public function import(){
|
||||
//列出备份文件列表
|
||||
$path = app()->getRuntimePath() . 'backup';
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
$path = realpath($path);
|
||||
$flag = \FilesystemIterator::KEY_AS_FILENAME;
|
||||
$glob = new \FilesystemIterator($path, $flag);
|
||||
|
||||
$list = array();
|
||||
foreach ($glob as $name => $file) {
|
||||
if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) {
|
||||
$name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d');
|
||||
|
||||
$date = "{$name[0]}-{$name[1]}-{$name[2]}";
|
||||
$time = "{$name[3]}:{$name[4]}:{$name[5]}";
|
||||
$part = $name[6];
|
||||
|
||||
if (isset($list["{$date} {$time}"])) {
|
||||
$info = $list["{$date} {$time}"];
|
||||
$info['part'] = max($info['part'], $part);
|
||||
$info['size'] = $info['size'] + $file->getSize();
|
||||
} else {
|
||||
$info['part'] = $part;
|
||||
$info['size'] = $file->getSize();
|
||||
}
|
||||
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
|
||||
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
|
||||
$info['time'] = strtotime("{$date} {$time}");
|
||||
|
||||
$list["{$date} {$time}"] = $info;
|
||||
}
|
||||
}
|
||||
$this->data['data'] = array(
|
||||
'list' => array()
|
||||
'list' => $list
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ return [
|
||||
// Session初始化
|
||||
\think\middleware\SessionInit::class,
|
||||
// 页面Trace调试
|
||||
// \think\middleware\TraceDebug::class,
|
||||
\think\middleware\TraceDebug::class,
|
||||
];
|
||||
|
||||
@@ -51,6 +51,7 @@ class Admin {
|
||||
);
|
||||
|
||||
$template = (isset($this->data['template']) && $this->data['template']) ? $this->data['template'] : $template;
|
||||
|
||||
return View::config($config)
|
||||
->assign('sent_version', sent_version)
|
||||
->assign('config', (isset($this->data['config']) ? $this->data['config'] : []))
|
||||
|
||||
@@ -17,7 +17,7 @@ use think\facade\View;
|
||||
*/
|
||||
class AdminAuth {
|
||||
|
||||
protected $data = ['headerMenu' => [], 'asideMenu' => []];
|
||||
protected $data = ['headerMenu' => [], 'asideMenu' => [], 'meta_title' => ''];
|
||||
|
||||
public function handle($request, \Closure $next) {
|
||||
$user = Session::get('user');
|
||||
@@ -44,9 +44,10 @@ class AdminAuth {
|
||||
$current_url = $current_controller . '/' . strtolower($request->action());
|
||||
$menu = Cache::get('menu');
|
||||
if (!$menu) {
|
||||
$dao = new \app\model\Menu();
|
||||
$res = $dao->where('is_menu', 1)->select();
|
||||
$menu = $res->toArray();
|
||||
$res = (new \app\model\Menu())->where('is_menu', 1)->select();
|
||||
foreach ($res as $key => $item) {
|
||||
$menu[$item['id']] = $item->toArray();
|
||||
}
|
||||
Cache::set('menu', $menu);
|
||||
}
|
||||
$current_pid = 0;
|
||||
@@ -79,6 +80,9 @@ class AdminAuth {
|
||||
} else {
|
||||
$value['active'] = false;
|
||||
}
|
||||
if (strpos($value['url'], $current_url) !== false) {
|
||||
$this->data['meta_title'] = $value['title'];
|
||||
}
|
||||
$asideMenu[$value['group']][] = $value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user