@@ -57,7 +59,6 @@ export const UserCenter = () => {
}
return (
<>
- {contextHolder}
@@ -73,24 +74,35 @@ export const UserCenter = () => {
- }
- onClick={() => modal.confirm({
- maskClosable: true,
- title: '确认登出?',
- cancelText: '保持登录',
- okText: '确认登出',
- okButtonProps: {
- icon: ,
- danger: true,
- },
- onOk: () => signOut(`${window.location.origin}/user-center`),
- })}
- >
- 登出
-
+
+ {isAuthExpired && (
+
+ } onClick={() => autoSignIn()}>
+ 重新登陆
+
+
+ )}
+
+ }
+ onClick={() => app.modal.confirm({
+ maskClosable: true,
+ title: '确认登出?',
+ cancelText: '保持登录',
+ okText: '确认登出',
+ okButtonProps: {
+ icon: ,
+ danger: true,
+ },
+ onOk: () => signOut(USER_CENTER_URL),
+ })}
+ >
+ 登出
+
+
+
>
);
diff --git a/src/services/xcxApi.ts b/src/services/xcxApi.ts
index c3e29a5..399a330 100644
--- a/src/services/xcxApi.ts
+++ b/src/services/xcxApi.ts
@@ -1,8 +1,8 @@
import type { GamesData, XCXFindUserResp, XCXMember, XCXProfile, XCXTag } from "../types";
-import { BASE_URL } from "../utils/common";
+import { KAIQIU_BASE_URL } from "../utils/common";
import { redis } from "../utils/server";
-const XCX_BASE_URL = `${BASE_URL}/xcx/public/index.php`;
+const XCX_BASE_URL = `${KAIQIU_BASE_URL}/xcx/public/index.php`;
export function createXCXHeader(token: string) {
const xcxDefaultHeaders = {
diff --git a/src/utils/common.ts b/src/utils/common.ts
index ef74086..70a2b05 100644
--- a/src/utils/common.ts
+++ b/src/utils/common.ts
@@ -1,6 +1,7 @@
import { chunk } from "lodash";
-export const BASE_URL = `https://kaiqiuwang.cc`;
+export const KAIQIU_BASE_URL = `https://kaiqiuwang.cc`;
+export const LOGTO_DOMAIN = 'https://logto.ksr.la';
export function sneckGroup(size: number, groupLen: number) {
const indexArray = new Array(size).fill(0).map((_, i) => i);
diff --git a/src/utils/front.ts b/src/utils/front.ts
index 5704757..e98d20b 100644
--- a/src/utils/front.ts
+++ b/src/utils/front.ts
@@ -90,4 +90,8 @@ export const openWebMapRaw = (type: MapType, location: MapLocation): void => {
if (url) {
window.open(url, '_blank');
}
-};
\ No newline at end of file
+};
+
+
+export const AUTH_CALLBACK_URL = `${window.location.origin}/auth/callback`;
+export const USER_CENTER_URL = `${window.location.origin}/user-center`;
\ No newline at end of file
diff --git a/src/utils/server.ts b/src/utils/server.ts
index bf85d50..4d1d4e0 100644
--- a/src/utils/server.ts
+++ b/src/utils/server.ts
@@ -1,7 +1,7 @@
import type { Player } from "../types";
import * as cheerio from "cheerio";
import { XCXAPI } from "../services/xcxApi";
-import { BASE_URL } from "./common";
+import { KAIQIU_BASE_URL, LOGTO_DOMAIN } from "./common";
import { RedisClient } from "bun";
import { createRemoteJWKSet, jwtVerify } from 'jose';
import { LOGTO_RESOURCE } from "./constants";
@@ -48,7 +48,7 @@ export const htmlRequestHeaders = {
* @returns HTML
*/
export async function fetchEventContentHTML(matchId: string) {
- const url = `${BASE_URL}/home/space.php?do=event&id=${matchId}&view=member&status=2`;
+ const url = `${KAIQIU_BASE_URL}/home/space.php?do=event&id=${matchId}&view=member&status=2`;
const resp = await fetch(url, { headers: htmlRequestHeaders });
return resp.text() ?? ''
}
@@ -97,7 +97,7 @@ export const extractBearerTokenFromHeaders = (authorization: string | null) => {
return authorization.slice(7); // The length of 'Bearer ' is 7
};
-const jwks = createRemoteJWKSet(new URL('https://logto.ksr.la/oidc/jwks'));
+const jwks = createRemoteJWKSet(new URL(`${LOGTO_DOMAIN}/oidc/jwks`));
export const verifyLogtoToken = async (headers: Headers) => {
const auth = headers.get('Authorization');
@@ -110,7 +110,7 @@ export const verifyLogtoToken = async (headers: Headers) => {
jwks,
{
// Expected issuer of the token, issued by the Logto server
- issuer: 'https://logto.ksr.la/oidc',
+ issuer: `${LOGTO_DOMAIN}/oidc`,
// Expected audience token, the resource indicator of the current API
audience: LOGTO_RESOURCE,
}