From 7bd4a2127bd4faa26ad186491d6be1c2a4129e4c Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 4 Oct 2024 16:40:57 +0800 Subject: [PATCH 1/3] refactor: change login url Signed-off-by: Ryan Wang --- packages/comment-widget/src/base-form.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/comment-widget/src/base-form.ts b/packages/comment-widget/src/base-form.ts index 08a1395..9b26b24 100644 --- a/packages/comment-widget/src/base-form.ts +++ b/packages/comment-widget/src/base-form.ts @@ -71,7 +71,7 @@ export class BaseForm extends LitElement { .join('-') .replaceAll(/-+/g, '-')}`; - return `/console/login?redirect_uri=${encodeURIComponent(window.location.href + parentDomId)}`; + return `/login?redirect_uri=${encodeURIComponent(window.location.href + parentDomId)}`; } get showCaptcha() { From ac8a016ce2debaed814bd9799f5ddd304dccd47a Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 4 Oct 2024 16:41:29 +0800 Subject: [PATCH 2/3] Update requires Signed-off-by: Ryan Wang --- src/main/resources/plugin.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index ea86813..f1c4018 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -8,7 +8,7 @@ metadata: "store.halo.run/app-id": "app-YXyaD" spec: enabled: true - requires: ">=2.17.0" + requires: ">=2.20.0" author: name: Halo website: https://github.com/halo-dev From d4505285bcdbdbb31f9f583fb72e43d0b8438dcf Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 6 Oct 2024 22:11:27 +0800 Subject: [PATCH 3/3] Change logout url --- packages/comment-widget/src/base-form.ts | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/packages/comment-widget/src/base-form.ts b/packages/comment-widget/src/base-form.ts index 9b26b24..c80799d 100644 --- a/packages/comment-widget/src/base-form.ts +++ b/packages/comment-widget/src/base-form.ts @@ -71,7 +71,7 @@ export class BaseForm extends LitElement { .join('-') .replaceAll(/-+/g, '-')}`; - return `/login?redirect_uri=${encodeURIComponent(window.location.href + parentDomId)}`; + return `/login?redirect_uri=${encodeURIComponent(window.location.pathname + parentDomId)}`; } get showCaptcha() { @@ -98,25 +98,9 @@ export class BaseForm extends LitElement { } async handleLogout() { - if (window.confirm('确定要退出登录吗?')) { + if (window.confirm('点击确定将跳转至退出登录页面,请确保正在编辑的内容已保存。')) { try { - const response = await fetch(`${this.baseUrl}/logout`, { - method: 'POST', - headers: { - 'X-Xsrf-Token': - document.cookie - .split('; ') - .find((row) => row.startsWith('XSRF-TOKEN')) - ?.split('=')[1] || '', - }, - credentials: 'same-origin', - }); - - if (!response.ok) { - throw new Error('Failed to logout'); - } - - window.location.reload(); + window.location.href = '/logout'; } catch (error) { console.error('Failed to logout', error); }