This commit is contained in:
1-6
2023-07-17 09:36:07 +08:00
parent a338fd5fb8
commit 568d9fc3cf
5 changed files with 51 additions and 26 deletions
+1 -1
View File
@@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/admin/umi.ce22547e.js"></script> <script src="/admin/umi.d07105ee.js"></script>
</body></html> </body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+35 -11
View File
@@ -28,6 +28,7 @@ type Sender struct {
ChatID string `json:"chat_id"` ChatID string `json:"chat_id"`
UserID string `json:"user_id"` UserID string `json:"user_id"`
Platfrom string `json:"platform"` Platfrom string `json:"platform"`
BotID string `json:"bot_id"`
} }
type Tasks struct { type Tasks struct {
@@ -43,6 +44,7 @@ type Tasks struct {
Remark string `json:"remark"` Remark string `json:"remark"`
Enable bool `json:"enable"` Enable bool `json:"enable"`
Handle func() `json:"-"` Handle func() `json:"-"`
Icons []interface{} `json:"icons"`
} }
var pts = []*Tasks{} var pts = []*Tasks{}
@@ -51,7 +53,7 @@ func RegistTasks(pt *Tasks) {
pt.Handle = func() { pt.Handle = func() {
content := pt.Command content := pt.Command
for _, meta := range pt.Senders { for _, meta := range pt.Senders {
adapter, _ := GetAdapter(meta.Platfrom, "") adapter, _ := GetAdapter(meta.Platfrom, meta.BotID)
if adapter != nil { if adapter != nil {
sender := adapter.Sender() sender := adapter.Sender()
sender.SetFsps(&common.FakerSenderParams{ sender.SetFsps(&common.FakerSenderParams{
@@ -96,8 +98,8 @@ func init() {
return nil return nil
}) })
sort.Sort(byCreatedAt2(pts)) sort.Sort(byCreatedAt2(pts))
for i := range cgs { for i := range pts {
cgs[i].Index = i + 1 pts[i].Index = i + 1
} }
storage.Watch(tasks, nil, func(old, new, key string) *storage.Final { storage.Watch(tasks, nil, func(old, new, key string) *storage.Final {
console.Log("已更新计划任务") console.Log("已更新计划任务")
@@ -173,6 +175,22 @@ func init() {
begin = end begin = end
} }
rr.Data = pts[begin:end] rr.Data = pts[begin:end]
for i := range rr.Data {
rr.Data[i].Icons = []interface{}{}
for _, script := range rr.Data[i].Scripts {
for _, f := range Functions {
if f.UUID == script {
if f.Icon != "" {
rr.Data[i].Icons = append(rr.Data[i].Icons, map[string]interface{}{
"link": f.Icon,
"title": f.Title,
})
break
}
}
}
}
}
ctx.JSON(200, rr) ctx.JSON(200, rr)
}) })
GinApi(POST, "/api/tasks", RequireAuth, func(ctx *gin.Context) { GinApi(POST, "/api/tasks", RequireAuth, func(ctx *gin.Context) {
@@ -230,6 +248,7 @@ func init() {
"success": false, "success": false,
"errorMessage": "Senders错误:" + err.Error(), "errorMessage": "Senders错误:" + err.Error(),
}) })
return
} }
tp.Senders = ss tp.Senders = ss
case "command": case "command":
@@ -319,28 +338,33 @@ func init() {
err := json.Unmarshal(b2, v) err := json.Unmarshal(b2, v)
if err == nil { if err == nil {
if v.Group { if v.Group {
if Contains(user_ids, code) {
user_names = append(user_names, NicklabeL{
Label: fmt.Sprintf("%s(%s)", v.Value, code),
Value: code,
})
}
} else {
if Contains(chat_ids, code) { if Contains(chat_ids, code) {
group_names = append(group_names, NicklabeL{ group_names = append(group_names, NicklabeL{
Label: fmt.Sprintf("%s(%s)", v.Value, code), Label: fmt.Sprintf("%s(%s)", v.Value, code),
Value: code, Value: code,
}) })
} }
} else {
if Contains(user_ids, code) {
user_names = append(user_names, NicklabeL{
Label: fmt.Sprintf("%s(%s)", v.Value, code),
Value: code,
})
}
} }
} }
return nil return nil
}) })
platforms := map[string][]string{}
for _, plt := range getPltsArray() {
platforms[plt] = GetAdapterBotsID(plt)
}
ctx.JSON(200, map[string]interface{}{ ctx.JSON(200, map[string]interface{}{
"success": true, "success": true,
"data": map[string]interface{}{ "data": map[string]interface{}{
"scripts": scripts, "scripts": scripts,
"platforms": getPltsArray(), "platforms": platforms,
"user_names": user_names, "user_names": user_names,
"group_names": group_names, "group_names": group_names,
}, },