diff --git a/backend/api/filter.go b/backend/api/filter.go index b3c176f..2b0a086 100644 --- a/backend/api/filter.go +++ b/backend/api/filter.go @@ -103,6 +103,7 @@ func Filter(r chi.Router) { return case 2: spider.Save2Local(proxies, "0.yaml") + reloadDefaultConfig() render.PlainText(w, r, "true") return case 3: @@ -215,7 +216,3 @@ func judge(array []string, key string) bool { return false } - -func saveFile() { - -} diff --git a/backend/api/getter.go b/backend/api/getter.go index 37339f8..093f434 100644 --- a/backend/api/getter.go +++ b/backend/api/getter.go @@ -40,16 +40,7 @@ func crawling(w http.ResponseWriter, r *http.Request) { return } - bytes := cache.Get(constant.DefaultProfile) - profile := resolve.Profile{} - err := json.Unmarshal(bytes, &profile) - if err != nil { - render.NoContent(w, r) - return - } - if profile.Selected { - meta.StartCore(profile, true) - } + reloadDefaultConfig() render.NoContent(w, r) } @@ -102,3 +93,15 @@ func deleteGetter(w http.ResponseWriter, r *http.Request) { render.NoContent(w, r) } + +func reloadDefaultConfig() { + bytes := cache.Get(constant.DefaultProfile) + profile := resolve.Profile{} + err := json.Unmarshal(bytes, &profile) + if err != nil { + return + } + if profile.Selected { + meta.StartCore(profile, true) + } +}