From 075a33760f7debd8f528f4a9904933fd66acd01d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com>
Date: Mon, 26 Jun 2023 12:22:35 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20?=
 =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=94=AF=E6=8C=81=E9=9F=B3?=
 =?UTF-8?q?=E8=A7=86=E9=A2=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 web/src/config/d2p-extends/types.js | 42 +++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/web/src/config/d2p-extends/types.js b/web/src/config/d2p-extends/types.js
index d466887..4937abe 100644
--- a/web/src/config/d2p-extends/types.js
+++ b/web/src/config/d2p-extends/types.js
@@ -84,6 +84,48 @@ export default {
       }
     }
   },
+  'video-uploader': {
+    form: { component: { name: 'd2p-file-uploader', props: { elProps: { limit: 1, listType: 'video', accept: '.avi,.wmv,.mpg,.mpeg,.mov,.rm,.ram,.swf,.flv,.mp4,.mp3,.wma,.avi,.rm,.rmvb,.flv,.mpg,.mkv', showFileList: false } } } },
+    component: { name: 'd2p-images-format' },
+    view: {
+      component: { props: { height: 100, width: 100 } }
+    },
+    align: 'center',
+    // 提交时,处理数据
+    valueResolve (row, col) {
+      const value = row[col.key]
+      if (value != null) {
+        if (value.length >= 0) {
+          if (value instanceof Array) {
+            // 剔除前缀
+            row[col.key] = value.map(str => str.replace(util.baseURL(), '')).toString()
+          } else {
+            // 剔除前缀
+            row[col.key] = value.replace(util.baseURL(), '')
+          }
+        } else {
+          row[col.key] = null
+        }
+      }
+    },
+    // 接收时,处理数据
+    valueBuilder (row, col) {
+      const value = row[col.key]
+      if (value != null && value) {
+        row[col.key] = value.split(',')
+        // 进行组装地址,纠正地址
+        row[col.key].map((val, index) => {
+          if (val.startsWith('/api')) {
+            row[col.key][index] = val
+          } else if (val.startsWith('/')) {
+            row[col.key][index] = util.baseURL() + val.slice(1)
+          } else {
+            row[col.key][index] = !val.startsWith('http') ? util.baseURL() + val : val
+          }
+        })
+      }
+    }
+  },
   'file-uploader': {
     form: { component: { name: 'd2p-file-uploader', props: { elProps: { listType: 'text' } } } },
     component: { name: 'd2p-files-format' },