mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
🎨 集市支持已安装的包单独显示 https://github.com/siyuan-note/siyuan/issues/5678
This commit is contained in:
parent
a563861ab8
commit
29021c8d02
6 changed files with 109 additions and 35 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue