refactor(chat): remove redundant auth state management from ChatScreen documentation
refactor(chat): update guest chat quota logic to use isProduction utility fix(user): add TODO for user initialization event on login status change
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
type GuestChatQuotaInput,
|
||||
type GuestChatQuotaData,
|
||||
} from "@/data/schemas/chat/guest_chat_quota";
|
||||
import { isProduction } from "@/utils/app-env";
|
||||
|
||||
export class GuestChatQuota {
|
||||
// 静态常量
|
||||
@@ -13,7 +14,7 @@ export class GuestChatQuota {
|
||||
static readonly maxQuotaPerDayTest = 4;
|
||||
|
||||
static readonly defaultTotalQuota = 50;
|
||||
static readonly defaultTotalQuotaDev = 5;
|
||||
static readonly defaultTotalQuotaTest = 5;
|
||||
static readonly quotaExhausted = 0;
|
||||
|
||||
declare readonly remaining: number;
|
||||
@@ -40,29 +41,22 @@ export class GuestChatQuota {
|
||||
return GuestChatQuota.quotaExhausted;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否处于开发环境
|
||||
*/
|
||||
static get isDevelopment(): boolean {
|
||||
return process.env.NODE_ENV !== "production";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前环境的每日最大配额
|
||||
*/
|
||||
static get threshold(): number {
|
||||
return GuestChatQuota.isDevelopment
|
||||
? GuestChatQuota.maxQuotaPerDayTest
|
||||
: GuestChatQuota.maxQuotaPerDay;
|
||||
return isProduction()
|
||||
? GuestChatQuota.maxQuotaPerDay
|
||||
: GuestChatQuota.maxQuotaPerDayTest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前环境的总配额默认值
|
||||
*/
|
||||
static get totalQuotaDefault(): number {
|
||||
return GuestChatQuota.isDevelopment
|
||||
? GuestChatQuota.defaultTotalQuotaDev
|
||||
: GuestChatQuota.defaultTotalQuota;
|
||||
return isProduction()
|
||||
? GuestChatQuota.defaultTotalQuota
|
||||
: GuestChatQuota.defaultTotalQuotaTest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user