VIP失效时间格式化逻辑修改
This commit is contained in:
@@ -359,19 +359,21 @@ export default class Utils {
|
|||||||
|
|
||||||
// 获取格式化字符串: vip失效时间
|
// 获取格式化字符串: vip失效时间
|
||||||
public static formatVipLeftTime(expiryTimestamp: number): string {
|
public static formatVipLeftTime(expiryTimestamp: number): string {
|
||||||
const dateNow = new Date();
|
// 当前时间戳,单位:秒
|
||||||
const timeDiff = Math.abs(expiryTimestamp - dateNow.getTime());
|
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||||
const hours = Math.floor(timeDiff / (1000 * 60 * 60));
|
// 差值(秒)
|
||||||
|
const diffSeconds = Math.max(0, expiryTimestamp - nowSeconds);
|
||||||
if (hours >= 24) {
|
// 转换为天、小时、分钟
|
||||||
return (
|
const days = Math.floor(diffSeconds / (60 * 60 * 24));
|
||||||
(hours % 24).toString() + LanguageUtils.getText("purchasepanel.day")
|
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);
|
if (hours > 0) {
|
||||||
//const seconds = Math.floor((timeDiff / 1000) % 60);
|
return `${hours}${LanguageUtils.getText("purchasepanel.hour")}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
|
||||||
return `${hours}${LanguageUtils.getText(
|
}
|
||||||
"purchasepanel.hour"
|
return `${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
|
||||||
)}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
|||||||
export class WalletData extends BaseData {
|
export class WalletData extends BaseData {
|
||||||
// 余额
|
// 余额
|
||||||
private _balance: number = 0;
|
private _balance: number = 0;
|
||||||
// vip失效时间戳
|
// vip失效时间戳,秒
|
||||||
private _vipExpire: number = 0;
|
private _vipExpire: number = 0;
|
||||||
|
|
||||||
public reset(): void {
|
public reset(): void {
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ export class ChatHistoryManager {
|
|||||||
const message: ChatMessage = {
|
const message: ChatMessage = {
|
||||||
role: serverMsg.isAi ? "model" : "user",
|
role: serverMsg.isAi ? "model" : "user",
|
||||||
parts: [{ text: serverMsg.msg }],
|
parts: [{ text: serverMsg.msg }],
|
||||||
timestamp: serverMsg.msgId || Date.now(),
|
timestamp: Number(serverMsg.msgId) || Date.now(),
|
||||||
};
|
};
|
||||||
messages.push(message);
|
messages.push(message);
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ export class ChatHistoryManager {
|
|||||||
const msg = girlData.getChatRecordMsg(category.toString(), roleId, id);
|
const msg = girlData.getChatRecordMsg(category.toString(), roleId, id);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
serverMessages.push({
|
serverMessages.push({
|
||||||
msgId: id,
|
msgId: id.toString(),
|
||||||
msg: msg,
|
msg: msg,
|
||||||
isAi: isAi,
|
isAi: isAi,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user