无限星辰工作室-客户无限互联网动力之源

标题: FastAdmin 使用过程中BUG修复 [打印本页]

作者: crx349    时间: 2022-2-27 01:45
标题: FastAdmin 使用过程中BUG修复
一、使用 在线命令 富文本编辑器 不显示bug
解决:
一键CRUD说明中的示例指令是 --editorclass=xmspace
插件“在线命令”生成指令是 --editorsuffix=xmspace
实际运行一键CRUD后无效。

生成编辑器字段的达到条件为:
1、字段是 text 类型:text,tinytext,smalltext,mediumtext,longtext
否则不会生成textarea元素,而仅生成input元素。
2、按照 --editorclass=abcabc执行。
3、检查生成view中的add、edit页面,对应“abcabc”应生成正确的textarea元素,并可能需要手工添加
  1. class="form-control editor"
复制代码
中的
  1. editor
复制代码
。查找 add.html、edit.html中的以下代码


  1. <textarea id="c-content_cn" data-rule="required" class="form-control editor" rows="5" name="row[content_cn]" cols="50">{$row.content_cn|htmlentities}</textarea>
复制代码


统一解决办法:
application\admin\command\Crud.php
(1)
  1. ->addOption('editorclass', null, Option::VALUE_OPTIONAL, 'automatically generate editor class', null)
复制代码

改为
  1. ->addOption('editorsuffix', null, Option::VALUE_OPTIONAL, 'automatically generate editor class', null)
复制代码

(2)
  1. $editorclass = $input->getOption('editorclass');
复制代码

改为
  1. $editorsuffix = $input->getOption('editorsuffix');
复制代码

(3)
  1. if ($editorclass) {
  2.     $this->editorClass = $editorclass;
  3. }
复制代码

改为
  1. if ($editorsuffix) {
  2.     $this->editorSuffix = $editorsuffix;
  3. }
复制代码

这个修改后 更新缓存

二、在线命令 关联模型不显示下拉列表
game 和 game_type 通过id相互关联
game表 的 game_type_id 与 game_type 里的 id 关联,显示name_cn字段
如果使用关联模型生成,会出现 game在选择game_type关联下拉不显示。
解决办法:
(1)add.html和edit.html里面修改
  1. <div class="form-group">
  2.         <label class="control-label col-xs-12 col-sm-2">{:__('Game_type_id')}:</label>
  3.         <div class="col-xs-12 col-sm-8">
  4.             <input id="c-game_type_id" data-rule="required" data-source="game/type/index" class="form-control selectpage" name="row[game_type_id]" type="text" value="">
  5.         </div>
  6.     </div>
复制代码

改成
  1. <div class="form-group">
  2.         <label class="control-label col-xs-12 col-sm-2">{:__('Game_type_id')}:</label>
  3.         <div class="col-xs-12 col-sm-8">
  4.             <input id="c-game_type_id" data-rule="required" data-source="game_type/index" data-field="name_cn" class="form-control selectpage" name="row[game_type_id]" type="text" value="">
  5.         </div>
  6.     </div>
复制代码


(2)在关联模型里面如果默认名称不是name也会错

需要指定
  1. data-field=""
复制代码
如:
  1. data-field="name_cn"
复制代码

(3)在app\common\model\game.php这个模型里面的 type关联函数要修改,否则列表显示报错
  1. $this->belongsTo('app\common\model\game\Type',
复制代码

改成
  1. $this->belongsTo('app\common\model\GameType',
复制代码

三、在线命令 Model和控制器生成生成不是驼峰的bug
使用命令 以下
  1. php think crud --table=fa_game_type --local=0
复制代码

生成带下划线数据表模型和控制器时 会出现模型和控制器多了一层目录,导致菜单生成错误显示
需要改成这个命令 在cmd或ssh下执行
  1. php think crud --table=fa_game_type --local=0 -c GameType -m GameType
复制代码


以上问题 在1.3.3.20220121上配合在线命令1.0.6使用时出现,但是同版本在线命令在1.2.0.20210401_beta下并不会出现 问题一 问题三 ,总结一点,插件和系统版本不太配套,且用且修bug吧,记录下,后面出现好解决。




欢迎光临 无限星辰工作室-客户无限互联网动力之源 (https://www.xmspace.net/) Powered by Discuz! X3.4