Module System
OpenTree's module system is an extensible functional unit.
Module Types
Data Modules
Interact directly with the World Tree database:
- Keychain (keychain)
- Favorites (favorites)
- Notes (notes)
- Music (music)
- Album (album)
- Countdown (countdown)
- Wallet (wallet)
- Card Holder (cardHolder)
- Address Book (address)
Function Modules
Independent features, not dependent on World Tree data:
- Skill Tree (skills)
- Check-in (checkin)
- Mail (mail)
- Quest Hall (questhall)
- Instance (instance)
Module API Interface
Each data module exposes standard CRUD via electronAPI:
interface ModuleAPI {
getAll(): Promise<Item[]>
create(data: Partial<Item>): Promise<Item>
update(id: string, data: Partial<Item>): Promise<Item>
remove(id: string): Promise<boolean>
}
Using Modules in Metaverse
// 1. Get API
const api = getWtElectronAPI()
// 2. Load data
const items = await api.keychain.getAll()
// 3. Render list
items.forEach(item => { /* ... */ })
// 4. Operations
await api.keychain.create({ name, password })
await api.keychain.update(id, { name })
await api.keychain.remove(id)