- migrate frontend to TypeScript (vue-tsc strict in build), upgrade all deps to latest (Vite 8, Tailwind 4, daisyUI 5, Pinia 4, vue-router 5) - restructure frontend dirs (api/components/common/layouts/styles/types/views) - drop Element Plus, add daisyUI TagInput; main CSS 490KB->163KB, entry JS 618KB->1.3KB - rewrite Dockerfile(.cn): frontend/backend stages pinned to $BUILDPLATFORM, CGO_ENABLED=0 cross-compile, no QEMU in multi-arch builds; add .dockerignore - local dev: Vite /api proxy + make dev targets; go:embed all:dist with .gitkeep so backend runs without prior frontend build - fix latent bugs: Keys.vue users ref, Settings.vue undefined userStore, Login.vue Ref-as-error display, res.error misuse - add REFACTOR_PLAN.md (phased refactor log)
66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"io/fs"
|
|
"log"
|
|
"opencatd-open/internal/cli"
|
|
"opencatd-open/internal/consts"
|
|
"opencatd-open/pkg/config"
|
|
"opencatd-open/pkg/store"
|
|
"opencatd-open/router"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// all:dist 使 dist 只含 .gitkeep 占位(尚未构建前端)时也能编译通过,
|
|
// 本地 go run ./cmd/openteam 无需先跑 pnpm build
|
|
//go:embed all:dist
|
|
var web embed.FS
|
|
|
|
func main() {
|
|
cfg, err := config.LoadConfig()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
db, err := store.InitDB(cfg)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
rootCmd := &cobra.Command{
|
|
Use: "openteam",
|
|
Short: "openteam cli",
|
|
Long: consts.Logo,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
router.SetRouter(cfg, db, &web)
|
|
},
|
|
}
|
|
|
|
rootCmd.AddCommand(cli.LoadCmd)
|
|
if err := rootCmd.Execute(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func printFilesAndDirs(fsys fs.FS, prefix string) error {
|
|
return fs.WalkDir(fsys, ".", func(p string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if d.IsDir() {
|
|
fmt.Printf("%s[DIR] %s\n", prefix, p)
|
|
} else {
|
|
info, err := d.Info()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Printf("%s[FILE] %s (%d bytes)\n", prefix, p, info.Size())
|
|
}
|
|
return nil
|
|
})
|
|
}
|