Compare commits
No commits in common. "b4a3a5b72e6e7603182a5e9a44d023ae3833e5e1" and "24c27d5efbe43bb00a9bc6004267e091598ea282" have entirely different histories.
b4a3a5b72e
...
24c27d5efb
@ -25,17 +25,13 @@
|
|||||||
class="result-item"
|
class="result-item"
|
||||||
>
|
>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p class="result-title subtitle">{{ item.title }}</p>
|
<a :href="item.url" class="result-title subtitle">{{ item.title }}</a>
|
||||||
<p class="result-description content-text">{{ item.description }}</p>
|
<p class="result-description content-text">{{ item.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pdf-icon">
|
||||||
<div
|
<a :href="item.url" target="_blank">
|
||||||
class="pdf-icon"
|
|
||||||
@click="downloadPdf(item.url)"
|
|
||||||
style="color: #2979ff; cursor: pointer"
|
|
||||||
>
|
|
||||||
<img src="@/assets/image/pdf.png" alt="PDF" />
|
<img src="@/assets/image/pdf.png" alt="PDF" />
|
||||||
{{ t("financialinformation.quarterlyresults.download") }}
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -345,31 +341,6 @@ const handleSearch = () => {
|
|||||||
// 搜索处理逻辑
|
// 搜索处理逻辑
|
||||||
console.log("搜索:", searchQuery.value);
|
console.log("搜索:", searchQuery.value);
|
||||||
};
|
};
|
||||||
const downloadPdf = async (pdfResource, filename = "") => {
|
|
||||||
try {
|
|
||||||
// 获取PDF文件
|
|
||||||
const response = await fetch(pdfResource);
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
// 创建Blob URL
|
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// 创建下载链接
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.href = blobUrl;
|
|
||||||
a.download = filename || pdfResource.split("/").pop() || "download.pdf";
|
|
||||||
|
|
||||||
// 触发下载
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
|
|
||||||
// 释放Blob URL
|
|
||||||
URL.revokeObjectURL(blobUrl);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("下载PDF文件失败:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.title {
|
.title {
|
||||||
@ -416,7 +387,7 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
.result-item {
|
.result-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
@ -430,6 +401,10 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-description {
|
.result-description {
|
||||||
|
@ -25,16 +25,13 @@
|
|||||||
class="result-item"
|
class="result-item"
|
||||||
>
|
>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p class="result-title subtitle">{{ item.title }}</p>
|
<a :href="item.url" class="result-title subtitle">{{ item.title }}</a>
|
||||||
<p class="result-description content-text">{{ item.description }}</p>
|
<p class="result-description content-text">{{ item.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="pdf-icon">
|
||||||
class="pdf-icon"
|
<a :href="item.url" target="_blank">
|
||||||
@click="downloadPdf(item.url)"
|
|
||||||
style="color: #2979ff; cursor: pointer"
|
|
||||||
>
|
|
||||||
<img src="@/assets/image/pdf.png" alt="PDF" />
|
<img src="@/assets/image/pdf.png" alt="PDF" />
|
||||||
{{ t("financialinformation.quarterlyresults.download") }}
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -344,32 +341,6 @@ const handleSearch = () => {
|
|||||||
// 搜索处理逻辑
|
// 搜索处理逻辑
|
||||||
console.log("搜索:", searchQuery.value);
|
console.log("搜索:", searchQuery.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadPdf = async (pdfResource, filename = "") => {
|
|
||||||
try {
|
|
||||||
// 获取PDF文件
|
|
||||||
const response = await fetch(pdfResource);
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
// 创建Blob URL
|
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// 创建下载链接
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.href = blobUrl;
|
|
||||||
a.download = filename || pdfResource.split("/").pop() || "download.pdf";
|
|
||||||
|
|
||||||
// 触发下载
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
|
|
||||||
// 释放Blob URL
|
|
||||||
URL.revokeObjectURL(blobUrl);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("下载PDF文件失败:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.title {
|
.title {
|
||||||
@ -416,7 +387,7 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
.result-item {
|
.result-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: flex-start;
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
@ -430,6 +401,10 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-description {
|
.result-description {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<img
|
<img
|
||||||
src="@/assets/image/download.svg"
|
src="@/assets/image/download.svg"
|
||||||
style="width: 20px; height: 20px"
|
style="width: 20px; height: 20px"
|
||||||
@click="downloadPdf(item.url)"
|
@click="handleDownload(item.url)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -345,29 +345,55 @@ const handleSearch = () => {
|
|||||||
console.log("搜索:", searchQuery.value);
|
console.log("搜索:", searchQuery.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadPdf = async (pdfResource, filename = "") => {
|
const handleDownload = (url) => {
|
||||||
try {
|
// 下载处理逻辑
|
||||||
// 获取PDF文件
|
console.log("下载:", url);
|
||||||
const response = await fetch(pdfResource);
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
// 创建Blob URL
|
// 创建一个隐藏的a元素
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
|
||||||
// 创建下载链接
|
// 修复文件名提取逻辑
|
||||||
const a = document.createElement("a");
|
let fileName = url.split("/").pop();
|
||||||
a.href = blobUrl;
|
// 移除可能存在的查询参数
|
||||||
a.download = filename || pdfResource.split("/").pop() || "download.pdf";
|
if (fileName.includes("?") || fileName.includes("_t=")) {
|
||||||
|
fileName = fileName.split(/[?_]/)[0];
|
||||||
|
}
|
||||||
|
link.download = fileName;
|
||||||
|
link.target = "_blank";
|
||||||
|
|
||||||
// 触发下载
|
// 对于移动设备,我们需要特殊处理
|
||||||
document.body.appendChild(a);
|
const isMobile =
|
||||||
a.click();
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||||
document.body.removeChild(a);
|
navigator.userAgent
|
||||||
|
);
|
||||||
|
|
||||||
// 释放Blob URL
|
if (isMobile) {
|
||||||
URL.revokeObjectURL(blobUrl);
|
// 在移动设备上,可能需要使用fetch下载文件并创建blob
|
||||||
} catch (error) {
|
fetch(url)
|
||||||
console.error("下载PDF文件失败:", error);
|
.then((response) => response.blob())
|
||||||
|
.then((blob) => {
|
||||||
|
const objectUrl = URL.createObjectURL(blob);
|
||||||
|
link.href = objectUrl;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
// 清理
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(objectUrl);
|
||||||
|
}, 100);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("下载文件时出错:", error);
|
||||||
|
// 如果fetch失败,回退到window.open
|
||||||
|
window.open(url, "_blank");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 桌面设备上直接点击链接
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -449,6 +475,10 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
font-size: 92px;
|
font-size: 92px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-description {
|
.result-description {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<img
|
<img
|
||||||
src="@/assets/image/download.svg"
|
src="@/assets/image/download.svg"
|
||||||
style="width: 20px; height: 20px"
|
style="width: 20px; height: 20px"
|
||||||
@click="downloadPdf(item.url)"
|
@click="handleDownload(item.url)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -345,29 +345,55 @@ const handleSearch = () => {
|
|||||||
console.log("搜索:", searchQuery.value);
|
console.log("搜索:", searchQuery.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadPdf = async (pdfResource, filename = "") => {
|
const handleDownload = (url) => {
|
||||||
try {
|
// 下载处理逻辑
|
||||||
// 获取PDF文件
|
console.log("下载:", url);
|
||||||
const response = await fetch(pdfResource);
|
|
||||||
const blob = await response.blob();
|
|
||||||
|
|
||||||
// 创建Blob URL
|
// 创建一个隐藏的a元素
|
||||||
const blobUrl = URL.createObjectURL(blob);
|
const link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
|
||||||
// 创建下载链接
|
// 修复文件名提取逻辑
|
||||||
const a = document.createElement("a");
|
let fileName = url.split("/").pop();
|
||||||
a.href = blobUrl;
|
// 移除可能存在的查询参数
|
||||||
a.download = filename || pdfResource.split("/").pop() || "download.pdf";
|
if (fileName.includes("?") || fileName.includes("_t=")) {
|
||||||
|
fileName = fileName.split(/[?_]/)[0];
|
||||||
|
}
|
||||||
|
link.download = fileName;
|
||||||
|
link.target = "_blank";
|
||||||
|
|
||||||
// 触发下载
|
// 对于移动设备,我们需要特殊处理
|
||||||
document.body.appendChild(a);
|
const isMobile =
|
||||||
a.click();
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||||
document.body.removeChild(a);
|
navigator.userAgent
|
||||||
|
);
|
||||||
|
|
||||||
// 释放Blob URL
|
if (isMobile) {
|
||||||
URL.revokeObjectURL(blobUrl);
|
// 在移动设备上,可能需要使用fetch下载文件并创建blob
|
||||||
} catch (error) {
|
fetch(url)
|
||||||
console.error("下载PDF文件失败:", error);
|
.then((response) => response.blob())
|
||||||
|
.then((blob) => {
|
||||||
|
const objectUrl = URL.createObjectURL(blob);
|
||||||
|
link.href = objectUrl;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
// 清理
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(objectUrl);
|
||||||
|
}, 100);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("下载文件时出错:", error);
|
||||||
|
// 如果fetch失败,回退到window.open
|
||||||
|
window.open(url, "_blank");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 桌面设备上直接点击链接
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -449,6 +475,10 @@ const downloadPdf = async (pdfResource, filename = "") => {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-description {
|
.result-description {
|
||||||
|
Loading…
Reference in New Issue
Block a user