feat(@vben/web-antd): 优化爬虫功能

This commit is contained in:
Kven 2025-05-13 17:24:20 +08:00
parent 71cd4b7363
commit d860741384
2 changed files with 14 additions and 16 deletions

View File

@ -1,7 +1,7 @@
VITE_BASE=/ VITE_BASE=/
# 接口地址 # 接口地址
VITE_GLOB_API_URL=https://mock-napi.vben.pro/api VITE_GLOB_API_URL=http://dify.vertoryao.xyz/api
# 是否开启压缩,可以设置为 none, brotli, gzip # 是否开启压缩,可以设置为 none, brotli, gzip
VITE_COMPRESS=none VITE_COMPRESS=none

View File

@ -111,25 +111,20 @@ const startFetching = async () => {
// //
const downloadFile = () => { const downloadFile = () => {
if (!fetchResult.value) return; if (!fetchResult.value || !fetchResult.value.startsWith('http')) {
message.error('无效的文件链接');
return;
}
// 使 const fileUrl = fetchResult.value;
const fileName = `${props.item.name}.txt`; const fileName = decodeURIComponent(
const fileContent = fetchResult.value; fileUrl.slice(Math.max(0, fileUrl.lastIndexOf('/') + 1)),
);
// Blob
const blob = new Blob([fileContent], { type: 'text/plain' });
//
const link = document.createElement('a'); const link = document.createElement('a');
link.href = URL.createObjectURL(blob); link.href = fileUrl;
link.download = fileName; link.download = fileName;
//
link.click(); link.click();
// URL
URL.revokeObjectURL(link.href);
}; };
const isFetching = ref(false); const isFetching = ref(false);
@ -152,7 +147,10 @@ const fetchStatus = ref('');
v-model:value="selectedDateRange" v-model:value="selectedDateRange"
format="YYYY/MM/DD" format="YYYY/MM/DD"
/> />
<Button :disabled="!item" @click="startFetching"> <Button
:disabled="!item || selectedDateRange.length < 2"
@click="startFetching"
>
{{ isFetching ? '抓取中...' : '开始抓取' }} {{ isFetching ? '抓取中...' : '开始抓取' }}
</Button> </Button>
<Button <Button