fny5jt9 发表于 2024-10-10 03:33:30

FastAdmin插件应用研发总结,给即将入门的新手。


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">前言</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Fastadmin是基于TP5+Bootstrap的快速<span style="color: black;">研发</span>框架,类似微擎,以插件的形式来<span style="color: black;">研发</span>应用,在TP框架里功能较为完善和成熟。<span style="color: black;">近期</span>需要折腾一套可装修的商城应用,于是尝试着学习了该框架的插件<span style="color: black;">研发</span>。虽然之前有尝试过几次,<span style="color: black;">不外</span>都<span style="color: black;">由于</span>fast的插件<span style="color: black;">研发</span>方式和普通的TP框架的插件<span style="color: black;">研发</span>方式不太<span style="color: black;">同样</span>,来回折腾了几次都<span style="color: black;">无</span>搞明白,最后以失败告终,<span style="color: black;">不外</span><span style="color: black;">近期</span>的一番折腾<span style="color: black;">最终</span>搞清楚了,写下这篇<span style="color: black;">研发</span><span style="color: black;">文案</span>,<span style="color: black;">期盼</span>对新手有所<span style="color: black;">帮忙</span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">研发</span>前准备:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1、配置环境LNMP/PHP&gt;=7.0</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2、辅助插件两款:在线命令管理、插件<span style="color: black;">研发</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3、任意一款插件,<span style="color: black;">例如</span>blog</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">起始</span><span style="color: black;">研发</span>:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1、创建一个插件</p>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">办法</span>一:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">为你的插件取一个英文标识,标识应尽量简短(如:kefu、security、vbot、dinghorn),<span style="color: black;">并且未被FastAdmin插件市场的其他插件占用</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开命令行<span style="color: black;">掌控</span>台</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">切换到 FastAdmin 根目录,<span style="color: black;">亦</span><span style="color: black;">便是</span>think文件所在的目录(命令:)。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">输入&nbsp;php think addon -a 插件名<span style="color: black;">叫作</span> -c create&nbsp;新建一个插件</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">办法</span>二:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.打开“插件<span style="color: black;">研发</span>”插件,将对应的信息填入,确定后,会在addons看到生成的对应的插件目录文件</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2、创建好的插件目录</p>插件文件夹或文件描述application此文件夹中的所有文件会在插件安装时覆盖到根目录的/application文件夹,卸载时自动移除assets此文件夹中的所有文件会在插件安装时,复制到/public/assets/addons/guestbook文件夹controller此文件夹为插件<span style="color: black;">掌控</span>器目录,可<span style="color: black;">经过</span>:域名/index.php/addons/guestbook/controller/action进行<span style="color: black;">拜访</span>lang插件语言包目录model插件模型目录view插件视图目录public此文件夹中所有文件会在插件安装时覆盖到根目录的/public文件夹XXX.php此文件为插件核心安装卸载<span style="color: black;">掌控</span>器,必需存在,<span style="color: black;">常常</span><span style="color: black;">这里</span>文件的插件安装<span style="color: black;">办法</span>内,完成添加后台菜单等操作bootstrap.js插件JS<span style="color: black;">起步</span>文件,插件在安装完启用后,FastAdmin会将此文件中的内容合并到/public/assets/js/addons.js中去,FastAdmin自带的admin和index模块会自动载入addons.js文件,这<span style="color: black;">寓意</span>着此文件中的js代码,在admin和index模块被<span style="color: black;">拜访</span>时,将会被执行到LICENSE插件版权文件config.php插件配置文件,必须存在info.ini插件基本信息文件,必须存在,此文件<span style="color: black;">保留</span>了插件的标识,名<span style="color: black;">叫作</span>,介绍、作者、版本和<span style="color: black;">是不是</span>开启等install.sql插件数据库安装文件,此文件仅在插件安装时会进行导入<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3、插件配置</p>
    <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">基本</span>配置信息</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">基本</span>配置对应的是插件文件夹info.ini文件,此文件<span style="color: black;">掌控</span>着插件的<span style="color: black;">基本</span>信息及开关状态,<span style="color: black;">日前</span>支持以下几个配置信息,按需填写<span style="color: black;">就可</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">name&nbsp;=&nbsp;插件<span style="color: black;">独一</span>英文标识</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">title&nbsp;=&nbsp;插件标题/名<span style="color: black;">叫作</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">intro&nbsp;=&nbsp;插件介绍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">author&nbsp;=&nbsp;插件作者</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">website&nbsp;=&nbsp;https://www.fastadmin.net</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">version&nbsp;=&nbsp;1.0.0state&nbsp;=&nbsp;1<span style="color: black;">能够</span>在FastAdmin任何<span style="color: black;">地区</span><span style="color: black;">运用</span>&nbsp;get_addon_info(guestbook);&nbsp;来获取插件的<span style="color: black;">基本</span>配置信息,<span style="color: black;">通常</span>用来<span style="color: black;">协同</span>其他插件<span style="color: black;">运用</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$dinghorn&nbsp;=&nbsp;get_addon_info(dinghorn);if&nbsp;($dinghorn&nbsp;&amp;&amp;&nbsp;$dinghorn&nbsp;==&nbsp;1)&nbsp;{</p>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;标识为&nbsp;dinghorn&nbsp;的插件存在且已开启}<h2 style="color: black; text-align: left; margin-bottom: 10px;">插件扩展配置</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">扩展配置对应的是插件文件夹中的config.php,此文件请直接return一个二维数组,此文件在插件安装以后用户将<span style="color: black;">能够</span>在插件管理中手动修改其中的配置值。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">return&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;以下几乎所有字段都是必须存在的</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;配置名<span style="color: black;">叫作</span>,该值在当前数组配置中<span style="color: black;">保证</span><span style="color: black;">独一</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">name&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;demo_config,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;用户在设置插件配置时,<span style="color: black;">能够</span>看到的配置标题</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title&nbsp;&nbsp;&nbsp;=&gt;&nbsp;配置标题,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;配置类型,支持的配置类型请参考下方的<span style="color: black;">仔细</span>介绍</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;string,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//配置select/selects/checkbox/radio/bool时<span style="color: black;">表示</span>的列表项</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content&nbsp;=&gt;&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1&nbsp;=&gt;&nbsp;<span style="color: black;">表示</span>,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;=&gt;&nbsp;不<span style="color: black;">表示</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//配置默认值,若是多选,<span style="color: black;">运用</span>半角逗号分隔</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;&nbsp;&nbsp;=&gt;&nbsp;1,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//配置验证规则,<span style="color: black;">更加多</span>规则可参考nice-validator文档</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rule&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;required,//&nbsp;必填</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;验证失败提示文字,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;字段填写<span style="color: black;">帮忙</span>,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">ok&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;验证成功提示文字,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;扩展信息</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extend&nbsp;&nbsp;=&gt;&nbsp;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;],</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;success_log,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title&nbsp;&nbsp;&nbsp;=&gt;&nbsp;记录成功日志,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;radio,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content&nbsp;=&gt;&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;=&gt;&nbsp;记录,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;=&gt;&nbsp;不记录</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;&nbsp;&nbsp;=&gt;&nbsp;1,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">rule&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;required,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;验证失败提示文字,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;发送<span style="color: black;">信息</span>成功后,记录日志,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ok&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt;&nbsp;验证成功提示文字,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;扩展信息</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extend&nbsp;&nbsp;=&gt;&nbsp;</p>&nbsp;&nbsp;&nbsp;&nbsp;]];<h3 style="color: black; text-align: left; margin-bottom: 10px;">支持的配置类型</h3>配置类型介绍string单行文本输入框text多行文本输入框(textarea)number数字输入框date日期<span style="color: black;">选取</span>控件(YYYY-MM-DD)time时间<span style="color: black;">选取</span>控件(HH:mm:ss)datetime日期时间<span style="color: black;">选取</span>控件(YYYY-MM-DD HH:mm:ss)array一维数组select下拉<span style="color: black;">选取</span>框,单选,在content中定义可<span style="color: black;">选取</span>项selects下拉<span style="color: black;">选取</span>框,单选,在content中定义可<span style="color: black;">选取</span>项image<span style="color: black;">照片</span>上传控件images多图上传控件file文件上传控件files多文件上传控件checkbox多选框,可<span style="color: black;">运用</span>半角逗号分隔其需要自动<span style="color: black;">选取</span>上的默认值,如value =&gt; 0,1,radio单选框bool类似单选框,自动生成是和否两个选项<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上传类控件,用户<span style="color: black;">选取</span>文件并自动上传成功后,<span style="color: black;">保留</span>文件路径到插件配置中</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">配置类型<span style="color: black;">倘若</span>是select/selects/checkbox/radio/bool其中之一,需要设置好content参考上方的示例</p>,<span style="color: black;">更加多</span>配置验证规则,请查阅&nbsp;nice-validator文档
    <h2 style="color: black; text-align: left; margin-bottom: 10px;">插件<span style="color: black;">起步</span>配置</h2>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">插件<span style="color: black;">起步</span>配置文件<span style="color: black;">位置于</span>/application/extra/addons.php,FastAdmin在后台安装或卸载插件时会自动更新此文件,你<span style="color: black;">亦</span><span style="color: black;">能够</span>手动配置插件的<span style="color: black;">起步</span>配置,配置如下</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;<span style="color: black;">是不是</span>自动读取取插件钩子配置信息(默认是关闭)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;autoload&nbsp;=&gt;&nbsp;false,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;当关闭自动获取配置时需要手动配置hooks信息</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;hooks&nbsp;=&gt;&nbsp;[</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;<span style="color: black;">能够</span>定义多个钩子</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">testhook=&gt;test&nbsp;&nbsp;//&nbsp;键为钩子名<span style="color: black;">叫作</span>,用于在业务中自定义钩子处理,值为实现该钩子的插件,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;多个插件<span style="color: black;">能够</span>用数组<span style="color: black;">亦</span><span style="color: black;">能够</span>用逗号分割</p>&nbsp;&nbsp;&nbsp;&nbsp;]];<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4、为插件添加后台功能(</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&nbsp; &nbsp; &nbsp; 后台功能的<span style="color: black;">研发</span>流程:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&nbsp; &nbsp; &nbsp; 计数据库-&gt;一键CRUD-&gt;修改生成好的CRUD(<span style="color: black;">按照</span>插件需要,<span style="color: black;">能够</span><span style="color: black;">选取</span>不改)-&gt;移动到插件对应目录-&gt;插件核心安装卸载<span style="color: black;">掌控</span>器的安装<span style="color: black;">办法</span>内创建菜单</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">例如我要在shopro插件中添加一个<span style="color: black;">文案</span>模块,我应该这么做</p>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&nbsp;设计好你所需要的数据库及字段,并将数据表fa_shopro_news导入到数据库</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">点击“在线命令管理”插件,<span style="color: black;">根据</span>下面的设置<span style="color: black;">选取</span>添加<span style="color: black;">保留</span>,生成对应的<span style="color: black;">掌控</span>器和模型</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://mmbiz.qpic.cn/mmbiz_png/gFdHZoIUeM8JgpzUOYdrllX2fjfsNOz1uf8uTtdJLcoicXcKHfj5LJsD6hweK9TP2ZJl7ZnoCYfMPApgTnGsnpQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">备注:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">掌控</span>器那里,若直接填写<span style="color: black;">掌控</span>器名<span style="color: black;">叫作</span>,会在application/admin/controller目录下生成对应的<span style="color: black;">掌控</span>器;若在前面加上目录,例如xxx/<span style="color: black;">掌控</span>器,则会在application/admin/controler/xxx/<span style="color: black;">掌控</span>器;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">模型的规则同上,<span style="color: black;">详细</span>的目录是在application/admin/model下生成</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">生成后台菜单:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">办法</span>:点击“插件<span style="color: black;">研发</span>”-&gt;对应插件-&gt;菜单-&gt;填写对应的菜单信息</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/gFdHZoIUeM8JgpzUOYdrllX2fjfsNOz1IxWymK5lmBt5uAT16Na4fEIGKThGamMrgc3yhjjH1JshYicPibGhf7bQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">备注:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">菜单规则那里为:文件名/<span style="color: black;">掌控</span>器,设置完后<span style="color: black;">就可</span>生成对应的菜单</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">菜单创建完后就<span style="color: black;">能够</span><span style="color: black;">运用</span>后台的增删盖改查了,对应的视图生成路径在application/admin/view/插件名<span style="color: black;">叫作</span>/xxx</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">至此,后台的<span style="color: black;">文案</span>模块就添加完毕。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5、插件的API</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">插件的api路径在,addons/插件名<span style="color: black;">叫作</span>/controller+model下,<span style="color: black;">倘若</span>想要添加插件的api,请在<span style="color: black;">这儿</span><span style="color: black;">增多</span>对应的<span style="color: black;">掌控</span>器和模型,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而后</span>插件需要继承Base.php,<span style="color: black;">这般</span>就<span style="color: black;">能够</span>正常<span style="color: black;">拜访</span>插件了。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">api的<span style="color: black;">拜访</span>路径为:https://你的域名/addons/插件名/<span style="color: black;">掌控</span>器/<span style="color: black;">办法</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">6、插件的打包</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">点击插件<span style="color: black;">研发</span>/打包<span style="color: black;">就可</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">备注:<span style="color: black;">倘若</span>插件不打包,直接将插件下载到本地修改,再次打包上传安装,会<span style="color: black;">显现</span>“找不到插件配置”的报错,<span style="color: black;">因此</span>每次<span style="color: black;">研发</span>完记得先打包一次。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">小结:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Fastadmin插件的<span style="color: black;">研发</span><span style="color: black;">区别</span>于其他插件,二开插件的时候,<span style="color: black;">不可</span>在addons直接修改;而是要在application/admin下</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">修改对应的文件<span style="color: black;">才可</span>生效。</p>




1fy07h 发表于 2024-10-15 19:55:38

这篇文章真的让我受益匪浅,外链发布感谢分享!
页: [1]
查看完整版本: FastAdmin插件应用研发总结,给即将入门的新手。