From 60c5a986edd4add11b229b2d3c869dcdf32c0428 Mon Sep 17 00:00:00 2001 From: xion Date: Sun, 30 Mar 2025 12:48:14 +0800 Subject: [PATCH] add week --- src/models/user.ts | 2 +- src/oauth/oauth.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/models/user.ts b/src/models/user.ts index 9425c13..4a16904 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -47,7 +47,7 @@ export class User extends Model { * @param uid * @returns */ - async createToken(uid?: string, loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year', expand: any = {}) { + async createToken(uid?: string, loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week', expand: any = {}) { const { id, username, type } = this; const oauthUser: OauthUser = { id, diff --git a/src/oauth/oauth.ts b/src/oauth/oauth.ts index 5a8af5b..c3e05d5 100644 --- a/src/oauth/oauth.ts +++ b/src/oauth/oauth.ts @@ -58,7 +58,7 @@ export type UserExpand = { } & StoreSetOpts; type StoreSetOpts = { - loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year'; // 登陆类型 'default' | 'plugin' | 'month' | 'season' | 'year' + loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year' | 'week'; // 登陆类型 'default' | 'plugin' | 'month' | 'season' | 'year' expire?: number; // 过期时间,单位为秒 hasRefreshToken?: boolean; [key: string]: any; @@ -137,6 +137,9 @@ export class RedisTokenStore implements Store { let expire = opts?.expire; if (!expire) { switch (opts.loginType) { + case 'week': + expire = 7 * 24 * 60 * 60; + break; case 'month': expire = 30 * 24 * 60 * 60; break;