Skip to content

Commit 3f29c07

Browse files
committed
feat: integrate engine service with task management and UI components
1 parent dd4bcee commit 3f29c07

File tree

17 files changed

+1635
-11
lines changed

17 files changed

+1635
-11
lines changed

backend/engine/engine.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package engine
2+
3+
import (
4+
"context"
5+
"muu-alpha/backend/pi"
6+
"os"
7+
"path/filepath"
8+
"sync"
9+
10+
"github.com/MaaXYZ/maa-framework-go/v3"
11+
)
12+
13+
var (
14+
srvInst *service
15+
srvOnce sync.Once
16+
)
17+
18+
func Engine() *service {
19+
srvOnce.Do(func() {
20+
srvInst = &service{}
21+
})
22+
return srvInst
23+
}
24+
25+
func Startup(ctx context.Context) {
26+
exePath, err := os.Executable()
27+
if err != nil {
28+
panic(err) // todo
29+
}
30+
exeDir := filepath.Dir(exePath)
31+
libDir := filepath.Join(exeDir, "lib")
32+
logDir := filepath.Join(exeDir, "log")
33+
34+
maa.Init(
35+
maa.WithLibDir(libDir),
36+
maa.WithLogDir(logDir),
37+
)
38+
s := Engine()
39+
s.ctx = ctx
40+
}
41+
42+
func GetPathsByResName(name string) []string {
43+
piSrv := pi.PI()
44+
v2Loaded := piSrv.V2Loaded()
45+
46+
if v2Loaded == nil || v2Loaded.Interface == nil {
47+
return []string{}
48+
}
49+
50+
iface := v2Loaded.Interface
51+
52+
for _, res := range iface.Resource {
53+
if res.Name == name {
54+
return res.Path
55+
}
56+
}
57+
58+
return []string{}
59+
}

0 commit comments

Comments
 (0)