修改 未解锁也能进入详情页,详情页增加购买弹窗
This commit is contained in:
@@ -378,6 +378,7 @@ export default class Utils {
|
||||
const nowSeconds = Math.floor(Date.now() / 1000);
|
||||
// 差值(秒)
|
||||
const diffSeconds = Math.max(0, expiryTimestamp - nowSeconds);
|
||||
if (diffSeconds == 0) return null;
|
||||
// 转换为天、小时、分钟
|
||||
const days = Math.floor(diffSeconds / (60 * 60 * 24));
|
||||
const hours = Math.floor((diffSeconds % (60 * 60 * 24)) / 3600);
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
import { ChatAIService } from '../core/ChatAIService';
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
/**
|
||||
* ChatAI 批量测试运行器 - 纯脚本版本
|
||||
*
|
||||
* 用法:
|
||||
* ```typescript
|
||||
* const testRunner = new ChatAIBatchTestRunner();
|
||||
* testRunner.runBatchTest();
|
||||
* ```
|
||||
*/
|
||||
export class ChatAIBatchTestRunner {
|
||||
|
||||
private isRunning: boolean = false;
|
||||
|
||||
constructor() {
|
||||
logger.log("[ChatAIBatchTestRunner] 测试运行器已初始化");
|
||||
}
|
||||
|
||||
/**
|
||||
* 延时工具函数
|
||||
* @param seconds 延时秒数
|
||||
*/
|
||||
private async delay(seconds: number): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, seconds * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行批量测试
|
||||
*/
|
||||
public async runBatchTest(): Promise<void> {
|
||||
if (this.isRunning) {
|
||||
logger.log("[ChatAIBatchTestRunner] 测试已在运行中,请等待完成...");
|
||||
return;
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
logger.log("[ChatAIBatchTestRunner] 开始批量测试角色ID 10001-10030");
|
||||
logger.log("[ChatAIBatchTestRunner] 每次测试间隔10秒");
|
||||
|
||||
const startTime = Date.now();
|
||||
const successIds: number[] = [];
|
||||
const failureIds: number[] = [];
|
||||
const errorDetails: { [roleId: number]: string } = {};
|
||||
|
||||
// 测试角色ID 10001-10030
|
||||
for (let roleId = 10001; roleId <= 10030; roleId++) {
|
||||
logger.log(`[ChatAIBatchTestRunner] 正在测试角色ID: ${roleId}`);
|
||||
|
||||
const testStartTime = Date.now();
|
||||
|
||||
try {
|
||||
const response = await ChatAIService.Instance.sendMessage(roleId, "hello");
|
||||
const testDuration = Date.now() - testStartTime;
|
||||
|
||||
if (response && response.trim() !== "") {
|
||||
successIds.push(roleId);
|
||||
logger.log(`[ChatAIBatchTestRunner] ✅ 角色 ${roleId} 测试成功 (${testDuration}ms)`);
|
||||
logger.log(`[ChatAIBatchTestRunner] 响应预览: ${response.substring(0, 50)}...`);
|
||||
} else {
|
||||
failureIds.push(roleId);
|
||||
errorDetails[roleId] = "返回空响应";
|
||||
logger.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 返回空响应 (${testDuration}ms)`);
|
||||
}
|
||||
} catch (error) {
|
||||
const testDuration = Date.now() - testStartTime;
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
|
||||
failureIds.push(roleId);
|
||||
errorDetails[roleId] = errorMessage;
|
||||
logger.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 测试失败 (${testDuration}ms): ${errorMessage}`);
|
||||
}
|
||||
|
||||
// 等待10秒(最后一个不需要等待)
|
||||
if (roleId < 10030) {
|
||||
logger.log(`[ChatAIBatchTestRunner] 等待10秒后继续下一个测试...`);
|
||||
await this.delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
const totalDuration = Date.now() - startTime;
|
||||
|
||||
// 输出最终报告
|
||||
this.printFinalReport(successIds, failureIds, errorDetails, totalDuration);
|
||||
|
||||
this.isRunning = false;
|
||||
logger.log("[ChatAIBatchTestRunner] 批量测试完成!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出最终测试报告
|
||||
*/
|
||||
private printFinalReport(
|
||||
successIds: number[],
|
||||
failureIds: number[],
|
||||
errorDetails: { [roleId: number]: string },
|
||||
totalDuration: number
|
||||
): void {
|
||||
const totalTests = 30;
|
||||
const successCount = successIds.length;
|
||||
const failureCount = failureIds.length;
|
||||
const successRate = ((successCount / totalTests) * 100).toFixed(2);
|
||||
|
||||
logger.log("\n" + "=".repeat(60));
|
||||
logger.log(" ChatAI 批量测试报告");
|
||||
logger.log("=".repeat(60));
|
||||
logger.log(`测试时间: ${new Date().toLocaleString()}`);
|
||||
logger.log(`总测试数: ${totalTests}`);
|
||||
logger.log(`成功数量: ${successCount}`);
|
||||
logger.log(`失败数量: ${failureCount}`);
|
||||
logger.log(`成功率: ${successRate}%`);
|
||||
logger.log(`总耗时: ${(totalDuration / 1000).toFixed(2)}秒`);
|
||||
logger.log(`平均耗时: ${(totalDuration / totalTests / 1000).toFixed(2)}秒/测试`);
|
||||
|
||||
logger.log("\n" + "-".repeat(30) + " 成功的角色ID " + "-".repeat(30));
|
||||
if (successIds.length > 0) {
|
||||
const successList = this.formatIdList(successIds);
|
||||
logger.log(successList);
|
||||
} else {
|
||||
logger.log("无成功案例");
|
||||
}
|
||||
|
||||
logger.log("\n" + "-".repeat(30) + " 失败的角色ID " + "-".repeat(30));
|
||||
if (failureIds.length > 0) {
|
||||
const failureList = this.formatIdList(failureIds);
|
||||
logger.log(failureList);
|
||||
|
||||
logger.log("\n" + "-".repeat(25) + " 失败详情 " + "-".repeat(25));
|
||||
failureIds.forEach(roleId => {
|
||||
logger.log(`角色 ${roleId}: ${errorDetails[roleId]}`);
|
||||
});
|
||||
} else {
|
||||
logger.log("无失败案例");
|
||||
}
|
||||
|
||||
logger.log("\n" + "=".repeat(60));
|
||||
|
||||
// 输出简洁版结果供复制使用
|
||||
logger.log("\n简洁结果:");
|
||||
logger.log(`成功(${successCount}): ${successIds.join(',')}`);
|
||||
logger.log(`失败(${failureCount}): ${failureIds.join(',')}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化ID列表为易读格式
|
||||
*/
|
||||
private formatIdList(ids: number[]): string {
|
||||
if (ids.length === 0) return "无";
|
||||
|
||||
const sortedIds = ids.sort((a, b) => a - b);
|
||||
const groups: string[] = [];
|
||||
let start = sortedIds[0];
|
||||
let end = sortedIds[0];
|
||||
|
||||
for (let i = 1; i < sortedIds.length; i++) {
|
||||
if (sortedIds[i] === end + 1) {
|
||||
end = sortedIds[i];
|
||||
} else {
|
||||
if (start === end) {
|
||||
groups.push(`${start}`);
|
||||
} else if (end === start + 1) {
|
||||
groups.push(`${start},${end}`);
|
||||
} else {
|
||||
groups.push(`${start}-${end}`);
|
||||
}
|
||||
start = end = sortedIds[i];
|
||||
}
|
||||
}
|
||||
|
||||
// 添加最后一组
|
||||
if (start === end) {
|
||||
groups.push(`${start}`);
|
||||
} else if (end === start + 1) {
|
||||
groups.push(`${start},${end}`);
|
||||
} else {
|
||||
groups.push(`${start}-${end}`);
|
||||
}
|
||||
|
||||
return groups.join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前运行状态
|
||||
*/
|
||||
public isTestRunning(): boolean {
|
||||
return this.isRunning;
|
||||
}
|
||||
}
|
||||
|
||||
// 全局实例,可以直接调用
|
||||
export const chatAIBatchTester = new ChatAIBatchTestRunner();
|
||||
|
||||
// 便捷的全局函数
|
||||
export async function runChatAIBatchTest(): Promise<void> {
|
||||
await chatAIBatchTester.runBatchTest();
|
||||
}
|
||||
|
||||
// 使用示例:
|
||||
// import { runChatAIBatchTest } from 'path/to/ChatAIBatchTestRunner';
|
||||
// runChatAIBatchTest();
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "76e29352-9c31-48f1-ac08-8646aa63a425",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
);
|
||||
if (!isFree && !isRelease) {
|
||||
//未解锁
|
||||
NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
|
||||
NavigationManager.Instance.openPopupPanel("GirlListPopupPanel-Fix", {
|
||||
base: this,
|
||||
category: this.categoryId,
|
||||
id: this.id,
|
||||
|
||||
@@ -77,6 +77,10 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
imgsLayout: Node;
|
||||
|
||||
videoAreaPos: Vec3;
|
||||
@property(Label)
|
||||
girlPrice: Label;
|
||||
@property(Node)
|
||||
sendMsgText: Node;
|
||||
|
||||
protected onEnable(): void {
|
||||
this.refresh();
|
||||
@@ -85,8 +89,6 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
onLoadCT() {
|
||||
super.onLoadCT();
|
||||
|
||||
//this.refresh();
|
||||
|
||||
DetailImageItemPool.Instance.setTemplate(this.imgItemInst.node);
|
||||
|
||||
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
||||
@@ -168,6 +170,22 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
}
|
||||
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
const isFree = girlData.isGirlFreeType(this.category.toString(), this.id);
|
||||
if (isRelease || isFree) {
|
||||
// 先设置选中的角色ID
|
||||
this.girlPrice.node.active = false;
|
||||
this.sendMsgText.active = true;
|
||||
} else {
|
||||
this.girlPrice.node.active = true;
|
||||
this.sendMsgText.active = false;
|
||||
|
||||
this.girlPrice.string = girlData
|
||||
.getGrilOriginalPrice(this.category.toString(), this.id)
|
||||
.toString();
|
||||
}
|
||||
|
||||
// 请求详细数据
|
||||
const reqData = {
|
||||
id: this.id,
|
||||
@@ -315,18 +333,31 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
}
|
||||
|
||||
OnClickChatBtn() {
|
||||
// 使用带过渡动画的导航方法
|
||||
NavigationManager.Instance.switchToPanel(
|
||||
PanelType.PAST_GIRL_LIST,
|
||||
false,
|
||||
(base) => {
|
||||
const chatData = { girlId: this.id, base: base };
|
||||
NavigationManager.Instance.openSubPanel("ChatPanel", base, chatData, {
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
});
|
||||
}
|
||||
);
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
const isFree = girlData.isGirlFreeType(this.category.toString(), this.id);
|
||||
if (isRelease || isFree) {
|
||||
// 使用带过渡动画的导航方法
|
||||
NavigationManager.Instance.switchToPanel(
|
||||
PanelType.PAST_GIRL_LIST,
|
||||
false,
|
||||
(base) => {
|
||||
const chatData = { girlId: this.id, base: base };
|
||||
NavigationManager.Instance.openSubPanel("ChatPanel", base, chatData, {
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
//未解锁
|
||||
NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: this.category,
|
||||
id: this.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
returnBtn() {
|
||||
|
||||
@@ -243,9 +243,13 @@ export class PurchasePanel extends li_BaseView {
|
||||
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
|
||||
const vipExpire = walletData.vipExpire;
|
||||
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
if (leftTime == null) {
|
||||
LanguageUtils.getText("purchasepanel.notvip");
|
||||
} else {
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
}
|
||||
|
||||
// 使用余额购买商品
|
||||
|
||||
@@ -357,9 +357,14 @@ export class ThemePanel extends li_BaseView {
|
||||
const vipExpire = walletData.vipExpire;
|
||||
|
||||
const leftTime = Utils.formatVipLeftTime(vipExpire);
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
|
||||
if (leftTime == null) {
|
||||
LanguageUtils.getText("purchasepanel.notvip");
|
||||
} else {
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,19 +209,21 @@ export class GirlListItem extends Component {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
// 是否已经解锁
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
if (isRelease) {
|
||||
// 先设置选中的角色ID
|
||||
NavigationManager.Instance.setSelectedGirlId(this.id);
|
||||
|
||||
// 通过switchToPanel切换到角色详情面板,保持动画和状态同步
|
||||
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
|
||||
} else {
|
||||
//未解锁
|
||||
NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
|
||||
base: this,
|
||||
category: this.category,
|
||||
id: this.id,
|
||||
});
|
||||
}
|
||||
NavigationManager.Instance.setSelectedGirlId(this.id);
|
||||
|
||||
// 通过switchToPanel切换到角色详情面板,保持动画和状态同步
|
||||
NavigationManager.Instance.switchToPanel(PanelType.GIRL_DETAIL);
|
||||
|
||||
// if (isRelease) {
|
||||
// // 先设置选中的角色ID
|
||||
// } else {
|
||||
// //未解锁
|
||||
// NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
|
||||
// base: this,
|
||||
// category: this.category,
|
||||
// id: this.id,
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2990,7 +2990,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "57520716-48c8-4a19-8acf-41c9f8777fb0@f9941",
|
||||
"__uuid__": "7e2364d2-b224-47b3-a753-ba22b201a7c7@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "1.1.50",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "afacd1df-6501-429b-9ea5-78e88900e6fa",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "GirlListPopupPanel-Fix"
|
||||
}
|
||||
}
|
||||
@@ -587,7 +587,7 @@
|
||||
"a": 255
|
||||
},
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "777fc276-1999-4eba-a9a4-9bcfb84cbd72@f9941",
|
||||
"__uuid__": "7e2364d2-b224-47b3-a753-ba22b201a7c7@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
"_type": 0,
|
||||
|
||||
+1122
-1105
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "7e2364d2-b224-47b3-a753-ba22b201a7c7",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "7e2364d2-b224-47b3-a753-ba22b201a7c7@6c48a",
|
||||
"displayName": "default-avatar",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "7e2364d2-b224-47b3-a753-ba22b201a7c7",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "7e2364d2-b224-47b3-a753-ba22b201a7c7@f9941",
|
||||
"displayName": "default-avatar",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 256,
|
||||
"height": 256,
|
||||
"rawWidth": 256,
|
||||
"rawHeight": 256,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-128,
|
||||
-128,
|
||||
0,
|
||||
128,
|
||||
-128,
|
||||
0,
|
||||
-128,
|
||||
128,
|
||||
0,
|
||||
128,
|
||||
128,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
256,
|
||||
256,
|
||||
256,
|
||||
0,
|
||||
0,
|
||||
256,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-128,
|
||||
-128,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
128,
|
||||
128,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "7e2364d2-b224-47b3-a753-ba22b201a7c7@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": false,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "7e2364d2-b224-47b3-a753-ba22b201a7c7@6c48a"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user