完成爬虫调用联调,完成爬虫UI优化。

This commit is contained in:
yyhouc 2023-04-21 18:11:21 +08:00
parent be9637e1b1
commit 89e58d173c
7 changed files with 329 additions and 99 deletions

BIN
public/baidu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
public/bing.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

68
src/api/crawl/index.js Normal file
View File

@ -0,0 +1,68 @@
import request, {crawlModule ,moduleName } from '/@/utils/request';
export const geoserve = (vordm_id , link , disaster_id, name) =>{
return request({
url: '/api/' + crawlModule + '/geoserve/pushing',
method: 'post',
data: {
vordm_id,
link,
disaster_id,
name
}
});
}
export const news = (disaster_id, keywords, page,isBaidu,id) =>{
return request({
url: '/api/' + crawlModule + '/news/'+(isBaidu?"baidu":"bing"),
method: 'post',
data: {
disaster_id,
keywords,
page,
id
}
});
}
export const rs = (stime, etime, disaster_id,ranges ,type =1) =>{
let method = 'sentinel';
if(type == 1){
method = 'sentinel';
}else if(type == 2){
method = 'landsat';
}else {
method = 'searchone';
}
return request({
url: '/api/' + crawlModule + '/news/'+method,
method: 'post',
data: {
stime, etime, disaster_id,ranges
}
});
}
export const submit = (row) => {
return request({
url: '/api/'+moduleName+'/ui/crawlInfo/submit',
method: 'post',
data: row
})
}
export const getList = (current, size, param) => {
let params = {
current,
size,
};
if(param){
params = Object.assign(params, param);
}
return request({
url: '/api/'+moduleName+'/ui/crawlInfo/list',
method: 'get',
params: params
});
}

View File

