Files
cdp_hub/cmd/chub/main.go
T

47 lines
977 B
Go
Raw Normal View History

2026-07-22 14:51:11 +08:00
package main
import (
"context"
2026-07-22 15:13:55 +08:00
"log/slog"
2026-07-22 14:51:11 +08:00
"os"
"chub/internal/platform/logging"
2026-07-22 15:13:55 +08:00
"chub/internal/ui"
"gioui.org/app"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/unit"
"gioui.org/widget/material"
2026-07-22 14:51:11 +08:00
)
const version = "0.1.0-dev"
func main() {
ctx := context.Background()
logger := logging.New(os.Stderr)
logger.InfoContext(ctx, "chub starting", "version", version)
2026-07-22 15:13:55 +08:00
go runWindow(logger)
app.Main()
}
func runWindow(logger *slog.Logger) {
window := new(app.Window)
window.Option(app.Title("Chub 浏览器管理"), app.Size(unit.Dp(1100), unit.Dp(720)))
theme := material.NewTheme()
shell := ui.NewShell(theme)
var ops op.Ops
for {
switch event := window.Event().(type) {
case app.DestroyEvent:
if event.Err != nil {
logger.ErrorContext(context.Background(), "chub window closed", "error", event.Err)
}
return
case app.FrameEvent:
gtx := app.NewContext(&ops, event)
shell.Layout(layout.Context(gtx))
event.Frame(gtx.Ops)
}
}
2026-07-22 14:51:11 +08:00
}