clash api: download clash-dashboard if external-ui directory is empty

This commit is contained in:
世界
2023-04-09 12:39:26 +08:00
parent 107a9a3b51
commit 2afe662646
8 changed files with 352 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ const dirName = "sing-box"
var (
basePath string
tempPath string
resourcePaths []string
)
@@ -22,10 +23,21 @@ func BasePath(name string) string {
return filepath.Join(basePath, name)
}
func CreateTemp(pattern string) (*os.File, error) {
if tempPath == "" {
tempPath = os.TempDir()
}
return os.CreateTemp(tempPath, pattern)
}
func SetBasePath(path string) {
basePath = path
}
func SetTempPath(path string) {
tempPath = path
}
func FindPath(name string) (string, bool) {
name = os.ExpandEnv(name)
if rw.FileExists(name) {