扩展插件完善优化
This commit is contained in:
+17
-17
@@ -15,24 +15,24 @@ namespace addons\syslogin;
|
|||||||
|
|
||||||
class Plugin extends \sent\Addons{
|
class Plugin extends \sent\Addons{
|
||||||
|
|
||||||
public $info = array(
|
public $info = array(
|
||||||
'name'=>'Syslogin',
|
'name'=>'Syslogin',
|
||||||
'title'=>'第三方登录',
|
'title'=>'第三方登录',
|
||||||
'description'=>'第三方登录',
|
'description'=>'第三方登录',
|
||||||
'status'=>1,
|
'status'=>1,
|
||||||
'author'=>'molong',
|
'author'=>'molong',
|
||||||
'version'=>'0.1'
|
'version'=>'0.1'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function loginBottomAddon(){
|
public function loginBottomAddon(){
|
||||||
|
return $this->fetch('login');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function install(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function install(){
|
public function uninstall(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,13 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace addons\syslogin\controller;
|
namespace addons\syslogin\controller;
|
||||||
use app\common\controller\Addons;
|
|
||||||
|
|
||||||
class Index extends Addons{
|
class Index extends \app\controller\front\Base{
|
||||||
|
|
||||||
public function login(){
|
public function login(){
|
||||||
$this->template('index/login');
|
}
|
||||||
|
|
||||||
|
public function callback(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -205,15 +205,19 @@ class Addons extends Base {
|
|||||||
*/
|
*/
|
||||||
public function addhook() {
|
public function addhook() {
|
||||||
if ($this->request->isPost()) {
|
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) {
|
if ($result !== false) {
|
||||||
return $this->success("修改成功");
|
return $this->success("添加成功");
|
||||||
} else {
|
} else {
|
||||||
return $this->error($hooks->getError());
|
return $this->error('添加失败!');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$keylist = Hooks::getaddons([]);
|
||||||
$this->data = array(
|
$this->data = array(
|
||||||
'keyList' => Hooks::$keylist,
|
'keyList' => $keylist,
|
||||||
);
|
);
|
||||||
return $this->fetch('admin/public/edit');
|
return $this->fetch('admin/public/edit');
|
||||||
}
|
}
|
||||||
@@ -225,12 +229,13 @@ class Addons extends Base {
|
|||||||
public function edithook($id) {
|
public function edithook($id) {
|
||||||
if ($this->request->isPost()) {
|
if ($this->request->isPost()) {
|
||||||
$data = $this->request->post();
|
$data = $this->request->post();
|
||||||
|
$data['addons'] = isset($data['addons'][0]) ? $data['addons'][0] : [];
|
||||||
|
|
||||||
$result = Hooks::update($data, ['id' => $data['id']]);
|
$result = Hooks::update($data, ['id' => $data['id']]);
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
return $this->success("修改成功");
|
return $this->success("修改成功");
|
||||||
} else {
|
} else {
|
||||||
return $this->error($hooks->getError());
|
return $this->error('修改失败!');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$info = Hooks::find($id);
|
$info = Hooks::find($id);
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class Base extends BaseC {
|
|||||||
if ($template == '') {
|
if ($template == '') {
|
||||||
$template = str_replace(".", "@", strtolower($this->request->controller())) . "/" . $this->request->action();
|
$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::config($this->tpl_config);
|
||||||
View::assign($this->data);
|
View::assign($this->data);
|
||||||
|
|||||||
+3
-4
@@ -20,8 +20,8 @@ class Hooks extends \think\Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function setAddonsAttr($value){
|
protected function setAddonsAttr($value){
|
||||||
if (!empty($value[0])) {
|
if (is_array($value) && !empty($value)) {
|
||||||
return implode(",", $value[0]);
|
return implode(",", $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +57,7 @@ class Hooks extends \think\Model {
|
|||||||
if (isset($row[$value]) && !empty($row[$value])) {
|
if (isset($row[$value]) && !empty($row[$value])) {
|
||||||
$info = $row[$value];
|
$info = $row[$value];
|
||||||
$addons = $info['addons'] ? explode(",", $info['addons']) : [];
|
$addons = $info['addons'] ? explode(",", $info['addons']) : [];
|
||||||
empty($addons) ? [$name] : array_push($addons, $name);
|
$info['addons'] = empty($addons) ? [$name] : array_push($addons, $name);
|
||||||
$info['addons'] = implode(",", $addons);
|
|
||||||
$save[] = $info;
|
$save[] = $info;
|
||||||
}else{
|
}else{
|
||||||
$save[] = ['name' => $value, 'type' => 1, 'create_time' => time(), 'status' => 1, 'addons'=> $name];
|
$save[] = ['name' => $value, 'type' => 1, 'create_time' => time(), 'status' => 1, 'addons'=> $name];
|
||||||
|
|||||||
@@ -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 class="col-sm-3" style="text-align: right;"><a href="{:url('/user/index/forget')}" class="btn btn-link">忘记密码</a></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div>{:hook('loginBottomAddon')}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user