浏览代码

优化插件配置分组

Karson 3 年之前
父节点
当前提交
2401cd3ba1

+ 5 - 1
application/admin/command/Addon/stubs/config.stub

@@ -8,12 +8,16 @@ return [
         'title'   => '用户名',
         //类型
         'type'    => 'string',
+        //分组
+        'group'    => '',
+        //动态显示
+        'visible'    => '',
         //数据字典
         'content' => [
         ],
         //值
         'value'   => '',
-        //验证规则 
+        //验证规则
         'rule'    => 'required',
         //错误消息
         'msg'     => '',

+ 6 - 1
application/admin/controller/Addon.php

@@ -96,8 +96,13 @@ class Addon extends Backend
         $tips = [];
         $groupList = [];
         foreach ($config as $index => &$item) {
+            //如果有设置分组
+            if (isset($item['group']) && $item['group']) {
+                if (!in_array($item['group'], $groupList)) {
+                    $groupList["custom" . (count($groupList) + 1)] = $item['group'];
+                }
+            }
             if ($item['name'] == '__tips__') {
-                $groupList = $item['content'] ? $item['content'] : [];
                 $tips = $item;
                 unset($config[$index]);
             }

+ 5 - 5
application/admin/view/addon/config.html

@@ -9,8 +9,8 @@
     {/if}
 
     <div class="panel panel-default panel-intro">
-        {if $groupList}
-        <div class="panel-heading">
+        {if count($groupList)>1}
+        <div class="panel-heading mb-3">
             <ul class="nav nav-tabs nav-group">
                 <li class="active"><a href="#all" data-toggle="tab">全部</a></li>
                 {foreach name="groupList" id="tab"}
@@ -20,15 +20,15 @@
         </div>
         {/if}
 
-        <div class="panel-body {if !$groupList}no-padding{/if}">
+        <div class="panel-body no-padding">
             <div id="myTabContent" class="tab-content">
                 {foreach name="groupList" id="group" key="groupName"}
                 <div class="tab-pane fade active in" id="tab-{$groupName}">
 
-                    <table class="table table-striped table-config">
+                    <table class="table table-striped table-config mb-0">
                         <tbody>
                         {foreach name="$addon.config" id="item"}
-                        {if ((!isset($item['group']) || $item['group']=='') && $groupName=='other') || (isset($item['group']) && $item['group']==$groupName)}
+                        {if ((!isset($item['group']) || $item['group']=='') && $groupName=='other') || (isset($item['group']) && $item['group']==$group)}
                         <tr data-favisible="{$item.visible|default=''|htmlentities}" data-name="{$item.name}" class="{if $item.visible??''}hidden{/if}">
                             <td width="15%">{$item.title}</td>
                             <td>