Casper Dai 3 лет назад
Родитель
Сommit
28e6181a42

+ 2 - 1
src/constant.js

@@ -12,7 +12,8 @@ export const AssetType = {
   VIDEO: 2,
   AUDIO: 3,
   PPT: 4,
-  PDF: 5
+  PDF: 5,
+  DOC: 6
 }
 
 export const Role = {

+ 0 - 0
src/icons/svg/audio-bg.svg → src/icons/svg/media/audio-bg.svg


+ 0 - 0
src/icons/svg/audio-thumb.svg → src/icons/svg/media/audio-thumb.svg


+ 0 - 0
src/icons/svg/audio.svg → src/icons/svg/media/audio.svg


+ 0 - 0
src/icons/svg/image-broken.svg → src/icons/svg/media/image-broken.svg


+ 0 - 0
src/icons/svg/image.svg → src/icons/svg/media/image.svg


+ 0 - 0
src/icons/svg/video-bg.svg → src/icons/svg/media/video-bg.svg


+ 0 - 0
src/icons/svg/video-broken.svg → src/icons/svg/media/video-broken.svg


+ 0 - 0
src/icons/svg/video-thumb.svg → src/icons/svg/media/video-thumb.svg


+ 0 - 0
src/icons/svg/video.svg → src/icons/svg/media/video.svg


+ 10 - 0
src/icons/svg/office/doc.svg

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 24.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 34 34" style="enable-background:new 0 0 34 34;" xml:space="preserve">
+<path d="M24.7,3H8.3c-2.8,0-5,2.2-5,5v18c0,2.8,2.2,5,5,5h18c2.8,0,5-2.2,5-5V9.6L24.7,3z M25.3,6.4L27.9,9h-1.6c-0.5,0-1-0.5-1-1
+	V6.4z M29.3,26c0,1.7-1.3,3-3,3h-18c-1.6,0-3-1.3-3-3V8c0-1.7,1.4-3,3-3h15v3c0,1.7,1.4,3,3,3h3V26z"/>
+<path d="M24.3,14c0,0.1,0,0.2-0.1,0.3c0,0-3,8-3,8c-0.1,0.4-0.5,0.7-0.9,0.7s-0.8-0.3-0.9-0.7l-2.1-5.5l-2.1,5.5
+	c-0.1,0.4-0.5,0.7-0.9,0.7s-0.8-0.3-0.9-0.7c0,0-3-8-3-8c0-0.1-0.1-0.2-0.1-0.3c0-0.5,0.5-1,1-1c0.4,0,0.8,0.3,0.9,0.6l2.1,5.5
+	l2.1-5.5c0.1-0.4,0.5-0.6,0.9-0.6s0.8,0.3,0.9,0.6l2.1,5.5l2.1-5.5c0.1-0.4,0.5-0.6,0.9-0.6C23.9,13,24.3,13.5,24.3,14z"/>
+</svg>

+ 0 - 0
src/icons/svg/pdf.svg → src/icons/svg/office/pdf.svg


+ 0 - 0
src/icons/svg/ppt.svg → src/icons/svg/office/ppt.svg


+ 1 - 1
src/layout/components/Navbar/UploadDashboard/index.vue

@@ -66,7 +66,7 @@ export default {
   },
   computed: {
     accept () {
-      return '.png,.jpg,.jpeg,.gif,.mp4,audio/mpeg,.ppt,.pptx,application/pdf'
+      return '.png,.jpg,.jpeg,.gif,.mp4,audio/mpeg,.ppt,.pptx,application/pdf,.doc,.docx'
     }
   },
   created () {

+ 2 - 0
src/utils/upload.js

@@ -213,6 +213,8 @@ function getType ({ name, type }) {
       return AssetType.PPT
     case /application\/pdf/.test(type):
       return AssetType.PDF
+    case /application\/(msword|vnd.openxmlformats-officedocument.wordprocessingml.document)/i.test(type):
+      return AssetType.DOC
     default:
       Message({
         type: 'warning',

+ 17 - 66
src/views/platform/media/index.vue

@@ -8,59 +8,17 @@
   >
     <div class="l-flex__none c-media-type">
       <div
+        v-for="tab in tabs"
+        :key="tab.key"
         class="c-media-type__item section u-pointer"
-        :class="{ active: isImage }"
-        @click="to('IMAGE')"
+        :class="{ active: type === tab.key }"
+        @click="to(tab.key)"
       >
         <svg-icon
           class="c-media-type__icon"
-          icon-class="image"
+          :icon-class="tab.icon"
         />
-        图片
-      </div>
-      <div
-        class="c-media-type__item section u-pointer"
-        :class="{ active: isVideo }"
-        @click="to('VIDEO')"
-      >
-        <svg-icon
-          class="c-media-type__icon"
-          icon-class="video"
-        />
-        视频
-      </div>
-      <div
-        class="c-media-type__item section u-pointer"
-        :class="{ active: isAudio }"
-        @click="to('AUDIO')"
-      >
-        <svg-icon
-          class="c-media-type__icon"
-          icon-class="audio"
-        />
-        音频
-      </div>
-      <div
-        class="c-media-type__item section u-pointer"
-        :class="{ active: isPPT }"
-        @click="to('PPT')"
-      >
-        <svg-icon
-          class="c-media-type__icon"
-          icon-class="ppt"
-        />
-        PPT
-      </div>
-      <div
-        class="c-media-type__item section u-pointer"
-        :class="{ active: isPDF }"
-        @click="to('PDF')"
-      >
-        <svg-icon
-          class="c-media-type__icon"
-          icon-class="pdf"
-        />
-        PDF
+        {{ tab.label }}
       </div>
     </div>
     <component
@@ -88,7 +46,15 @@ export default {
   },
   data () {
     return {
-      type: AssetType.IMAGE
+      type: AssetType.IMAGE,
+      tabs: [
+        { key: AssetType.IMAGE, label: '图片', icon: 'image' },
+        { key: AssetType.VIDEO, label: '视频', icon: 'video' },
+        { key: AssetType.AUDIO, label: '音频', icon: 'audio' },
+        { key: AssetType.PPT, label: 'PPT', icon: 'ppt' },
+        { key: AssetType.PDF, label: 'PDF', icon: 'pdf' },
+        { key: AssetType.DOC, label: 'DOC', icon: 'doc' }
+      ]
     }
   },
   computed: {
@@ -96,29 +62,14 @@ export default {
       return this.accessSet.has(Access.MANAGE_CALENDAR)
         ? 'Designer'
         : 'Viewer'
-    },
-    isImage () {
-      return this.type === AssetType.IMAGE
-    },
-    isVideo () {
-      return this.type === AssetType.VIDEO
-    },
-    isAudio () {
-      return this.type === AssetType.AUDIO
-    },
-    isPPT () {
-      return this.type === AssetType.PPT
-    },
-    isPDF () {
-      return this.type === AssetType.PDF
     }
   },
   methods: {
     to (type) {
-      if (this.type !== AssetType[type]) {
+      if (this.type !== type) {
         this.type = null
         this.$nextTick(() => {
-          this.type = AssetType[type]
+          this.type = type
         })
       }
     },

+ 14 - 25
src/views/platform/media/mixin.js

@@ -13,6 +13,14 @@ import {
   parseDuration
 } from '@/utils'
 
+function createMap (type) {
+  return {
+    [State.AVAILABLE_ASSET]: createListOptions({ type, status: State.AVAILABLE_ASSET }),
+    [State.RESOLVED]: createListOptions({ type, status: State.RESOLVED, originalName: '' }),
+    [State.REJECTED]: createListOptions({ type, status: State.REJECTED })
+  }
+}
+
 export default {
   props: {
     type: {
@@ -22,31 +30,12 @@ export default {
   },
   data () {
     return {
-      [AssetType.IMAGE]: {
-        [State.AVAILABLE_ASSET]: createListOptions({ type: AssetType.IMAGE, status: State.AVAILABLE_ASSET }),
-        [State.RESOLVED]: createListOptions({ type: AssetType.IMAGE, status: State.RESOLVED, originalName: '' }),
-        [State.REJECTED]: createListOptions({ type: AssetType.IMAGE, status: State.REJECTED })
-      },
-      [AssetType.VIDEO]: {
-        [State.AVAILABLE_ASSET]: createListOptions({ type: AssetType.VIDEO, status: State.AVAILABLE_ASSET }),
-        [State.RESOLVED]: createListOptions({ type: AssetType.VIDEO, status: State.RESOLVED, originalName: '' }),
-        [State.REJECTED]: createListOptions({ type: AssetType.VIDEO, status: State.REJECTED })
-      },
-      [AssetType.AUDIO]: {
-        [State.AVAILABLE_ASSET]: createListOptions({ type: AssetType.AUDIO, status: State.AVAILABLE_ASSET }),
-        [State.RESOLVED]: createListOptions({ type: AssetType.AUDIO, status: State.RESOLVED, originalName: '' }),
-        [State.REJECTED]: createListOptions({ type: AssetType.AUDIO, status: State.REJECTED })
-      },
-      [AssetType.PPT]: {
-        [State.AVAILABLE_ASSET]: createListOptions({ type: AssetType.PPT, status: State.AVAILABLE_ASSET }),
-        [State.RESOLVED]: createListOptions({ type: AssetType.PPT, status: State.RESOLVED, originalName: '' }),
-        [State.REJECTED]: createListOptions({ type: AssetType.PPT, status: State.REJECTED })
-      },
-      [AssetType.PDF]: {
-        [State.AVAILABLE_ASSET]: createListOptions({ type: AssetType.PDF, status: State.AVAILABLE_ASSET }),
-        [State.RESOLVED]: createListOptions({ type: AssetType.PDF, status: State.RESOLVED, originalName: '' }),
-        [State.REJECTED]: createListOptions({ type: AssetType.PDF, status: State.REJECTED })
-      }
+      [AssetType.IMAGE]: createMap(AssetType.IMAGE),
+      [AssetType.VIDEO]: createMap(AssetType.VIDEO),
+      [AssetType.AUDIO]: createMap(AssetType.AUDIO),
+      [AssetType.PPT]: createMap(AssetType.PPT),
+      [AssetType.PDF]: createMap(AssetType.PDF),
+      [AssetType.DOC]: createMap(AssetType.DOC)
     }
   },
   computed: {