├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── babel.config.js
├── example
├── App.vue
└── main.js
├── lib
├── EleUploadFile.vue
├── EleUploadList.vue
├── iconList.js
├── images
│ ├── access.svg
│ ├── ai.svg
│ ├── audio.svg
│ ├── bat.svg
│ ├── config.svg
│ ├── css.svg
│ ├── db.svg
│ ├── dmg.svg
│ ├── excel.svg
│ ├── file.svg
│ ├── fla.svg
│ ├── flash.svg
│ ├── font.svg
│ ├── html.svg
│ ├── image.svg
│ ├── ini.svg
│ ├── jar.svg
│ ├── js.svg
│ ├── markdown.svg
│ ├── onenote.svg
│ ├── pdf.svg
│ ├── photoshop.svg
│ ├── php.svg
│ ├── powerpoint.svg
│ ├── reactjs.svg
│ ├── ts.svg
│ ├── txt.svg
│ ├── video.svg
│ ├── vue.svg
│ ├── web.svg
│ ├── word.svg
│ ├── xfl.svg
│ └── zip.svg
└── index.js
├── package-lock.json
├── package.json
├── public
├── favicon.ico
└── index.html
└── vue.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw?
22 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | tests
3 | docs
4 | documentation
5 | public
6 | vue.config.js
7 | coverage
8 | jest.config.js
9 | .eslintrc.js
10 | cypress.json
11 | postcss.config.js
12 | babel.config.js
13 | .editorconfig
14 | .cypress.json
15 | dist/demo.html
16 | .browserslistrc
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 二当家的
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-ele-upload-file | 使 element-ui upload 组件更简单、好用
2 |
3 | [](https://dream2023.github.io/vue-ele-upload-file/)
4 | [](https://www.npmjs.com/package/vue-ele-upload-file)
5 | [](https://www.npmjs.com/package/vue-ele-upload-file)
6 | [](https://npmcharts.com/compare/vue-ele-upload-file?minimal=true)
7 |
8 | 
9 |
10 | ## 安装
11 |
12 | ```bash
13 | npm install vue-ele-upload-file --save
14 | ```
15 |
16 | ### 用法
17 |
18 | ```js
19 | import EleUploadFile from "vue-ele-upload-file";
20 |
21 | export default {
22 | components: {
23 | EleUploadFile
24 | }
25 | };
26 | ```
27 |
28 | ## 示例
29 |
30 | ### 简单用法
31 |
32 | ```html
33 |
34 |
39 |
40 |
59 | ```
60 |
61 | ### 增加属性
62 |
63 | ```html
64 |
65 |
81 |
82 | ```
83 |
84 | ## Props 参数
85 |
86 | ```js
87 | props: {
88 | // 值
89 | value: [String, Object, Array],
90 | // 必选参数,上传的地址
91 | // 同 element-ui upload 组件
92 | action: {
93 | type: String,
94 | required: true
95 | },
96 | // 大小限制(MB)
97 | fileSize: Number,
98 | // 响应处理函数
99 | responseFn: Function,
100 | // 文件类型, 例如['png', 'jpg', 'jpeg']
101 | fileType: Array,
102 | // 提示
103 | placeholder: String,
104 | // 是否禁用
105 | disabled: Boolean,
106 | // 是否显示文件大小
107 | isShowSize: {
108 | type: Boolean,
109 | default: true
110 | },
111 | // 是否显示下载
112 | isCanDownload: {
113 | type: Boolean,
114 | default: true
115 | },
116 | // 是否可删除
117 | isCanDelete: {
118 | type: Boolean,
119 | default: true
120 | },
121 | // 是否可上传相同文件
122 | isCanUploadSame: {
123 | type: Boolean,
124 | default: true
125 | },
126 | // 是否显示提示
127 | isShowTip: {
128 | type: Boolean,
129 | default: true
130 | },
131 | // 是否显示上传成功的提示
132 | isShowSuccessTip: {
133 | type: Boolean,
134 | default: true
135 | },
136 | // 删除前的操作
137 | // 同 element-ui upload 组件
138 | beforeRemove: Function
139 | // 设置上传的请求头部
140 | // 同 element-ui upload 组件
141 | headers: Object,
142 | // 是否支持多选文件
143 | // 同 element-ui upload 组件
144 | multiple: {
145 | type: Boolean,
146 | default: true
147 | },
148 | // 上传时附带的额外参数
149 | // 同 element-ui upload 组件
150 | data: Object,
151 | // 上传的文件字段名
152 | // 同 element-ui upload 组件
153 | name: {
154 | type: String,
155 | default: 'file'
156 | },
157 | // 支持发送 cookie 凭证信息
158 | // 同 element-ui upload 组件
159 | withCredentials: {
160 | type: Boolean,
161 | default: false
162 | },
163 | // 接受上传的文件类型
164 | // 同 element-ui upload 组件
165 | accept: String,
166 | // 最大允许上传个数
167 | // 同 element-ui upload 组件
168 | limit: Number
169 | },
170 | ```
171 |
172 | ## 事件
173 |
174 | | 事件名称 | 说明 | 回调参数 |
175 | | -------- | ------------------ | ---------------- |
176 | | remove | 当文件被删除时触发 | (file, fileList) |
177 | | success | 文件上传成功时触发 | (file, fileList) |
178 | | error | 上传失败时触发 | (error) |
179 |
180 | ## 相关链接
181 |
182 | - [element-ui upload 组件](https://element.eleme.cn/#/zh-CN/component/upload)
183 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/example/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 |
45 |
--------------------------------------------------------------------------------
/example/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 | import ElementUI from 'element-ui'
4 | import 'element-ui/lib/theme-chalk/index.css'
5 | import EleUploadFile from '../lib/index'
6 |
7 | Vue.config.productionTip = false
8 | Vue.use(ElementUI)
9 | Vue.component('ele-upload-file', EleUploadFile)
10 |
11 | new Vue({
12 | render: h => h(App)
13 | }).$mount('#app')
14 |
--------------------------------------------------------------------------------
/lib/EleUploadFile.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
20 | {{ btnText }}
21 |
22 |
23 | 请上传
24 |
25 | 大小不超过
26 | {{ fileSize }}MB
27 |
28 |
29 | 格式为
30 | {{ fileType.join("/") }}
31 |
32 | 的文件
33 |
34 |
35 |
36 |
37 |
46 |
47 |
48 |
49 |
268 |
269 |
274 |
--------------------------------------------------------------------------------
/lib/EleUploadList.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
17 |
21 | {{file.name}}
22 |
23 |
24 | {{getSize(file.size)}}
28 | 下载
33 | 删除
39 |
40 |
41 |
42 |
43 |
121 |
122 |
149 |
--------------------------------------------------------------------------------
/lib/iconList.js:
--------------------------------------------------------------------------------
1 | const icons = {
2 | mdb: 'access',
3 | accdb: 'access',
4 | ai: 'ai',
5 | html: 'html',
6 | htm: 'html',
7 | asp: 'web',
8 | pdf: 'pdf',
9 | psd: 'photoshop',
10 | psb: 'photoshop',
11 | mpo: 'photoshop',
12 | eps: 'photoshop',
13 | avi: 'video',
14 | wmv: 'video',
15 | rm: 'video',
16 | rmvb: 'video',
17 | mp4: 'video',
18 | '3gp': 'video',
19 | asf: 'video',
20 | mov: 'video',
21 | m4v: 'video',
22 | flv: 'video',
23 | f4v: 'video',
24 | mkv: 'video',
25 | mts: 'video',
26 | swf: 'flash',
27 | ts: 'video',
28 | mp3: 'audio',
29 | wav: 'audio',
30 | wma: 'audio',
31 | ape: 'audio',
32 | aac: 'audio',
33 | zip: 'zip',
34 | rar: 'zip',
35 | gz: 'zip',
36 | '7z': 'zip',
37 | z: 'zip',
38 | bmp: 'image',
39 | jpg: 'image',
40 | jpeg: 'image',
41 | png: 'image',
42 | gif: 'image',
43 | webp: 'image',
44 | svg: 'image',
45 | txt: 'txt',
46 | rtf: 'txt',
47 | xls: 'excel',
48 | xlsx: 'excel',
49 | xlsm: 'excel',
50 | xltx: 'excel',
51 | doc: 'word',
52 | docx: 'word',
53 | docm: 'word',
54 | wps: 'word',
55 | dotx: 'word',
56 | dotm: 'word',
57 | ppt: 'powerpoint',
58 | pptx: 'powerpoint',
59 | mdf: 'db',
60 | db: 'db',
61 | dbf: 'db',
62 | wdb: 'db',
63 | vue: 'vue',
64 | php: 'php',
65 | jar: 'jar',
66 | ini: 'ini',
67 | bat: 'bat',
68 | config: 'config',
69 | fla: 'fla',
70 | eot: 'font',
71 | otf: 'font',
72 | fon: 'font',
73 | font: 'font',
74 | ttf: 'font',
75 | ttc: 'font',
76 | woff: 'font',
77 | woff2: 'font',
78 | js: 'js',
79 | md: 'markdown',
80 | one: 'onenote',
81 | jsx: 'reactjs',
82 | xfl: 'xfl',
83 | file: 'file',
84 | css: 'css'
85 | }
86 |
87 | Object.keys(icons).forEach(item => {
88 | icons[item] = require('./images/' + icons[item] + '.svg')
89 | })
90 |
91 | export default icons
92 |
--------------------------------------------------------------------------------
/lib/images/access.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/ai.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/audio.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/bat.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/config.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/css.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/db.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/dmg.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/excel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/file.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/fla.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/flash.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/font.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/html.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/image.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/ini.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/jar.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/js.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/markdown.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/onenote.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/pdf.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/photoshop.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/php.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/powerpoint.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/reactjs.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/ts.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/txt.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/video.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/vue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/web.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/word.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/xfl.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/images/zip.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | import EleUploadFile from './EleUploadFile'
2 |
3 | export default EleUploadFile
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-ele-upload-file",
3 | "description": "对 element-ui upload 组件进一步封装, 使其更简单、易用",
4 | "version": "0.0.7",
5 | "private": false,
6 | "license": "MIT",
7 | "scripts": {
8 | "serve": "vue-cli-service serve",
9 | "lint": "vue-cli-service lint"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/dream2023/vue-ele-upload-file"
14 | },
15 | "main": "lib/index.js",
16 | "homepage": "https://github.com/dream2023/vue-ele-upload-file/",
17 | "keywords": [
18 | "vue-ele-upload-file",
19 | "element upload",
20 | "element-ui upload",
21 | "vue upload",
22 | "vue uploader",
23 | "vue",
24 | "vue 上传"
25 | ],
26 | "dependencies": {
27 | "ly-downloader": "^1.0.5",
28 | "pretty-bytes": "^5.3.0"
29 | },
30 | "devDependencies": {
31 | "core-js": "^2.6.5",
32 | "vue": "^2.6.10",
33 | "@vue/cli-plugin-babel": "^3.8.0",
34 | "@vue/cli-plugin-eslint": "^3.8.0",
35 | "@vue/cli-service": "^3.8.0",
36 | "babel-eslint": "^10.0.1",
37 | "element-ui": "^2.9.1",
38 | "eslint": "^5.16.0",
39 | "eslint-plugin-vue": "^5.0.0",
40 | "vue-template-compiler": "^2.6.10"
41 | },
42 | "eslintConfig": {
43 | "root": true,
44 | "env": {
45 | "node": true
46 | },
47 | "extends": [
48 | "plugin:vue/essential",
49 | "eslint:recommended"
50 | ],
51 | "rules": {},
52 | "parserOptions": {
53 | "parser": "babel-eslint"
54 | }
55 | },
56 | "postcss": {
57 | "plugins": {
58 | "autoprefixer": {}
59 | }
60 | },
61 | "browserslist": [
62 | "> 1%",
63 | "last 2 versions"
64 | ]
65 | }
66 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dream2023/vue-ele-upload-file/5f1a30a54b91e667835c9bbbd64b7da8bcca595f/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-ele-upload-file
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | css: {
3 | extract: false
4 | },
5 | configureWebpack: {
6 | entry: './example/main.js',
7 | output: {
8 | libraryExport: 'default'
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------