mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
🎨 Improve the fallback logic for fetching README in the marketplace (#16551)
* 加载已下载插件列表时,如果插件指定 README 文件不存在,则回退到 README.md https://github.com/siyuan-note/siyuan/issues/14636#issuecomment-3035905944 * 加载已下载插件列表时,如果插件指定 README 文件不存在,则回退到 README.md https://github.com/siyuan-note/siyuan/issues/14636#issuecomment-3035905944 * 提取公共函数 * 获取首选 Readme Name Desc 时优先回退到指定的默认值 * 兼容赞助链接 * 在线获取 README 时最后回退到 README.md
This commit is contained in:
parent
d11ed21f06
commit
058ade01c7
6 changed files with 108 additions and 78 deletions
|
|
@ -171,9 +171,9 @@ func InstalledThemes() (ret []*Theme) {
|
|||
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
||||
theme.PreferredName = GetPreferredName(theme.Package)
|
||||
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "theme.json"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
logging.LogWarnf("stat install theme.json failed: %s", statErr)
|
||||
continue
|
||||
}
|
||||
theme.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
|
|
@ -185,14 +185,7 @@ func InstalledThemes() (ret []*Theme) {
|
|||
packageInstallSizeCache.SetDefault(theme.RepoURL, is)
|
||||
}
|
||||
theme.HInstallSize = humanize.BytesCustomCeil(uint64(theme.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(theme.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
logging.LogWarnf("read installed README.md failed: %s", readErr)
|
||||
continue
|
||||
}
|
||||
|
||||
theme.PreferredReadme, _ = renderLocalREADME("/appearance/themes/"+dirName+"/", readme)
|
||||
theme.PreferredReadme = loadInstalledReadme(installPath, "/appearance/themes/"+dirName+"/", theme.Readme)
|
||||
theme.Outdated = isOutdatedTheme(theme, bazaarThemes)
|
||||
ret = append(ret, theme)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue