🎨 Improve marketplace loading when offline https://github.com/siyuan-note/siyuan/issues/12050
This commit is contained in:
parent
b908bae496
commit
c86ed9bd59
7 changed files with 35 additions and 1 deletions
|
@ -37,6 +37,11 @@ type Icon struct {
|
|||
func Icons() (icons []*Icon) {
|
||||
icons = []*Icon{}
|
||||
|
||||
isOnline := isBazzarOnline()
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
|
||||
stageIndex, err := getStageIndex("icons")
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
@ -482,6 +482,15 @@ func isOutdatedTemplate(template *Template, bazaarTemplates []*Template) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func isBazzarOnline() (ret bool) {
|
||||
// Improve marketplace loading when offline https://github.com/siyuan-note/siyuan/issues/12050
|
||||
ret = util.IsOnline(util.BazaarOSSServer, true)
|
||||
if !ret {
|
||||
util.PushErrMsg(util.Langs[util.Lang][24], 5000)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetPackageREADME(repoURL, repoHash, packageType string) (ret string) {
|
||||
repoURLHash := repoURL + "@" + repoHash
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ type Plugin struct {
|
|||
func Plugins(frontend string) (plugins []*Plugin) {
|
||||
plugins = []*Plugin{}
|
||||
|
||||
isOnline := isBazzarOnline()
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
|
||||
stageIndex, err := getStageIndex("plugins")
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
@ -38,6 +38,11 @@ type Template struct {
|
|||
func Templates() (templates []*Template) {
|
||||
templates = []*Template{}
|
||||
|
||||
isOnline := isBazzarOnline()
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
|
||||
stageIndex, err := getStageIndex("templates")
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
@ -39,6 +39,11 @@ type Theme struct {
|
|||
func Themes() (ret []*Theme) {
|
||||
ret = []*Theme{}
|
||||
|
||||
isOnline := isBazzarOnline()
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
|
||||
stageIndex, err := getStageIndex("themes")
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
@ -37,6 +37,11 @@ type Widget struct {
|
|||
func Widgets() (widgets []*Widget) {
|
||||
widgets = []*Widget{}
|
||||
|
||||
isOnline := isBazzarOnline()
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
|
||||
stageIndex, err := getStageIndex("widgets")
|
||||
if nil != err {
|
||||
return
|
||||
|
|
|
@ -111,7 +111,7 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
|||
}
|
||||
c.SetUserAgent(UserAgent)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := 0; i < 2; i++ {
|
||||
resp, err := c.R().Get(checkURL)
|
||||
|
||||
if resp.GetHeader("Location") != "" {
|
||||
|
|
Loading…
Add table
Reference in a new issue