Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
download-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
downloader
download-web
Commits
bd08d501
Commit
bd08d501
authored
Sep 01, 2025
by
焦子成
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a2c01127
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
120 additions
and
28 deletions
+120
-28
src/api/api.js
+1
-0
src/stores/download.js
+31
-1
src/views/Downloader.vue
+0
-0
src/views/History.vue
+88
-27
No files found.
src/api/api.js
View file @
bd08d501
...
...
@@ -28,6 +28,7 @@ const config = {
uploadDetailDelete
:
`
${
domain
}
/uploadDetail/delete`
,
downLoadStatus
:
`
${
domain
}
/uploadDetail/downLoadStatus`
,
fileUploadDetail
:
`
${
domain
}
/uploadBatch/fileUploadDetail`
,
queryFileAll
:
`
${
domain
}
/uploadBatch/queryFileAll`
,
};
export
default
config
;
src/stores/download.js
View file @
bd08d501
...
...
@@ -2,6 +2,8 @@ import { defineStore } from 'pinia'
import
{
ref
,
computed
}
from
'vue'
import
{
ElMessage
}
from
'element-plus'
import
{
useAuthStore
}
from
'./auth'
import
http
from
'@/utils/request.js'
;
import
config
from
'@/api/api.js'
;
export
const
useDownloadStore
=
defineStore
(
'download'
,
()
=>
{
const
authStore
=
useAuthStore
()
...
...
@@ -148,13 +150,32 @@ export const useDownloadStore = defineStore('download', () => {
// 创建 AbortController 用于取消下载
download
.
controller
=
new
AbortController
()
console
.
log
(
'download config.url-->'
,
config
.
downLoadStatus
)
console
.
log
(
'download id-->'
,
download
.
id
)
try
{
await
performDownload
(
download
)
http
.
post
(
config
.
downLoadStatus
,{
detailId
:
download
.
id
,
fileStatus
:
3
,
//下载状态 0:等待中 1:下载中 2:已暂停 3:已完成 4:失败
}).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
}
else
{
ElMessage
.
error
(
res
.
message
)
}
})
}
catch
(
error
)
{
if
(
error
.
name
===
'AbortError'
)
{
download
.
status
=
'paused'
saveToStorage
()
http
.
post
(
config
.
downLoadStatus
,{
detailId
:
download
.
id
,
fileStatus
:
2
,
//下载状态 0:等待中 1:下载中 2:已暂停 3:已完成 4:失败
}).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
}
else
{
ElMessage
.
error
(
res
.
message
)
}
})
}
else
{
// 处理重试逻辑
if
(
download
.
retryCount
<
download
.
maxRetries
)
{
...
...
@@ -169,6 +190,15 @@ export const useDownloadStore = defineStore('download', () => {
download
.
status
=
'error'
download
.
error
=
error
.
message
saveToStorage
()
http
.
post
(
config
.
downLoadStatus
,{
detailId
:
download
.
id
,
fileStatus
:
4
,
//下载状态 0:等待中 1:下载中 2:已暂停 3:已完成 4:失败
}).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
}
else
{
ElMessage
.
error
(
res
.
message
)
}
})
}
}
}
finally
{
...
...
src/views/Downloader.vue
View file @
bd08d501
This diff is collapsed.
Click to expand it.
src/views/History.vue
View file @
bd08d501
...
...
@@ -48,7 +48,7 @@
<div
class=
"card-header"
>
<span>
历史记录
</span>
<div
class=
"header-actions"
>
<el-select
v-model=
"
deQuery.fileStatus
"
placeholder=
"状态筛选"
size=
"small"
style=
"width: 120px;"
>
<el-select
v-model=
"
statusFilter
"
placeholder=
"状态筛选"
size=
"small"
style=
"width: 120px;"
>
<el-option
label=
"全部"
value=
""
/>
<el-option
label=
"已完成"
:value=
"3"
/>
<el-option
label=
"失败"
:value=
"4"
/>
...
...
@@ -57,10 +57,10 @@
<el-select
v-model=
"excelFileFilter"
placeholder=
"Excel文件筛选"
size=
"small"
style=
"width: 150px; margin-left: 10px;"
>
<el-option
label=
"全部Excel文件"
value=
""
/>
<el-option
v-for=
"excelFile in
uniqueExcelFiles
"
:key=
"excelFile"
:label=
"excelFile"
<el-option
v-for=
"excelFile in
excelFileFilterList
"
:key=
"excelFile"
:label=
"excelFile"
:value=
"excelFile"
/>
</el-select>
<el-input
v-model=
"
deQuery.fileName
"
placeholder=
"搜索文件名或Excel文件"
size=
"small"
<el-input
v-model=
"
searchKeyword
"
placeholder=
"搜索文件名或Excel文件"
size=
"small"
style=
"width: 200px; margin-left: 10px;"
clearable
>
<template
#
prefix
>
<el-icon>
...
...
@@ -73,7 +73,7 @@
</template>
<!-- 历史记录表格 -->
<el-table
:data=
"
deTableData
"
style=
"width: 100%"
:default-sort=
"{ prop: 'timestamp', order: 'descending' }"
<el-table
:data=
"
filteredHistory
"
style=
"width: 100%"
:default-sort=
"{ prop: 'timestamp', order: 'descending' }"
stripe
>
<el-table-column
prop=
"timestamp"
label=
"时间"
width=
"180"
sortable
>
<
template
#
default=
"scope"
>
...
...
@@ -142,10 +142,10 @@
<el-table-column
label=
"操作"
width=
"120"
fixed=
"right"
>
<
template
#
default=
"scope"
>
<el-button
v-if=
"scope.row.status === 'error'"
@
click=
"retryDownload(scope.row)"
type=
"primary"
<
!--
<
el-button
v-if=
"scope.row.status === 'error'"
@
click=
"retryDownload(scope.row)"
type=
"primary"
size=
"small"
>
重试
</el-button>
</el-button>
-->
<el-button
@
click=
"viewDetails(scope.row)"
type=
"info"
size=
"small"
>
详情
</el-button>
...
...
@@ -155,7 +155,7 @@
<!-- 分页 -->
<div
class=
"pagination-container"
>
<el-pagination
v-model:current-page=
"
deQuery.current"
v-model:page-size=
"deQuery.
pageSize"
:page-sizes=
"[10, 20, 50, 100]"
<el-pagination
v-model:current-page=
"
currentPage"
v-model:page-size=
"
pageSize"
:page-sizes=
"[10, 20, 50, 100]"
:total=
"deTotal"
layout=
"total, sizes, prev, pager, next, jumper"
@
size-change=
"handleSizeChange"
@
current-change=
"handleCurrentChange"
/>
</div>
...
...
@@ -196,7 +196,7 @@
<
script
setup
>
import
{
ref
,
computed
,
onMounted
,
reactive
}
from
'vue'
import
{
useRouter
}
from
'vue-router'
import
{
ElMessage
,
ElMessageBox
}
from
'element-plus'
import
{
ElMessage
,
ElMessageBox
,
valueEquals
}
from
'element-plus'
import
{
Clock
,
Search
}
from
'@element-plus/icons-vue'
import
{
useAuthStore
}
from
'../stores/auth'
import
http
from
'@/utils/request.js'
;
...
...
@@ -214,21 +214,71 @@ const currentPage = ref(1)
const
pageSize
=
ref
(
20
)
const
detailsVisible
=
ref
(
false
)
const
selectedRecord
=
ref
(
null
)
const
deQuery
=
ref
({
current
:
1
,
pageSize
:
10
,
fileStatus
:
3
,
fileName
:
''
})
let
deTableData
=
reactive
([])
const
excelFileFilterList
=
ref
([])
// const deQuery = ref({
// current: 1,
// pageSize: 10,
// fileStatus: 3,
// fileName: ''
// })
// let deTableData =
// reactive([])
let
deTotal
=
ref
(
0
)
const
statusMap
=
{
0
:
'pending'
,
1
:
'downloading'
,
2
:
'paused'
,
3
:
'completed'
,
4
:
'error'
}
function
laodFileAll
(){
http
.
post
(
config
.
queryFileAll
).
then
(
res
=>
{
if
(
res
.
code
===
200
){
excelFileFilterList
.
value
=
res
.
data
}
else
{
ElMessage
.
error
(
res
.
message
)
}
})
}
// 加载历史数据
const
loadHistory
=
()
=>
{
// historyData.value = authStore.getDownloadHistory()
http
.
post
(
config
.
uploadDetailList
,
deQuery
.
value
).
then
(
res
=>
{
http
.
post
(
config
.
uploadDetailList
,
{
current
:
currentPage
.
value
,
pageSize
:
pageSize
.
value
,
fileStatus
:
statusFilter
.
value
,
uploadName
:
excelFileFilter
.
value
,
fileName
:
searchKeyword
.
value
}).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
deTableData
=
res
.
data
.
rows
var
list
=
[]
var
updateTime
=
''
for
(
const
element
of
res
.
data
.
rows
)
{
updateTime
=
element
.
updateTime
list
.
push
({
"id"
:
element
.
detailId
,
"fileName"
:
element
.
fileName
,
"fileNamePrefix"
:
""
,
"excelFileName"
:
element
.
uploadName
,
"url"
:
element
.
fileUrl
,
"status"
:
statusMap
[
element
.
fileStatus
],
"progress"
:
100
,
"fileSize"
:
element
.
fileLength
,
"downloadedBytes"
:
0
,
"startTime"
:
element
.
createTime
,
"endTime"
:
''
,
"error"
:
null
})
}
historyData
.
value
=
[
{
downloads
:
list
,
timestamp
:
updateTime
,
userId
:
''
}
]
// deTableData = res.data.rows
deTotal
.
value
=
res
.
data
.
total
}
else
{
ElMessage
.
error
(
res
.
message
)
...
...
@@ -400,9 +450,19 @@ const clearAllHistory = async () => {
}
)
authStore
.
clearDownloadHistory
()
loadHistory
()
ElMessage
.
success
(
'历史记录已清空'
)
// authStore.clearDownloadHistory()
// loadHistory()
// ElMessage.success('历史记录已清空')
http
.
post
(
config
.
uploadDetailDeleteAll
,
{
type
:
1
}).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
loadHistory
()
ElMessage
.
success
(
'历史记录已清空'
)
}
else
{
ElMessage
.
error
(
res
.
message
)
}
})
}
catch
{
// 用户取消
}
...
...
@@ -410,16 +470,16 @@ const clearAllHistory = async () => {
// 分页处理
const
handleSizeChange
=
(
size
)
=>
{
//
pageSize.value = size
//
currentPage.value = 1
deQuery
.
value
.
pageSize
=
size
deQuery
.
value
.
current
=
1
pageSize
.
value
=
size
currentPage
.
value
=
1
//
deQuery.value.pageSize = size
//
deQuery.value.current = 1
loadHistory
()
}
const
handleCurrentChange
=
(
page
)
=>
{
//
currentPage.value = page
deQuery
.
value
.
current
=
page
currentPage
.
value
=
page
//
deQuery.value.current = page
loadHistory
()
}
...
...
@@ -432,6 +492,7 @@ const goBack = () => {
onMounted
(()
=>
{
loadHistory
()
loadUploadDetailTotalNum
()
laodFileAll
()
})
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment