Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
fbf99266
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
8 个月 前同步成功
通知
324
Star
18154
Fork
5505
代码
文件
提交
分支
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 搜索 >>
未验证
提交
fbf99266
编写于
1月 01, 2022
作者:
Mr.奇淼(
提交者:
GitHub
1月 01, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into gva-2.4.6+
上级
20a56332
7da1962d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
45 addition
and
24 deletion
+45
-24
server/api/v1/example/exa_breakpoint_continue.go
server/api/v1/example/exa_breakpoint_continue.go
+9
-8
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
server/source/system/api.go
server/source/system/api.go
+3
-2
server/source/system/casbin.go
server/source/system/casbin.go
+1
-0
web/src/api/breakpoint.js
web/src/api/breakpoint.js
+9
-0
web/src/components/chooseImg/index.vue
web/src/components/chooseImg/index.vue
+1
-1
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
浏览文件 @
fbf99266
...
...
@@ -2,6 +2,7 @@ package example
import
(
"fmt"
"github.com/flipped-aurora/gin-vue-admin/server/model/example"
"io/ioutil"
"mime/multipart"
"strconv"
...
...
@@ -123,18 +124,18 @@ 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"
)
fileName
:=
c
.
Query
(
"fileName"
)
filePath
:=
c
.
Query
(
"filePath"
)
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
))
return
}
err
=
fileUploadAndDownloadService
.
DeleteFileChunk
(
file
Md5
,
fileName
,
f
ilePath
)
err
=
fileUploadAndDownloadService
.
DeleteFileChunk
(
file
.
FileMd5
,
file
.
FileName
,
file
.
F
ilePath
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"缓存切片删除失败!"
,
zap
.
Error
(
err
))
response
.
FailWith
Detailed
(
exampleRes
.
FilePathResponse
{
FilePath
:
filePath
},
"缓存切片删除失败"
,
c
)
global
.
GVA_LOG
.
Error
(
err
.
Error
()
,
zap
.
Error
(
err
))
response
.
FailWith
Message
(
err
.
Error
()
,
c
)
}
else
{
response
.
OkWith
Detailed
(
exampleRes
.
FilePathResponse
{
FilePath
:
filePath
},
"缓存切片删除成功"
,
c
)
response
.
OkWith
Message
(
"缓存切片删除成功"
,
c
)
}
}
server/model/example/exa_breakpoint_continue.go
浏览文件 @
fbf99266
...
...
@@ -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
浏览文件 @
fbf99266
...
...
@@ -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
}
...
...
server/source/system/api.go
浏览文件 @
fbf99266
...
...
@@ -60,8 +60,9 @@ func (a *api) Initialize() error {
{
ApiGroup
:
"菜单"
,
Method
:
"POST"
,
Path
:
"/menu/addMenuAuthority"
,
Description
:
"增加menu和角色关联关系"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/findFile"
,
Description
:
"寻找目标文件(秒传)"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/breakpointContinueFinish"
,
Description
:
"断点续传"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/removeChunk"
,
Description
:
"上传完成"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/breakpointContinue"
,
Description
:
"断点续传"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/breakpointContinueFinish"
,
Description
:
"断点续传完成"
},
{
ApiGroup
:
"分片上传"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/removeChunk"
,
Description
:
"上传完成移除文件"
},
{
ApiGroup
:
"文件上传与下载"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/upload"
,
Description
:
"文件上传示例"
},
{
ApiGroup
:
"文件上传与下载"
,
Method
:
"POST"
,
Path
:
"/fileUploadAndDownload/deleteFile"
,
Description
:
"删除文件"
},
...
...
server/source/system/casbin.go
浏览文件 @
fbf99266
...
...
@@ -56,6 +56,7 @@ func (c *casbin) Initialize() error {
{
PType
:
"p"
,
V0
:
"888"
,
V1
:
"/fileUploadAndDownload/findFile"
,
V2
:
"GET"
},
{
PType
:
"p"
,
V0
:
"888"
,
V1
:
"/fileUploadAndDownload/breakpointContinueFinish"
,
V2
:
"POST"
},
{
PType
:
"p"
,
V0
:
"888"
,
V1
:
"/fileUploadAndDownload/breakpointContinue"
,
V2
:
"POST"
},
{
PType
:
"p"
,
V0
:
"888"
,
V1
:
"/fileUploadAndDownload/removeChunk"
,
V2
:
"POST"
},
{
PType
:
"p"
,
V0
:
"888"
,
V1
:
"/fileUploadAndDownload/upload"
,
V2
:
"POST"
},
...
...
web/src/api/breakpoint.js
浏览文件 @
fbf99266
...
...
@@ -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/components/chooseImg/index.vue
浏览文件 @
fbf99266
...
...
@@ -19,7 +19,7 @@
</template>
<
script
>
const
path
=
process
.
env
.
VUE_APP
_BASE_API
const
path
=
import
.
meta
.
env
.
VITE
_BASE_API
import
{
getFileList
}
from
'
@/api/fileUploadAndDownload
'
export
default
{
props
:
{
...
...
web/src/utils/request.js
浏览文件 @
fbf99266
...
...
@@ -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
浏览文件 @
fbf99266
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录