diff --git a/src/app/(main)/character/[id]/page.tsx b/src/app/(main)/character/[id]/page.tsx index 1b3dc2d..e25c2c9 100644 --- a/src/app/(main)/character/[id]/page.tsx +++ b/src/app/(main)/character/[id]/page.tsx @@ -19,7 +19,7 @@ export default async function Page({ params }: { params: Promise<{ id: string }> {/* 内容区 */} -
+
diff --git a/src/hooks/auth.ts b/src/hooks/auth.ts index 0b96f55..fc6d897 100644 --- a/src/hooks/auth.ts +++ b/src/hooks/auth.ts @@ -129,34 +129,34 @@ export function useDeleteUser() { } // 注册功能暂未实现,保留接口定义 -export function useRegister() { - const queryClient = useQueryClient(); +// export function useRegister() { +// const queryClient = useQueryClient(); - return useMutation({ - mutationFn: (data: any) => { - // TODO: 实现注册接口 - throw new Error('注册功能暂未实现'); - }, - onSuccess: (response: LoginResponse) => { - // 注册成功后自动登录 - tokenManager.setToken(response.token); - toast.success('Successful registration!'); - queryClient.invalidateQueries({ - queryKey: authKeys.currentUser(), - }); - }, - onError: (error: ApiError) => { - console.error('注册失败:', { - errorCode: error.errorCode, - errorMsg: error.errorMsg, - traceId: error.traceId, - }); - toast.error('Registration failed.', { - description: error.errorMsg || '请稍后重试', - }); - }, - }); -} +// return useMutation({ +// mutationFn: (data: any) => { +// // TODO: 实现注册接口 +// throw new Error('注册功能暂未实现'); +// }, +// onSuccess: (response: LoginResponse) => { +// // 注册成功后自动登录 +// tokenManager.setToken(response.token); +// toast.success('Successful registration!'); +// queryClient.invalidateQueries({ +// queryKey: authKeys.currentUser(), +// }); +// }, +// onError: (error: ApiError) => { +// console.error('注册失败:', { +// errorCode: error.errorCode, +// errorMsg: error.errorMsg, +// traceId: error.traceId, +// }); +// toast.error('Registration failed.', { +// description: error.errorMsg || '请稍后重试', +// }); +// }, +// }); +// } // 检查是否已登录的hook export function useIsAuthenticated() { diff --git a/src/lib/auth/token.ts b/src/lib/auth/token.ts index a660777..e37ce2f 100644 --- a/src/lib/auth/token.ts +++ b/src/lib/auth/token.ts @@ -10,8 +10,8 @@ function generateDeviceId(): string { const browserInfo = typeof window !== 'undefined' ? `${window.navigator.userAgent}${window.screen.width}${window.screen.height}` - .replace(/\s/g, '') - .substring(0, 10) + .replace(/\s/g, '') + .substring(0, 10) : 'server'; return `did_${timestamp}_${randomStr}_${browserInfo}`.toLowerCase(); @@ -82,10 +82,9 @@ export const tokenManager = { // 设置token setToken: (token: string): void => { if (typeof window !== 'undefined') { - // 设置cookie,30天过期 Cookies.set(TOKEN_COOKIE_NAME, token, { - expires: 30, - secure: process.env.NODE_ENV === 'production', + expires: 365, + secure: false, sameSite: 'lax', }); } @@ -97,7 +96,7 @@ export const tokenManager = { // 设置cookie,365天过期(设备ID应该长期保存) Cookies.set(DEVICE_ID_COOKIE_NAME, deviceId, { expires: 365, - secure: process.env.NODE_ENV === 'production', + secure: false, sameSite: 'lax', }); }