diff --git a/components/ArticleItem.vue b/components/ArticleItem.vue index 181f1fe..c41bd63 100644 --- a/components/ArticleItem.vue +++ b/components/ArticleItem.vue @@ -85,7 +85,7 @@ async function download(link: string, title: string) { const zip = await packHTMLAssets(fullHTML, title) const blob = await zip.generateAsync({type: 'blob'}) - saveAs(blob, title) + saveAs(blob, title + '.zip') await uploadProxy() } catch (e: any) { diff --git a/utils/index.ts b/utils/index.ts index 91dbf60..e14c997 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -119,6 +119,7 @@ export async function downloadArticleHTMLs(articles: DownloadableArticle[], call return results } + /** * 打包 html 中的资源 * @param html @@ -145,6 +146,29 @@ export async function packHTMLAssets(html: string, title: string, zip?: JSZip) { el.remove() }) + // 渲染ip属地 + function getIpWoridng(ipConfig: any) { + let ipWording = ''; + if (parseInt(ipConfig.countryId, 10) === 156) { + ipWording = ipConfig.provinceName; + } else if (ipConfig.countryId) { + ipWording = ipConfig.countryName; + } + return ipWording; + } + const ipWrp = document.getElementById('js_ip_wording_wrp')! + const ipWording = document.getElementById('js_ip_wording')! + const ipWordingMatchResult = html.match(/window\.ip_wording = (?{\s+countryName: '[^']+',[^}]+})/s) + if (ipWordingMatchResult && ipWordingMatchResult.groups && ipWordingMatchResult.groups.data) { + const json = ipWordingMatchResult.groups.data + eval('window.ip_wording = ' + json) + const ipWordingDisplay = getIpWoridng((window as any).ip_wording) + if (ipWordingDisplay !== '') { + ipWording.innerHTML = ipWordingDisplay; + ipWrp.style.display = 'inline-block'; + } + } + zip.folder('assets')