feat: 添加微信SDK和关卡页面,重构预制体结构

- 新增 WxSDK 微信SDK工具类
- 新增 PageLevel 关卡选择页面组件
- 将 prefabs 目录从 resources 移至根目录
- 更新 ViewManager 支持预制体属性引用
- 添加 BaseView 页面基类

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
richarjiang
2026-03-11 10:35:21 +08:00
parent 8986d8d8f2
commit 0bda6904fa
18 changed files with 1149 additions and 1646 deletions

View File

@@ -1,6 +1,6 @@
import { _decorator, Component } from 'cc';
import { _decorator, Component, Prefab } from 'cc';
import { ViewManager } from './scripts/core/ViewManager';
const { ccclass } = _decorator;
const { ccclass, property } = _decorator;
/**
* 主入口脚本
@@ -8,6 +8,12 @@ const { ccclass } = _decorator;
*/
@ccclass('main')
export class main extends Component {
@property({ type: Prefab, tooltip: '首页预制体' })
pageHomePrefab: Prefab | null = null;
@property({ type: Prefab, tooltip: '关卡页面预制体' })
pageLevelPrefab: Prefab | null = null;
/**
* onLoad 比 start 更早执行
* 确保 ViewManager 在 PageLoading.start() 之前初始化
@@ -23,18 +29,21 @@ export class main extends Component {
// 初始化 ViewManager绑定 Canvas 作为页面容器
ViewManager.instance.init(this.node);
// 注册页面配置
ViewManager.instance.register('PageHome', {
prefabPath: 'prefabs/PageHome',
cache: true,
zIndex: 0
});
// 注册页面配置(通过编辑器属性引用预制体)
if (this.pageHomePrefab) {
ViewManager.instance.register('PageHome', {
prefab: this.pageHomePrefab,
cache: true,
zIndex: 0
});
}
// 注册关卡页面
ViewManager.instance.register('PageLevel', {
prefabPath: 'prefabs/PageLevel',
cache: true,
zIndex: 1
});
if (this.pageLevelPrefab) {
ViewManager.instance.register('PageLevel', {
prefab: this.pageLevelPrefab,
cache: true,
zIndex: 1
});
}
}
}