@ddwl/ddwl-ui 1.0.30 → 1.0.31-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import previewVue from '../../packages/file-preview/index.vue'
|
|
2
|
+
|
|
3
|
+
export default (Vue) => {
|
|
4
|
+
console.log(Vue)
|
|
5
|
+
// 文件预览
|
|
6
|
+
Vue.prototype.$preview = ({ defaultIndex = 0, list = [] }) => {
|
|
7
|
+
console.log(2, defaultIndex, list)
|
|
8
|
+
const Preview = Vue.extend(previewVue)
|
|
9
|
+
const instance = new Preview()
|
|
10
|
+
document.body.appendChild(instance.$mount().$el)
|
|
11
|
+
instance.value = true
|
|
12
|
+
instance.defaultIndex = defaultIndex
|
|
13
|
+
instance.list = list
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/main.js
CHANGED
|
@@ -3,7 +3,6 @@ import Descriptions from './packages/descriptions'
|
|
|
3
3
|
import Dialog from './packages/dialog'
|
|
4
4
|
import DialogConfirm from './packages/dialog-confirm'
|
|
5
5
|
import Drawer from './packages/drawer'
|
|
6
|
-
import FilePreview from './packages/file-preview'
|
|
7
6
|
import FilterTree from './packages/filter-tree'
|
|
8
7
|
import Form from './packages/form'
|
|
9
8
|
import FormItem from './packages/form-item'
|
|
@@ -17,6 +16,8 @@ import SearchTable from './packages/search-table'
|
|
|
17
16
|
import SvgIcon from './packages/svg-icon'
|
|
18
17
|
import Table from './packages/table'
|
|
19
18
|
import Upload from './packages/upload'
|
|
19
|
+
import extendComponentInstall from './lib/install/index.js'
|
|
20
|
+
|
|
20
21
|
import './lib/theme/index.css'
|
|
21
22
|
|
|
22
23
|
const components = [
|
|
@@ -25,7 +26,6 @@ const components = [
|
|
|
25
26
|
Dialog,
|
|
26
27
|
DialogConfirm,
|
|
27
28
|
Drawer,
|
|
28
|
-
FilePreview,
|
|
29
29
|
FilterTree,
|
|
30
30
|
Form,
|
|
31
31
|
FormItem,
|
|
@@ -50,6 +50,8 @@ const install = (Vue, opts = {}) => {
|
|
|
50
50
|
|
|
51
51
|
if (install.installed) return
|
|
52
52
|
components.forEach((component) => Vue.component(component.name, component))
|
|
53
|
+
|
|
54
|
+
extendComponentInstall(Vue)
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import previewVue from './index.vue'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
install (Vue) {
|
|
5
|
+
Vue.prototype.$preview = ({ defaultIndex = 0, list = [] }) => {
|
|
6
|
+
const Preview = Vue.extend(previewVue)
|
|
7
|
+
const instance = new Preview()
|
|
8
|
+
document.body.appendChild(instance.$mount().$el)
|
|
9
|
+
instance.value = true
|
|
10
|
+
instance.defaultIndex = defaultIndex
|
|
11
|
+
instance.list = list
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
v-if="visible &&
|
|
3
|
+
v-if="visible && list.length"
|
|
4
4
|
class="container"
|
|
5
5
|
>
|
|
6
6
|
<div
|
|
@@ -79,16 +79,12 @@ const audioExts = ['mp3', 'wav', 'ogg']
|
|
|
79
79
|
export default {
|
|
80
80
|
name: 'DFilePreview',
|
|
81
81
|
components: { ElImageViewer },
|
|
82
|
-
model: {
|
|
83
|
-
prop: 'value',
|
|
84
|
-
event: 'change'
|
|
85
|
-
},
|
|
86
82
|
props: {
|
|
87
83
|
value: {
|
|
88
84
|
type: Boolean,
|
|
89
85
|
default: false
|
|
90
86
|
},
|
|
91
|
-
|
|
87
|
+
list: {
|
|
92
88
|
type: Array,
|
|
93
89
|
default: () => {
|
|
94
90
|
return [
|
|
@@ -97,30 +93,27 @@ export default {
|
|
|
97
93
|
{ name: '音频', type: 'audio', urls: [] }
|
|
98
94
|
]
|
|
99
95
|
}
|
|
100
|
-
}
|
|
96
|
+
},
|
|
97
|
+
defaultIndex: {
|
|
98
|
+
type: Number,
|
|
99
|
+
default: 0
|
|
100
|
+
}
|
|
101
101
|
},
|
|
102
102
|
data () {
|
|
103
103
|
return {
|
|
104
104
|
fileList: [],
|
|
105
105
|
currentFileIndex: 0,
|
|
106
|
-
activeTab: ''
|
|
106
|
+
activeTab: 'image',
|
|
107
|
+
visible: true
|
|
107
108
|
}
|
|
108
109
|
},
|
|
109
110
|
computed: {
|
|
110
111
|
currentFileList () {
|
|
111
112
|
return this.fileList.find(item => item.type === this.activeTab)?.urls || []
|
|
112
|
-
},
|
|
113
|
-
visible: {
|
|
114
|
-
get () {
|
|
115
|
-
return this.value
|
|
116
|
-
},
|
|
117
|
-
set (value) {
|
|
118
|
-
this.$emit('change', value)
|
|
119
|
-
}
|
|
120
113
|
}
|
|
121
114
|
},
|
|
122
115
|
watch: {
|
|
123
|
-
|
|
116
|
+
list: {
|
|
124
117
|
handler (val) {
|
|
125
118
|
if (val.length && typeof (val[0]) === 'string') {
|
|
126
119
|
let arr = [
|
|
@@ -128,22 +121,23 @@ export default {
|
|
|
128
121
|
{ name: '视频', type: 'video', urls: [] },
|
|
129
122
|
{ name: '音频', type: 'audio', urls: [] }
|
|
130
123
|
]
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
124
|
+
const exts = [imgExts, videoExts, audioExts]
|
|
125
|
+
val.map((url, index) => {
|
|
126
|
+
exts.forEach((item, i) => {
|
|
127
|
+
if (item.includes(url.substring(url.lastIndexOf('.') + 1))) {
|
|
128
|
+
arr[i].urls.push(url)
|
|
129
|
+
// 判断初始化tab、index
|
|
130
|
+
if (this.defaultIndex === index) {
|
|
131
|
+
this.activeTab = arr[i].type
|
|
132
|
+
this.currentFileIndex = arr[i].urls.length - 1
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
})
|
|
141
136
|
})
|
|
142
137
|
this.fileList = arr.filter(item => item.urls.length)
|
|
143
138
|
} else {
|
|
144
139
|
this.fileList = val
|
|
145
140
|
}
|
|
146
|
-
this.activeTab = this.fileList[0].type
|
|
147
141
|
},
|
|
148
142
|
immediate: true,
|
|
149
143
|
deep: true
|