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
},
"_spriteFrame": {
"__uuid__": "d532045e-55f8-47c2-9493-b918e18364b0@f9941",
"__uuid__": "10047f2e-bf2c-46f0-ba98-6fc23cf7ea87@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -597,8 +597,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 80,
"height": 50.4
"width": 88,
"height": 58.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -646,19 +646,19 @@
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isBold": true,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": false,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"r": 72,
"g": 158,
"b": 35,
"a": 255
},
"_outlineWidth": 2,
"_outlineWidth": 4,
"_enableShadow": false,
"_shadowColor": {
"__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 { ViewManager } from 'db://assets/scripts/core/ViewManager';
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;
/**
@@ -10,12 +13,19 @@ const { ccclass, property } = _decorator;
*/
@ccclass('PageHome')
export class PageHome extends BaseView {
/** 默认体力上限 */
private static readonly DEFAULT_STAMINA_MAX = 50;
@property({ type: Node, tooltip: '开始游戏按钮' })
startGameBtn: Node | null = null;
@property({ type: Node, tooltip: 'PK按钮' })
pkBtn: Node | null = null;
/** 体力值显示标签 */
@property(Label)
liveLabel: Label | null = null;
/**
* 页面首次加载时调用
*/
@@ -85,7 +95,7 @@ export class PageHome extends BaseView {
*/
private _onPkClick(): void {
console.log('[PageHome] PK按钮点击');
ViewManager.instance.open('PageWriteLevels');
ToastManager.show('功能正在开发中,敬请期待吧!');
}
/**
@@ -93,6 +103,25 @@ export class PageHome extends BaseView {
*/
onViewShow(): void {
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;
}
// 提示用户消耗体力
ToastManager.show(`消耗1点体力剩余 ${enterData.stamina.current}/${this._getStaminaMax(enterData.stamina)}`);
// 用 enter 接口返回的数据更新关卡配置(填充答案和线索)
LevelDataManager.instance.updateLevelDetails(

View File

@@ -1376,7 +1376,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 92.5,
"width": 185,
"height": 121
},
"_anchorPoint": {
@@ -1538,7 +1538,7 @@
},
"_mode": 0,
"_totalLength": 925,
"_progress": 0.1,
"_progress": 0.2,
"_reverse": false,
"_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",
"importer": "image",
"imported": true,
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0",
"uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d",
"files": [
".json",
".png"
@@ -10,14 +10,14 @@
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0@6c48a",
"displayName": "Bg",
"uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@6c48a",
"displayName": "Plus",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "d532045e-55f8-47c2-9493-b918e18364b0",
"imageUuidOrDatabaseUri": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d",
"isUuid": true,
"visible": false,
"minfilter": "linear",
@@ -34,8 +34,8 @@
},
"f9941": {
"importer": "sprite-frame",
"uuid": "d532045e-55f8-47c2-9493-b918e18364b0@f9941",
"displayName": "Bg",
"uuid": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@f9941",
"displayName": "Plus",
"id": "f9941",
"name": "spriteFrame",
"userData": {
@@ -45,10 +45,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 750,
"height": 1626,
"rawWidth": 750,
"rawHeight": 1626,
"width": 26,
"height": 26,
"rawWidth": 26,
"rawHeight": 26,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0,
"vertices": {
"rawPosition": [
-375,
-813,
-13,
-13,
0,
375,
-813,
13,
-13,
0,
-375,
813,
-13,
13,
0,
375,
813,
13,
13,
0
],
"indexes": [
@@ -83,12 +83,12 @@
],
"uv": [
0,
1626,
750,
1626,
26,
26,
26,
0,
0,
750,
26,
0
],
"nuv": [
@@ -102,18 +102,18 @@
1
],
"minPos": [
-375,
-813,
-13,
-13,
0
],
"maxPos": [
375,
813,
13,
13,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "d532045e-55f8-47c2-9493-b918e18364b0@6c48a",
"imageUuidOrDatabaseUri": "a2cba4c9-ed0a-46c4-9184-362cfd0d878d@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
@@ -129,6 +129,6 @@
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false,
"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",
"importer": "image",
"imported": true,
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8",
"uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc",
"files": [
".json",
".png"
@@ -10,14 +10,14 @@
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8@6c48a",
"displayName": "startGame",
"uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@6c48a",
"displayName": "HomeButtonGreen",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "010e6809-3636-4c23-8403-1424c771f0f8",
"imageUuidOrDatabaseUri": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc",
"isUuid": true,
"visible": false,
"minfilter": "linear",
@@ -34,8 +34,8 @@
},
"f9941": {
"importer": "sprite-frame",
"uuid": "010e6809-3636-4c23-8403-1424c771f0f8@f9941",
"displayName": "startGame",
"uuid": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@f9941",
"displayName": "HomeButtonGreen",
"id": "f9941",
"name": "spriteFrame",
"userData": {
@@ -45,10 +45,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 216,
"height": 107,
"rawWidth": 216,
"rawHeight": 107,
"width": 488,
"height": 197,
"rawWidth": 488,
"rawHeight": 197,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0,
"vertices": {
"rawPosition": [
-108,
-53.5,
-244,
-98.5,
0,
108,
-53.5,
244,
-98.5,
0,
-108,
53.5,
-244,
98.5,
0,
108,
53.5,
244,
98.5,
0
],
"indexes": [
@@ -83,12 +83,12 @@
],
"uv": [
0,
107,
216,
107,
197,
488,
197,
0,
0,
216,
488,
0
],
"nuv": [
@@ -102,18 +102,18 @@
1
],
"minPos": [
-108,
-53.5,
-244,
-98.5,
0
],
"maxPos": [
108,
53.5,
244,
98.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "010e6809-3636-4c23-8403-1424c771f0f8@6c48a",
"imageUuidOrDatabaseUri": "02047ea3-2a13-4f17-b4dd-5aefa0e182dc@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
@@ -129,6 +129,6 @@
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false,
"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",
"importer": "image",
"imported": true,
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26",
"uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768",
"files": [
".json",
".png"
@@ -10,14 +10,14 @@
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@6c48a",
"displayName": "ButtonBg",
"uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768@6c48a",
"displayName": "HomeButtonOrange",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26",
"imageUuidOrDatabaseUri": "2270362e-66d7-4d0f-ab51-b5cbca25a768",
"isUuid": true,
"visible": false,
"minfilter": "linear",
@@ -34,21 +34,21 @@
},
"f9941": {
"importer": "sprite-frame",
"uuid": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@f9941",
"displayName": "ButtonBg",
"uuid": "2270362e-66d7-4d0f-ab51-b5cbca25a768@f9941",
"displayName": "HomeButtonOrange",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0.5,
"trimX": 1,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 306,
"height": 77,
"rawWidth": 308,
"rawHeight": 78,
"width": 488,
"height": 197,
"rawWidth": 488,
"rawHeight": 197,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
@@ -60,17 +60,17 @@
"meshType": 0,
"vertices": {
"rawPosition": [
-153,
-38.5,
-244,
-98.5,
0,
153,
-38.5,
244,
-98.5,
0,
-153,
38.5,
-244,
98.5,
0,
153,
38.5,
244,
98.5,
0
],
"indexes": [
@@ -82,38 +82,38 @@
3
],
"uv": [
1,
78,
307,
78,
1,
1,
307,
1
0,
197,
488,
197,
0,
0,
488,
0
],
"nuv": [
0.003246753246753247,
0.01282051282051282,
0.9967532467532467,
0.01282051282051282,
0.003246753246753247,
0,
0,
1,
0,
0,
1,
1,
0.9967532467532467,
1
],
"minPos": [
-153,
-38.5,
-244,
-98.5,
0
],
"maxPos": [
153,
38.5,
244,
98.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "e1267c1b-ceb0-4483-b36d-bc9cb4d2fd26@6c48a",
"imageUuidOrDatabaseUri": "2270362e-66d7-4d0f-ab51-b5cbca25a768@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
@@ -129,6 +129,6 @@
"type": "sprite-frame",
"fixAlphaTransparencyArtifacts": false,
"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,
"imageUuidOrDatabaseUri": "929dfe4e-9eab-48f1-a87d-344d51f07402@6c48a",
"atlasUuid": "",
"trimType": "auto"
"trimType": "none"
},
"ver": "1.0.12",
"imported": true,

View File

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