import { store } from './store'; /** * Cocos Creator 3.8 扩展主进程入口。 * 关键约定(与官方 first/message 文档一致): * - 处理函数必须挂在 `methods` 对象里(Cocos 读取 module.exports.methods), * methods 的 key 必须与 package.json 中 contributions.messages[*].methods 引用的名字一致。 * - 生命周期钩子为 `load`/`unload`(不是 onLoad)。 * - 处理函数直接接收消息参数(无 event),返回值即 Editor.Message.request 的 resolve 结果。 */ function load() { store.reloadAll(); } function unload() { // 进程级单例随扩展卸载自然销毁,无需显式清理。 } const methods: Record any> = { 'open-panel'() { Editor.Panel.open('pixelhero-config-editor'); }, 'query-schema'(id?: string) { return store.querySchema(id as any); }, 'query-enums'() { return store.queryEnums(); }, 'query-keys'(id: string) { return store.queryKeys(id as any); }, 'query-record'(id: string, key: string) { return store.queryRecord(id as any, key); }, 'query-preview-desc'(hero: any) { return store.queryPreviewDesc(hero); }, 'validate'(id: string) { return store.validate(id as any); }, 'save-record'(id: string, key: string, value: any) { return store.saveRecord(id as any, key, value); }, 'revert-record'(id: string, key: string) { return store.revertRecord(id as any, key); }, }; module.exports = { methods, load, unload };