Files
lucemon/app.go
Jonathan Atta 17beab746e feat: add Wails runtime library and initial application setup
- Created package.json for Wails JavaScript runtime library.
- Added TypeScript definitions for runtime functions.
- Implemented runtime.js with event handling and logging functions.
- Initialized Go module with dependencies for Wails and other libraries.
- Added main.go for application entry point and asset embedding.
- Configured wails.json for application settings and build commands.
2026-03-11 17:06:52 +01:00

59 lines
1.3 KiB
Go

package main
import (
"context"
"fmt"
"sysmon/backend"
)
// App struct
type App struct {
ctx context.Context
sys *backend.SysInfo
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
a.InitBackend(ctx)
}
// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}
// Initialise backend SysInfo on startup and expose its methods
func (a *App) InitBackend(ctx context.Context) {
if ctx == nil {
ctx = context.Background()
}
a.ctx = ctx
a.sys = backend.NewSysInfo(a.ctx)
}
// GetMetrics proxies to backend.SysInfo.GetMetrics
func (a *App) GetMetrics() (*backend.Metrics, error) {
if a.sys == nil {
a.InitBackend(a.ctx)
}
return a.sys.GetMetrics()
}
// GetProcessDetail returns all available details for the given PID.
func (a *App) GetProcessDetail(pid int32) (*backend.ProcessDetail, error) {
return backend.FetchProcessDetail(pid)
}
// KillProcess terminates a process by PID. Set force=true for SIGKILL.
func (a *App) KillProcess(pid int32, force bool) error {
return backend.KillProcess(pid, force)
}