Skip to content

A full-featured download manager.

feat: task file filter add document extensions

Dr_rOot5daece6dab69
diff --git a/src/renderer/components/Icons/document.js b/src/renderer/components/Icons/document.js
new file mode 100644
index 00000000..63bf5aa9
--- /dev/null
+++ b/src/renderer/components/Icons/document.js
@@ -0,0 +1,21 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'document': {
+ 'width': 24,
+ 'height': 24,
+ 'raw': `<rect x="3" y="1" width="18" height="22"></rect>
+ <line x1="15" y1="6" x2="17" y2="6"></line>
+ <line x1="15" y1="10" x2="17" y2="10"></line>
+ <line x1="7" y1="14" x2="17" y2="14"></line>
+ <line x1="7" y1="18" x2="17" y2="18"></line>
+ <rect x="7" y="6" width="4" height="4"></rect>`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '2',
+ 'fill': 'none'
+ }
+ }
+})
diff --git a/src/renderer/components/TaskDetail/TaskFiles.vue b/src/renderer/components/TaskDetail/TaskFiles.vue
index 4c76a6ca..fceae057 100644
--- a/src/renderer/components/TaskDetail/TaskFiles.vue
+++ b/src/renderer/components/TaskDetail/TaskFiles.vue
@@ -65,6 +65,9 @@
<el-button @click="toggleImageSelection()">
<mo-icon name="image" width="12" height="12" />
</el-button>
+ <el-button @click="toggleDocumentSelection()">
+ <mo-icon name="document" width="12" height="12" />
+ </el-button>
</el-button-group>
</el-col>
<el-col
@@ -85,6 +88,7 @@
import '@/components/Icons/video'
import '@/components/Icons/audio'
import '@/components/Icons/image'
+ import '@/components/Icons/document'
import {
NONE_SELECTED_FILES,
SELECTED_ALL_FILES
@@ -92,9 +96,10 @@
import {
bytesToSize,
calcProgress,
- filterVideoFiles,
filterAudioFiles,
+ filterDocumentFiles,
filterImageFiles,
+ filterVideoFiles,
removeExtensionDot
} from '@shared/utils'
@@ -192,6 +197,10 @@
const filtered = filterImageFiles(this.files)
this.toggleSelection(filtered)
},
+ toggleDocumentSelection () {
+ const filtered = filterDocumentFiles(this.files)
+ this.toggleSelection(filtered)
+ },
handleRowDbClick (row, column, event) {
this.$refs.torrentTable.toggleRowSelection(row)
},
diff --git a/src/shared/constants.js b/src/shared/constants.js
index f663ad24..eced3ff2 100644
--- a/src/shared/constants.js
+++ b/src/shared/constants.js
@@ -229,7 +229,9 @@ export const IMAGE_SUFFIXES = [
'.ai',
'.bmp',
'.eps',
+ '.fig',
'.gif',
+ '.heic',
'.icn',
'.ico',
'.jpeg',
@@ -243,6 +245,7 @@ export const IMAGE_SUFFIXES = [
'.webp',
'.xd'
]
+
export const AUDIO_SUFFIXES = [
'.aac',
'.ape',
@@ -254,6 +257,7 @@ export const AUDIO_SUFFIXES = [
'.wav',
'.wma'
]
+
export const VIDEO_SUFFIXES = [
'.avi',
'.m4v',
@@ -275,3 +279,21 @@ export const SUB_SUFFIXES = [
'.sst',
'.sub'
]
+
+export const DOCUMENT_SUFFIXES = [
+ '.azw3',
+ '.csv',
+ '.doc',
+ '.docx',
+ '.epub',
+ '.key',
+ '.mobi',
+ '.numbers',
+ '.pages',
+ '.pdf',
+ '.ppt',
+ '.pptx',
+ '.txt',
+ '.xsl',
+ '.xslx'
+]
diff --git a/src/shared/utils/index.js b/src/shared/utils/index.js
index 8d552073..56421386 100644
--- a/src/shared/utils/index.js
+++ b/src/shared/utils/index.js
@@ -28,7 +28,8 @@ import {
SUB_SUFFIXES,
UNKNOWN_PEERID,
SUPPORT_RTL_LOCALES,
- UNKNOWN_PEERID_NAME
+ UNKNOWN_PEERID_NAME,
+ DOCUMENT_SUFFIXES
} from '@shared/constants'
export const bytesToSize = (bytes, precision = 1) => {
@@ -429,6 +430,7 @@ export const compactUndefined = (arr = []) => {
}
export const splitTextRows = (text = '') => {
+ text = `${text}`
let result = text
.replace(/(?:\\\r\\\n|\\\r|\\\n)/g, ' ')
.replace(/(?:\r\n|\r|\n)/g, '\n')
@@ -438,6 +440,7 @@ export const splitTextRows = (text = '') => {
}
export const convertCommaToLine = (text = '') => {
+ text = `${text}`
let arr = text.split(',')
arr = arr.map((row) => row.trim())
const result = arr.join('\n').trim()
@@ -468,6 +471,12 @@ export const filterImageFiles = (files = []) => {
})
}
+export const filterDocumentFiles = (files = []) => {
+ return files.filter((item) => {
+ return DOCUMENT_SUFFIXES.includes(item.extension)
+ })
+}
+
export const isAudioOrVideo = (uri = '') => {
const suffixs = [...AUDIO_SUFFIXES, ...VIDEO_SUFFIXES]
const result = suffixs.some((suffix) => {
@@ -570,6 +579,7 @@ export const diffConfig = (current = {}, next = {}) => {
}
return curr[key] === val
})
+
return result
}