feat: wrap message by fluent ui toast

This commit is contained in:
zhaoyupeng
2024-09-27 14:52:10 +08:00
parent 77dff6649d
commit b2c13508f4
27 changed files with 677 additions and 102 deletions

View File

@ -1,13 +1,13 @@
package controller
import (
"bytes"
"context"
"encoding/json"
"github.com/loveuer/nf-disk/internal/api"
"github.com/loveuer/nf-disk/internal/db"
"github.com/loveuer/nf-disk/internal/model"
"github.com/loveuer/nf-disk/internal/tool"
"github.com/loveuer/nf-disk/ndh"
"github.com/loveuer/nf/nft/log"
"nf-disk/internal/ndh"
"nf-disk/internal/tool"
"strings"
)
type App struct {
@ -22,24 +22,11 @@ func NewApp() *App {
}
func (a *App) Startup(ctx context.Context) {
a.ctx = ctx
log.Info("app startup!!!")
initApi(a)
}
func (a *App) Invoke(path string, req string) (res string) {
log.Info("app invoke: path = %s, req = %s", path, req)
handler, ok := a.handlers[path]
if !ok {
return `{"err": "handler not found", "status": 404}`
}
var buf bytes.Buffer
ctx := ndh.NewCtx(tool.Timeout(), json.NewDecoder(strings.NewReader(req)), &buf)
if err := handler(ctx); err != nil {
return err.Error()
}
return buf.String()
a.ctx = ctx
tool.Must(db.Init(ctx, "sqlite::memory", db.OptSqliteByMem(nil)))
tool.Must(model.Init(db.Default.Session()))
tool.Must(api.Init(ctx))
}