This commit is contained in:
cdle
2023-07-06 22:05:21 +08:00
parent 8ed0cc485f
commit 876a2e32bc
6 changed files with 64 additions and 25 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.1177c492.js"></script> <script src="/admin/umi.0643bb4a.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
+47 -6
View File
@@ -24,8 +24,10 @@ type RequestPluginResult struct {
Tab1 int `json:"tab1"` Tab1 int `json:"tab1"`
Tab2 int `json:"tab2"` Tab2 int `json:"tab2"`
Tab3 int `json:"tab3"` Tab3 int `json:"tab3"`
Tab string `json:"tab"`
Time time.Time `json:"time"` Time time.Time `json:"time"`
Classes map[string]int `json:"classes"` Classes map[string]int `json:"classes"`
Origins map[string]string `json:"origins"`
} }
var plugin_list = []*common.Function{} var plugin_list = []*common.Function{}
@@ -117,12 +119,15 @@ func initWebPluginList() {
return nil return nil
}) })
GinApi(GET, "/api/plugins/list.json", func(ctx *gin.Context) { GinApi(GET, "/api/plugins/list.json", func(ctx *gin.Context) {
// ctx.QueryArray()
origins := ctx.QueryArray("origin[]")
current := utils.Int(ctx.Query("current")) current := utils.Int(ctx.Query("current"))
pageSize := utils.Int(ctx.Query("pageSize")) pageSize := utils.Int(ctx.Query("pageSize"))
activeKey := ctx.Query("activeKey") activeKey := ctx.Query("activeKey")
init := ctx.Query("init") init := ctx.Query("init")
keyword := ctx.Query("keyword") keyword := ctx.Query("keyword")
class := ctx.Query("class") class := ctx.Query("class")
mclass := ctx.Query("mclass")
rr := RequestPluginResult{ rr := RequestPluginResult{
Success: true, Success: true,
} }
@@ -140,13 +145,33 @@ func initWebPluginList() {
} }
var list []*common.Function var list []*common.Function
if keyword == "" { if keyword == "" {
list = append(list, plugin_list...) if len(origins) == 0 {
} else { list = append(list, plugin_list...)
for _, f := range plugin_list {
if strings.Contains(f.Title, keyword) || strings.Contains(f.Organization, keyword) { } else {
list = append(list, f) for _, f := range plugin_list {
if Contains(origins, f.Organization) {
list = append(list, f)
}
} }
} }
} else {
if len(origins) == 0 {
for _, f := range plugin_list {
if strings.Contains(f.Title, keyword) || strings.Contains(f.Organization, keyword) {
list = append(list, f)
}
}
} else {
for _, f := range plugin_list {
if strings.Contains(f.Title, keyword) || strings.Contains(f.Organization, keyword) {
if Contains(origins, f.Organization) {
list = append(list, f)
}
}
}
}
} }
rr.Total = len(list) rr.Total = len(list)
tab1 := []*common.Function{} tab1 := []*common.Function{}
@@ -165,6 +190,7 @@ func initWebPluginList() {
classes[class] = append(classes[class], list[i]) classes[class] = append(classes[class], list[i])
} else { } else {
for _, class := range list[i].Classes { for _, class := range list[i].Classes {
class = strings.TrimRight(class, "类")
if _, ok := classes[class]; !ok { if _, ok := classes[class]; !ok {
classes[class] = []*common.Function{} classes[class] = []*common.Function{}
} }
@@ -181,7 +207,11 @@ func initWebPluginList() {
list, _ = classes[class] list, _ = classes[class]
} }
rr.Classes = classesNum rr.Classes = classesNum
var origins = map[string]string{}
for i := range list { //处理第二分类 for i := range list { //处理第二分类
if list[i].Organization != "" {
origins[list[i].Organization] = list[i].Organization
}
ded := false ded := false
for j := range fc { for j := range fc {
if list[i].UUID == fc[j].UUID { if list[i].UUID == fc[j].UUID {
@@ -198,7 +228,7 @@ func initWebPluginList() {
tab2 = append(tab2, list[i]) tab2 = append(tab2, list[i])
} }
} }
rr.Origins = origins
if activeKey == "tab2" { if activeKey == "tab2" {
list = tab2 list = tab2
rr.Tab1 = len(tab1) rr.Tab1 = len(tab1)
@@ -215,6 +245,17 @@ func initWebPluginList() {
rr.Tab2 = len(tab2) rr.Tab2 = len(tab2)
rr.Tab3 = len(tab3) rr.Tab3 = len(tab3)
} }
tab := ""
if mclass == "true" {
if rr.Tab2 > rr.Tab1 {
list = tab2
tab = "tab2"
} else {
list = tab1
tab = "tab1"
}
}
rr.Tab = tab
rr.Total = len(list) rr.Total = len(list)
if len(list) == 0 { if len(list) == 0 {
ctx.JSON(200, rr) ctx.JSON(200, rr)
+5 -7
View File
@@ -126,18 +126,16 @@ func init() {
proxies.Foreach(func(b1, b2 []byte) error { proxies.Foreach(func(b1, b2 []byte) error {
new := string(b2) new := string(b2)
var ncfg = ProxyConfig{} var ncfg = ProxyConfig{}
var params = map[string]interface{}{}
if strings.HasPrefix(new, "o:") { if strings.HasPrefix(new, "o:") {
err := json.Unmarshal([]byte(strings.Replace(new, "o:", "", 1)), &ncfg) var data = []byte(strings.Replace(new, "o:", "", 1))
err := json.Unmarshal(data, &ncfg)
json.Unmarshal(data, &params)
if err != nil { if err != nil {
console.Log("无法解析的代理数据:", err) console.Log("无法解析的代理数据:", err)
return nil return nil
} }
// ncfg.RuleMatcher, err = preprocessRules(ncfg.Rules) p, err := adapter.ParseProxy(params)
if err != nil {
console.Log("无法处理的代理匹配规则:", err)
return nil
}
p, err := adapter.ParseProxy(structToMap(ncfg))
if err != nil { if err != nil {
console.Log("无法解析的代理:", err) console.Log("无法解析的代理:", err)
return nil return nil