🎨 移除多余模块

This commit is contained in:
2026-04-08 12:19:24 +08:00
parent 22bb5fdc94
commit 7599146f24
192 changed files with 623 additions and 13983 deletions

View File

@@ -1,7 +1,6 @@
package ast
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/pkg/errors"
"go/ast"
"go/format"
@@ -61,7 +60,7 @@ func (a *Base) Format(filename string, writer io.Writer, file *ast.File) error {
// RelativePath 绝对路径转相对路径
func (a *Base) RelativePath(filePath string) string {
server := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server)
server := resolveServerRoot()
hasServer := strings.Index(filePath, server)
if hasServer != -1 {
filePath = strings.TrimPrefix(filePath, server)
@@ -73,9 +72,30 @@ func (a *Base) RelativePath(filePath string) string {
// AbsolutePath 相对路径转绝对路径
func (a *Base) AbsolutePath(filePath string) string {
server := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server)
server := resolveServerRoot()
keys := strings.Split(filePath, "/")
filePath = filepath.Join(keys...)
filePath = filepath.Join(server, filePath)
return filePath
}
func resolveProjectRoot() string {
if cwd, err := os.Getwd(); err == nil {
if filepath.Base(cwd) == "server" {
return filepath.Dir(cwd)
}
if _, err := os.Stat(filepath.Join(cwd, "server")); err == nil {
return cwd
}
return cwd
}
return "."
}
func resolveServerRoot() string {
root := resolveProjectRoot()
if filepath.Base(root) == "server" {
return root
}
return filepath.Join(root, "server")
}