Jelajahi Sumber

优化本地上传cdnurl

修复移动端站点配置不可见的问题
优化代码和注释
Karson 2 tahun lalu
induk
melakukan
2c02ed019b

+ 4 - 2
application/admin/controller/Ajax.php

@@ -59,8 +59,10 @@ class Ajax extends Backend
     public function upload()
     {
         Config::set('default_return_type', 'json');
-        //必须设定cdnurl为空,否则cdnurl函数计算错误
-        Config::set('upload.cdnurl', '');
+
+        //必须还原upload配置,否则分片及cdnurl函数计算错误
+        Config::load(APP_PATH . 'extra/upload.php', 'upload');
+
         $chunkid = $this->request->post("chunkid");
         if ($chunkid) {
             if (!Config::get('upload.chunking')) {

+ 2 - 2
application/admin/view/addon/config.html

@@ -70,13 +70,13 @@
                                         {foreach name="item.content" item="vo"}
                                         <label for="row[{$item.name}][]-{$key}"><input id="row[{$item.name}][]-{$key}" name="row[{$item.name}][]" type="checkbox" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
                                         {/foreach}
-                                        <span class="msg-box n-right" for="c-{$item.name}"></span>
+                                        <span class="msg-box n-right" for="row[{$item.name}]"></span>
                                         {/case}
                                         {case radio}
                                         {foreach name="item.content" item="vo"}
                                         <label for="row[{$item.name}]-{$key}"><input id="row[{$item.name}]-{$key}" name="row[{$item.name}]" type="radio" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
                                         {/foreach}
-                                        <span class="msg-box n-right" for="c-{$item.name}"></span>
+                                        <span class="msg-box n-right" for="row[{$item.name}]"></span>
                                         {/case}
                                         {case value="select" break="0"}{/case}
                                         {case value="selects"}

+ 0 - 9
application/admin/view/general/config/index.html

@@ -21,15 +21,6 @@
         visibility: visible;
     }
 
-    @media (max-width: 767px) {
-        .edit-form table tr th:nth-last-child(-n + 2), .edit-form table tr td:nth-last-child(-n + 2) {
-            display: none;
-        }
-
-        .edit-form table tr td .msg-box {
-            display: none;
-        }
-    }
 </style>
 <div class="panel panel-default panel-intro">
     <div class="panel-heading">

+ 4 - 4
extend/fast/Form.php

@@ -42,10 +42,10 @@ use ArrayAccess;
  * @method static string checkboxs(string $name, array $list = [], string $checked = null, array $options = []) 一组复选框
  * @method static string radio(string $name, string $value = null, string $checked = null, array $options = [])) 单个单选框
  * @method static string radios(string $name, array $list = [], string $checked = null, array $options = [])) 一组单选框
- * @method static string image(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件
- * @method static string images(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件(多图))
- * @method static string upload(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件
- * @method static string uploads(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件(多文件))
+ * @method static string image(string $name = null, string $value = null, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件
+ * @method static string images(string $name = null, string $value = null, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传图片组件(多图))
+ * @method static string upload(string $name = null, string $value = null, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件
+ * @method static string uploads(string $name = null, string $value = null, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 上传文件组件(多文件))
  * @method static string button(string $value = null, array $options = []) 表单button
  */
 class Form

+ 0 - 61
extend/fast/Random.php

@@ -90,67 +90,6 @@ class Random
     }
 
     /**
-     * 根据数组元素的概率获得键名
-     *
-     * @param array $ps     array('p1'=>20, 'p2'=>30, 'p3'=>50);
-     * @param int   $num    默认为1,即随机出来的数量
-     * @param bool  $unique 默认为true,即当num>1时,随机出的数量是否唯一
-     * @return mixed 当num为1时返回键名,反之返回一维数组
-     */
-    public static function lottery($ps, $num = 1, $unique = true)
-    {
-        if (!$ps) {
-            return $num == 1 ? '' : [];
-        }
-        if ($num >= count($ps) && $unique) {
-            $res = array_keys($ps);
-            return $num == 1 ? $res[0] : $res;
-        }
-        $max_exp = 0;
-        $res = [];
-        foreach ($ps as $key => $value) {
-            $value = substr($value, 0, stripos($value, ".") + 6);
-            $exp = strlen(strchr($value, '.')) - 1;
-            if ($exp > $max_exp) {
-                $max_exp = $exp;
-            }
-        }
-        $pow_exp = pow(10, $max_exp);
-        if ($pow_exp > 1) {
-            reset($ps);
-            foreach ($ps as $key => $value) {
-                $ps[$key] = $value * $pow_exp;
-            }
-        }
-        $pro_sum = array_sum($ps);
-        if ($pro_sum < 1) {
-            return $num == 1 ? '' : [];
-        }
-        for ($i = 0; $i < $num; $i++) {
-            $rand_num = mt_rand(1, $pro_sum);
-            reset($ps);
-            foreach ($ps as $key => $value) {
-                if ($rand_num <= $value) {
-                    break;
-                } else {
-                    $rand_num -= $value;
-                }
-            }
-            if ($num == 1) {
-                $res = $key;
-                break;
-            } else {
-                $res[$i] = $key;
-            }
-            if ($unique) {
-                $pro_sum -= $value;
-                unset($ps[$key]);
-            }
-        }
-        return $res;
-    }
-
-    /**
      * 获取全球唯一标识
      * @return string
      */