Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loujc2008
gin-vue-admin
提交
7da1962d
G
gin-vue-admin
项目概览
loujc2008
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7da1962d
编写于
1月 01, 2022
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed: #862
上级
4ef717f7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
16 deletion
+41
-16
server/api/v1/example/exa_breakpoint_continue.go
server/api/v1/example/exa_breakpoint_continue.go
+10
-3
server/model/example/exa_breakpoint_continue.go
server/model/example/exa_breakpoint_continue.go
+3
-3
server/service/example/exa_breakpoint_continue.go
server/service/example/exa_breakpoint_continue.go
+1
-1
web/src/api/breakpoint.js
web/src/api/breakpoint.js
+9
-0
web/src/utils/request.js
web/src/utils/request.js
+3
-3
web/src/view/example/breakpoint/breakpoint.vue
web/src/view/example/breakpoint/breakpoint.vue
+15
-6
未找到文件。
server/api/v1/example/exa_breakpoint_continue.go
浏览文件 @
7da1962d
...
...
@@ -2,6 +2,7 @@ package example
import
(
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"io/ioutil"
"mime/multipart"
"strconv"
...
...
@@ -123,11 +124,17 @@ func (b *FileUploadAndDownloadApi) BreakpointContinueFinish(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"缓存切片删除成功"}"
// @Router /fileUploadAndDownload/removeChunk [post]
func
(
u
*
FileUploadAndDownloadApi
)
RemoveChunk
(
c
*
gin
.
Context
)
{
fileMd5
:=
c
.
Query
(
"fileMd5"
)
err
:=
utils
.
RemoveChunk
(
fileMd5
)
var
file
example
.
ExaFile
c
.
ShouldBindJSON
(
&
file
)
err
:=
utils
.
RemoveChunk
(
file
.
FileMd5
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"缓存切片删除失败!"
,
zap
.
Error
(
err
))
response
.
FailWithMessage
(
"缓存切片删除失败"
,
c
)
return
}
err
=
fileUploadAndDownloadService
.
DeleteFileChunk
(
file
.
FileMd5
,
file
.
FileName
,
file
.
FilePath
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
err
.
Error
(),
zap
.
Error
(
err
))
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
response
.
OkWithMessage
(
"缓存切片删除成功"
,
c
)
}
...
...
server/model/example/exa_breakpoint_continue.go
浏览文件 @
7da1962d
...
...
@@ -7,9 +7,9 @@ import (
// file struct, 文件结构体
type
ExaFile
struct
{
global
.
GVA_MODEL
FileName
string
FileMd5
string
FilePath
string
FileName
string
`json:"fileName"`
FileMd5
string
`json:"fileMd5"`
FilePath
string
`json:"filePath"`
ExaFileChunk
[]
ExaFileChunk
ChunkTotal
int
IsFinish
bool
...
...
server/service/example/exa_breakpoint_continue.go
浏览文件 @
7da1962d
...
...
@@ -56,7 +56,7 @@ func (e *FileUploadAndDownloadService) CreateFileChunk(id uint, fileChunkPath st
func
(
e
*
FileUploadAndDownloadService
)
DeleteFileChunk
(
fileMd5
string
,
fileName
string
,
filePath
string
)
error
{
var
chunks
[]
example
.
ExaFileChunk
var
file
example
.
ExaFile
err
:=
global
.
GVA_DB
.
Where
(
"file_md5 = ?
AND file_name = ?"
,
fileMd5
,
fileName
)
.
First
(
&
file
)
.
Update
(
"IsFinish"
,
true
)
.
Update
(
"file_path"
,
filePath
)
.
Error
err
:=
global
.
GVA_DB
.
Where
(
"file_md5 = ?
"
,
fileMd5
)
.
First
(
&
file
)
.
Update
(
"IsFinish"
,
true
)
.
Update
(
"file_path"
,
filePath
)
.
Error
if
err
!=
nil
{
return
err
}
...
...
web/src/api/breakpoint.js
浏览文件 @
7da1962d
...
...
@@ -16,6 +16,15 @@ export const findFile = (params) => {
})
}
export
const
breakpointContinue
=
(
data
)
=>
{
return
service
({
url
:
'
/fileUploadAndDownload/breakpointContinue
'
,
method
:
'
post
'
,
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
},
data
})
}
export
const
breakpointContinueFinish
=
(
params
)
=>
{
return
service
({
url
:
'
/fileUploadAndDownload/breakpointContinueFinish
'
,
...
...
web/src/utils/request.js
浏览文件 @
7da1962d
...
...
@@ -36,11 +36,11 @@ service.interceptors.request.use(
}
const
token
=
store
.
getters
[
'
user/token
'
]
const
user
=
store
.
getters
[
'
user/userInfo
'
]
config
.
data
=
JSON
.
stringify
(
config
.
data
)
config
.
headers
=
{
'
Content-Type
'
:
'
application/json
'
,
'
x-token
'
:
token
,
'
x-user-id
'
:
user
.
ID
'
x-user-id
'
:
user
.
ID
,
...
config
.
headers
}
return
config
},
...
...
@@ -70,7 +70,7 @@ service.interceptors.response.use(
}
else
{
ElMessage
({
showClose
:
true
,
message
:
response
.
data
.
msg
||
decodeURI
(
response
.
headers
.
msg
),
message
:
response
.
data
.
msg
||
decodeURI
(
response
.
headers
.
msg
),
type
:
'
error
'
})
if
(
response
.
data
.
data
&&
response
.
data
.
data
.
reload
)
{
...
...
web/src/view/example/breakpoint/breakpoint.vue
浏览文件 @
7da1962d
...
...
@@ -33,11 +33,11 @@
<
script
>
import
SparkMD5
from
'
spark-md5
'
import
axios
from
'
axios
'
import
{
findFile
,
breakpointContinueFinish
,
removeChunk
removeChunk
,
breakpointContinue
}
from
'
@/api/breakpoint
'
export
default
{
name
:
'
BreakPoint
'
,
...
...
@@ -47,13 +47,18 @@ export default {
fileMd5
:
''
,
formDataList
:
[],
waitUpLoad
:
[],
waitNum
:
0
,
waitNum
:
NaN
,
limitFileSize
:
false
,
percentage
:
0
,
percentageFlage
:
true
,
customColor
:
'
#409eff
'
}
},
watch
:
{
waitNum
()
{
this
.
percentage
=
Math
.
floor
(((
this
.
formDataList
.
length
-
this
.
waitNum
)
/
this
.
formDataList
.
length
)
*
100
)
}
},
methods
:
{
// 选中文件的函数
async
choseFile
(
e
)
{
...
...
@@ -107,6 +112,7 @@ export default {
})
}
else
{
this
.
waitUpLoad
=
[]
// 秒传则没有需要上传的切片
this
.
$message
.
success
(
'
文件已秒传
'
)
}
this
.
waitNum
=
this
.
waitUpLoad
.
length
// 记录长度用于百分比展示
}
...
...
@@ -121,7 +127,6 @@ export default {
this
.
$message
(
'
请先上传文件
'
)
return
}
this
.
percentage
=
Math
.
floor
(((
this
.
formDataList
.
length
-
this
.
waitNum
)
/
this
.
formDataList
.
length
)
*
100
)
if
(
this
.
percentage
===
100
)
{
this
.
percentageFlage
=
false
}
...
...
@@ -145,7 +150,10 @@ export default {
},
async
upLoadFileSlice
(
item
)
{
// 切片上传
await
axios
.
post
(
import
.
meta
.
env
.
VITE_BASE_API
+
'
/fileUploadAndDownload/breakpointContinue
'
,
item
.
formData
)
const
fileRe
=
await
breakpointContinue
(
item
.
formData
)
if
(
fileRe
.
code
!==
0
)
{
return
}
this
.
waitNum
--
// 百分数增加
if
(
this
.
waitNum
===
0
)
{
// 切片传完以后 合成文件
...
...
@@ -154,13 +162,14 @@ export default {
fileMd5
:
this
.
fileMd5
}
const
res
=
await
breakpointContinueFinish
(
params
)
if
(
res
.
success
)
{
if
(
res
.
code
===
0
)
{
// 合成文件过后 删除缓存切片
const
params
=
{
fileName
:
this
.
file
.
name
,
fileMd5
:
this
.
fileMd5
,
filePath
:
res
.
data
.
filePath
}
this
.
$message
.
success
(
'
上传成功
'
)
await
removeChunk
(
params
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录