fix(stage-tamagotchi): missing register of widgets for chat window
This commit is contained in:
@@ -126,7 +126,6 @@ app.whenReady().then(async () => {
|
||||
injeca.setLogger(createLoggLogger(useLogg('injeca').useGlobalConfig()))
|
||||
|
||||
const channelServerModule = injeca.provide('modules:channel-server', async () => setupChannelServer())
|
||||
const chatWindow = injeca.provide('windows:chat', { build: () => setupChatWindowReusableFunc() })
|
||||
const widgetsManager = injeca.provide('windows:widgets', { build: () => setupWidgetsWindowManager() })
|
||||
const noticeWindow = injeca.provide('windows:notice', { build: () => setupNoticeWindowManager() })
|
||||
|
||||
@@ -134,6 +133,12 @@ app.whenReady().then(async () => {
|
||||
const beatSync = injeca.provide('windows:beat-sync', {
|
||||
build: () => setupBeatSync(),
|
||||
})
|
||||
|
||||
const chatWindow = injeca.provide('windows:chat', {
|
||||
dependsOn: { widgetsManager },
|
||||
build: ({ dependsOn }) => setupChatWindowReusableFunc(dependsOn),
|
||||
})
|
||||
|
||||
const settingsWindow = injeca.provide('windows:settings', {
|
||||
dependsOn: { widgetsManager, beatSync },
|
||||
build: async ({ dependsOn }) => async () => {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { WidgetsWindowManager } from '../widgets'
|
||||
|
||||
import { join, resolve } from 'node:path'
|
||||
|
||||
import { BrowserWindow, shell } from 'electron'
|
||||
@@ -6,8 +8,11 @@ import icon from '../../../../resources/icon.png?asset'
|
||||
|
||||
import { baseUrl, getElectronMainDirname, load, withHashRoute } from '../../libs/electron/location'
|
||||
import { createReusableWindow } from '../../libs/electron/window-manager'
|
||||
import { setupChatWindowElectronInvokes } from './rpc/index.electron'
|
||||
|
||||
export function setupChatWindowReusableFunc() {
|
||||
export function setupChatWindowReusableFunc(params: {
|
||||
widgetsManager: WidgetsWindowManager
|
||||
}) {
|
||||
return createReusableWindow(async () => {
|
||||
const window = new BrowserWindow({
|
||||
title: 'Chat',
|
||||
@@ -29,6 +34,11 @@ export function setupChatWindowReusableFunc() {
|
||||
|
||||
await load(window, withHashRoute(baseUrl(resolve(getElectronMainDirname(), '..', 'renderer')), '/chat'))
|
||||
|
||||
setupChatWindowElectronInvokes({
|
||||
window,
|
||||
widgetsManager: params.widgetsManager,
|
||||
})
|
||||
|
||||
return window
|
||||
}).getWindow
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { BrowserWindow } from 'electron'
|
||||
|
||||
import type { WidgetsWindowManager } from '../../widgets'
|
||||
|
||||
import { defineInvokeHandler } from '@moeru/eventa'
|
||||
import { createContext } from '@moeru/eventa/adapters/electron/main'
|
||||
import { ipcMain } from 'electron'
|
||||
|
||||
import { electronOpenMainDevtools } from '../../../../shared/eventa'
|
||||
import { createWidgetsService } from '../../../services/airi/widgets'
|
||||
import { createScreenService, createWindowService } from '../../../services/electron'
|
||||
|
||||
export function setupChatWindowElectronInvokes(params: {
|
||||
window: BrowserWindow
|
||||
widgetsManager: WidgetsWindowManager
|
||||
}) {
|
||||
// TODO: once we refactored eventa to support window-namespaced contexts,
|
||||
// we can remove the setMaxListeners call below since eventa will be able to dispatch and
|
||||
// manage events within eventa's context system.
|
||||
ipcMain.setMaxListeners(0)
|
||||
|
||||
const { context } = createContext(ipcMain, params.window)
|
||||
|
||||
createScreenService({ context, window: params.window })
|
||||
createWindowService({ context, window: params.window })
|
||||
createWidgetsService({ context, widgetsManager: params.widgetsManager, window: params.window })
|
||||
|
||||
defineInvokeHandler(context, electronOpenMainDevtools, () => params.window.webContents.openDevTools({ mode: 'detach' }))
|
||||
}
|
||||
Reference in New Issue
Block a user