refactor(display): migrate stale Wails calls to IPC, remove wrapper types
Migrate handleOpenFile to dialog.TaskOpenFile IPC, handleSaveFile/handleRun/ handleBuild to ActionIDECommand IPC. Remove DialogManager, EnvManager, EventManager interfaces and wailsDialogManager, wailsEnvManager, wailsEventManager adapter structs. App interface now has Quit() + Logger() only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
07bc116abd
commit
49a83110fb
2 changed files with 21 additions and 65 deletions
|
|
@ -841,25 +841,30 @@ func (s *Service) handleNewFile() {
|
|||
}
|
||||
|
||||
func (s *Service) handleOpenFile() {
|
||||
dialog := s.app.Dialog().OpenFile()
|
||||
dialog.SetTitle("Open File")
|
||||
dialog.CanChooseFiles(true)
|
||||
dialog.CanChooseDirectories(false)
|
||||
result, err := dialog.PromptForSingleSelection()
|
||||
if err != nil || result == "" {
|
||||
result, handled, err := s.Core().PERFORM(dialog.TaskOpenFile{
|
||||
Opts: dialog.OpenFileOptions{
|
||||
Title: "Open File",
|
||||
AllowMultiple: false,
|
||||
},
|
||||
})
|
||||
if err != nil || !handled {
|
||||
return
|
||||
}
|
||||
paths, ok := result.([]string)
|
||||
if !ok || len(paths) == 0 {
|
||||
return
|
||||
}
|
||||
_, _, _ = s.Core().PERFORM(window.TaskOpenWindow{
|
||||
Opts: []window.WindowOption{
|
||||
window.WithName("editor"),
|
||||
window.WithTitle(result + " - Editor"),
|
||||
window.WithURL("/#/developer/editor?file=" + result),
|
||||
window.WithTitle(paths[0] + " - Editor"),
|
||||
window.WithURL("/#/developer/editor?file=" + paths[0]),
|
||||
window.WithSize(1200, 800),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Service) handleSaveFile() { s.app.Event().Emit("ide:save") }
|
||||
func (s *Service) handleSaveFile() { _ = s.Core().ACTION(ActionIDECommand{Command: "save"}) }
|
||||
func (s *Service) handleOpenEditor() {
|
||||
_, _, _ = s.Core().PERFORM(window.TaskOpenWindow{
|
||||
Opts: []window.WindowOption{
|
||||
|
|
@ -880,8 +885,8 @@ func (s *Service) handleOpenTerminal() {
|
|||
},
|
||||
})
|
||||
}
|
||||
func (s *Service) handleRun() { s.app.Event().Emit("ide:run") }
|
||||
func (s *Service) handleBuild() { s.app.Event().Emit("ide:build") }
|
||||
func (s *Service) handleRun() { _ = s.Core().ACTION(ActionIDECommand{Command: "run"}) }
|
||||
func (s *Service) handleBuild() { _ = s.Core().ACTION(ActionIDECommand{Command: "build"}) }
|
||||
|
||||
// --- Tray (setup delegated via IPC) ---
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +1,16 @@
|
|||
// pkg/display/interfaces.go
|
||||
package display
|
||||
|
||||
import (
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/wailsapp/wails/v3/pkg/events"
|
||||
)
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
// App abstracts the Wails application for the orchestrator.
|
||||
// After Spec D cleanup, only Quit() and Logger() remain —
|
||||
// all other Wails Manager APIs are accessed via IPC.
|
||||
type App interface {
|
||||
Dialog() DialogManager
|
||||
Env() EnvManager
|
||||
Event() EventManager
|
||||
Logger() Logger
|
||||
Quit()
|
||||
}
|
||||
|
||||
// DialogManager wraps Wails dialog operations.
|
||||
type DialogManager interface {
|
||||
Info() *application.MessageDialog
|
||||
Warning() *application.MessageDialog
|
||||
OpenFile() *application.OpenFileDialogStruct
|
||||
}
|
||||
|
||||
// EnvManager wraps Wails environment queries.
|
||||
type EnvManager interface {
|
||||
Info() application.EnvironmentInfo
|
||||
IsDarkMode() bool
|
||||
}
|
||||
|
||||
// EventManager wraps Wails application events.
|
||||
type EventManager interface {
|
||||
OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func()
|
||||
Emit(name string, data ...any) bool
|
||||
}
|
||||
|
||||
// Logger wraps Wails logging.
|
||||
type Logger interface {
|
||||
Info(message string, args ...any)
|
||||
|
|
@ -48,31 +25,5 @@ func newWailsApp(app *application.App) App {
|
|||
return &wailsApp{app: app}
|
||||
}
|
||||
|
||||
func (w *wailsApp) Dialog() DialogManager { return &wailsDialogManager{app: w.app} }
|
||||
func (w *wailsApp) Env() EnvManager { return &wailsEnvManager{app: w.app} }
|
||||
func (w *wailsApp) Event() EventManager { return &wailsEventManager{app: w.app} }
|
||||
func (w *wailsApp) Logger() Logger { return w.app.Logger }
|
||||
func (w *wailsApp) Quit() { w.app.Quit() }
|
||||
|
||||
type wailsDialogManager struct{ app *application.App }
|
||||
|
||||
func (d *wailsDialogManager) Info() *application.MessageDialog { return d.app.Dialog.Info() }
|
||||
func (d *wailsDialogManager) Warning() *application.MessageDialog { return d.app.Dialog.Warning() }
|
||||
func (d *wailsDialogManager) OpenFile() *application.OpenFileDialogStruct {
|
||||
return d.app.Dialog.OpenFile()
|
||||
}
|
||||
|
||||
type wailsEnvManager struct{ app *application.App }
|
||||
|
||||
func (e *wailsEnvManager) Info() application.EnvironmentInfo { return e.app.Env.Info() }
|
||||
func (e *wailsEnvManager) IsDarkMode() bool { return e.app.Env.IsDarkMode() }
|
||||
|
||||
type wailsEventManager struct{ app *application.App }
|
||||
|
||||
func (ev *wailsEventManager) OnApplicationEvent(eventType events.ApplicationEventType, handler func(*application.ApplicationEvent)) func() {
|
||||
return ev.app.Event.OnApplicationEvent(eventType, handler)
|
||||
}
|
||||
func (ev *wailsEventManager) Emit(name string, data ...any) bool {
|
||||
return ev.app.Event.Emit(name, data...)
|
||||
}
|
||||
|
||||
func (w *wailsApp) Logger() Logger { return w.app.Logger }
|
||||
func (w *wailsApp) Quit() { w.app.Quit() }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue