Browse Source

优化表格分页判断

优化语言包加载
Karson 3 years ago
parent
commit
3fd25c3de0

+ 1 - 0
application/common/controller/Api.php

@@ -153,6 +153,7 @@ class Api
     protected function loadlang($name)
     {
         $name = Loader::parseName($name);
+        $name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index';
         $lang = $this->request->langset();
         $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
         Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');

+ 4 - 3
application/common/controller/Backend.php

@@ -237,6 +237,7 @@ class Backend extends Controller
     protected function loadlang($name)
     {
         $name = Loader::parseName($name);
+        $name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index';
         $lang = $this->request->langset();
         $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
         Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
@@ -365,9 +366,9 @@ class Backend extends Controller
                 case 'BETWEEN':
                 case 'NOT BETWEEN':
                     $arr = array_slice(explode(',', $v), 0, 2);
-                    if (stripos($v, ',') === false || !array_filter($arr, function($v){
-                        return $v != '' && $v !== false && $v !== null;
-                    })) {
+                    if (stripos($v, ',') === false || !array_filter($arr, function ($v) {
+                            return $v != '' && $v !== false && $v !== null;
+                        })) {
                         continue 2;
                     }
                     //当出现一边为空时改变操作符

+ 1 - 0
application/common/controller/Frontend.php

@@ -128,6 +128,7 @@ class Frontend extends Controller
     protected function loadlang($name)
     {
         $name = Loader::parseName($name);
+        $name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index';
         $lang = $this->request->langset();
         $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
         Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');

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


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


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

@@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                 },
                 ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
             },
-            pageSize: Config.pagesize || 10,
+            pageSize: Config.pagesize || localStorage.getItem("pagesize") || 10,
             pageList: [10, 15, 20, 25, 50, 'All'],
             pagination: true,
             clickToSelect: true, //是否启用点击选中
@@ -114,6 +114,12 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                 $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
                     return this.$selectItem;
                 };
+                var _onPageListChange = $.fn.bootstrapTable.Constructor.prototype.onPageListChange;
+                $.fn.bootstrapTable.Constructor.prototype.onPageListChange = function () {
+                    _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
+                    localStorage.setItem('pagesize', this.options.pageSize);
+                    return false;
+                };
                 // 写入bootstrap-table默认配置
                 $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
                 // 写入bootstrap-table column配置