@ -5,6 +5,7 @@ import { Session } from '/@/utils/storage';
// export const moduleName = 'zqq-biz-vordm';
export const moduleName = 'yyhouc-biz-vordm';
export const crawlModule = "vordm-crawl";
// 配置新建一个 axios 实例
const service = axios.create({

View File

@ -0,0 +1,204 @@
<template>
<el-dialog title="Collection robot" v-model="state.isShowDialog" width="700px">
<el-row>
<el-col :span="5" style="text-align:center ;">
<el-image style="height:40px ; width:100px!" src="/baidu.jpg"></el-image>
</el-col>
<el-col :span="9">
<el-form-item label="Confirm keywords" style="text-align:center;">
<el-input v-model="state.baidu.keywords">
</el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="page" style="text-align:center ; margin-left: 10px;">
<el-input v-model="state.baidu.page" type="number" style="width: 70px ;"></el-input>
</el-form-item>
</el-col>
<el-col :span="4" style="text-align:center ;">
<el-icon :size="40" style="cursor:pointer ;" :title="state.baidu.status==0?'Waiting in queue……':'start'" :color="state.baidu.status==0?'#4f4':'blue'" @click="state.baidu.status==0?confirmBox('baidu'):start('baidu')" v-if="state.baiduOption.buttonIs&&(state.baidu.status==0||!state.baidu.status)">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="m249.6 417.088 319.744 43.072 39.168 310.272L845.12 178.88 249.6 417.088zm-129.024 47.168a32 32 0 0 1-7.68-61.44l777.792-311.04a32 32 0 0 1 41.6 41.6l-310.336 775.68a32 32 0 0 1-61.44-7.808L512 516.992l-391.424-52.736z"></path></svg>
</el-icon>
<el-icon :size="40" style="cursor:pointer ;" title="Data collection in progress, please wait……" color="#131313" v-if="state.baiduOption.buttonIs&&state.baidu.status==1">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"></path></svg>
</el-icon>
<el-icon :size="40" style="cursor:pointer ;" title="once more start" color="#4f4" @click="start('baidu')" v-if="state.baiduOption.buttonIs&&state.baidu.status==2">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="M406.656 706.944 195.84 496.256a32 32 0 1 0-45.248 45.248l256 256 512-512a32 32 0 0 0-45.248-45.248L406.592 706.944z"></path></svg>
</el-icon>
<span v-if="!state.baiduOption.buttonIs" style="height: 40; line-height: 40px;">{{ state.baiduOption.runTitle }}</span>
</el-col>
</el-row>
<el-row>
<el-col :span="5" style="text-align:center ;">
<el-image style="height:40px ; width:100px!" src="/bing.webp"></el-image>
</el-col>
<el-col :span="9" >
<el-form-item label="Confirm keywords" style="text-align:center ;">
<el-input v-model="state.bing.keywords"></el-input>
</el-form-item>
</el-col>
<el-col :span="5" >
<el-form-item label="page" style="text-align:center; margin-left: 10px;">
<el-input v-model="state.bing.page" type="number" style="width: 70px ;"></el-input>
</el-form-item>
</el-col>
<el-col :span="4" style="text-align:center ;">
<el-icon :size="40" style="cursor:pointer ;" :title="state.bing.status==0?'Waiting in queue……':'start'" :color="state.bing.status==0?'#4f4':'blue'" @click="state.bing.status==0?confirmBox('bing'):start('bing')" v-if="state.bingOption.buttonIs&&(state.bing.status==0||!state.bing.status)">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="m249.6 417.088 319.744 43.072 39.168 310.272L845.12 178.88 249.6 417.088zm-129.024 47.168a32 32 0 0 1-7.68-61.44l777.792-311.04a32 32 0 0 1 41.6 41.6l-310.336 775.68a32 32 0 0 1-61.44-7.808L512 516.992l-391.424-52.736z"></path></svg>
</el-icon>
<el-icon :size="40" style="cursor:pointer ;" title="Data collection in progress, please wait……" color="#131313" v-if="state.buttonIs&&state.bing.status==1">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32zm0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32zm448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32zm-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32zM195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0zm-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"></path></svg>
</el-icon>
<el-icon :size="40" style="cursor:pointer ;" title="once more start" color="#4f4" @click="start('bing')" v-if="state.bingOption.buttonIs&&state.bing.status==2">
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-ea893728=""><path fill="currentColor" d="M406.656 706.944 195.84 496.256a32 32 0 1 0-45.248 45.248l256 256 512-512a32 32 0 0 0-45.248-45.248L406.592 706.944z"></path></svg>
</el-icon>
<span v-if="!state.bingOption.buttonIs" style="height: 40; line-height: 40px;">{{ state.bingOption.runTitle }}</span>
</el-col>
</el-row>
<template #footer>
<span class="dialog-footer">
<el-button @click="state.isShowDialog=false" size="default">close</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup >
import { ElMessage,ElMessageBox} from 'element-plus';
import {reactive,defineExpose} from 'vue';
import {news,submit,getList} from '/@/api/crawl/index';
import { useUserInfo } from '/@/stores/userInfo';
const userInfo = useUserInfo();
const state = reactive({
isShowDialog:false,
data:{},
table:[],
baidu:{
keywords:"",
page:5,
disaster_id:undefined
},
bing:{
keywords:"",
page:10,
disaster_id:undefined
},
baiduOption:{
buttonIs:true,
runTitle:""
},
bingOption:{
buttonIs:true,
runTitle:""
}
})
const confirmBox = (text)=>{
ElMessageBox.confirm(
'Already in queue, continue to start?',
'Warning',
{
confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
type: 'warning',
}
)
.then(() => {
start(text)
ElMessage({
type: 'success',
message: 'restart success',
})
})
.catch(() => {
ElMessage({
type: 'info',
message: 'Cancel restart',
})
})
}
const openDialog = (row) => {
state.data = row;
state.baidu.keywords = row.disasterKeyword;
state.baidu.disaster_id = row.id
state.bing.keywords=row.disasterKeyword;
state.bing.disaster_id = row.id
getDate();
state.isShowDialog = true;
}
const getDate = ()=>{
getList(1,10,{disasterId:state.data.id}).then(res=>{
let data = res.records;
for (let index = 0; index < data.length; index++) {
const element = data[index];
if(element.type == 2){
state.baidu = element;
}
if(element.type == 1){
state.baidu = element;
}
}
state.baidu.page=10;
state.bing.page=10;
})
}
const start = (text)=>{
state.baiduOption.runTitle="start(5s)";
let count = 4;
const countdown = setInterval(function() {
if(text=='baidu'){
state.baiduOption.runTitle="start("+count+"s)";
}else{
state.bingOption.runTitle="start("+count+"s)";
}
count -= 1;
if (count < 0) {
if(text=='baidu'){
state.baiduOption.buttonIs= true ;
}else{
state.bingOption.buttonIs= true ;
}
clearInterval(countdown);
console.log('倒计时结束');
}
}, 1000);
let keywords = (text=='baidu'?state.baidu.keywords:state.bing.keywords);
let page = (text=='baidu'?state.baidu.page:state.bing.page);
let id = (text=='baidu'?state.baidu.id:state.bing.id);
submit(
{
type:text=='baidu'?2:1,
manageId:userInfo.userInfos.id,
status:0,
disasterId:state.data.id,
keywords:keywords,
id:(id?id:null)
}
).then(ret=>{
if(ret == 1042){
ElMessage.error("error")
}else{
news(ret.disasterId, keywords, page,(text=="baidu"),ret.id).then(res=>{
getData();
ElMessage.success("success")
})
}
})
}
defineExpose({
openDialog,
})
</script>
<style >
.inline-block {
display: inline-block;
}
</style>

View File

@ -17,9 +17,8 @@
<el-table-column prop="disasterTime" label="disaster time" show-overflow-tooltip></el-table-column>
<el-table-column prop="Operate" label="Operate" show-overflow-tooltip>
<template #default="scope">
<el-button size="small" text type="primary" v-if="scope.row.respondStatus == 2"
@click="ElMessage.info('start')">start</el-button>
<el-tag type="info" v-if="scope.row.respondStatus == 3">complete</el-tag>
<el-button size="small" text type="primary" @click="startBot(scope.row)">start</el-button>
<!-- <el-tag type="info" v-if="scope.row.respondStatus == 3">complete</el-tag> -->
</template>
</el-table-column>
</el-table>
@ -35,20 +34,23 @@
<div class="system-role-padding layout-padding-auto layout-padding-view">
<div class="system-user-search mb15" style="display: flex;margin-left: 10px;margin-top: 10px;">
<el-form-item label="type" label-width="100px">
<el-select v-model="state.searchName" placeholder="please select data type" style="max-width: 200px"
size="default" clearable>
<el-select v-model="state.searchName" placeholder="Please select data type" style="max-width: 200px"
size="default" clearable @change="getTableData();state.queryTitle=''">
<el-option value="1" label="news"></el-option>
<el-option value="2" label="socialMedia"></el-option>
</el-select>
</el-form-item>
<el-form-item label="stateus" label-width="100px">
<el-select v-model="state.srarchType" placeholder="please select data type" style="max-width: 200px"
<el-select v-model="state.srarchType" placeholder="Please select data type" style="max-width: 200px"
size="default" clearable>
<el-option value="0" label="No review"></el-option>
<el-option value="1" label="reserve"></el-option>
<el-option value="2" label="not retain"></el-option>
</el-select>
</el-form-item>
<el-form-item label="title" label-width="100px" v-if = "state.searchName=='1'">
<el-input v-model="state.queryTitle" placeholder="Please enter a title"></el-input>
</el-form-item>
<el-button size="default" type="primary" class="ml10" @click="getTableData">
<el-icon>
<ele-Search />
@ -66,6 +68,7 @@
@selection-change="handleSelectionChange" style="width: 100%">
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="ID" width="50" />
<el-table-column v-if = "state.searchName=='1'" prop="title" label="title" show-overflow-tooltip></el-table-column>
<el-table-column prop="content" label="content" show-overflow-tooltip></el-table-column>
<el-table-column prop="type" label="type" show-overflow-tooltip >
<template #default="scope">
@ -105,7 +108,7 @@
</div>
</el-col>
</el-row>
<el-dialog v-model="state.dialogVisible" title="Review" width="30%" :before-close="handleClose">
<el-dialog v-model="state.dialogVisible" title="Review" width="30%" >
<!-- <el-form-item label="status">
<el-select v-model="state.edit.status" placeholder="please select data type" style="max-width: 200px"
size="default" clearable>
@ -128,11 +131,11 @@
</template>
</el-dialog>
</el-config-provider>
<Upload ref="uploadRef" @callback="getTableData" />
<boot ref="bootRef" @callback="getTableData" />
</div>
</template>
<script lang="ts" setup name="systemRole">
<script lang="ts" setup name="dataMultimediaData">
import en from 'element-plus/dist/locale/en.mjs'
import type { TabsPaneContext } from 'element-plus';
import { getOtherDataPage, getDisasterPage, deleteData } from '/@/api/data/otherData.js'
@ -143,9 +146,10 @@ import { getDictionary } from '/@/api/system/dictbiz';
//
import { defineAsyncComponent, reactive, onMounted, ref } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus';
import boot from "./component/boot.vue"
//
const auditRef = ref();
const uploadRef = ref();
const bootRef = ref();
//
@ -160,6 +164,7 @@ const state = reactive({
multipleSelection: [],
searchName: '1',
disasterId: null,
queryTitle:"",
edit: {
status: 0,
},
@ -271,7 +276,7 @@ const getDisasterData = () => {
//
const getTableData = () => {
state.tableData.loading = true;
getNewsList(state.tableData.param.pageNum, state.tableData.param.pageSize, { "disasterId": state.disasterId, "isDeleted": 0,status :state.srarchType }, state.searchName == '1' ? true : false).then(res => {
getNewsList(state.tableData.param.pageNum, state.tableData.param.pageSize, { "disasterId": state.disasterId, "isDeleted": 0,status :state.srarchType ,title:state.queryTitle}, state.searchName == '1' ? true : false).then(res => {
state.tableData.data = res.records;
state.tableData.total = res.total;
})
@ -282,12 +287,9 @@ const getTableData = () => {
}, 500);
};
//
const uploadData = () => {
if (state.disasterId == null) {
ElMessage.warning("Please select the disaster first")
return false;
}
uploadRef.value.openDialog(state.disasterId);
const startBot = (row:any) => {
bootRef.value.openDialog(row);
};
//
const onOpenEditRole = (type, row) => {

View File

@ -1,99 +1,53 @@
<template>
<div class="system-user-container layout-padding">
<el-card shadow="hover"
class="layout-padding-auto">
<el-card shadow="hover" class="layout-padding-auto">
<div class="system-user-search mb15">
<el-input size="default"
placeholder="请输入用户名称"
style="max-width: 180px"> </el-input>
<el-button size="default"
type="primary"
class="ml10">
<el-input size="default" placeholder="请输入用户名称" style="max-width: 180px"> </el-input>
<el-button size="default" type="primary" class="ml10">
<el-icon>
<ele-Search />
</el-icon>
查询
</el-button>
<el-button size="default"
type="success"
class="ml10"
@click="onOpenAddUser('add')">
<el-button size="default" type="success" class="ml10" @click="onOpenAddUser('add')">
<el-icon>
<ele-FolderAdd />
</el-icon>
新增用户
</el-button>
</div>
<el-table :data="state.tableData.data"
v-loading="state.tableData.loading"
style="width: 100%">
<el-table-column type="index"
label="序号"
width="60" />
<el-table-column prop="userName"
label="账户名称"
show-overflow-tooltip></el-table-column>
<el-table-column prop="userNickname"
label="用户昵称"
show-overflow-tooltip></el-table-column>
<el-table-column prop="roleSign"
label="关联角色"
show-overflow-tooltip></el-table-column>
<el-table-column prop="department"
label="部门"
show-overflow-tooltip></el-table-column>
<el-table-column prop="phone"
label="手机号"
show-overflow-tooltip></el-table-column>
<el-table-column prop="email"
label="邮箱"
show-overflow-tooltip></el-table-column>
<el-table-column prop="status"
label="用户状态"
show-overflow-tooltip>
<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
<el-table-column type="index" label="序号" width="60" />
<el-table-column prop="userName" label="账户名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="userNickname" label="用户昵称" show-overflow-tooltip></el-table-column>
<el-table-column prop="roleSign" label="关联角色" show-overflow-tooltip></el-table-column>
<el-table-column prop="department" label="部门" show-overflow-tooltip></el-table-column>
<el-table-column prop="phone" label="手机号" show-overflow-tooltip></el-table-column>
<el-table-column prop="email" label="邮箱" show-overflow-tooltip></el-table-column>
<el-table-column prop="status" label="用户状态" show-overflow-tooltip>
<template #default="scope">
<el-tag type="success"
v-if="scope.row.status">启用</el-tag>
<el-tag type="info"
v-else>禁用</el-tag>
<el-tag type="success" v-if="scope.row.status">启用</el-tag>
<el-tag type="info" v-else>禁用</el-tag>
</template>
</el-table-column>
<el-table-column prop="describe"
label="用户描述"
show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime"
label="创建时间"
show-overflow-tooltip></el-table-column>
<el-table-column label="操作"
width="100">
<el-table-column prop="describe" label="用户描述" show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
<el-table-column label="操作" width="100">
<template #default="scope">
<el-button :disabled="scope.row.userName === 'admin'"
size="small"
text
type="primary"
<el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary"
@click="onOpenEditUser('edit', scope.row)">修改</el-button>
<el-button :disabled="scope.row.userName === 'admin'"
size="small"
text
type="primary"
<el-button :disabled="scope.row.userName === 'admin'" size="small" text type="primary"
@click="onRowDel(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination @size-change="onHandleSizeChange"
@current-change="onHandleCurrentChange"
class="mt15"
:pager-count="5"
:page-sizes="[10, 20, 30]"
v-model:current-page="state.tableData.param.pageNum"
background
v-model:page-size="state.tableData.param.pageSize"
layout="total, sizes, prev, pager, next, jumper"
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15"
:pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.pageNum" background
v-model:page-size="state.tableData.param.pageSize" layout="total, sizes, prev, pager, next, jumper"
:total="state.tableData.total">
</el-pagination>
</el-card>
<UserDialog ref="userDialogRef"
@refresh="getTableData()" />
<UserDialog ref="userDialogRef" @refresh="getTableData()" />
</div>
</template>
@ -188,6 +142,7 @@ onMounted(() => {
flex-direction: column;
flex: 1;
overflow: auto;
.el-table {
flex: 1;
}