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')); }