From ce9b63dda1645c4312dd1bd22f5c14bba72f3b1d Mon Sep 17 00:00:00 2001 From: tensent Date: Thu, 16 Apr 2020 22:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=8F=92=E4=BB=B6=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/syslogin/Plugin.php | 34 +++++++++---------- addons/syslogin/controller/Index.php | 8 +++-- addons/syslogin/view/login.html | 8 +++++ app/controller/admin/Addons.php | 15 +++++--- app/controller/front/Base.php | 4 +++ app/model/Hooks.php | 7 ++-- public/template/default/user/index_login.html | 1 + 7 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 addons/syslogin/view/login.html diff --git a/addons/syslogin/Plugin.php b/addons/syslogin/Plugin.php index d95e5649..0f1acbb1 100644 --- a/addons/syslogin/Plugin.php +++ b/addons/syslogin/Plugin.php @@ -15,24 +15,24 @@ namespace addons\syslogin; class Plugin extends \sent\Addons{ - public $info = array( - 'name'=>'Syslogin', - 'title'=>'第三方登录', - 'description'=>'第三方登录', - 'status'=>1, - 'author'=>'molong', - 'version'=>'0.1' - ); + public $info = array( + 'name'=>'Syslogin', + 'title'=>'第三方登录', + 'description'=>'第三方登录', + 'status'=>1, + 'author'=>'molong', + 'version'=>'0.1' + ); - public function loginBottomAddon(){ + public function loginBottomAddon(){ + return $this->fetch('login'); + } - } + public function install(){ + return true; + } - public function install(){ - return true; - } - - public function uninstall(){ - return true; - } + public function uninstall(){ + return true; + } } \ No newline at end of file diff --git a/addons/syslogin/controller/Index.php b/addons/syslogin/controller/Index.php index 34c72d53..12aa7c3f 100644 --- a/addons/syslogin/controller/Index.php +++ b/addons/syslogin/controller/Index.php @@ -8,11 +8,13 @@ // +---------------------------------------------------------------------- namespace addons\syslogin\controller; -use app\common\controller\Addons; -class Index extends Addons{ +class Index extends \app\controller\front\Base{ public function login(){ - $this->template('index/login'); + } + + public function callback(){ + } } diff --git a/addons/syslogin/view/login.html b/addons/syslogin/view/login.html new file mode 100644 index 00000000..ad194a26 --- /dev/null +++ b/addons/syslogin/view/login.html @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/app/controller/admin/Addons.php b/app/controller/admin/Addons.php index 50e99006..8c9f7d7f 100644 --- a/app/controller/admin/Addons.php +++ b/app/controller/admin/Addons.php @@ -205,15 +205,19 @@ class Addons extends Base { */ public function addhook() { if ($this->request->isPost()) { - $result = $hooks->change(); + $data = $this->request->post(); + $data['addons'] = isset($data['addons'][0]) ? $data['addons'][0] : []; + + $result = Hooks::create($data); if ($result !== false) { - return $this->success("修改成功"); + return $this->success("添加成功"); } else { - return $this->error($hooks->getError()); + return $this->error('添加失败!'); } } else { + $keylist = Hooks::getaddons([]); $this->data = array( - 'keyList' => Hooks::$keylist, + 'keyList' => $keylist, ); return $this->fetch('admin/public/edit'); } @@ -225,12 +229,13 @@ class Addons extends Base { public function edithook($id) { if ($this->request->isPost()) { $data = $this->request->post(); + $data['addons'] = isset($data['addons'][0]) ? $data['addons'][0] : []; $result = Hooks::update($data, ['id' => $data['id']]); if ($result !== false) { return $this->success("修改成功"); } else { - return $this->error($hooks->getError()); + return $this->error('修改失败!'); } } else { $info = Hooks::find($id); diff --git a/app/controller/front/Base.php b/app/controller/front/Base.php index 5fa6e20d..51c21266 100644 --- a/app/controller/front/Base.php +++ b/app/controller/front/Base.php @@ -29,6 +29,10 @@ class Base extends BaseC { if ($template == '') { $template = str_replace(".", "@", strtolower($this->request->controller())) . "/" . $this->request->action(); } + if($this->request->param('addon')){ + $this->tpl_config['view_depr'] = '/'; + $this->tpl_config['view_dir_name'] = 'addons' . DIRECTORY_SEPARATOR . $this->request->param('addon') . DIRECTORY_SEPARATOR . 'view'; + } View::config($this->tpl_config); View::assign($this->data); diff --git a/app/model/Hooks.php b/app/model/Hooks.php index ca22e35b..dba6a97e 100644 --- a/app/model/Hooks.php +++ b/app/model/Hooks.php @@ -20,8 +20,8 @@ class Hooks extends \think\Model { } protected function setAddonsAttr($value){ - if (!empty($value[0])) { - return implode(",", $value[0]); + if (is_array($value) && !empty($value)) { + return implode(",", $value); } } @@ -57,8 +57,7 @@ class Hooks extends \think\Model { if (isset($row[$value]) && !empty($row[$value])) { $info = $row[$value]; $addons = $info['addons'] ? explode(",", $info['addons']) : []; - empty($addons) ? [$name] : array_push($addons, $name); - $info['addons'] = implode(",", $addons); + $info['addons'] = empty($addons) ? [$name] : array_push($addons, $name); $save[] = $info; }else{ $save[] = ['name' => $value, 'type' => 1, 'create_time' => time(), 'status' => 1, 'addons'=> $name]; diff --git a/public/template/default/user/index_login.html b/public/template/default/user/index_login.html index 552c4101..647e3f1f 100644 --- a/public/template/default/user/index_login.html +++ b/public/template/default/user/index_login.html @@ -62,6 +62,7 @@
忘记密码
+
{:hook('loginBottomAddon')}