improve path processing

This commit is contained in:
josc146 2024-02-03 20:29:56 +08:00
parent e07f0fa6e3
commit 5329537a2f
2 changed files with 12 additions and 7 deletions

View File

@ -23,6 +23,7 @@ type App struct {
ctx context.Context
HasConfigData bool
ConfigData map[string]any
Dev bool
exDir string
cmdPrefix string
}
@ -48,7 +49,11 @@ func (a *App) OnStartup(ctx context.Context) {
a.exDir = filepath.Dir(ex) + "/"
a.cmdPrefix = "cd " + a.exDir + " && "
}
os.Chdir(a.exDir)
if a.Dev {
a.exDir = ""
} else {
os.Chdir(a.exDir)
}
}
os.Chmod(a.exDir+"backend-rust/webgpu_server", 0777)

12
main.go
View File

@ -67,9 +67,12 @@ var midiAssets embed.FS
var components embed.FS
func main() {
dev := true
// Create an instance of the app structure
app := backend.NewApp()
app.Dev = true
if buildInfo, ok := debug.ReadBuildInfo(); !ok || strings.Contains(buildInfo.String(), "-ldflags") {
dev = false
app.Dev = false
backend.CopyEmbed(assets)
os.RemoveAll("./py310/Lib/site-packages/cyac-1.7.dist-info")
@ -83,9 +86,6 @@ func main() {
backend.CopyEmbed(components)
}
// Create an instance of the app structure
app := backend.NewApp()
var zoomFactor float64 = 1.0
data, err := app.ReadJson("config.json")
if err == nil {
@ -99,7 +99,7 @@ func main() {
}
var logger wailsLogger.Logger
if dev {
if app.Dev {
logger = wailsLogger.NewDefaultLogger()
} else {
logger = wailsLogger.NewFileLogger("crash.log")