配置文件config.php
完整的配置信息
<?php
namespace app\hello;//hello插件目录标识
use app\controller\Addons;
use think\facade\View;
use think\facade\Db;
use app\BaseController;
use think\facade\Request;
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2025 All rights reserved.
// +----------------------------------------------------------------------
// | Author: @梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class config extends Addons
{
// 插件的信息配置
public $info = array(
'name' => 'hello',//插件目录,标识
'title' => '插件标题',//插件名称
'description' => '插件的描述',//插件描述
'banben' => '1.0',//插件版本号
'pic' => '/app/hello/ico.svg',//插件图标
'fa' => 'fa-bars',//fa图标侧边显示使用/index.php/admin/web/fa.html
'admin' => '1',////是否在左侧显示
'url' => array(
'/index.php/hello/index/index.html' => '测试管理',
)
);
// 插件的设置配置
public $admin = array(
'open' => array(
'md' => '12',//容器宽度1-12
'title' => '单选框',//标题说明
'type' => '单选框',//类型 单选框 选择框 输入框 文本域 密码框 附件 颜色 时间
'options' => array(
'1' => '启用',
'0' => '关闭',
),
'value' => '1',//默认值
),
'' => array(
'title' => '我是分割线',
),
'url' => array(
'md' => '4',
'title' => '示例选择',
'type' => '选择框',
'options' => array(
'1' => '选择一',
'2' => '选择二',
),
'value' => '2',
'required' => 'required',//必填 可空
),
'demo2' => array(
'md' => '4',
'title' => '示例输入',
'type' => '输入框',
'value' => '我的默认值',
'required' => 'required',//必填 可空
),
'demo3' => array(
'md' => '4',
'title' => '示例密码框',
'type' => '密码框',
'value' => '',
'required' => 'required',//必填 可空
),
'demo4' => array(
'md' => '12',
'title' => '示例文本域',
'type' => '文本域',
'value' => '',
'rows' => '4',//文本域高度
'required' => 'required',//必填 可空
),
'demo5' => array(
'md' => '4',
'title' => '示例附件',
'type' => '附件',
'value' => '',
'required' => 'required',//必填 可空
),
'demo6' => array(
'md' => '4',
'title' => '示例颜色',
'type' => '颜色',
'value' => '#000000',
'required' => 'required',//必填 可空
),
'demo7' => array(
'md' => '4',
'title' => '示例时间',
'type' => '时间',
'value' => '',
'required' => 'required',//必填 可空
),
);
// 安装方法
public function install()
{
$this->Hook('hello', $this->info['name']);//创建的钩子
$sqldata = file_get_contents(dirname(__FILE__) . '/install.sql');
sql($sqldata,false);
return true;
}
// 卸载方法
public function uninstall()
{
$sqldata = file_get_contents(dirname(__FILE__) . '/uninstall.sql');
sql($sqldata,false);
return true;
}
// 钩子一方法
public function hello()
{
echo View::fetch('app/hello/view/home.html');
}
}