110 lines
2.4 KiB
Go
110 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"verstak/internal/core/actions"
|
|
"verstak/internal/core/activity"
|
|
"verstak/internal/core/config"
|
|
"verstak/internal/core/files"
|
|
"verstak/internal/core/nodes"
|
|
"verstak/internal/core/notes"
|
|
"verstak/internal/core/plugins"
|
|
"verstak/internal/core/search"
|
|
"verstak/internal/core/storage"
|
|
syncsvc "verstak/internal/core/sync"
|
|
"verstak/internal/core/templates"
|
|
"verstak/internal/core/worklog"
|
|
|
|
"github.com/wailsapp/wails/v2"
|
|
"github.com/wailsapp/wails/v2/pkg/options"
|
|
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
|
)
|
|
|
|
//go:embed all:frontend-dist
|
|
var assets embed.FS
|
|
|
|
func main() {
|
|
vaultPath := "."
|
|
if len(os.Args) > 1 {
|
|
vaultPath = os.Args[1]
|
|
}
|
|
|
|
abs, err := filepath.Abs(vaultPath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
dbPath := filepath.Join(abs, ".verstak", "index.db")
|
|
db, err := storage.Open(dbPath)
|
|
if err != nil {
|
|
log.Fatalf("Open vault: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
// Init core services
|
|
nodeRepo := nodes.NewRepository(db)
|
|
fileSvc := files.NewService(db, abs, nodeRepo)
|
|
noteSvc := notes.NewService(db, abs, nodeRepo, fileSvc)
|
|
actionSvc := actions.NewService(db)
|
|
activitySvc := activity.NewService(db)
|
|
worklogSvc := worklog.NewService(db)
|
|
searchSvc := search.NewService(db)
|
|
pm := plugins.NewManager(abs)
|
|
pm.Discover()
|
|
|
|
templatesReg := templates.NewRegistry()
|
|
if err := templatesReg.LoadSystem(); err != nil {
|
|
log.Printf("warning: failed to load system templates: %v", err)
|
|
}
|
|
|
|
// Sync service — use configured device ID or vault ID as fallback.
|
|
deviceID := ""
|
|
if cfg, err := config.Load(abs); err == nil {
|
|
deviceID = cfg.Sync.DeviceID
|
|
}
|
|
if deviceID == "" {
|
|
deviceID = "gui-" + abs[:8]
|
|
}
|
|
syncSvc := syncsvc.NewService(db, deviceID)
|
|
|
|
app := &App{
|
|
db: db,
|
|
nodes: nodeRepo,
|
|
templates: templatesReg,
|
|
files: fileSvc,
|
|
notes: noteSvc,
|
|
activity: activitySvc,
|
|
actions: actionSvc,
|
|
worklog: worklogSvc,
|
|
search: searchSvc,
|
|
plugins: pm,
|
|
sync: syncSvc,
|
|
vault: abs,
|
|
}
|
|
|
|
err = wails.Run(&options.App{
|
|
Title: "Верстак",
|
|
Width: 1280,
|
|
Height: 800,
|
|
MinWidth: 800,
|
|
MinHeight: 600,
|
|
BackgroundColour: &options.RGBA{R: 19, G: 19, B: 31, A: 1},
|
|
AssetServer: &assetserver.Options{
|
|
Assets: assets,
|
|
},
|
|
OnStartup: app.startup,
|
|
DragAndDrop: &options.DragAndDrop{
|
|
EnableFileDrop: true,
|
|
},
|
|
Bind: []interface{}{app},
|
|
})
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|