后臺管理系統ConsoleHtml
1.在插件目錄下創建文件admin/listen/ConsoleHtml.php控制臺綁定html事件,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class ConsoleHtml
{
public function handle()
{
$html['header'] = '定義你的css文件';
$html['content'] = '這是我在OneKeyAdmin里使用的第一個事件~~';
$html['footer'] = '定義你的JS文件 ';
return $html;
}
}
~~~
2.已綁定控制臺頁面,“這是我在OneKeyAdmin里使用的第一個事件”;
后臺管理系統CommonGlobal
1.在插件目錄下創建文件admin/listen/CommonGlobal.php模板全局變量,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class CommonGlobal
{
public function handle()
{
$global = [];
$global['ceshi'] = '這是后臺模板全局變量';
return $global;
}
}
~~~
2.已綁定Global全局變量,打印console.log(Global)查看;
后臺管理系統CommonHtml
1.在插件目錄下創建文件admin/listen/CommonHtml.php模板全局html,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class CommonHtml
{
public function handle()
{
$html['header'] = '你想要引入的css文件';
$html['content'] = '你想要引入的html代碼';
$html['footer'] = '你想要引入的js代碼';
return $html;
}
}
~~~
2.已綁定全部html頁面,“你想要引入的html代碼”;
后臺管理系統UploadEnd
1.在插件目錄下創建文件admin/listen/UploadEnd.php文件上傳結束事件,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class UploadEnd
{
public function handle(string $url)
{
echo "已獲取$url,請做你想做的事";
}
}
~~~
2.上傳結束后,獲得$url參數;
后臺管理系統ConfigHook
1.在插件目錄下創建文件admin/listen/ConfigHook.php綁定系統配置鉤子,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class ConfigHook
{
public function handle()
{
$arr[] = [
"title" => "測試配置", // 插件配置標題
"name" => "ceshi", // 插件配置別名
"url" => "ceshi/config/index", // 插件配置路由
];
return $arr;
}
}
~~~
2.已綁定常規管理->系統配置->我是測試配置;
后臺管理系統UserConfigHook
1.在插件目錄下創建文件admin/listen/UserConfigHook.php綁定會員配置鉤子,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class UserConfigHook
{
public function handle()
{
$field[] = [
"title" => "測試",
"name" => "text", // 請參考common.js中的formType方法
"bind" => "el-input",// 請參考common.js中的formType方法
"value" => 0,
"field" => "ceshi",
"label" => "新增會員測試字段:",
];
return $field;
}
}
~~~
2.已綁定常規管理->系統配置->會員配置->新增測試字段(文本格式);
后臺管理系統UserAdminField
1.在插件目錄下創建文件admin/listen/UserAdminField.php綁定管理員自定義字段,例:
~~~php
<?php
namespace plugins\ceshi\admin\listen;
class UserAdminField
{
public function handle()
{
$field[] = [
"title" => "開關",
"name" => "switch", // 請參考common.js中的formType方法
"bind" => "el-switch", // 請參考common.js中的formType方法
"value" => false,
"field" => "technical_customer_service_switch",
"label" => "技術客服:",
];
$field[] = [
"title" => "字符",
"name" => "text",
"bind" => "el-input",
"value" => "",
"field" => "qq",
"label" => "客服QQ:",
];
return $field;
}
}
~~~
2.已綁定后臺管理系統->管理員插件自定義字段;
前臺主題模板AppCheckInit
1.在插件目錄下創建文件index/listen/AppCheckInit.php主題模板初始化檢測,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class AppCheckInit
{
public function handle()
{
$arrIp = ['127.0.0.1'];
if (in_array(request()->ip(), $arrIp)) {
die('很抱歉,您被禁止訪問此網站');
}
}
}
~~~
2.綁定主題模板初始化檢測鉤子;
前臺主題模板UserDashboard
1.在插件目錄下創建文件index/listen/UserDashboard.php主題模板會員中心主頁,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class UserDashboard
{
public function handle()
{
$dashboard = [
[
'number' => 0,
'icon' => 'el-icon-star-off',
'title' => 'Number of products collected', //可在語言包中設置
'url' => 'cms/user/productCollection',
"color" => "#18bc9c"
],
];
return $dashboard;
}
}
~~~
2.綁定主題模板->會員中心->主頁數據統計;
前臺主題模板PersonalPublic
1.在插件目錄下創建文件index/listen/PersonalPublic.php主題模板會員中心側邊欄,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class PersonalPublic
{
public function handle()
{
return [
['title' =>'會員中心側邊', 'url' => get_url('blog/user/letterList'), 'icon' => 'el-icon-chat-line-round', 'count' => 20],
];
}
}
~~~
2.綁定主題模板會員中心側邊欄;
前臺主題模板RouteCheckEnd
1.在插件目錄下創建文件index/listen/RouteCheckEnd.php主題模板路由檢測完畢,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class RouteCheckEnd
{
public function handle()
{
echo '路由檢測完畢';
}
}
~~~
2.綁定主題模板路由檢測完畢鉤子;
前臺主題模板UserRegisterEnd
1.在插件目錄下創建文件index/listen/UserRegisterEnd.php主題模板用戶注冊完成鉤子,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class UserRegisterEnd
{
public function handle($registerInfo)
{
echo "注冊完成啦";
}
}
~~~
2.綁定主題模板用戶注冊完成后;
前臺主題模板UserLoginApi
1.在插件目錄下創建文件index/listen/UserLoginApi.php主題模板會員第三方登錄,例:
~~~php
<?php
namespace plugins\ceshi\index\listen;
class UserLoginApi
{
public function handle()
{
$api= [
[
'url' => 'ceshi/index/qqLogin',
'title' => 'QQ登錄',
'cover' => '/image/xxx.png',
],
];
return $api;
}
}
~~~
2.綁定主題模板第三方登錄;
前臺主題模板CommonGlobal、CommonHtml
與后臺管理系統調用方式一致只需要修改namespace plugins\\ceshi\\admin\\listen;命名空間admin改為index即可;