rabin 1 anno fa
parent
commit
cc9f202f13
3 ha cambiato i file con 54 aggiunte e 1 eliminazioni
  1. 22 1
      lib/Page.php
  2. 3 0
      package.json
  3. 29 0
      table/manage/admin.php

+ 22 - 1
lib/Page.php

@@ -344,14 +344,35 @@ class Page extends Auth
         if (strpos($value['type'], '(')) {
             $value['type'] = $type;
         }
-        if (isset($value['upload'])) {
+        if (isset($value['upload']) && Dever::project('upload')) {
             $value['url'] = Dever::url('upload/save.act', array('id' => $value['upload']));
+            $value['config'] = Dever::load('upload/save')->get($value['upload']);
             if (isset($value['multiple']) && $value['multiple']) {
                 $value['limit'] = 10;
             } else {
                 $value['limit'] = 1;
             }
         }
+        if (isset($value['editorMenu'])) {
+            if (isset($value['editorMenu']['uploadImage'])) {
+                if (!is_array($value['editorMenu']['uploadImage'])) {
+                    $value['editorMenu']['uploadImage'] = array('upload' => $value['editorMenu']['uploadImage']);
+                }
+                $value['editorMenu']['uploadImage']['server'] = Dever::url('upload/save.wangEditor', array('id' => $value['editorMenu']['uploadImage']['upload']));
+                if (empty($value['editorMenu']['uploadImage']['fieldName'])) {
+                    $value['editorMenu']['uploadImage']['fieldName'] = 'file';
+                }
+            }
+             if (isset($value['editorMenu']['uploadVideo'])) {
+                if (!is_array($value['editorMenu']['uploadVideo'])) {
+                    $value['editorMenu']['uploadVideo'] = array('upload' => $value['editorMenu']['uploadVideo']);
+                }
+                $value['editorMenu']['uploadVideo']['server'] = Dever::url('upload/save.wangEditor', array('id' => $value['editorMenu']['uploadVideo']['upload']));
+                if (empty($value['editorMenu']['uploadImage']['fieldName'])) {
+                    $value['editorMenu']['uploadImage']['fieldName'] = 'file';
+                }
+            }
+        }
     }
 
     private function setDisable(&$value, $disable)

+ 3 - 0
package.json

@@ -0,0 +1,3 @@
+{
+	"rely": "upload"
+}

+ 29 - 0
table/manage/admin.php

@@ -236,6 +236,33 @@ return array
             'name' => array
             (
                 'type' => 'text',
+                # 定义editor的工具栏,一般无需配置,参考wangEditor https://www.wangeditor.com/v5/toolbar-config.html#toolbarkeys,这里直接配置toolbarConfig的值
+                /*
+                'editorToolBar' => array
+                (
+                    'toolbarKeys' => array
+                    (
+                        'headerSelect',
+                        '|',
+                        'bold', 'italic',
+                    ),
+                    'insertKeys' => array(),
+                    'excludeKeys' => array(),
+                ),*/
+                # 定义editor的菜单配置,一般只需要配置上传规则即可,其余也可以配置,参考wangEditor https://www.wangeditor.com/v5/menu-config.html,这里直接配置editorConfig.MENU_CONF的值
+                'editorMenu' => array
+                (
+                    # 定义上传规则,与uploadVideo一样,无需定义server
+                    'uploadImage' => array
+                    (
+                        # 这里传入上传规则id
+                        'upload' => 1,
+                        # 不传则默认为file
+                        'fieldName' => 'file',
+                    ),
+                    # 也可以直接传入上传规则,其余配置默认
+                    'uploadVideo' => 3,
+                ),
                 'maxlength' => 30,
                 # 描述
                 'desc' => '',
@@ -428,6 +455,8 @@ return array
                 'type' => 'upload',
                 # 这里传入上传规则id
                 'upload' => '1',
+                # 如果上传规则是上传到云端,配置了这个将直接上传至云端,不做本地上传
+                'yun' => false,
                 # 是否支持多选
                 'multiple' => false,
                 # 提示