From 2eff7811660429dbeabc69216f322b4967ef9348 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Oct 2019 16:33:28 +0800 Subject: [PATCH] =?UTF-8?q?SDK=E7=94=A8=E6=88=B7=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/SdkMenuController.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/SdkMenuController.class.php b/Application/Admin/Controller/SdkMenuController.class.php index fc50f758a..f7611245c 100644 --- a/Application/Admin/Controller/SdkMenuController.class.php +++ b/Application/Admin/Controller/SdkMenuController.class.php @@ -8,9 +8,12 @@ class SdkMenuController extends ThinkController{ { $sdkMenus = M('tool','tab_')->where(['name' => 'sdk_menu'])->find(); $config = json_decode($sdkMenus['config'],true); - foreach($config as $k => $v) + if(!empty($config)) { - $config[$k]['icon'] = is_https()?'https://':'http://' . $_SERVER['SERVER_NAME'] . $v['icon']; + foreach($config as $k => $v) + { + $config[$k]['icon'] = is_https()?'https://':'http://' . $_SERVER['SERVER_NAME'] . $v['icon']; + } } $this->assign('list',$config); $this->meta_title = 'SDk用户菜单'; @@ -38,7 +41,15 @@ class SdkMenuController extends ThinkController{ $post['id'] = $id; array_push($config,$post); $sdkMenus['config'] = json_encode($config); - M('tool','tab_')->where(['name' => 'sdk_menu'])->data($sdkMenus)->save(); + if(empty($sdkMenus['name'])) + { + $sdkMenus['name'] = 'sdk_menu'; + $sdkMenus['title'] = 'SDK用户菜单'; + M('tool','tab_')->data($sdkMenus)->add(); + }else + { + M('tool','tab_')->where(['name' => 'sdk_menu'])->data($sdkMenus)->save(); + } $this->success('新增成功', U('lists')); }