浏览代码

新增toggle开关disable参数
新增buttons数组按钮confirm支持function
修复CRUD生成多级模型时事务失效的BUG
修复token为空不验证的BUG

Karson 6 年之前
父节点
当前提交
a85db2323a

+ 3 - 3
application/admin/command/Addon.php

@@ -120,7 +120,7 @@ class Addon extends Command
                             $output->warning($v);
                         }
                         $output->info("Are you sure you want to " . ($action == 'enable' ? 'override' : 'delete') . " all those files?  Type 'yes' to continue: ");
-                        $line = fgets(STDIN);
+                        $line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
                         if (trim($line) != 'yes') {
                             throw new Exception("Operation is aborted!");
                         }
@@ -156,7 +156,7 @@ class Addon extends Command
                             $output->warning($v);
                         }
                         $output->info("Are you sure you want to override all those files?  Type 'yes' to continue: ");
-                        $line = fgets(STDIN);
+                        $line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
                         if (trim($line) != 'yes') {
                             throw new Exception("Operation is aborted!");
                         }
@@ -186,7 +186,7 @@ class Addon extends Command
                             $output->warning($v);
                         }
                         $output->info("Are you sure you want to delete all those files?  Type 'yes' to continue: ");
-                        $line = fgets(STDIN);
+                        $line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
                         if (trim($line) != 'yes') {
                             throw new Exception("Operation is aborted!");
                         }

+ 1 - 1
application/admin/command/Crud.php

@@ -840,7 +840,7 @@ class Crud extends Command
             }
 
             $data = [
-                'databaseConfigName'      => $db,
+                'modelConnection'         => $db == 'database' ? '' : "protected \$connection = '{$db}';",
                 'controllerNamespace'     => $controllerNamespace,
                 'modelNamespace'          => $modelNamespace,
                 'validateNamespace'       => $validateNamespace,

+ 2 - 2
application/admin/command/Crud/stubs/model.stub

@@ -10,8 +10,8 @@ class {%modelName%} extends Model
 
     {%softDelete%}
 
-    //数据库
-    protected $connection = '{%databaseConfigName%}';
+    {%modelConnection%}
+
     // 表名
     protected ${%modelTableType%} = '{%modelTableTypeName%}';
     

+ 1 - 1
application/admin/command/Menu.php

@@ -81,7 +81,7 @@ class Menu extends Command
             }
             if (!$force) {
                 $output->info("Are you sure you want to delete all those menu?  Type 'yes' to continue: ");
-                $line = fgets(STDIN);
+                $line = fgets(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'));
                 if (trim($line) != 'yes') {
                     throw new Exception("Operation is aborted!");
                 }

+ 1 - 1
application/admin/controller/Index.php

@@ -67,7 +67,7 @@ class Index extends Backend
             $rule = [
                 'username'  => 'require|length:3,30',
                 'password'  => 'require|length:3,30',
-                '__token__' => 'token',
+                '__token__' => 'require|token',
             ];
             $data = [
                 'username'  => $username,

+ 2 - 2
application/index/controller/User.php

@@ -92,7 +92,7 @@ class User extends Frontend
                 'email'     => 'require|email',
                 'mobile'    => 'regex:/^1\d{10}$/',
                 'captcha'   => 'require|captcha',
-                '__token__' => 'token',
+                '__token__' => 'require|token',
             ];
 
             $msg = [
@@ -152,7 +152,7 @@ class User extends Frontend
             $rule = [
                 'account'   => 'require|length:3,50',
                 'password'  => 'require|length:6,30',
-                '__token__' => 'token',
+                '__token__' => 'require|token',
             ];
 
             $msg = [

+ 5 - 1
public/assets/js/require-backend.min.js

@@ -10394,7 +10394,11 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
                     var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
                     var no = typeof this.no !== 'undefined' ? this.no : 0;
                     var url = typeof this.url !== 'undefined' ? this.url : '';
-                    return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change' data-id='"
+                    var disable = false;
+                    if (typeof this.disable !== "undefined") {
+                        disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
+                    }
+                    return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled' : '') + "' data-id='"
                         + row.id + "' " + (url ? "data-url='" + url + "'" : "") + " data-params='" + this.field + "=" + (value == yes ? no : yes) + "'><i class='fa fa-toggle-on " + (value == yes ? 'text-' + color : 'fa-flip-horizontal text-gray') + " fa-2x'></i></a>";
                 },
                 url: function (value, row, index) {

+ 7 - 2
public/assets/js/require-table.js

@@ -485,7 +485,11 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                     var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
                     var no = typeof this.no !== 'undefined' ? this.no : 0;
                     var url = typeof this.url !== 'undefined' ? this.url : '';
-                    return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change' data-id='"
+                    var disable = false;
+                    if (typeof this.disable !== "undefined") {
+                        disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
+                    }
+                    return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled' : '') + "' data-id='"
                         + row.id + "' " + (url ? "data-url='" + url + "'" : "") + " data-params='" + this.field + "=" + (value == yes ? no : yes) + "'><i class='fa fa-toggle-on " + (value == yes ? 'text-' + color : 'fa-flip-horizontal text-gray') + " fa-2x'></i></a>";
                 },
                 url: function (value, row, index) {
@@ -638,7 +642,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                         text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
                         title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
                         refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
-                        confirm = j.confirm ? 'data-confirm="' + j.confirm + '"' : '';
+                        confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.disable : false);
+                        confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
                         extend = j.extend ? j.extend : '';
                         disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
                         if (disable) {