mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: update external-ui
This commit is contained in:
parent
fd3ba21a8f
commit
b89e997f9a
|
@ -608,6 +608,8 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ExternalUIFolder = ExternalUIPath
|
||||
}
|
||||
|
||||
cfg.Tun.RedirectToTun = cfg.EBpf.RedirectToTun
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -24,29 +26,29 @@ func UpdateUI() error {
|
|||
xdMutex.Lock()
|
||||
defer xdMutex.Unlock()
|
||||
|
||||
if ExternalUIPath == "" || ExternalUIFolder == "" || ExternalUIName == "" {
|
||||
if ExternalUIPath == "" || ExternalUIFolder == "" {
|
||||
return fmt.Errorf("ExternalUI configure incomplete")
|
||||
}
|
||||
|
||||
err := cleanup(ExternalUIFolder)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("cleanup exist file error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := downloadForBytes(ExternalUIURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't download file: %w", err)
|
||||
}
|
||||
|
||||
saved := path.Join(ExternalUIPath, "download.zip")
|
||||
saved := path.Join(C.Path.HomeDir(), "download.zip")
|
||||
if saveFile(data, saved) != nil {
|
||||
return fmt.Errorf("can't save zip file: %w", err)
|
||||
}
|
||||
defer os.Remove(saved)
|
||||
|
||||
unzipFolder, err := unzip(saved, ExternalUIPath)
|
||||
err = cleanup(ExternalUIFolder)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("cleanup exist file error: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
unzipFolder, err := unzip(saved, C.Path.HomeDir())
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't extract zip file: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user