2023-10-26 10:07:08 +08:00
|
|
|
package config
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
// wxHelper
|
|
|
|
// @description: 微信助手
|
|
|
|
type wechat struct {
|
2023-12-06 10:16:52 +08:00
|
|
|
Host string `json:"host" yaml:"host"` // 接口地址
|
2024-01-09 10:48:21 +08:00
|
|
|
VncUrl string `json:"vncUrl" yaml:"vncUrl"` // vnc页面地址
|
2023-12-06 10:16:52 +08:00
|
|
|
AutoSetCallback bool `json:"autoSetCallback" yaml:"autoSetCallback"` // 是否自动设置回调地址
|
|
|
|
Callback string `json:"callback" yaml:"callback"` // 回调地址
|
|
|
|
Forward []string `json:"forward" yaml:"forward"` // 转发地址
|
2023-10-26 10:07:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check
|
|
|
|
// @description: 检查配置是否可用
|
|
|
|
// @receiver w
|
|
|
|
// @return bool
|
|
|
|
func (w wechat) Check() bool {
|
|
|
|
if w.Host == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if w.AutoSetCallback && w.Callback == "" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w wechat) GetURL(uri string) string {
|
|
|
|
host := w.Host
|
|
|
|
if !strings.HasPrefix(w.Host, "http://") {
|
|
|
|
host = "http://" + w.Host
|
|
|
|
}
|
|
|
|
return host + uri
|
|
|
|
}
|