* @return mixed|string * @throws \think\Exception */ public function index($group = 'local') { // 配置分组信息 $list_group = ['local' => '本地数据包']; $tab_list = []; foreach ($list_group as $key => $value) { $tab_list[$key]['title'] = $value; $tab_list[$key]['url'] = url('index', ['group' => $key]); } $PacketModel = new PacketModel; $data_list = $PacketModel->getAll(); foreach ($data_list as &$value) { if (isset($value['author_url']) && !empty($value['author_url'])) { $value['author'] = ''. $value['author'] .''; } } if ($data_list === false) { $this->error($PacketModel->getError()); } // 自定义按钮 $btn_install = [ 'title' => '安装', 'icon' => 'fa fa-fw fa-sign-in', 'class' => 'btn btn-xs btn-default ajax-get confirm', 'href' => url('install', ['name' => '__id__']) ]; $btn_uninstall = [ 'title' => '卸载', 'icon' => 'fa fa-fw fa-sign-out', 'class' => 'btn btn-xs btn-default ajax-get confirm', 'href' => url('uninstall', ['name' => '__id__']) ]; $btn_install_all = [ 'title' => '安装', 'icon' => 'fa fa-fw fa-sign-in', 'class' => 'btn btn-primary ajax-post confirm', 'href' => url('install') ]; $btn_uninstall_all = [ 'title' => '卸载', 'icon' => 'fa fa-fw fa-sign-out', 'class' => 'btn btn-danger ajax-post confirm', 'href' => url('uninstall') ]; switch ($group) { case 'local': // 使用ZBuilder快速创建数据表格 return ZBuilder::make('table') ->setPageTitle('数据包管理') // 设置页面标题 ->setPrimaryKey('name') ->setTabNav($tab_list, $group) // 设置tab分页 ->addColumns([ // 批量添加数据列 ['name', '名称'], ['title', '标题'], ['author', '作者'], ['version', '版本号'], ['status', '是否安装', 'yesno'], ['right_button', '操作', 'btn'] ]) ->addTopButton('custom', $btn_install_all) ->addTopButton('custom', $btn_uninstall_all) ->addRightButton('custom', $btn_install) // 添加右侧按钮 ->addRightButton('custom', $btn_uninstall) // 添加右侧按钮 ->setRowList($data_list) // 设置表格数据 ->fetch(); // 渲染模板 break; case 'online': return '