From 78c5c2a6585b533ae05f47391d05436006ed7ada Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Tue, 5 Aug 2025 17:03:23 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 1eb8e0ac..be96a03c 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -725,7 +725,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table if (top + 154 > $(window).height()) { top = top - 154; } - if ($(window).width() < 480) { + if (left < 0 || $(window).width() < 480) { top = left = undefined; } Layer.confirm( From e06f0e2738cdfcd75cbf3c547d9aefb2c192c519 Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Wed, 6 Aug 2025 10:19:08 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E9=A3=8E=E6=A0=BC?= =?UTF-8?q?=E9=83=BD=E7=94=A8$user->id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index c7b2fa32..938ce2c5 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -179,14 +179,14 @@ class User extends Api $bio = $this->request->post('bio'); $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); if ($username) { - $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find(); + $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $user->id)->find(); if ($exists) { $this->error(__('Username already exists')); } $user->username = $username; } if ($nickname) { - $exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find(); + $exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $user->id)->find(); if ($exists) { $this->error(__('Nickname already exists')); } From cfd7068a99d4ae7e315625ff3038598eafd15460 Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Wed, 6 Aug 2025 10:24:22 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=A4=9A=E8=AF=AD?= =?UTF-8?q?=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/lang/zh-cn/user.php | 1 + application/index/view/user/profile.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/index/lang/zh-cn/user.php b/application/index/lang/zh-cn/user.php index b9089b7e..64c492d7 100755 --- a/application/index/lang/zh-cn/user.php +++ b/application/index/lang/zh-cn/user.php @@ -8,6 +8,7 @@ return [ 'Mobile' => '手机号', 'Email' => '邮箱', 'Captcha' => '验证码', + 'Get code' => '获取验证码', 'Lv' => 'Lv', 'Score' => '积分', 'Day' => '天', diff --git a/application/index/view/user/profile.html b/application/index/view/user/profile.html index 50c7ed86..8a60d762 100644 --- a/application/index/view/user/profile.html +++ b/application/index/view/user/profile.html @@ -123,7 +123,7 @@
- 获取验证码 + {:__('Get code')}
@@ -156,7 +156,7 @@
- 获取验证码 + {:__('Get code')}
From fad4731136dd6ed926ad48c3af346db3a01efc0d Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 14 Aug 2025 11:05:16 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/lang/zh-cn/user/user.php | 58 +++++++++++----------- application/admin/validate/User.php | 2 +- application/admin/view/user/user/edit.html | 2 +- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/application/admin/lang/zh-cn/user/user.php b/application/admin/lang/zh-cn/user/user.php index 13f096df..329522c4 100644 --- a/application/admin/lang/zh-cn/user/user.php +++ b/application/admin/lang/zh-cn/user/user.php @@ -1,33 +1,35 @@ 'ID', - 'Group_id' => '组别ID', - 'Username' => '用户名', - 'Nickname' => '昵称', - 'Password' => '密码', - 'Salt' => '密码盐', - 'Email' => '电子邮箱', - 'Mobile' => '手机号', - 'Avatar' => '头像', - 'Level' => '等级', - 'Gender' => '性别', - 'Male' => '男', - 'FeMale' => '女', - 'Birthday' => '生日', - 'Bio' => '格言', - 'Score' => '积分', - 'Successions' => '连续登录天数', - 'Maxsuccessions' => '最大连续登录天数', - 'Prevtime' => '上次登录时间', - 'Logintime' => '登录时间', - 'Loginip' => '登录IP', - 'Loginfailure' => '失败次数', - 'Joinip' => '加入IP', - 'Jointime' => '加入时间', - 'Createtime' => '创建时间', - 'Updatetime' => '更新时间', - 'Token' => 'Token', - 'Status' => '状态', + 'Id' => 'ID', + 'Group_id' => '组别ID', + 'Username' => '用户名', + 'Nickname' => '昵称', + 'Password' => '密码', + 'Salt' => '密码盐', + 'Email' => '电子邮箱', + 'Mobile' => '手机号', + 'Avatar' => '头像', + 'Level' => '等级', + 'Gender' => '性别', + 'Male' => '男', + 'FeMale' => '女', + 'Birthday' => '生日', + 'Bio' => '格言', + 'Score' => '积分', + 'Successions' => '连续登录天数', + 'Maxsuccessions' => '最大连续登录天数', + 'Prevtime' => '上次登录时间', + 'Logintime' => '登录时间', + 'Loginip' => '登录IP', + 'Loginfailure' => '失败次数', + 'Joinip' => '加入IP', + 'Jointime' => '加入时间', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Token' => 'Token', + 'Status' => '状态', + 'Username must be 3 to 30 characters' => '用户名只能由3-30位数字、字母、下划线组合', + 'Password must be 6 to 30 characters' => '密码长度必须在6-30位之间,不能包含空格', 'Leave password blank if dont want to change' => '不修改密码请留空', ]; diff --git a/application/admin/validate/User.php b/application/admin/validate/User.php index 7d7e0f50..99c80892 100644 --- a/application/admin/validate/User.php +++ b/application/admin/validate/User.php @@ -13,7 +13,7 @@ class User extends Validate 'username' => 'require|regex:\w{3,30}|unique:user', 'nickname' => 'require|unique:user', 'password' => 'regex:\S{6,30}', - 'email' => 'require|email|unique:user', + 'email' => 'email|unique:user', 'mobile' => 'unique:user' ]; diff --git a/application/admin/view/user/user/edit.html b/application/admin/view/user/user/edit.html index f7c50f84..41a3e0ec 100644 --- a/application/admin/view/user/user/edit.html +++ b/application/admin/view/user/user/edit.html @@ -10,7 +10,7 @@
- +
From 87710c0a1857467098d23bdd9f562fe468767fe9 Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Thu, 14 Aug 2025 17:43:29 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=A4=9A=E9=80=89=E6=B2=A1=E6=9C=89=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-form.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/assets/js/require-form.js b/public/assets/js/require-form.js index 7b8ecdd0..767d39cd 100755 --- a/public/assets/js/require-form.js +++ b/public/assets/js/require-form.js @@ -134,9 +134,13 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio $(form).on("reset", function () { setTimeout(function () { $(".selectpage", form).each(function () { - var selectpage = $(this).data("selectPageObject"); - selectpage.elem.hidden.val($(this).val()); - $(this).selectPageRefresh(); + if($(this).val()){ + var selectpage = $(this).data("selectPageObject"); + selectpage.elem.hidden.val($(this).val()); + $(this).selectPageRefresh(); + }else{ + $(this).selectPageClear(); + } }); }, 1); }); From e24cefeffc5883942a28ccb1ec12368b43cf2aca Mon Sep 17 00:00:00 2001 From: Karson Date: Mon, 18 Aug 2025 10:04:11 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E8=BE=B9=E6=A0=8F=E5=8F=B3=E4=BE=A7=E5=9B=BE=E6=A0=87=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/css/fastadmin.css | 4 +++- public/assets/less/fastadmin/sidebar-mini.less | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/public/assets/css/fastadmin.css b/public/assets/css/fastadmin.css index dc94bd4f..56ecbf53 100644 --- a/public/assets/css/fastadmin.css +++ b/public/assets/css/fastadmin.css @@ -714,6 +714,8 @@ a:focus { .sidebar-menu li > a > .pull-right-container { position: absolute; right: 10px; +} +.sidebar-collapse .sidebar-menu li > a > .pull-right-container { top: 50%; margin-top: -7px; } @@ -1424,7 +1426,7 @@ select.form-control { .input-lg + .form-control-feedback.fa, .input-group-lg + .form-control-feedback.fa, .form-group-lg .form-control + .form-control-feedback.fa { - line-height: 45px; + line-height: 44px; } .input-sm + .form-control-feedback.fa, .input-group-sm + .form-control-feedback.fa, diff --git a/public/assets/less/fastadmin/sidebar-mini.less b/public/assets/less/fastadmin/sidebar-mini.less index bb9f32b6..7b96bedd 100755 --- a/public/assets/less/fastadmin/sidebar-mini.less +++ b/public/assets/less/fastadmin/sidebar-mini.less @@ -164,8 +164,15 @@ > .pull-right-container { position: absolute; right: 10px; - top: 50%; - margin-top: -7px; } } +.sidebar-collapse { + .sidebar-menu li > a { + > .pull-right-container { + top: 50%; + margin-top: -7px; + } + } +} + From eae4e388453353c4ddf0a968e91a66949f270f7c Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Tue, 19 Aug 2025 17:05:29 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E5=A4=9A=E8=A1=A8=E5=8D=95=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=99=90=E5=88=B6=E6=90=9C=E7=B4=A2=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-form.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/assets/js/require-form.js b/public/assets/js/require-form.js index 767d39cd..81351597 100755 --- a/public/assets/js/require-form.js +++ b/public/assets/js/require-form.js @@ -106,7 +106,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio $('.selectpicker', form).selectpicker(); $(form).on("reset", function () { setTimeout(function () { - $('.selectpicker').selectpicker('refresh').trigger("change"); + $('.selectpicker', form).selectpicker('refresh').trigger("change"); }, 1); }); }); @@ -163,7 +163,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio require(['citypicker'], function () { $(form).on("reset", function () { setTimeout(function () { - $("[data-toggle='city-picker']").citypicker('refresh'); + $("[data-toggle='city-picker']", form).citypicker('refresh'); }, 1); }); }); @@ -517,10 +517,10 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio tagsinput: function (form) { if ($("[data-role='tagsinput']", form).length > 0) { require(['tagsinput', 'autocomplete'], function () { - $("[data-role='tagsinput']").tagsinput(); + $("[data-role='tagsinput']", form).tagsinput(); form.on("reset", function () { setTimeout(function () { - $("[data-role='tagsinput']").tagsinput('reset'); + $("[data-role='tagsinput']", form).tagsinput('reset'); }, 0); }); }); From 8e5a3e38dfc64c9c501ba00d452f869da4a45a14 Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 21 Aug 2025 09:57:50 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BC=98=E5=8C=96SelectPage=E9=87=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-form.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/assets/js/require-form.js b/public/assets/js/require-form.js index 81351597..eea360fd 100755 --- a/public/assets/js/require-form.js +++ b/public/assets/js/require-form.js @@ -134,13 +134,14 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio $(form).on("reset", function () { setTimeout(function () { $(".selectpage", form).each(function () { - if($(this).val()){ - var selectpage = $(this).data("selectPageObject"); + var selectpage = $(this).data("selectPageObject"); + if ($(this).val()) { selectpage.elem.hidden.val($(this).val()); $(this).selectPageRefresh(); - }else{ + } else { $(this).selectPageClear(); } + selectpage.hideResults(selectpage); }); }, 1); }); From 6abc58a2d524ef95a2837ca7c75f2785610f08dc Mon Sep 17 00:00:00 2001 From: guke Date: Sun, 31 Aug 2025 22:58:00 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF=E7=9A=84=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=EF=BC=8C=E4=BB=8E=E7=A9=BA=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=A9=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index e03f7244..d9db4368 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -1251,7 +1251,7 @@ EOD; $output->info("Build Successed"); } - protected function getEnum(&$getEnum, &$controllerAssignList, $field, $itemArr = '', $inputType = '') + protected function getEnum(&$getEnum, &$controllerAssignList, $field, $itemArr = [], $inputType = '') { if (!in_array($inputType, ['datetime', 'select', 'multiple', 'checkbox', 'radio'])) { return; From 1f5d58bc2457f7ad024bfbeae599ec9e9ca440db Mon Sep 17 00:00:00 2001 From: ken678 <530765310@qq.com> Date: Tue, 2 Sep 2025 15:29:29 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/config.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/config.php b/application/config.php index 14cb0a66..f0df19b4 100755 --- a/application/config.php +++ b/application/config.php @@ -293,15 +293,15 @@ return [ 'user_level_rule' => '', //会员等级积分字典,键名表示等级,值表示所需的积分 'user_level_dict' => [1 => 0, 2 => 30, 3 => 100, 4 => 500, 5 => 1000, 6 => 2000, 7 => 3000, 8 => 5000, 9 => 8000, 10 => 10000], - //登录验证码 + //后台登录验证码 'login_captcha' => true, - //登录失败超过10次则1天后重试 + //后台登录失败超过10次则1天后重试 'login_failure_retry' => true, - //是否同一账号同一时间只能在一个地方登录 + //后台是否同一账号同一时间只能在一个地方登录 'login_unique' => false, - //是否开启IP变动检测 + //后台是否开启IP变动检测 'loginip_check' => true, - //登录页默认背景图 + //后台登录页默认背景图 'login_background' => "", //是否启用简洁导航,如同时启用多级菜单导航,简洁导航将失效 'simplenav' => false, From d178d788828bf02144bf670bc06d153277482811 Mon Sep 17 00:00:00 2001 From: Karson Date: Wed, 3 Sep 2025 17:56:22 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E4=BC=98=E5=8C=96API=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Api.php | 6 ++++++ application/admin/command/Api/template/index.html | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/application/admin/command/Api.php b/application/admin/command/Api.php index 925cb977..759c4ff8 100644 --- a/application/admin/command/Api.php +++ b/application/admin/command/Api.php @@ -18,6 +18,7 @@ class Api extends Command $this ->setName('api') ->addOption('url', 'u', Option::VALUE_OPTIONAL, 'default api url', '') + ->addOption('cdnurl', 'd', Option::VALUE_OPTIONAL, 'default cdn url', '') ->addOption('module', 'm', Option::VALUE_OPTIONAL, 'module name(admin/index/api)', 'api') ->addOption('output', 'o', Option::VALUE_OPTIONAL, 'output index file name', 'api.html') ->addOption('template', 'e', Option::VALUE_OPTIONAL, '', 'index.html') @@ -36,6 +37,7 @@ class Api extends Command $force = $input->getOption('force'); $url = $input->getOption('url'); + $cdnurl = $input->getOption('cdnurl'); $language = $input->getOption('language'); $template = $input->getOption('template'); if (!preg_match("/^([a-z0-9]+)\.html\$/i", $template)) { @@ -116,15 +118,19 @@ class Api extends Command $classes = array_unique(array_filter($classes)); + $cdnurl = $cdnurl ? : Config::get('site.cdnurl'); + $config = [ 'sitename' => config('site.name'), 'title' => $title, 'author' => config('site.name'), 'description' => '', 'apiurl' => $url, + 'cdnurl' => $cdnurl, 'language' => $language, ]; + Config::set('view_replace_str.__CDN__', $cdnurl); $builder = new Builder($classes); $content = $builder->render($template_file, ['config' => $config, 'lang' => $lang]); diff --git a/application/admin/command/Api/template/index.html b/application/admin/command/Api/template/index.html index 698e84c2..10d5a977 100755 --- a/application/admin/command/Api/template/index.html +++ b/application/admin/command/Api/template/index.html @@ -8,16 +8,10 @@ {$config.title} - + - - - - +
{:build_heading()} diff --git a/extend/fast/Tree.php b/extend/fast/Tree.php index 0e63a77d..656c87c3 100644 --- a/extend/fast/Tree.php +++ b/extend/fast/Tree.php @@ -55,15 +55,15 @@ class Tree /** * 初始化方法 * @param array $arr 2维数组,例如: - * array( - * 1 => array('id'=>'1','pid'=>0,'name'=>'一级栏目一'), - * 2 => array('id'=>'2','pid'=>0,'name'=>'一级栏目二'), - * 3 => array('id'=>'3','pid'=>1,'name'=>'二级栏目一'), - * 4 => array('id'=>'4','pid'=>1,'name'=>'二级栏目二'), - * 5 => array('id'=>'5','pid'=>2,'name'=>'二级栏目三'), - * 6 => array('id'=>'6','pid'=>3,'name'=>'三级栏目一'), - * 7 => array('id'=>'7','pid'=>3,'name'=>'三级栏目二') - * ) + * array( + * 1 => array('id'=>'1','pid'=>0,'name'=>'一级栏目一'), + * 2 => array('id'=>'2','pid'=>0,'name'=>'一级栏目二'), + * 3 => array('id'=>'3','pid'=>1,'name'=>'二级栏目一'), + * 4 => array('id'=>'4','pid'=>1,'name'=>'二级栏目二'), + * 5 => array('id'=>'5','pid'=>2,'name'=>'二级栏目三'), + * 6 => array('id'=>'6','pid'=>3,'name'=>'三级栏目一'), + * 7 => array('id'=>'7','pid'=>3,'name'=>'三级栏目二') + * ) * @param string $pidname 父字段名称 * @param string $nbsp 空格占位符 * @return Tree @@ -435,4 +435,55 @@ class Tree } return $arr; } + + public function getTreeArrayList($pid = 0) + { + $map = []; + $data = []; + + $items = $this->arr; + + foreach ($items as &$item) { + $item['children'] = []; // 初始化子节点 + $map[$item['id']] = &$item; + } + unset($item); + + foreach ($items as &$item) { + if ($item[$this->pidname] == $pid) { + $data[] = &$item; + } else { + if (isset($map[$item[$this->pidname]])) { + $map[$item[$this->pidname]]['children'][] = &$item; + } + } + } + unset($item); + + return $this->getFlattenTree($data); + } + + /** + * 将多维树形结构数据扁平化处理 + * + * 该函数递归遍历树形结构,将嵌套的节点展开为一维数组, + * 并为每个节点添加层级标识 + * + * @param array $data 树形结构数据,每个节点可能包含children子节点 + * @param int $level 当前节点的层级深度,默认为0(根节点) + * @param array &$result 引用传递的结果数组,用于存储扁平化后的所有节点 + * + * @return array 扁平化后的节点数组,每个节点包含原始数据和level层级信息 + */ + public function getFlattenTree($data, $level = 0, &$result = []) + { + foreach ($data as $node) { + $node['level'] = $level; + $result[] = $node; + if (!empty($node['children'])) { + $this->getFlattenTree($node['children'], $level + 1, $result); + } + } + return $result; + } } diff --git a/public/assets/js/backend/auth/rule.js b/public/assets/js/backend/auth/rule.js index 6020ab72..7713b0c4 100755 --- a/public/assets/js/backend/auth/rule.js +++ b/public/assets/js/backend/auth/rule.js @@ -14,6 +14,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function } }); + var isExpanded = false; + var table = $("#table"); // 初始化表格 @@ -29,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function {field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon}, {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name}, {field: 'weigh', title: __('Weigh')}, - {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, + {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, operate: false}, { field: 'ismenu', title: __('Ismenu'), @@ -50,8 +52,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function search: false, commonSearch: false, rowAttributes: function (row, index) { - var expanded = $(".btn-toggle-all i").hasClass("fa-minus"); - return row.pid == 0 || expanded ? {} : {style: "display:none"}; + return row.pid == 0 || isExpanded ? {} : {style: "display:none"}; + } + }); + + table.on('post-body.bs.table', function (e, data) { + if (data.length > 2000) { + $(".btn-dragsort").addClass("disabled"); } }); @@ -142,6 +149,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function $(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show); $(".btn-node-sub").data("shown", show); $(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show); + isExpanded = show; }); }, add: function () { @@ -153,13 +161,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function api: { formatter: { title: function (value, row, index) { - value = value.toString().replace(/(&|&)nbsp;/g, ' '); var caret = row.haschild == 1 || row.ismenu == 1 ? '' : ''; - value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value; value = !row.ismenu || row.status == 'hidden' ? "" + value + "" : value; return '' + value + ''; + + (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + (' '.repeat(row.level)) + (' '.repeat(parseInt(row.level) * 4)) + caret + ' ' + value + ''; }, name: function (value, row, index) { return !row.ismenu || row.status == 'hidden' ? "" + value + "" : value; From 92e722c674fdf96e1c90bee479212ddee0689f5b Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 11 Sep 2025 14:24:50 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=BB=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/auth/Group.php | 5 +- application/admin/view/auth/group/add.html | 10 +-- application/admin/view/auth/group/edit.html | 10 +-- public/assets/js/backend/auth/group.js | 71 ++++++++++++--------- 4 files changed, 58 insertions(+), 38 deletions(-) diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index be4c2c62..aec0cd5c 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -258,7 +258,10 @@ class Group extends Backend } if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) { $id = $id ? $id : null; - $ruleList = collection(model('AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray(); + $ruleList = Db::name("auth_rule") + ->field('id,pid,name,title,icon,ismenu,status,weigh') + ->order('weigh DESC,id ASC') + ->select(); //读取父类角色所有节点列表 $parentRuleList = []; if (in_array('*', explode(',', $parentGroupModel->rules))) { diff --git a/application/admin/view/auth/group/add.html b/application/admin/view/auth/group/add.html index 3c281ee0..7e0a4644 100644 --- a/application/admin/view/auth/group/add.html +++ b/application/admin/view/auth/group/add.html @@ -1,6 +1,6 @@
{:token()} - +
@@ -10,14 +10,16 @@
- +
- - +
+ + +
diff --git a/application/admin/view/auth/group/edit.html b/application/admin/view/auth/group/edit.html index a062e43c..12e48a20 100644 --- a/application/admin/view/auth/group/edit.html +++ b/application/admin/view/auth/group/edit.html @@ -1,6 +1,6 @@ {:token()} - +
@@ -10,14 +10,16 @@
- +
- - +
+ + +
diff --git a/public/assets/js/backend/auth/group.js b/public/assets/js/backend/auth/group.js index 8002fd1b..34cfc237 100755 --- a/public/assets/js/backend/auth/group.js +++ b/public/assets/js/backend/auth/group.js @@ -47,7 +47,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( {field: 'state', checkbox: true,}, {field: 'id', title: 'ID'}, {field: 'pid', title: __('Parent')}, - {field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) { + { + field: 'name', title: __('Name'), align: 'left', formatter: function (value, row, index) { return value.toString().replace(/(&|&)nbsp;/g, ' '); } }, @@ -79,14 +80,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( }, api: { bindevent: function () { + var treeview = $("#treeview"); + + // 表单提交前设定规则集合 Form.api.bindevent($("form[role=form]"), null, null, function () { - if ($("#treeview").length > 0) { - var r = $("#treeview").jstree("get_all_checked"); + if (treeview.length > 0) { + var r = treeview.jstree("get_all_checked"); $("input[name='row[rules]']").val(r.join(',')); } return true; }); - //渲染权限节点树 + //变更级别后需要重建节点树 $(document).on("change", "select[name='row[pid]']", function () { var pid = $(this).data("pid"); @@ -96,37 +100,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( Backend.api.toastr.error(__('Can not change the parent to self')); return false; } - $.ajax({ - url: "auth/group/roletree", - type: 'post', - dataType: 'json', - data: {id: id, pid: $(this).val()}, - success: function (ret) { - if (ret.hasOwnProperty("code")) { - var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : ""; - if (ret.code === 1) { - //销毁已有的节点树 - $("#treeview").jstree("destroy"); - Controller.api.rendertree(data); - } else { - Backend.api.toastr.error(ret.msg); - } - } - }, error: function (e) { - Backend.api.toastr.error(e.message); - } - }); + treeview.jstree(true).refresh(false); }); + //全选和展开 $(document).on("click", "#checkall", function () { - $("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all"); + treeview.jstree($(this).prop("checked") ? "check_all" : "uncheck_all"); }); $(document).on("click", "#expandall", function () { - $("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all"); + treeview.jstree($(this).prop("checked") ? "open_all" : "close_all"); }); - $("select[name='row[pid]']").trigger("change"); + + //首次渲染 + Controller.api.rendertree(); }, - rendertree: function (content) { + rendertree: function () { $("#treeview") .on('redraw.jstree', function (e) { $(".layer-footer").attr("domrefresh", Math.random()); @@ -150,7 +138,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( "plugins": ["checkbox", "types"], "core": { 'check_callback': true, - "data": content + 'strings': { + 'Loading ...': __('Loading') + }, + "data": function (obj, callback) { + var pidObj = $("select[name='row[pid]']"); + $.ajax({ + url: "auth/group/roletree", + type: 'post', + dataType: 'json', + data: {id: pidObj.data('id'), pid: pidObj.val()}, + success: function (ret) { + if (ret.hasOwnProperty("code")) { + var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : ""; + if (ret.code === 1) { + callback(data); + } else { + Backend.api.toastr.error(ret.msg); + callback([]); + } + } + }, error: function (e) { + Backend.api.toastr.error(e.message); + callback([]); + } + }); + } } }); } From 5f70f0ceae939a1f854aa56ceb3ff06a3dd077ef Mon Sep 17 00:00:00 2001 From: sixXing <464401240@qq.com> Date: Thu, 25 Sep 2025 03:55:40 +0000 Subject: [PATCH 14/14] update application/admin/command/Crud.php. Signed-off-by: sixXing <464401240@qq.com> --- application/admin/command/Crud.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 3c54d39f..2e3fde0a 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -1553,6 +1553,7 @@ EOD; $valArr = explode('=', $v); if (count($valArr) == 2) { list($key, $value) = $valArr; + $key = trim($key); $itemArr[$key] = $field . ' ' . $key; } }