Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fk-spider-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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
fk-spider-web
Commits
3b63ab86
Commit
3b63ab86
authored
Jan 21, 2026
by
周田
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'liucan' into 'main'
feat:任务执行记录新增根据任务名称查询 See merge request
!29
parents
521284c3
27122a78
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
79 deletions
+114
-79
request.ts
src/utils/request.ts
+78
-78
index.vue
src/views/os-taskRecord/index.vue
+36
-1
No files found.
src/utils/request.ts
View file @
3b63ab86
import
axios
from
"axios"
;
import
{
ElMessage
}
from
"element-plus"
;
import
{
getToken
,
removeToken
}
from
"@/utils/auth"
;
import
axios
from
'axios'
import
{
ElMessage
}
from
'element-plus'
import
{
getToken
,
removeToken
}
from
'@/utils/auth'
// 创建axios实例
const
instance
=
axios
.
create
({
baseURL
:
import
.
meta
.
env
.
VITE_APP_BASE_API
||
""
,
baseURL
:
import
.
meta
.
env
.
VITE_APP_BASE_API
||
''
,
timeout
:
10000
,
// 毫秒
headers
:
{
"Content-Type"
:
"application/zip; charset=utf-8"
,
}
,
})
;
'Content-Type'
:
'application/zip; charset=utf-8'
}
})
// 请求拦截器
instance
.
interceptors
.
request
.
use
(
(
config
)
=>
{
const
token
=
getToken
()
;
const
token
=
getToken
()
if
(
token
)
{
// 保持与原项目相同的Token头设置
config
.
headers
[
"Token"
]
=
token
;
config
.
headers
[
'Token'
]
=
token
}
return
config
;
return
config
},
(
err
)
=>
{
console
.
log
(
"请求出错"
);
return
Promise
.
reject
(
err
)
;
console
.
log
(
'请求出错'
)
return
Promise
.
reject
(
err
)
}
)
;
)
// 响应拦截器
instance
.
interceptors
.
response
.
use
(
(
res
)
=>
{
let
result
=
res
.
data
;
let
result
=
res
.
data
if
(
typeof
res
.
data
===
"string"
)
{
if
(
typeof
res
.
data
===
'string'
)
{
try
{
result
=
JSON
.
parse
(
res
.
data
)
;
result
=
JSON
.
parse
(
res
.
data
)
}
catch
(
e
)
{
// 不是JSON格式,保持原样
}
}
else
{
// 4000 token无效或者过期
if
(
result
.
code
===
4000
)
{
removeToken
()
;
window
.
location
.
reload
()
;
removeToken
()
window
.
location
.
reload
()
}
if
(
result
.
code
===
0
)
{
result
.
ok
=
true
;
result
.
ok
=
true
}
else
{
result
.
ok
=
false
;
ElMessage
.
error
(
result
.
msg
||
"请求失败"
);
result
.
ok
=
false
ElMessage
.
error
(
result
.
msg
||
'请求失败'
)
}
}
return
result
;
return
result
},
(
err
)
=>
{
ElMessage
.
error
(
"网络请求出错, 请检查网络"
);
return
Promise
.
reject
(
err
)
;
ElMessage
.
error
(
'网络请求出错, 请检查网络'
)
return
Promise
.
reject
(
err
)
}
)
;
)
// HTTP 请求方法常量
export
const
GET
=
"get"
;
export
const
POST
=
"post"
;
export
const
PUT
=
"put"
;
export
const
DELETE
=
"delete"
;
export
const
GET
=
'get'
export
const
POST
=
'post'
export
const
PUT
=
'put'
export
const
DELETE
=
'delete'
// 请求函数类型
export
interface
RequestConfig
{
url
:
string
;
method
:
"get"
|
"post"
|
"put"
|
"delete"
;
params
?:
any
;
data
?:
any
;
headers
?:
Record
<
string
,
string
>
;
url
:
string
method
:
'get'
|
'post'
|
'put'
|
'delete'
params
?:
any
data
?:
any
headers
?:
Record
<
string
,
string
>
}
export
interface
ApiResponse
<
T
=
any
>
{
code
:
number
;
data
:
T
;
message
:
string
;
code
:
number
data
:
T
message
:
string
}
export
interface
QueryParams
{
page
?:
number
;
size
?:
number
;
project
?:
string
;
spider
?:
string
;
scrapydServerId
?:
string
;
order_prop
?:
string
;
order_type
?:
string
;
status
?:
any
;
job
?:
any
;
page
?:
number
size
?:
number
project
?:
string
spider
?:
string
scrapydServerId
?:
string
order_prop
?:
string
order_type
?:
string
status
?:
any
job
?:
any
}
// 请求函数
export
const
request
=
(
config
:
RequestConfig
)
=>
{
return
instance
(
config
)
;
}
;
return
instance
(
config
)
}
export
interface
UserQueryParams
{
page
?:
number
;
size
?:
number
;
username
?:
string
;
nickname
?:
string
;
password
?:
string
;
role
?:
number
;
status
?:
any
;
id
?:
number
;
ids
?:
any
;
scrapydServerId
?:
string
;
project
?:
string
;
spiders
?:
any
;
times
?:
any
;
job_id
?:
string
;
scrapyd_server_id
?:
string
;
schedule_type
?:
string
;
spider
?:
string
;
cron
?:
string
;
options
?:
string
;
sat_name
?:
string
;
ntc_id
?:
string
;
filters
?:
any
;
norad_cat_id
?:
string
;
object_name
?:
string
;
name
?:
string
;
spacecraft
?:
string
;
station
?:
string
;
interval
?:
number
[];
}
\ No newline at end of file
page
?:
number
size
?:
number
username
?:
string
nickname
?:
string
password
?:
string
role
?:
number
status
?:
any
id
?:
number
ids
?:
any
scrapydServerId
?:
string
project
?:
string
spiders
?:
any
times
?:
any
job_id
?:
string
scrapyd_server_id
?:
string
schedule_type
?:
string
spider
?:
string
cron
?:
string
options
?:
string
sat_name
?:
string
ntc_id
?:
string
filters
?:
any
norad_cat_id
?:
string
object_name
?:
string
name
?:
string
spacecraft
?:
string
station
?:
string
interval
?:
number
[]
schedule_job_id
?:
string
}
src/views/os-taskRecord/index.vue
View file @
3b63ab86
...
...
@@ -22,6 +22,17 @@
</el-config-provider>
</div>
<div
class=
"spider w-[300px] flex items-center"
>
<span
style=
"color: white"
class=
"w-[100px]"
>
任务名称:
</span>
<el-select
v-model=
"jobname"
placeholder=
"请选择任务名称"
>
<el-option
v-for=
"item in jobNameOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
></el-option>
</el-select>
</div>
<div
class=
"spider w-[300px] flex items-center"
>
<span
style=
"color: white"
class=
"w-[100px]"
>
所属爬虫:
</span>
<el-select
v-model=
"spidername"
placeholder=
"请选择爬虫"
>
<el-option
...
...
@@ -99,7 +110,7 @@ import { ref, onMounted } from 'vue'
import
Pagination
from
'@/components/pagination/index.vue'
import
{
useRoute
}
from
'vue-router'
import
{
useRouter
}
from
'vue-router'
import
{
getSpiderTaskRecord
}
from
'@/api/spiderTask.ts'
import
{
getSpiderTask
List
,
getSpiderTask
Record
}
from
'@/api/spiderTask.ts'
import
MenuTitle
from
'@/components/MenuTitle.vue'
import
TableSearch
from
'@/components/TableSearch.vue'
//时间处理库
...
...
@@ -157,6 +168,9 @@ const spideOptions = [
}
]
// 任务名称下拉框选项
const
jobNameOptions
=
ref
<
Array
<
{
label
:
string
;
value
:
string
}
>>
([])
//表单loading标记
const
tableLoading
=
ref
(
false
)
...
...
@@ -164,9 +178,27 @@ const tableLoading = ref(false)
const
resetQuery
=
()
=>
{
timeValue
.
value
=
[]
spidername
.
value
=
''
jobname
.
value
=
''
getData
()
}
// 任务列表
const
taskList
=
ref
([])
// 获取任务列表
const
getTaskList
=
async
()
=>
{
const
res
=
await
getSpiderTaskList
({})
taskList
.
value
=
res
.
data
jobNameOptions
.
value
=
taskList
.
value
.
filter
((
task
:
any
)
=>
task
.
id
)
.
map
((
task
:
any
)
=>
({
label
:
task
.
kwargs
.
spider
,
value
:
task
.
id
}))
console
.
log
(
taskList
.
value
)
}
// 获取任务执行记录列表
const
getData
=
async
()
=>
{
let
resTime
:
any
[]
=
[]
...
...
@@ -186,6 +218,7 @@ const getData = async () => {
}
const
spidername
=
ref
(
''
)
const
jobname
=
ref
(
''
)
//查询数据的方法
const
searchData
=
async
()
=>
{
...
...
@@ -202,6 +235,7 @@ const searchData = async () => {
size
:
pageObj
.
value
.
pageSize
,
status
:
'total'
,
spider
:
spidername
.
value
,
schedule_job_id
:
jobname
.
value
,
times
:
resTime
})
pageObj
.
value
.
total
=
res
.
data
.
total
...
...
@@ -211,6 +245,7 @@ const searchData = async () => {
onMounted
(()
=>
{
getData
()
getTaskList
()
})
</
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