diff --git a/README.md b/README.md
index 836a407..fbc9882 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@
| template | string | 否 | - | 外部模板链接或内部模板名称 |
| ruleProvider | string | 否 | - | 格式 `[Behavior,Url,Group,Prepend,Name],[Behavior,Url,Group,Prepend,Name]...`,其中 `Group` 是该规则集所走的策略组名,`Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到MATCH规则之前) |
| rule | string | 否 | - | 格式 `[Rule,Prepend],[Rule,Prepend]...`,其中 `Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到MATCH规则之前) |
-| autoTest | bool | 否 | `false` | 指定国家策略组是否自动测速 |
+| autoTest | bool | 否 | `false` | 国家策略组是否自动测速 |
| lazy | bool | 否 | `false` | 自动测速是否启用 lazy |
| sort | string | 否 | `nameasc` | 国家策略组排序策略,可选值 `nameasc`、`namedesc`、`sizeasc`、`sizedesc` |
@@ -64,4 +64,4 @@
## TODO
-- [ ] 可视化面板
\ No newline at end of file
+- [x] 可视化面板
\ No newline at end of file
diff --git a/api/route.go b/api/route.go
index 4feb5e9..e56cc39 100644
--- a/api/route.go
+++ b/api/route.go
@@ -1,13 +1,25 @@
package api
import (
+ "embed"
"github.com/gin-gonic/gin"
+ "html/template"
"sub2clash/api/controller"
"sub2clash/middleware"
)
+//go:embed templates/*
+var templates embed.FS
+
func SetRoute(r *gin.Engine) {
r.Use(middleware.ZapLogger())
+ // 使用内嵌的模板文件
+ r.SetHTMLTemplate(template.Must(template.New("").ParseFS(templates, "templates/*")))
+ r.GET(
+ "/", func(c *gin.Context) {
+ c.HTML(200, "index.html", nil)
+ },
+ )
r.GET(
"/clash", func(c *gin.Context) {
controller.SubmodHandler(c)
diff --git a/api/templates/index.html b/api/templates/index.html
new file mode 100644
index 0000000..2e75aa0
--- /dev/null
+++ b/api/templates/index.html
@@ -0,0 +1,279 @@
+
+
+
+
+
+
+ sub2clash
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
sub2clash
+
通用订阅链接转 Clash(Meta) 配置工具 使用文档
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/templates/template_meta.yaml b/templates/template_meta.yaml
index ea0bcf0..ec264c5 100644
--- a/templates/template_meta.yaml
+++ b/templates/template_meta.yaml
@@ -13,6 +13,12 @@ proxy-groups:
- name: 手动切换
type: select
proxies:
+ - name: 微软服务
+ type: select
+ proxies:
+ - 节点选择
+ - 手动切换
+ - DIRECT
- name: 游戏平台
type: select
proxies:
@@ -48,14 +54,14 @@ proxy-groups:
- 手动切换
- DIRECT
rules:
- - GEOSITE,private,全球直连
+ - GEOSITE,private,全球直连,no-resolve
- GEOIP,private,全球直连
- GEOSITE,category-ads-all,广告拦截
- - GEOSITE,CN,全球直连
- - GEOIP,CN,全球直连
- - GEOSITE,biliintl,哔哩哔哩
+ - GEOSITE,microsoft,微软服务
- GEOSITE,bilibili,哔哩哔哩
- GEOSITE,bahamut,巴哈姆特
- GEOSITE,category-games,游戏平台
- GEOSITE,geolocation-!cn,节点选择
+ - GEOSITE,CN,全球直连
+ - GEOIP,CN,全球直连
- MATCH,漏网之鱼
\ No newline at end of file
diff --git a/utils/template.go b/utils/template.go
index cd90a45..781a099 100644
--- a/utils/template.go
+++ b/utils/template.go
@@ -8,7 +8,7 @@ import (
)
// LoadTemplate 加载模板
-// template 模板文件名
+// templates 模板文件名
func LoadTemplate(template string) ([]byte, error) {
tPath := filepath.Join("templates", template)
if _, err := os.Stat(tPath); err == nil {
diff --git a/validator/sub.go b/validator/sub.go
index bd2b649..4db8340 100644
--- a/validator/sub.go
+++ b/validator/sub.go
@@ -17,7 +17,7 @@ type SubQuery struct {
Proxy string `form:"proxy" binding:""`
Proxies []string `form:"-" binding:""`
Refresh bool `form:"refresh,default=false" binding:""`
- Template string `form:"template" binding:""`
+ Template string `form:"templates" binding:""`
RuleProvider string `form:"ruleProvider" binding:""`
RuleProviders []RuleProviderStruct `form:"-" binding:""`
Rule string `form:"rule" binding:""`
@@ -101,6 +101,14 @@ func ParseQuery(c *gin.Context) (SubQuery, error) {
},
)
}
+ // 校验 Rule-Provider 是否有重名
+ names := make(map[string]bool)
+ for _, ruleProvider := range query.RuleProviders {
+ if _, ok := names[ruleProvider.Name]; ok {
+ return SubQuery{}, errors.New("参数错误: Rule-Provider 名称重复")
+ }
+ names[ruleProvider.Name] = true
+ }
} else {
query.RuleProviders = nil
}