Browse Source

优化表单重置时组件渲染

移除CRUD默认的重置按钮
优化上传大小判断
优化插件管理
Karson 1 year ago
parent
commit
aca4e9221c

+ 0 - 1
application/admin/command/Crud/stubs/add.stub

@@ -5,7 +5,6 @@
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">
             <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
-            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
         </div>
     </div>
 </form>

+ 0 - 1
application/admin/command/Crud/stubs/edit.stub

@@ -5,7 +5,6 @@
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">
             <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
-            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
         </div>
     </div>
 </form>

+ 1 - 4
application/admin/lang/zh-cn/addon.php

@@ -14,7 +14,6 @@ return [
     'Refresh addon cache'                                     => '刷新插件缓存',
     'Userinfo'                                                => '会员信息',
     'Reload authorization'                                    => '刷新授权',
-    'Online store'                                            => '在线商店',
     'Local addon'                                             => '本地插件',
     'Conflict tips'                                           => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作',
     'Pay tips'                                                => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!',
@@ -24,8 +23,7 @@ return [
     'Upgrade tips'                                            => '确认升级<b>《%s》</b>?<p class="text-danger">1、请务必做好代码和数据库备份!备份!备份!<br>2、升级后如出现冗余数据,请根据需要移除即可!<br>3、不建议在生产环境升级,请在本地完成升级测试</p>如有重要数据请备份后再操作!',
     'Offline installed tips'                                  => '安装成功!清除浏览器缓存和框架缓存后生效!',
     'Online installed tips'                                   => '安装成功!清除浏览器缓存和框架缓存后生效!',
-    'Not login tips'                                          => '你当前未登录FastAdmin,请登录后操作!',
-    'Please login and try to install'                         => '请登录FastAdmin后再进行离线安装!',
+    'Please login and try to install'                         => '请登录FastAdmin后再进行本地安装!',
     'Not installed tips'                                      => '请安装后再访问插件前台页面!',
     'Not enabled tips'                                        => '插件已经禁用,请启用后再访问插件前台页面!',
     'New version tips'                                        => '发现新版本:%s 点击查看更新日志',
@@ -78,7 +76,6 @@ return [
     'Enable'                                                  => '启用',
     'Your username or email'                                  => '你的手机号、用户名或邮箱',
     'Your password'                                           => '你的密码',
-    'Login FastAdmin'                                         => '登录',
     'Login'                                                   => '登录',
     'Logout'                                                  => '退出登录',
     'Register'                                                => '注册账号',

+ 1 - 1
application/common/library/Upload.php

@@ -147,7 +147,7 @@ class Upload
         $size = $matches ? $matches[1] : $this->config['maxsize'];
         $type = $matches ? strtolower($matches[2]) : 'b';
         $typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
-        $size = (int)($size * pow(1024, $typeDict[$type] ?? 0));
+        $size = $size * pow(1024, $typeDict[$type] ?? 0);
         if ($this->fileInfo['size'] > $size) {
             throw new UploadException(__(
                 'File is too big (%sMiB), Max filesize: %sMiB.',

+ 4 - 11
public/assets/js/backend/addon.js

@@ -297,6 +297,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
                     Fast.api.ajax({
                         url: Config.api_url + '/user/logintpl',
                         type: 'post',
+                        loading: false,
                         data: {
                             version: Config.faversion,
                             sid: Controller.api.sid()
@@ -306,7 +307,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
                             content: Template.render(tpldata, {}),
                             zIndex: 99,
                             area: area,
-                            title: __('Login FastAdmin'),
+                            title: __('Login'),
                             resize: false,
                             btn: [__('Login')],
                             yes: function (index, layero) {
@@ -608,16 +609,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
                 var uid = userinfo ? userinfo.id : 0;
 
                 if (parseInt(uid) === 0) {
-                    return Layer.alert(__('Not login tips'), {
-                        title: __('Warning'),
-                        btn: [__('Login now')],
-                        yes: function (index, layero) {
-                            $(".btn-userinfo").trigger("click", name, version);
-                        },
-                        btn2: function () {
-                            install(name, version, false);
-                        }
-                    });
+                    $(".btn-userinfo").trigger("click", name, version);
+                    return false;
                 }
                 install(name, version, false);
             });

+ 2 - 2
public/assets/js/require-backend.js

@@ -6,7 +6,7 @@ require.config({
         main: 'moment'
     }],
     //在打包压缩时将会把include中的模块合并到主文件中
-    include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage'],
+    include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage', 'bootstrap-daterangepicker'],
     paths: {
         'lang': "empty:",
         'form': 'require-form',
@@ -63,7 +63,7 @@ require.config({
             exports: '$.fn.bootstrapTable.defaults'
         },
         'bootstrap-table-export': {
-            deps: ['bootstrap-table', 'tableexport'],
+            deps: ['bootstrap-table'],
             exports: '$.fn.bootstrapTable.defaults'
         },
         'bootstrap-table-fixed-columns': {

File diff suppressed because it is too large
+ 17 - 16
public/assets/js/require-backend.min.js


+ 17 - 2
public/assets/js/require-form.js

@@ -128,7 +128,11 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                     });
                     $(form).on("reset", function () {
                         setTimeout(function () {
-                            $('.selectpage', form).selectPageClear();
+                            $(".selectpage", form).each(function () {
+                                var selectpage = $(this).data("selectPageObject");
+                                selectpage.elem.hidden.val($(this).val());
+                                $(this).selectPageRefresh();
+                            });
                         }, 1);
                     });
                 }
@@ -361,6 +365,12 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                             return obj;
                         };
                         var fieldlist = $(".fieldlist", form);
+                        //表单重置
+                        form.on("reset", function () {
+                            setTimeout(function () {
+                                fieldlist.trigger("fa.event.refreshfieldlist");
+                            });
+                        });
                         //监听文本框改变事件
                         $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
                             var container = $(this).closest(".fieldlist");
@@ -478,6 +488,11 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                 if ($("[data-role='tagsinput']", form).length > 0) {
                     require(['tagsinput', 'autocomplete'], function () {
                         $("[data-role='tagsinput']").tagsinput();
+                        form.on("reset", function () {
+                            setTimeout(function () {
+                                $("[data-role='tagsinput']").tagsinput('reset');
+                            }, 0);
+                        });
                     });
                 }
             },
@@ -505,7 +520,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
                         '==': function(a, b) { return a == b; },
                         '!=': function(a, b) { return a != b; },
                         'in': function(a, b) { return b.split(/\,/).indexOf(a) > -1; },
-                        'regex': function(a, b) {
+                        'regex': function (a, b) {
                             var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
                             var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
                             return regexp.test(a);

+ 1 - 1
public/assets/js/require-frontend.js

@@ -62,7 +62,7 @@ require.config({
             exports: '$.fn.bootstrapTable.defaults'
         },
         'bootstrap-table-export': {
-            deps: ['bootstrap-table', 'tableexport'],
+            deps: ['bootstrap-table'],
             exports: '$.fn.bootstrapTable.defaults'
         },
         'bootstrap-table-fixed-columns': {

File diff suppressed because it is too large
+ 10 - 10
public/assets/js/require-frontend.min.js


+ 5 - 0
public/assets/js/require-upload.js

@@ -398,6 +398,11 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
                             });
                         }
                         if (input_id) {
+                            $("#" + input_id).closest("form").on("reset", function () {
+                                setTimeout($.proxy(function () {
+                                    $("#" + input_id, this).trigger("change");
+                                }, this), 0);
+                            });
                             //粘贴上传、拖拽上传
                             $("body").on('paste drop', "#" + input_id, function (event) {
                                 var originEvent = event.originalEvent;

File diff suppressed because it is too large
+ 1 - 2
public/assets/js/require.min.js


+ 9 - 0
public/assets/js/tagsinput.js

@@ -274,6 +274,15 @@
         },
 
         /**
+         * reset the items
+         */
+        reset: function () {
+            var val = this.$element.val();
+            this.removeAll();
+            this.add(val);
+        },
+
+        /**
          * Returns the items added as tags
          */
         items: function () {