VIP失效时间格式化逻辑修改

This commit is contained in:
chen wei bo
2025-09-18 09:38:17 +08:00
parent c36ff6dc76
commit 1fa5eb7cb0
3 changed files with 18 additions and 16 deletions
+15 -13
View File
@@ -359,19 +359,21 @@ export default class Utils {
// 获取格式化字符串: vip失效时间
public static formatVipLeftTime(expiryTimestamp: number): string {
const dateNow = new Date();
const timeDiff = Math.abs(expiryTimestamp - dateNow.getTime());
const hours = Math.floor(timeDiff / (1000 * 60 * 60));
if (hours >= 24) {
return (
(hours % 24).toString() + LanguageUtils.getText("purchasepanel.day")
);
// 当前时间戳,单位:秒
const nowSeconds = Math.floor(Date.now() / 1000);
// 差值(秒)
const diffSeconds = Math.max(0, expiryTimestamp - nowSeconds);
// 转换为天、小时、分钟
const days = Math.floor(diffSeconds / (60 * 60 * 24));
const hours = Math.floor((diffSeconds % (60 * 60 * 24)) / 3600);
const minutes = Math.floor((diffSeconds % 3600) / 60);
console.log("vip失效剩余时间差(秒):", diffSeconds, "天:", days, "小时:", hours, "分钟:", minutes);
if (days > 0) {
return `${days}${LanguageUtils.getText("purchasepanel.day")}`;
}
const minutes = Math.floor((timeDiff / (1000 * 60)) % 60);
//const seconds = Math.floor((timeDiff / 1000) % 60);
return `${hours}${LanguageUtils.getText(
"purchasepanel.hour"
)}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
if (hours > 0) {
return `${hours}${LanguageUtils.getText("purchasepanel.hour")}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
}
return `${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
export class WalletData extends BaseData {
// 余额
private _balance: number = 0;
// vip失效时间戳
// vip失效时间戳,秒
private _vipExpire: number = 0;
public reset(): void {
@@ -242,7 +242,7 @@ export class ChatHistoryManager {
const message: ChatMessage = {
role: serverMsg.isAi ? "model" : "user",
parts: [{ text: serverMsg.msg }],
timestamp: serverMsg.msgId || Date.now(),
timestamp: Number(serverMsg.msgId) || Date.now(),
};
messages.push(message);
}
@@ -396,7 +396,7 @@ export class ChatHistoryManager {
const msg = girlData.getChatRecordMsg(category.toString(), roleId, id);
if (msg) {
serverMessages.push({
msgId: id,
msgId: id.toString(),
msg: msg,
isAi: isAi,
});