Skip to content

Commit

Permalink
feat: Add dev:test script and test logic for fake upload in qiniu.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ATQQ committed Jan 21, 2024
1 parent 9f975a7 commit 0a1100a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"dev:test": "VITE_APP_FAKE_UPLOAD=true vite",
"build": "vite build",
"build:github": "node ./../cli/token.js && vite build --base /image-bed-qiniu/",
"preview": "vite preview",
Expand Down
25 changes: 14 additions & 11 deletions packages/client/src/utils/qiniu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ async function uploadFile(file: File, qiniuOps: QiNiuConfig, options?: {
fname: key,
customVars: {},
}
// let i = 0
// const timer = setInterval(() => {
// if (i <= 100) {
// options?.process?.(i)
// i += 10
// return
// }
// clearInterval(timer)
// resolve(`${domain}/${putExtra.fname}`)
// }, 100)
// return
// 测试逻辑
if (import.meta.env.VITE_APP_FAKE_UPLOAD) {
let i = 0
const timer = setInterval(() => {
if (i <= 100) {
options?.process?.(i)
i += 10
return
}
clearInterval(timer)
resolve(`${domain}/${putExtra.fname}`)
}, 100)
return
}
const observable = qiniu.upload(file, putExtra.fname, token, putExtra, config)
observable.subscribe({
next(res) {
Expand Down

0 comments on commit 0a1100a

Please sign in to comment.