扩展插件完善优化

This commit is contained in:
2020-04-16 22:16:28 +08:00
parent 5439ccd8fb
commit ce9b63dda1
7 changed files with 48 additions and 29 deletions

View File

@@ -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;
}
}

View File

@@ -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(){
}
}

View File

@@ -0,0 +1,8 @@
<style type="text/css">
.third-login{margin: 0;}
.third-login li{list-style: none;}
</style>
<ul class="third-login">
<li><a href="{:addons_url('syslogin/index/login', ['type' => 'qq'])}"><i class="fa fa-qq"></i> QQ登录</a></li>
<li><a href="{:addons_url('syslogin/index/login', ['type' => 'wechat'])}"><i class="fa fa-wechat"></i> 微信登录</a></li>
</ul>

View File

@@ -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);

View File

@@ -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);

View File

@@ -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];

View File

@@ -62,6 +62,7 @@
<div class="col-sm-3" style="text-align: right;"><a href="{:url('/user/index/forget')}" class="btn btn-link">忘记密码</a></div>
</div>
</form>
<div>{:hook('loginBottomAddon')}</div>
</div>
</div>
</section>