feat(@vben/web-antd): 优化爬虫功能
This commit is contained in:
parent
71cd4b7363
commit
d860741384
@ -1,7 +1,7 @@
|
||||
VITE_BASE=/
|
||||
|
||||
# 接口地址
|
||||
VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
|
||||
VITE_GLOB_API_URL=http://dify.vertoryao.xyz/api
|
||||
|
||||
# 是否开启压缩,可以设置为 none, brotli, gzip
|
||||
VITE_COMPRESS=none
|
||||
|
@ -111,25 +111,20 @@ const startFetching = async () => {
|
||||
|
||||
// 下载文件逻辑
|
||||
const downloadFile = () => {
|
||||
if (!fetchResult.value) return;
|
||||
if (!fetchResult.value || !fetchResult.value.startsWith('http')) {
|
||||
message.error('无效的文件链接');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用抓取结果作为文件内容
|
||||
const fileName = `${props.item.name}.txt`;
|
||||
const fileContent = fetchResult.value;
|
||||
const fileUrl = fetchResult.value;
|
||||
const fileName = decodeURIComponent(
|
||||
fileUrl.slice(Math.max(0, fileUrl.lastIndexOf('/') + 1)),
|
||||
);
|
||||
|
||||
// 创建 Blob 对象
|
||||
const blob = new Blob([fileContent], { type: 'text/plain' });
|
||||
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob);
|
||||
link.href = fileUrl;
|
||||
link.download = fileName;
|
||||
|
||||
// 触发下载
|
||||
link.click();
|
||||
|
||||
// 释放 URL 对象
|
||||
URL.revokeObjectURL(link.href);
|
||||
};
|
||||
|
||||
const isFetching = ref(false);
|
||||
@ -152,7 +147,10 @@ const fetchStatus = ref('');
|
||||
v-model:value="selectedDateRange"
|
||||
format="YYYY/MM/DD"
|
||||
/>
|
||||
<Button :disabled="!item" @click="startFetching">
|
||||
<Button
|
||||
:disabled="!item || selectedDateRange.length < 2"
|
||||
@click="startFetching"
|
||||
>
|
||||
{{ isFetching ? '抓取中...' : '开始抓取' }}
|
||||
</Button>
|
||||
<Button
|
||||
|
Loading…
Reference in New Issue
Block a user