🎨 集市支持已安装的包单独显示 https://github.com/siyuan-note/siyuan/issues/5678

This commit is contained in:
Liang Ding 2022-09-01 19:37:33 +08:00
parent a563861ab8
commit 29021c8d02
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 109 additions and 35 deletions

View file

@ -178,9 +178,7 @@ func InstalledThemes() (ret []*Theme) {
}
theme.README = gulu.Str.FromBytes(readme)
if !existThemes(ret, theme) {
ret = append(ret, theme)
}
ret = append(ret, theme)
}
return
}
@ -189,15 +187,6 @@ func isBuiltInTheme(dirName string) bool {
return "daylight" == dirName || "midnight" == dirName
}
func existThemes(themes []*Theme, theme *Theme) bool {
for _, t := range themes {
if t.Name == theme.Name {
return true
}
}
return false
}
func InstallTheme(repoURL, repoHash, installPath string, systemID string) error {
repoURLHash := repoURL + "@" + repoHash
data, err := downloadPackage(repoURLHash, true, systemID)
@ -215,25 +204,3 @@ func UninstallTheme(installPath string) error {
//logging.Logger.Infof("uninstalled theme [%s]", installPath)
return nil
}
func ThemeJSON(themeName string) (ret map[string]interface{}, err error) {
p := filepath.Join(util.ThemesPath, themeName, "theme.json")
if !gulu.File.IsExist(p) {
err = os.ErrNotExist
return
}
data, err := os.ReadFile(p)
if nil != err {
logging.LogErrorf("read theme.json [%s] failed: %s", p, err)
return
}
if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
logging.LogErrorf("parse theme.json [%s] failed: %s", p, err)
return
}
if 5 > len(ret) {
logging.LogWarnf("invalid theme.json [%s]", p)
return nil, errors.New("invalid theme.json")
}
return
}