diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php
index 5b15d204..f70d5076 100644
--- a/application/admin/controller/Index.php
+++ b/application/admin/controller/Index.php
@@ -3,7 +3,6 @@
namespace app\admin\controller;
use app\common\controller\Backend;
-use fast\Menu;
use think\Validate;
/**
@@ -28,7 +27,7 @@ class Index extends Backend
public function index()
{
//
- $menulist = Menu::instance()->sidebar([
+ $menulist = $this->auth->getSidebar([
'dashboard' => 'hot',
'auth' => ['new', 'red', 'badge'],
'auth/admin' => 12,
diff --git a/application/admin/lang/zh-cn/general/database.php b/application/admin/lang/zh-cn/general/database.php
index a63b0cf4..1defa653 100644
--- a/application/admin/lang/zh-cn/general/database.php
+++ b/application/admin/lang/zh-cn/general/database.php
@@ -18,7 +18,7 @@ return [
'Max output:%s' => '最大返回%s条',
'Total:%s' => '共有%s条记录! ',
'Row:%s' => '记录:%s',
- 'Executes one or multiple queries which are concatenated by a semicolon' => '请输入SQL语句,支持批量查询,多条SQL以分号(,)分格',
+ 'Executes one or multiple queries which are concatenated by a semicolon' => '请输入SQL语句,支持批量查询,多条SQL以分号(;)分格',
'Query affected %s rows and took %s seconds' => '共影响%s条记录! 耗时:%s秒!',
'Query returned an empty result' => '返回结果为空!',
'Query took %s seconds' => '耗时%s秒!',
diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php
index 7fbb2f80..e8126925 100644
--- a/application/admin/library/Auth.php
+++ b/application/admin/library/Auth.php
@@ -4,6 +4,7 @@ namespace app\admin\library;
use app\admin\model\Admin;
use fast\Random;
+use fast\Tree;
use think\Cookie;
use think\Request;
use think\Session;
@@ -202,4 +203,67 @@ class Auth extends \fast\Auth
return in_array('*', $this->getRuleIds()) ? TRUE : FALSE;
}
+ /**
+ * 获取左侧菜单栏
+ *
+ * @param array $params URL对应的badge数据
+ * @return string
+ */
+ public function getSidebar($params = [])
+ {
+ $colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
+ $colorNums = count($colorArr);
+ $badgeList = [];
+ // 生成菜单的badge
+ foreach ($params as $k => $v)
+ {
+ if (stripos($k, '/') === false)
+ {
+ $url = '/admin/' . $k;
+ }
+ else
+ {
+ $url = url($k);
+ }
+
+ if (is_array($v))
+ {
+ $nums = isset($v[0]) ? $v[0] : 0;
+ $color = isset($v[1]) ? $v[1] : $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
+ $class = isset($v[2]) ? $v[2] : 'label';
+ }
+ else
+ {
+ $nums = $v;
+ $color = $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
+ $class = 'label';
+ }
+ //必须nums大于0才显示
+ if ($nums)
+ {
+ $badgeList[$url] = '' . $nums . '';
+ }
+ }
+
+ // 读取管理员当前拥有的权限节点
+ $userRule = $this->getRuleList();
+
+ $select_id = 0;
+ $dashboard = rtrim(url('dashboard/'), '/');
+ // 必须将结果集转换为数组
+ $ruleList = collection(model('AuthRule')->where('ismenu', 1)->order('weigh', 'desc')->cache("__menu__")->select())->toArray();
+ foreach ($ruleList as $k => &$v)
+ {
+ if (!in_array($v['name'], $userRule))
+ continue;
+ $select_id = $v['name'] == $dashboard ? $v['id'] : $select_id;
+ $v['url'] = $v['name'];
+ $v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : '';
+ }
+ // 构造菜单数据
+ Tree::instance()->init($ruleList);
+ $menu = Tree::instance()->getTreeMenu(0, '
@title @caret @badge @childlist', $select_id, '', 'ul', 'class="treeview-menu"');
+ return $menu;
+ }
+
}
diff --git a/extend/fast/Menu.php b/extend/fast/Menu.php
deleted file mode 100644
index 62081718..00000000
--- a/extend/fast/Menu.php
+++ /dev/null
@@ -1,166 +0,0 @@
-config = array_merge($this->config, $config);
- }
- $this->config = array_merge($this->config, is_array($options) ? $options : []);
- }
-
- /**
- * 单例
- * @param array $options 参数
- * @return Menu
- */
- public static function instance($options = [])
- {
- if (is_null(self::$instance))
- {
- self::$instance = new static($options);
- }
-
- return self::$instance;
- }
-
- /**
- * 导入节点数据
- * @param array $treearr
- * @param int $pid
- * @param string $module
- */
- public function import($treearr, $pid = 0, $module = NULL)
- {
- $module = is_null($module) ? Config::user('request.modulename') : $module;
- foreach ($treearr as $key => & $v)
- {
- $controller = strtolower($v['controller']) . ($v['childlist'] ? "_folder" : '');
- $icon = isset($v['icon']) ? $v['icon'] : (stripos($v['name'], '_') !== FALSE ? $v['childlist'] ? 'folder' : 'circle-o' : strtolower($v['name']));
- $actionkeys = array_keys($v['actionlist']);
- $action = '-' . ($v['actionlist'] ? reset($actionkeys) : '');
- $values = array(
- 'name' => $v['name'],
- 'weigh' => $key,
- 'pid' => $pid,
- 'module' => $module,
- 'controller' => $controller,
- 'action' => $action,
- 'icon' => $icon,
- 'type' => 'menu',
- 'status' => 'normal'
- );
- $id = Db::table("node")->data($values)->insert();
- $v['id'] = $id;
- }
- unset($v);
- foreach ($treearr as $k => $v)
- {
- if ($v['childlist'])
- {
- $this->import($v['childlist'], $v['id'], $module);
- }
- else
- {
- $i = 0;
- foreach ($v['actionlist'] as $m => $n)
- {
- $values = array(
- 'name' => $n ? $n : $m,
- 'weigh' => $i,
- 'pid' => $v['id'],
- 'module' => $module,
- 'controller' => strtolower($v['controller']),
- 'action' => $m,
- 'icon' => 'circle-o',
- 'type' => 'file',
- 'status' => 'normal'
- );
- Db::table("node")->data($values)->insert();
- $i++;
- }
- }
- }
- }
-
- /**
- * 获取左侧菜单栏
- *
- * @param array $params URL对应的badge数据
- * @return string
- */
- public function sidebar($params = [])
- {
- $colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
- $colorNums = count($colorArr);
- $badgeList = [];
- // 生成菜单的badge
- foreach ($params as $k => $v)
- {
- if (stripos($k, '/') === false)
- {
- $url = '/admin/' . $k;
- }
- else
- {
- $url = url($k);
- }
-
- if (is_array($v))
- {
- $nums = isset($v[0]) ? $v[0] : 0;
- $color = isset($v[1]) ? $v[1] : $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
- $class = isset($v[2]) ? $v[2] : 'label';
- }
- else
- {
- $nums = $v;
- $color = $colorArr[(is_numeric($nums) ? $nums : strlen($nums)) % $colorNums];
- $class = 'label';
- }
- //必须nums大于0才显示
- if ($nums)
- {
- $badgeList[$url] = '' . $nums . '';
- }
- }
-
- // 读取管理员当前拥有的权限节点
- $userRule = Auth::instance()->getRuleList();
-
- $select_id = 0;
- $dashboard = rtrim(url('dashboard/'), '/');
- // 必须将结果集转换为数组
- $ruleList = collection(model('AuthRule')->where('ismenu', 1)->order('weigh', 'desc')->cache("__menu__")->select())->toArray();
- foreach ($ruleList as $k => &$v)
- {
- if (!in_array($v['name'], $userRule))
- continue;
- $select_id = $v['name'] == $dashboard ? $v['id'] : $select_id;
- $v['url'] = $v['name'];
- $v['badge'] = isset($badgeList[$v['name']]) ? $badgeList[$v['name']] : '';
- }
- // 构造菜单数据
- Tree::instance()->init($ruleList);
- $menu = Tree::instance()->getTreeMenu(0, ' @title @caret @badge @childlist', $select_id, '', 'ul', 'class="treeview-menu"');
- return $menu;
- }
-
-}