Skip to content

Commit b60321f

Browse files
committed
build
1 parent 084d17d commit b60321f

File tree

8 files changed

+43
-30
lines changed

8 files changed

+43
-30
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ npm install vue-simple-uploader@next --save
4242
``` js
4343
import { createApp } from 'vue'
4444
import uploader from 'vue-simple-uploader'
45+
import 'vue-simple-uploader/dist/style.css'
4546
import App from './App.vue'
4647

4748
const app = createApp(App)

README_zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ npm install vue-simple-uploader@next --save
4545
``` js
4646
import { createApp } from 'vue'
4747
import uploader from 'vue-simple-uploader'
48+
import 'vue-simple-uploader/dist/style.css'
4849
import App from './App.vue'
4950

5051
const app = createApp(App)

dist/vue-simple-uploader.es.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-simple-uploader.umd.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/App.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<uploader :options="options" :file-status-text="statusText" class="uploader-example" ref="uploader" @file-complete="fileComplete" @complete="complete"></uploader>
2+
<uploader :options="options" :file-status-text="statusText" class="uploader-example" ref="uploaderRef" @file-complete="fileComplete" @complete="complete"></uploader>
33
</template>
44

55
<script>
66
import { nextTick, ref, onMounted } from 'vue'
77
export default {
88
setup () {
9-
const uploader = ref(null)
9+
const uploaderRef = ref(null)
1010
const options = {
1111
target: '//localhost:3000/upload', // '//jsonplaceholder.typicode.com/posts/',
1212
testChunks: false
@@ -21,19 +21,19 @@
2121
paused: '暂停中',
2222
waiting: '等待中'
2323
}
24-
const complete = () => {
24+
const complete = function () {
2525
console.log('complete', arguments)
2626
}
27-
const fileComplete = () => {
27+
const fileComplete = function () {
2828
console.log('file complete', arguments)
2929
}
3030
onMounted(() => {
3131
nextTick(() => {
32-
window.uploader = uploader.value.uploader
32+
window.uploader = uploaderRef.value.uploader
3333
})
3434
})
3535
return {
36-
uploader,
36+
uploaderRef,
3737
options,
3838
attrs,
3939
statusText,

example/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createApp } from 'vue'
2-
import uploader from '../src'
2+
import uploader from '../dist/vue-simple-uploader.es'
3+
import '../dist/style.css'
34
import App from './App.vue'
45

56
const app = createApp(App)

src/components/file.vue

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,26 @@ export default {
156156
}
157157
return parsedTimeRemaining
158158
})
159-
const _actionCheck = () => {
159+
const actionCheck = () => {
160160
paused.value = props.file.paused
161161
error.value = props.file.error
162162
isUploading.value = props.file.isUploading()
163163
}
164164
const pause = () => {
165165
props.file.pause()
166-
_actionCheck()
167-
_fileProgress()
166+
actionCheck()
167+
fileProgress()
168168
}
169169
const resume = () => {
170170
props.file.resume()
171-
_actionCheck()
171+
actionCheck()
172172
}
173173
const remove = () => {
174174
props.file.cancel()
175175
}
176176
const retry = () => {
177177
props.file.retry()
178-
_actionCheck()
178+
actionCheck()
179179
}
180180
const processResponse = (message) => {
181181
let res = message
@@ -196,28 +196,28 @@ export default {
196196
instance.setupState[`_${event}`](args)
197197
}
198198
}
199-
const _fileProgress = () => {
199+
const fileProgress = () => {
200200
progress.value = props.file.progress()
201201
averageSpeed.value = props.file.averageSpeed
202202
currentSpeed.value = props.file.currentSpeed
203203
timeRemaining.value = props.file.timeRemaining()
204204
uploadedSize.value = props.file.sizeUploaded()
205-
_actionCheck()
205+
actionCheck()
206206
}
207-
const _fileSuccess = (rootFile, file, message) => {
207+
const fileSuccess = (rootFile, file, message) => {
208208
if (rootFile) {
209209
processResponse(message)
210210
}
211-
_fileProgress()
211+
fileProgress()
212212
error.value = false
213213
isComplete.value = true
214214
isUploading.value = false
215215
}
216-
const _fileComplete = () => {
217-
_fileSuccess()
216+
const fileComplete = () => {
217+
fileSuccess()
218218
}
219-
const _fileError = (rootFile, file, message) => {
220-
_fileProgress()
219+
const fileError = (rootFile, file, message) => {
220+
fileProgress()
221221
processResponse(message)
222222
error.value = true
223223
isComplete.value = false
@@ -285,17 +285,17 @@ export default {
285285
status,
286286
statusText,
287287
formatedTimeRemaining,
288-
_actionCheck,
288+
actionCheck,
289289
pause,
290290
resume,
291291
remove,
292292
retry,
293293
processResponse,
294294
fileEventsHandler,
295-
_fileProgress,
296-
_fileSuccess,
297-
_fileComplete,
298-
_fileError
295+
fileProgress,
296+
fileSuccess,
297+
fileComplete,
298+
fileError
299299
}
300300
}
301301
}

vite.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ export default defineConfig(
3030
outDir: path.resolve(__dirname, 'dist'),
3131
lib: {
3232
entry: './src/index.js',
33-
name: 'vue-uploader.js'
33+
name: 'vue-uploader'
34+
},
35+
rollupOptions: {
36+
// 确保外部化处理那些你不想打包进库的依赖
37+
external: ['vue'],
38+
output: {
39+
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
40+
globals: {
41+
vue: 'Vue'
42+
}
43+
}
3444
},
3545
cssCodeSplit: false
3646
},

0 commit comments

Comments
 (0)