feat: 支持首页 UI

This commit is contained in:
richarjiang
2026-04-27 09:29:50 +08:00
parent 950572ad74
commit fbea31b9ea
22 changed files with 2201 additions and 506 deletions

View File

@@ -176,7 +176,7 @@
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "d532045e-55f8-47c2-9493-b918e18364b0@f9941", "__uuid__": "10047f2e-bf2c-46f0-ba98-6fc23cf7ea87@f9941",
"__expectedType__": "cc.SpriteFrame" "__expectedType__": "cc.SpriteFrame"
}, },
"_type": 0, "_type": 0,
@@ -597,8 +597,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 80, "width": 88,
"height": 50.4 "height": 58.4
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -646,19 +646,19 @@
"_isSystemFontUsed": true, "_isSystemFontUsed": true,
"_spacingX": 0, "_spacingX": 0,
"_isItalic": false, "_isItalic": false,
"_isBold": false, "_isBold": true,
"_isUnderline": false, "_isUnderline": false,
"_underlineHeight": 2, "_underlineHeight": 2,
"_cacheMode": 0, "_cacheMode": 0,
"_enableOutline": false, "_enableOutline": true,
"_outlineColor": { "_outlineColor": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 0, "r": 72,
"g": 0, "g": 158,
"b": 0, "b": 35,
"a": 255 "a": 255
}, },
"_outlineWidth": 2, "_outlineWidth": 4,
"_enableShadow": false, "_enableShadow": false,
"_shadowColor": { "_shadowColor": {
"__type__": "cc.Color", "__type__": "cc.Color",

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,10 @@
import { _decorator, Node, Button } from 'cc'; import { _decorator, Node, Button, Label } from 'cc';
import { BaseView } from 'db://assets/scripts/core/BaseView'; import { BaseView } from 'db://assets/scripts/core/BaseView';
import { ViewManager } from 'db://assets/scripts/core/ViewManager'; import { ViewManager } from 'db://assets/scripts/core/ViewManager';
import { WxSDK, checkPrivacySetting, requirePrivacyAuthorize } from 'db://assets/scripts/utils/WxSDK'; import { WxSDK, checkPrivacySetting, requirePrivacyAuthorize } from 'db://assets/scripts/utils/WxSDK';
import { StaminaManager } from 'db://assets/scripts/utils/StaminaManager';
import { ToastManager } from 'db://assets/scripts/utils/ToastManager';
import { StaminaInfo } from 'db://assets/scripts/types/ApiTypes';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
/** /**
@@ -10,12 +13,19 @@ const { ccclass, property } = _decorator;
*/ */
@ccclass('PageHome') @ccclass('PageHome')
export class PageHome extends BaseView { export class PageHome extends BaseView {
/** 默认体力上限 */
private static readonly DEFAULT_STAMINA_MAX = 50;
@property({ type: Node, tooltip: '开始游戏按钮' }) @property({ type: Node, tooltip: '开始游戏按钮' })
startGameBtn: Node | null = null; startGameBtn: Node | null = null;
@property({ type: Node, tooltip: 'PK按钮' }) @property({ type: Node, tooltip: 'PK按钮' })
pkBtn: Node | null = null; pkBtn: Node | null = null;
/** 体力值显示标签 */
@property(Label)
liveLabel: Label | null = null;
/** /**
* 页面首次加载时调用 * 页面首次加载时调用
*/ */
@@ -85,7 +95,7 @@ export class PageHome extends BaseView {
*/ */
private _onPkClick(): void { private _onPkClick(): void {
console.log('[PageHome] PK按钮点击'); console.log('[PageHome] PK按钮点击');
ViewManager.instance.open('PageWriteLevels'); ToastManager.show('功能正在开发中,敬请期待吧!');
} }
/** /**
@@ -93,6 +103,25 @@ export class PageHome extends BaseView {
*/ */
onViewShow(): void { onViewShow(): void {
console.log('[PageHome] onViewShow'); console.log('[PageHome] onViewShow');
this.updateStaminaLabel();
}
/**
* 获取体力上限
*/
private _getStaminaMax(stamina: StaminaInfo): number {
return typeof stamina.max === 'number' ? stamina.max : PageHome.DEFAULT_STAMINA_MAX;
}
/**
* 更新体力值显示
*/
private updateStaminaLabel(): void {
if (this.liveLabel) {
const stamina = StaminaManager.instance.getStamina();
const maxStamina = this._getStaminaMax(stamina);
this.liveLabel.string = `${stamina.current}/${maxStamina}`;
}
} }
/** /**

View File

@@ -301,8 +301,6 @@ export class PageLevel extends BaseView {
return; return;
} }
// 提示用户消耗体力
ToastManager.show(`消耗1点体力剩余 ${enterData.stamina.current}/${this._getStaminaMax(enterData.stamina)}`);
// 用 enter 接口返回的数据更新关卡配置(填充答案和线索) // 用 enter 接口返回的数据更新关卡配置(填充答案和线索)
LevelDataManager.instance.updateLevelDetails( LevelDataManager.instance.updateLevelDetails(

View File

@@ -1376,7 +1376,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 92.5, "width": 185,
"height": 121 "height": 121
}, },
"_anchorPoint": { "_anchorPoint": {
@@ -1538,7 +1538,7 @@
}, },
"_mode": 0, "_mode": 0,
"_totalLength": 925, "_totalLength": 925,
"_progress": 0.1, "_progress": 0.2,
"_reverse": false, "_reverse": false,
"_id": "" "_id": ""
}, },

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

View File

@@ -2,7 +2,7 @@
"ver": "1.0.27", "ver": "1.0.27",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0", "uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d",
"files": [ "files": [
".json", ".json",
".png" ".png"
@@ -10,14 +10,14 @@
"subMetas": { "subMetas": {
"6c48a": { "6c48a": {
"importer": "texture", "importer": "texture",
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0@6c48a", "uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@6c48a",
"displayName": "Bg", "displayName": "Plus",
"id": "6c48a", "id": "6c48a",
"name": "texture", "name": "texture",
"userData": { "userData": {
"wrapModeS": "clamp-to-edge", "wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge", "wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "d532045e-55f8-47c2-9493-b918e18364b0", "imageUuidOrDatabaseUri": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d",
"isUuid": true, "isUuid": true,
"visible": false, "visible": false,
"minfilter": "linear", "minfilter": "linear",
@@ -34,8 +34,8 @@
}, },
"f9941": { "f9941": {
"importer": "sprite-frame", "importer": "sprite-frame",
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0@f9941", "uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@f9941",
"displayName": "Bg", "displayName": "Plus",
"id": "f9941", "id": "f9941",
"name": "spriteFrame", "name": "spriteFrame",
"userData": { "userData": {
@@ -45,10 +45,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 750, "width": 26,
"height": 1626, "height": 26,
"rawWidth": 750, "rawWidth": 26,
"rawHeight": 1626, "rawHeight": 26,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0, "meshType": 0,
"vertices": { "vertices": {
"rawPosition": [ "rawPosition": [
-375, -13,
-813, -13,
0, 0,
375, 13,
-813, -13,
0, 0,
-375, -13,
813, 13,
0, 0,
375, 13,
813, 13,
0 0
], ],
"indexes": [ "indexes": [
@@ -83,12 +83,12 @@
], ],
"uv": [ "uv": [
0, 0,
1626, 26,
750, 26,
1626, 26,
0, 0,
0, 0,
750, 26,
0 0
], ],
"nuv": [ "nuv": [
@@ -102,18 +102,18 @@
1 1
], ],
"minPos": [ "minPos": [
-375, -13,
-813, -13,
0 0
], ],
"maxPos": [ "maxPos": [
375, 13,
813, 13,
0 0
] ]
}, },
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "d532045e-55f8-47c2-9493-b918e18364b0@6c48a", "imageUuidOrDatabaseUri": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@6c48a",
"atlasUuid": "", "atlasUuid": "",
"trimType": "auto" "trimType": "auto"
}, },
@@ -129,6 +129,6 @@
"type": "sprite-frame", "type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false, "fixAlphaTransparencyArtifacts": false,
"hasAlpha": true, "hasAlpha": true,
"redirect": "d532045e-55f8-47c2-9493-b918e18364b0@6c48a" "redirect": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@6c48a"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -2,7 +2,7 @@
"ver": "1.0.27", "ver": "1.0.27",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8", "uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc",
"files": [ "files": [
".json", ".json",
".png" ".png"
@@ -10,14 +10,14 @@
"subMetas": { "subMetas": {
"6c48a": { "6c48a": {
"importer": "texture", "importer": "texture",
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8@6c48a", "uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@6c48a",
"displayName": "startGame", "displayName": "HomeButtonGreen",
"id": "6c48a", "id": "6c48a",
"name": "texture", "name": "texture",
"userData": { "userData": {
"wrapModeS": "clamp-to-edge", "wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge", "wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "010e6809-3636-4c23-8403-1424c771f0f8", "imageUuidOrDatabaseUri": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc",
"isUuid": true, "isUuid": true,
"visible": false, "visible": false,
"minfilter": "linear", "minfilter": "linear",
@@ -34,8 +34,8 @@
}, },
"f9941": { "f9941": {
"importer": "sprite-frame", "importer": "sprite-frame",
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8@f9941", "uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@f9941",
"displayName": "startGame", "displayName": "HomeButtonGreen",
"id": "f9941", "id": "f9941",
"name": "spriteFrame", "name": "spriteFrame",
"userData": { "userData": {
@@ -45,10 +45,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 216, "width": 488,
"height": 107, "height": 197,
"rawWidth": 216, "rawWidth": 488,
"rawHeight": 107, "rawHeight": 197,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0, "meshType": 0,
"vertices": { "vertices": {
"rawPosition": [ "rawPosition": [
-108, -244,
-53.5, -98.5,
0, 0,
108, 244,
-53.5, -98.5,
0, 0,
-108, -244,
53.5, 98.5,
0, 0,
108, 244,
53.5, 98.5,
0 0
], ],
"indexes": [ "indexes": [
@@ -83,12 +83,12 @@
], ],
"uv": [ "uv": [
0, 0,
107, 197,
216, 488,
107, 197,
0, 0,
0, 0,
216, 488,
0 0
], ],
"nuv": [ "nuv": [
@@ -102,18 +102,18 @@
1 1
], ],
"minPos": [ "minPos": [
-108, -244,
-53.5, -98.5,
0 0
], ],
"maxPos": [ "maxPos": [
108, 244,
53.5, 98.5,
0 0
] ]
}, },
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "010e6809-3636-4c23-8403-1424c771f0f8@6c48a", "imageUuidOrDatabaseUri": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@6c48a",
"atlasUuid": "", "atlasUuid": "",
"trimType": "auto" "trimType": "auto"
}, },
@@ -129,6 +129,6 @@
"type": "sprite-frame", "type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false, "fixAlphaTransparencyArtifacts": false,
"hasAlpha": true, "hasAlpha": true,
"redirect": "010e6809-3636-4c23-8403-1424c771f0f8@6c48a" "redirect": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@6c48a"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -2,7 +2,7 @@
"ver": "1.0.27", "ver": "1.0.27",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26", "uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768",
"files": [ "files": [
".json", ".json",
".png" ".png"
@@ -10,14 +10,14 @@
"subMetas": { "subMetas": {
"6c48a": { "6c48a": {
"importer": "texture", "importer": "texture",
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@6c48a", "uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768@6c48a",
"displayName": "ButtonBg", "displayName": "HomeButtonOrange",
"id": "6c48a", "id": "6c48a",
"name": "texture", "name": "texture",
"userData": { "userData": {
"wrapModeS": "clamp-to-edge", "wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge", "wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26", "imageUuidOrDatabaseUri": "2270362e-66d7-4d0f-ab51-b5cbca25a768",
"isUuid": true, "isUuid": true,
"visible": false, "visible": false,
"minfilter": "linear", "minfilter": "linear",
@@ -34,21 +34,21 @@
}, },
"f9941": { "f9941": {
"importer": "sprite-frame", "importer": "sprite-frame",
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@f9941", "uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768@f9941",
"displayName": "ButtonBg", "displayName": "HomeButtonOrange",
"id": "f9941", "id": "f9941",
"name": "spriteFrame", "name": "spriteFrame",
"userData": { "userData": {
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": 0, "offsetX": 0,
"offsetY": 0.5, "offsetY": 0,
"trimX": 1, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 306, "width": 488,
"height": 77, "height": 197,
"rawWidth": 308, "rawWidth": 488,
"rawHeight": 78, "rawHeight": 197,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0, "meshType": 0,
"vertices": { "vertices": {
"rawPosition": [ "rawPosition": [
-153, -244,
-38.5, -98.5,
0, 0,
153, 244,
-38.5, -98.5,
0, 0,
-153, -244,
38.5, 98.5,
0, 0,
153, 244,
38.5, 98.5,
0 0
], ],
"indexes": [ "indexes": [
@@ -82,38 +82,38 @@
3 3
], ],
"uv": [ "uv": [
1, 0,
78, 197,
307, 488,
78, 197,
1, 0,
1, 0,
307, 488,
1 0
], ],
"nuv": [ "nuv": [
0.003246753246753247, 0,
0.01282051282051282, 0,
0.9967532467532467, 1,
0.01282051282051282, 0,
0.003246753246753247, 0,
1,
1, 1,
0.9967532467532467,
1 1
], ],
"minPos": [ "minPos": [
-153, -244,
-38.5, -98.5,
0 0
], ],
"maxPos": [ "maxPos": [
153, 244,
38.5, 98.5,
0 0
] ]
}, },
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@6c48a", "imageUuidOrDatabaseUri": "2270362e-66d7-4d0f-ab51-b5cbca25a768@6c48a",
"atlasUuid": "", "atlasUuid": "",
"trimType": "auto" "trimType": "auto"
}, },
@@ -129,6 +129,6 @@
"type": "sprite-frame", "type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false, "fixAlphaTransparencyArtifacts": false,
"hasAlpha": true, "hasAlpha": true,
"redirect": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@6c48a" "redirect": "2270362e-66d7-4d0f-ab51-b5cbca25a768@6c48a"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3@6c48a",
"displayName": "friendChallenge",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3",
"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": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3@f9941",
"displayName": "friendChallenge",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -8.5,
"trimX": 170,
"trimY": 243,
"width": 684,
"height": 555,
"rawWidth": 1024,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-342,
-277.5,
0,
342,
-277.5,
0,
-342,
277.5,
0,
342,
277.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
170,
781,
854,
781,
170,
226,
854,
226
],
"nuv": [
0.166015625,
0.220703125,
0.833984375,
0.220703125,
0.166015625,
0.7626953125,
0.833984375,
0.7626953125
],
"minPos": [
-342,
-277.5,
0
],
"maxPos": [
342,
277.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false,
"hasAlpha": true,
"redirect": "12eb7a16-3f31-40d8-a9cd-30e18900a3a3@6c48a"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -115,7 +115,7 @@
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "929dfe4e-9eab-48f1-a87d-344d51f07402@6c48a", "imageUuidOrDatabaseUri": "929dfe4e-9eab-48f1-a87d-344d51f07402@6c48a",
"atlasUuid": "", "atlasUuid": "",
"trimType": "auto" "trimType": "none"
}, },
"ver": "1.0.12", "ver": "1.0.12",
"imported": true, "imported": true,

View File

@@ -51,8 +51,8 @@
"rawHeight": 164, "rawHeight": 164,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 120,
"borderRight": 0, "borderRight": 120,
"packable": true, "packable": true,
"pixelsToUnit": 100, "pixelsToUnit": 100,
"pivotX": 0.5, "pivotX": 0.5,

View File

@@ -35,5 +35,10 @@
} }
} }
} }
},
"splash-setting": {
"logo": {
"type": "none"
}
} }
} }

View File

@@ -6,7 +6,7 @@
"label": "customSplash", "label": "customSplash",
"enable": true, "enable": true,
"customSplash": { "customSplash": {
"complete": false, "complete": true,
"form": "https://creator-api.cocos.com/api/form/show?sid=51d0aa399094bb683b7737f0a16a459b" "form": "https://creator-api.cocos.com/api/form/show?sid=51d0aa399094bb683b7737f0a16a459b"
} }
}, },