fix generateconfig

This commit is contained in:
huyunfan 2024-12-17 15:26:23 +08:00
parent b2b9ef41cd
commit 98f6d47bfd

View File

@ -263,6 +263,7 @@ func main() {
// 下载 Clash 配置 // 下载 Clash 配置
authorized.GET("/download", func(c *gin.Context) { authorized.GET("/download", func(c *gin.Context) {
service.GenerateConfig()
if _, err := os.Stat(clashConfigPath); os.IsNotExist(err) { if _, err := os.Stat(clashConfigPath); os.IsNotExist(err) {
c.String(http.StatusNotFound, "Clash configuration file not found") c.String(http.StatusNotFound, "Clash configuration file not found")
return return
@ -272,6 +273,7 @@ func main() {
// 将 Clash 配置放入剪贴板 // 将 Clash 配置放入剪贴板
authorized.GET("/clipboard", func(c *gin.Context) { authorized.GET("/clipboard", func(c *gin.Context) {
service.GenerateConfig()
config, err := readClashConfig() config, err := readClashConfig()
if err != nil { if err != nil {
c.String(http.StatusInternalServerError, fmt.Sprintf("Error reading Clash config: %v", err)) c.String(http.StatusInternalServerError, fmt.Sprintf("Error reading Clash config: %v", err))