From 4cdf6dcdf6ca03ad7268c098945cb957ecb5e814 Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 2 Sep 2020 11:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E5=A4=96=E9=93=BE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Menu.php | 7 ++++ app/admin/view/config/index.html | 2 +- app/admin/view/menu/form.html | 29 +++++++++++---- vendor/composer/installed.json | 12 +++---- vendor/services.php | 2 +- vendor/zoujingli/think-library/.gitignore | 10 +++--- .../zoujingli/think-library/src/Command.php | 8 ++--- .../zoujingli/think-library/src/Library.php | 2 +- .../zoujingli/think-library/src/Storage.php | 7 ++-- .../think-library/src/extend/Parsedown.php | 2 +- .../think-library/src/multiple/App.php | 15 ++++---- .../src/service/InterfaceService.php | 4 +-- .../think-library/src/service/MenuService.php | 36 ++++++++++++------- .../src/service/SystemService.php | 26 ++++++++------ .../src/service/ZtSmsService.php | 6 ++-- 15 files changed, 103 insertions(+), 65 deletions(-) diff --git a/app/admin/controller/Menu.php b/app/admin/controller/Menu.php index ef6fb53ce..015a2c534 100644 --- a/app/admin/controller/Menu.php +++ b/app/admin/controller/Menu.php @@ -19,6 +19,7 @@ use think\admin\Controller; use think\admin\extend\DataExtend; use think\admin\service\AdminService; use think\admin\service\MenuService; +use think\admin\service\NodeService; /** * 系统菜单管理 @@ -102,7 +103,13 @@ class Menu extends Controller // 选择自己的上级菜单 $vo['pid'] = $vo['pid'] ?? input('pid', '0'); // 读取系统功能节点 + $this->auths = []; $this->nodes = MenuService::instance()->getList(); + foreach (NodeService::instance()->getMethods() as $node => $item) { + if ($item['isauth'] && substr_count($node, '/') >= 2) { + $this->auths[] = ['node' => $node, 'title' => $item['title']]; + } + } // 列出可选上级菜单 $menus = $this->app->db->name($this->table)->order('sort desc,id asc')->column('id,pid,icon,url,title,params', 'id'); $this->menus = DataExtend::arr2table(array_merge($menus, [['id' => '0', 'pid' => '-1', 'url' => '#', 'title' => '顶部菜单']])); diff --git a/app/admin/view/config/index.html b/app/admin/view/config/index.html index f1ee06785..281ba1e9d 100644 --- a/app/admin/view/config/index.html +++ b/app/admin/view/config/index.html @@ -110,7 +110,7 @@ 核心框架 - ThinkPHP Version {$app->version()} + ThinkPHP Version {$app->version()} 管理程序 diff --git a/app/admin/view/menu/form.html b/app/admin/view/menu/form.html index 25293f33f..0b2afe413 100644 --- a/app/admin/view/menu/form.html +++ b/app/admin/view/menu/form.html @@ -14,7 +14,7 @@ {/eq} {/foreach} -

必选,请选择上级菜单或顶级菜单(目前最多支持三级菜单)

+

必选,请选择上级菜单或顶级菜单(目前最多支持三级菜单)

@@ -22,7 +22,7 @@
-

必填,请填写菜单名称(如:系统管理),建议字符不要太长,一般4-6个汉字

+

必选,请填写菜单名称(如:系统管理),建议字符不要太长,一般4-6个汉字

@@ -31,8 +31,8 @@

- 必填,请填写系统节点(如:admin/user/index),节点加入权限管理时菜单才会自动隐藏,非规则内的不会隐藏; -
正常情况下,在输入的时候会有自动提示。如果是上级菜单时,请填写"#"符号,不要填写地址或节点地址 + 必选,请填写链接地址或选择系统节点(如:https://domain.com/admin/user/index.html 或 admin/user/index) +
当填写链接地址时,以下面的“权限节点”来判断菜单自动隐藏或显示,注意未填写“权限节点”时将不会隐藏该菜单哦

@@ -45,6 +45,14 @@ +
+ +
+ +

可选,请填写系统权限节点(如:admin/user/index),未填写时默认解释"菜单链接"判断是否拥有访问权限;

+
+
+
@@ -68,22 +76,29 @@
- {block name='script'} {/block} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 5f6cf8d0c..0c5cc383c 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -958,17 +958,17 @@ }, { "name": "zoujingli/think-library", - "version": "v6.0.2", - "version_normalized": "6.0.2.0", + "version": "v6.0.3", + "version_normalized": "6.0.3.0", "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "a498595d637568481601091985ae22d5cd05a057" + "reference": "98f56d2c2a589cfa4074733c655021d38d78b4aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a498595d637568481601091985ae22d5cd05a057", - "reference": "a498595d637568481601091985ae22d5cd05a057", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/98f56d2c2a589cfa4074733c655021d38d78b4aa", + "reference": "98f56d2c2a589cfa4074733c655021d38d78b4aa", "shasum": "", "mirrors": [ { @@ -985,7 +985,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-08-31T11:59:58+00:00", + "time": "2020-09-02T03:17:43+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index da4051860..e546d4c68 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/.gitignore b/vendor/zoujingli/think-library/.gitignore index 301c8c264..b7f883d2c 100644 --- a/vendor/zoujingli/think-library/.gitignore +++ b/vendor/zoujingli/think-library/.gitignore @@ -1,8 +1,8 @@ +.git +.svn .idea !.gitignore !composer.json -composer.lock -app -config -vendor -public +/composer.lock +/vendor +/test.php \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/Command.php b/vendor/zoujingli/think-library/src/Command.php index 51f6afbff..7ebc3683b 100644 --- a/vendor/zoujingli/think-library/src/Command.php +++ b/vendor/zoujingli/think-library/src/Command.php @@ -44,7 +44,7 @@ abstract class Command extends ThinkCommand * 初始化指令变量 * @param Input $input * @param Output $output - * @return $this + * @return static * @throws Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException @@ -69,7 +69,7 @@ abstract class Command extends ThinkCommand * 设置进度消息并继续执行 * @param null|string $message 进度消息 * @param null|integer $progress 进度数值 - * @return Command + * @return static */ protected function setQueueProgress($message = null, $progress = null) { @@ -84,7 +84,7 @@ abstract class Command extends ThinkCommand /** * 设置失败消息并结束进程 * @param string $message 消息内容 - * @return Command + * @return static * @throws Exception */ protected function setQueueError($message) @@ -100,7 +100,7 @@ abstract class Command extends ThinkCommand /** * 设置成功消息并结束进程 * @param string $message 消息内容 - * @return Command + * @return static * @throws Exception */ protected function setQueueSuccess($message) diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php index f2b09fcfa..c59c73517 100644 --- a/vendor/zoujingli/think-library/src/Library.php +++ b/vendor/zoujingli/think-library/src/Library.php @@ -41,7 +41,7 @@ class Library extends Service /** * 扩展库版本号 */ - const VERSION = '6.0.2'; + const VERSION = '6.0.3'; /** * 启动服务 diff --git a/vendor/zoujingli/think-library/src/Storage.php b/vendor/zoujingli/think-library/src/Storage.php index b231c48a1..96b169f65 100644 --- a/vendor/zoujingli/think-library/src/Storage.php +++ b/vendor/zoujingli/think-library/src/Storage.php @@ -119,10 +119,9 @@ abstract class Storage */ public static function name($url, $ext = '', $pre = '', $fun = 'md5') { - if (empty($ext)) $ext = pathinfo($url, 4); - [$xmd, $ext] = [$fun($url), trim($ext, '.\\/')]; - $attr = [trim($pre, '.\\/'), substr($xmd, 0, 2), substr($xmd, 2, 30)]; - return trim(join('/', $attr), '/') . '.' . strtolower($ext ? $ext : 'tmp'); + [$hah, $ext] = [$fun($url), trim($ext ?: pathinfo($url, 4), '.\\/')]; + $attr = [trim($pre, '.\\/'), substr($hah, 0, 2), substr($hah, 2, 30)]; + return trim(join('/', $attr), '/') . '.' . strtolower($ext ?: 'tmp'); } /** diff --git a/vendor/zoujingli/think-library/src/extend/Parsedown.php b/vendor/zoujingli/think-library/src/extend/Parsedown.php index 07d321232..53b9e42e4 100644 --- a/vendor/zoujingli/think-library/src/extend/Parsedown.php +++ b/vendor/zoujingli/think-library/src/extend/Parsedown.php @@ -3,7 +3,7 @@ // +---------------------------------------------------------------------- // | Library for ThinkAdmin // +---------------------------------------------------------------------- -// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ] +// | 此文件版权所有归原作者所有,在此特别感觉 !!!!!!!!!!!!!!! // +---------------------------------------------------------------------- // | 官方网站: https://gitee.com/zoujingli/ThinkLibrary // +---------------------------------------------------------------------- diff --git a/vendor/zoujingli/think-library/src/multiple/App.php b/vendor/zoujingli/think-library/src/multiple/App.php index 793096853..b8121ab4f 100644 --- a/vendor/zoujingli/think-library/src/multiple/App.php +++ b/vendor/zoujingli/think-library/src/multiple/App.php @@ -20,13 +20,16 @@ use think\Request; use think\Response; /** - * 多应用支持 - * Class MultiApp + * 多应用支持组件 + * Class App * @package think\admin\multiple */ class App { - /** @var \think\App */ + /** + * 应用实例 + * @var \think\App + */ protected $app; /** @@ -118,8 +121,7 @@ class App } if (isset($map[$name])) { if ($map[$name] instanceof Closure) { - $result = call_user_func_array($map[$name], [$this->app]); - $appName = $result ?: $name; + $appName = call_user_func_array($map[$name], [$this->app]) ?: $name; } else { $appName = $map[$name]; } @@ -131,8 +133,7 @@ class App $appName = $name ?: $defaultApp; $appPath = $this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR; if (!is_dir($appPath)) { - $express = $this->app->config->get('app.app_express', false); - if ($express) { + if ($this->app->config->get('app.app_express', false)) { $this->setApp($defaultApp); return true; } else { diff --git a/vendor/zoujingli/think-library/src/service/InterfaceService.php b/vendor/zoujingli/think-library/src/service/InterfaceService.php index ee78c7917..951a9a220 100644 --- a/vendor/zoujingli/think-library/src/service/InterfaceService.php +++ b/vendor/zoujingli/think-library/src/service/InterfaceService.php @@ -105,8 +105,8 @@ class InterfaceService extends Service /** * 设置授权账号 - * @param string $appid - * @param string $appkey + * @param string $appid 接口账号 + * @param string $appkey 接口密钥 * @return $this */ public function setAuth($appid, $appkey) diff --git a/vendor/zoujingli/think-library/src/service/MenuService.php b/vendor/zoujingli/think-library/src/service/MenuService.php index 33b6ac1e8..882047312 100644 --- a/vendor/zoujingli/think-library/src/service/MenuService.php +++ b/vendor/zoujingli/think-library/src/service/MenuService.php @@ -31,7 +31,7 @@ class MenuService extends Service * @return array * @throws \ReflectionException */ - public function getList() + public function getList(): array { static $nodes = []; if (count($nodes) > 0) return $nodes; @@ -49,32 +49,42 @@ class MenuService extends Service * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function getTree() + public function getTree(): array { - $result = $this->app->db->name('SystemMenu')->where(['status' => '1'])->order('sort desc,id asc')->select(); - return $this->_buildData(DataExtend::arr2tree($result->toArray()), NodeService::instance()->getMethods()); + $query = $this->app->db->name('SystemMenu'); + $query->where(['status' => '1'])->order('sort desc,id asc'); + return $this->_buildData(DataExtend::arr2tree($query->select()->toArray())); } /** * 后台主菜单权限过滤 * @param array $menus 当前菜单列表 - * @param array $nodes 系统权限节点 * @return array * @throws \ReflectionException */ - private function _buildData($menus, $nodes) + private function _buildData(array $menus): array { + $service = AdminService::instance(); foreach ($menus as $key => &$menu) { if (!empty($menu['sub'])) { - $menu['sub'] = $this->_buildData($menu['sub'], $nodes); + $menu['sub'] = $this->_buildData($menu['sub']); } - if (!empty($menu['sub'])) $menu['url'] = '#'; - elseif ($menu['url'] === '#') unset($menus[$key]); - elseif (preg_match('|^https?://|i', $menu['url'])) continue; - else { + if (!empty($menu['sub'])) { + $menu['url'] = '#'; + } elseif ($menu['url'] === '#') { + unset($menus[$key]); + } elseif (preg_match('|^https?://|i', $menu['url'])) { + if (!!$menu['node'] && !$service->check($menu['node'])) { + unset($menus[$key]); + } elseif ($menu['params']) { + $menu['url'] .= (strpos($menu['url'], '?') === false ? '?' : '&') . $menu['params']; + } + } elseif (!!$menu['node'] && !$service->check($menu['node'])) { + unset($menus[$key]); + } else { $node = join('/', array_slice(explode('/', $menu['url']), 0, 3)); - $menu['url'] = url($menu['url']) . (empty($menu['params']) ? '' : "?{$menu['params']}"); - if (!AdminService::instance()->check($node)) unset($menus[$key]); + $menu['url'] = url($menu['url']) . ($menu['params'] ? '' : "?{$menu['params']}"); + if (!$service->check($node)) unset($menus[$key]); } } return $menus; diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index c7357dfb7..de484d932 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -49,15 +49,19 @@ class SystemService extends Service */ public function set($name, $value = '') { - [$this->data, $count] = [[], 0]; - [$type, $field] = $this->parse($name, 'base'); + $this->data = []; + [$type, $field] = $this->_parse($name, 'base'); if (is_array($value)) { - foreach ($value as $kk => $vv) $count += $this->set("{$field}.{$kk}", $vv); + $count = 0; + foreach ($value as $kk => $vv) { + $count += $this->set("{$field}.{$kk}", $vv); + } return $count; } else { $this->app->cache->delete($this->table); - $data = ['type' => $type, 'name' => $field, 'value' => $value]; - $query = $this->app->db->name($this->table)->where(['type' => $type, 'name' => $field]); + $map = ['type' => $type, 'name' => $field]; + $data = array_merge($map, ['value' => $value]); + $query = $this->app->db->name($this->table)->master(true)->where($map); return (clone $query)->count() > 0 ? $query->update($data) : $query->insert($data); } } @@ -73,10 +77,12 @@ class SystemService extends Service */ public function get($name = '', $default = '') { - [$type, $field, $outer] = $this->parse($name, 'base'); - if (empty($this->data)) $this->app->db->name($this->table)->cache($this->table)->select()->map(function ($item) { - $this->data[$item['type']][$item['name']] = $item['value']; - }); + if (empty($this->data)) { + $this->app->db->name($this->table)->cache($this->table)->select()->map(function ($item) { + $this->data[$item['type']][$item['name']] = $item['value']; + }); + } + [$type, $field, $outer] = $this->_parse($name, 'base'); if (empty($name)) { return $this->data; } elseif (isset($this->data[$type])) { @@ -115,7 +121,7 @@ class SystemService extends Service * @param string $type 配置类型 * @return array */ - private function parse($rule, $type = 'base') + private function _parse($rule, $type = 'base') { if (stripos($rule, '.') !== false) { [$type, $rule] = explode('.', $rule, 2); diff --git a/vendor/zoujingli/think-library/src/service/ZtSmsService.php b/vendor/zoujingli/think-library/src/service/ZtSmsService.php index 0a9090989..aebdaa431 100644 --- a/vendor/zoujingli/think-library/src/service/ZtSmsService.php +++ b/vendor/zoujingli/think-library/src/service/ZtSmsService.php @@ -45,8 +45,8 @@ class ZtSmsService extends Service */ protected function initialize() { - $this->username = sysconf('ztsms.username'); - $this->password = sysconf('ztsms.password'); + $this->username = sysconf('ztsms.username') ?: ''; + $this->password = sysconf('ztsms.password') ?: ''; } /** @@ -55,7 +55,7 @@ class ZtSmsService extends Service * @param string $password 账号密码 * @return static */ - public function make(string $username, string $password) + public function setAuth(string $username, string $password) { $this->username = $username; $this->password = $password;