Skip to content

Commit

Permalink
修复命令行下,强制生成以及删除操作的提示, 防止误操作
Browse files Browse the repository at this point in the history
  • Loading branch information
99php committed Jun 11, 2020
1 parent 165c729 commit 260d066
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
27 changes: 25 additions & 2 deletions app/common/command/Curd.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use think\console\input\Option;
use think\console\Output;
use EasyAdmin\auth\Node as NodeService;
use think\Exception;

class Curd extends Command
{
Expand Down Expand Up @@ -124,20 +125,42 @@ protected function execute(Input $input, Output $output)
}

$build = $build->render();
$fileList = $build->getFileList();

if (!$delete) {
$result = $build->create();
if($force){
$output->info(">>>>>>>>>>>>>>>");
foreach ($fileList as $key => $val) {
$output->info($key);
}
$output->info(">>>>>>>>>>>>>>>");
$output->info("确定强制生成上方所有文件? 如果文件存在会直接覆盖。 请输入 'yes' 按回车键继续操作: ");
$line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
if (trim($line) != 'yes') {
throw new Exception("取消文件CURD生成操作");
}
}
CliEcho::success('自动生成CURD成功');
} else {
$output->info(">>>>>>>>>>>>>>>");
foreach ($fileList as $key => $val) {
$output->info($key);
}
$output->info(">>>>>>>>>>>>>>>");
$output->info("确定删除上方所有文件? 请输入 'yes' 按回车键继续操作: ");
$line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
if (trim($line) != 'yes') {
throw new Exception("取消删除文件操作");
}
$result = $build->delete();
CliEcho::success('>>>>>>>>>>>>>>>');
CliEcho::success('删除自动生成CURD文件成功');
}

CliEcho::success('>>>>>>>>>>>>>>>');
foreach ($result as $vo) {
CliEcho::success($vo);
}

} catch (\Exception $e) {
CliEcho::error($e->getMessage());
return false;
Expand Down
2 changes: 1 addition & 1 deletion public/static/plugs/easy-admin/easy-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
text: function (data, option) {
var field = option.field;
try {
var value = eval("data." + field);status
var value = eval("data." + field);
} catch (e) {
var value = undefined;
}
Expand Down
9 changes: 9 additions & 0 deletions vendor/zhongshaofa/easy-admin/src/curd/BuildCurd.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,15 @@ public function setIgnoreFields($array)
return $this;
}

/**
* 获取相关的文件
* @return array
*/
public function getFileList()
{
return $this->fileList;
}

/**
* 构建基础视图、JS、URL
* @return $this
Expand Down

0 comments on commit 260d066

Please sign in to comment.