perf: 支持跳转到分享页面

This commit is contained in:
richarjiang
2026-04-06 11:04:09 +08:00
parent b732e4d8f8
commit 261c4d6878
8 changed files with 4005 additions and 7 deletions

View File

@@ -474,6 +474,10 @@
"__uuid__": "8611dbdc-4749-49f1-97ca-aedae3d16320",
"__expectedType__": "cc.Prefab"
},
"pageWriteLevelsPrefab": {
"__uuid__": "3b33c592-ea62-4449-84ed-bf72416d7457",
"__expectedType__": "cc.Prefab"
},
"toastPrefab": {
"__uuid__": "cff2809d-6daa-4749-a911-bb99e97b4b54",
"__expectedType__": "cc.Prefab"

View File

@@ -15,6 +15,9 @@ export class main extends Component {
@property({ type: Prefab, tooltip: '关卡页面预制体' })
pageLevelPrefab: Prefab | null = null;
@property({ type: Prefab, tooltip: '写关卡页面预制体' })
pageWriteLevelsPrefab: Prefab | null = null;
@property({ type: Prefab, tooltip: 'Toast 预制体' })
toastPrefab: Prefab | null = null;
@@ -50,6 +53,14 @@ export class main extends Component {
});
}
if (this.pageWriteLevelsPrefab) {
ViewManager.instance.register('PageWriteLevels', {
prefab: this.pageWriteLevelsPrefab,
cache: true,
zIndex: 2
});
}
// 初始化 Toast 管理器
if (this.toastPrefab) {
ToastManager.instance.init(this.toastPrefab, this.node);

View File

@@ -23,22 +23,25 @@
},
{
"__id__": 10
},
{
"__id__": 20
}
],
"_active": true,
"_components": [
{
"__id__": 20
"__id__": 34
},
{
"__id__": 22
"__id__": 36
},
{
"__id__": 24
"__id__": 38
}
],
"_prefab": {
"__id__": 26
"__id__": 40
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -460,6 +463,378 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "PkButton",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 21
}
],
"_active": true,
"_components": [
{
"__id__": 27
},
{
"__id__": 29
},
{
"__id__": 31
}
],
"_prefab": {
"__id__": 33
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 2.942,
"y": 2.942,
"z": 2.942
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 512,
"__editorExtras__": {},
"_parent": {
"__id__": 20
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
},
{
"__id__": 24
}
],
"_prefab": {
"__id__": 26
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 21
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "090bEiOaRHhb2BFj6qtlz9"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 21
},
"_enabled": true,
"__prefab": {
"__id__": 25
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_string": "好友挑战",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 20,
"_fontSize": 20,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 1,
"_enableWrapText": false,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": false,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
},
"_shadowBlur": 2,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8f0IK/uwJMEKmX0y3dlIk3"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "c9WpfO3dZLZqSGYZTjjBzX",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 28
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ecyXRuWtFMa5tvFcIIyTw5"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 30
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "35NgLucXJO6ZNpSM+3vGcI"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 20
},
"_enabled": true,
"__prefab": {
"__id__": 32
},
"clickEvents": [],
"_interactable": true,
"_transition": 2,
"_normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_hoverSprite": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_pressedSprite": {
"__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_disabledSprite": {
"__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": {
"__id__": 20
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "4bd2QEn9FKO6dHoXyJYD9c"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "ffcHy29O9MbLMT7Vn1/hrH",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
@@ -470,7 +845,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 21
"__id__": 35
},
"_contentSize": {
"__type__": "cc.Size",
@@ -498,7 +873,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 23
"__id__": 37
},
"_alignFlags": 45,
"_target": null,
@@ -534,11 +909,14 @@
},
"_enabled": true,
"__prefab": {
"__id__": 25
"__id__": 39
},
"startGameBtn": {
"__id__": 10
},
"pkBtn": {
"__id__": 20
},
"_id": ""
},
{

View File

@@ -13,6 +13,9 @@ export class PageHome extends BaseView {
@property({ type: Node, tooltip: '开始游戏按钮' })
startGameBtn: Node | null = null;
@property({ type: Node, tooltip: 'PK按钮' })
pkBtn: Node | null = null;
/**
* 页面首次加载时调用
*/
@@ -40,6 +43,9 @@ export class PageHome extends BaseView {
if (this.startGameBtn) {
this.startGameBtn.on(Button.EventType.CLICK, this._onStartGameClick, this);
}
if (this.pkBtn) {
this.pkBtn.on(Button.EventType.CLICK, this._onPkClick, this);
}
}
/**
@@ -50,6 +56,14 @@ export class PageHome extends BaseView {
ViewManager.instance.open('PageLevel');
}
/**
* PK按钮点击回调
*/
private _onPkClick(): void {
console.log('[PageHome] PK按钮点击');
ViewManager.instance.open('PageWriteLevels');
}
/**
* 页面每次显示时调用
*/
@@ -73,5 +87,8 @@ export class PageHome extends BaseView {
if (this.startGameBtn) {
this.startGameBtn.off(Button.EventType.CLICK, this._onStartGameClick, this);
}
if (this.pkBtn) {
this.pkBtn.off(Button.EventType.CLICK, this._onPkClick, this);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "3b33c592-ea62-4449-84ed-bf72416d7457",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "PageWriteLevels"
}
}

View File

@@ -0,0 +1,63 @@
import { _decorator, Node, Button } from 'cc';
import { BaseView } from 'db://assets/scripts/core/BaseView';
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
const { ccclass, property } = _decorator;
/**
* 写关卡/分享页面组件
* 用于展示用户已通关的关卡列表,选择关卡进行分享
*/
@ccclass('PageWriteLevels')
export class PageWriteLevels extends BaseView {
@property({ type: Node, tooltip: '返回按钮' })
backBtn: Node | null = null;
/**
* 页面首次加载时调用
*/
onViewLoad(): void {
console.log('[PageWriteLevels] onViewLoad');
this._initButtons();
}
/**
* 初始化按钮事件
*/
private _initButtons(): void {
if (this.backBtn) {
this.backBtn.on(Button.EventType.CLICK, this._onBackClick, this);
}
}
/**
* 返回按钮点击回调
*/
private _onBackClick(): void {
console.log('[PageWriteLevels] 返回按钮点击');
ViewManager.instance.back();
}
/**
* 页面每次显示时调用
*/
onViewShow(): void {
console.log('[PageWriteLevels] onViewShow');
}
/**
* 页面隐藏时调用
*/
onViewHide(): void {
console.log('[PageWriteLevels] onViewHide');
}
/**
* 页面销毁时调用
*/
onViewDestroy(): void {
console.log('[PageWriteLevels] onViewDestroy');
if (this.backBtn) {
this.backBtn.off(Button.EventType.CLICK, this._onBackClick, this);
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "d186ef08-9ac6-4456-82c4-d6b3f8924017",
"files": [],
"subMetas": {},
"userData": {}
}