From 8ff79b3aee29c15ad479d0c996ec3215479cd553 Mon Sep 17 00:00:00 2001 From: niltor Date: Wed, 29 May 2024 11:29:15 +0800 Subject: [PATCH] =?UTF-8?q?#6=20=E5=88=86=E7=B1=BB=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=9C=A8=E4=BA=8C=E7=BA=A7=E7=9B=AE=E5=BD=95=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebApp/js/index.js | 3 ++- WebApp/ts/index.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WebApp/js/index.js b/WebApp/js/index.js index 4117618..716ac69 100644 --- a/WebApp/js/index.js +++ b/WebApp/js/index.js @@ -92,6 +92,7 @@ class Index { renderBlogs() { let blogList = document.getElementById('blogList'); if (blogList) { + const pathName = window.location.pathname; blogList.innerHTML = ''; this.blogs.forEach(blog => { let blogDiv = document.createElement('div'); @@ -101,7 +102,7 @@ class Index { let blogTitleDiv = document.createElement('div'); blogTitleDiv.className = 'font-bold text-xl mb-2'; let blogLink = document.createElement('a'); - blogLink.href = './blogs' + blog.Path; + blogLink.href = pathName + 'blogs' + blog.Path; blogLink.target = '_blank'; blogLink.className = 'block text-lg py-2 text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100'; blogLink.innerText = "📑 " + blog.Title; diff --git a/WebApp/ts/index.ts b/WebApp/ts/index.ts index f1e5c87..3a67a17 100644 --- a/WebApp/ts/index.ts +++ b/WebApp/ts/index.ts @@ -26,7 +26,7 @@ class Index { document.addEventListener('DOMContentLoaded', () => this.init()); } - init(){ + init() { this.getData(); this.addEvent(); } @@ -119,8 +119,8 @@ class Index { renderBlogs(): void { let blogList = document.getElementById('blogList'); - if (blogList) { + const pathName = window.location.pathname; blogList.innerHTML = ''; this.blogs.forEach(blog => { let blogDiv = document.createElement('div'); @@ -130,7 +130,7 @@ class Index { let blogTitleDiv = document.createElement('div'); blogTitleDiv.className = 'font-bold text-xl mb-2'; let blogLink = document.createElement('a'); - blogLink.href = './blogs' + blog.Path; + blogLink.href = pathName + 'blogs' + blog.Path; blogLink.target = '_blank'; blogLink.className = 'block text-lg py-2 text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100'; blogLink.innerText = "📑 " + blog.Title;