mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve network img convert to local https://github.com/siyuan-note/siyuan/issues/13936
This commit is contained in:
parent
5143121ac4
commit
8e90578a21
13 changed files with 40 additions and 14 deletions
|
|
@ -98,6 +98,7 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
|
|||
EnableInsecureSkipVerify().
|
||||
SetProxy(httpclient.ProxyFromEnvironment)
|
||||
|
||||
forbiddenCount := 0
|
||||
destNodes := getRemoteAssetsLinkDestsInTree(tree, onlyImg)
|
||||
for _, destNode := range destNodes {
|
||||
dests := getRemoteAssetsLinkDests(destNode, onlyImg)
|
||||
|
|
@ -172,6 +173,10 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
|
|||
request.SetHeader("Referer", originalURL) // 改进浏览器剪藏扩展转换本地图片成功率 https://github.com/siyuan-note/siyuan/issues/7464
|
||||
}
|
||||
resp, reqErr := request.Get(u)
|
||||
if http.StatusForbidden == resp.StatusCode || http.StatusUnauthorized == resp.StatusCode {
|
||||
forbiddenCount++
|
||||
}
|
||||
|
||||
if strings.Contains(strings.ToLower(resp.GetContentType()), "text/html") {
|
||||
// 忽略超链接网页 `Convert network assets to local` no longer process webpage https://github.com/siyuan-note/siyuan/issues/9965
|
||||
continue
|
||||
|
|
@ -242,14 +247,23 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
|
|||
}
|
||||
}
|
||||
|
||||
util.PushClearMsg(msgId)
|
||||
if 0 < files {
|
||||
util.PushUpdateMsg(msgId, Conf.Language(113), 7000)
|
||||
msgId = util.PushMsg(Conf.Language(113), 7000)
|
||||
if err = writeTreeUpsertQueue(tree); err != nil {
|
||||
return
|
||||
}
|
||||
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(120), files), 5000)
|
||||
|
||||
if 0 < forbiddenCount {
|
||||
util.PushErrMsg(fmt.Sprintf(Conf.Language(255), forbiddenCount), 5000)
|
||||
}
|
||||
} else {
|
||||
util.PushUpdateMsg(msgId, Conf.Language(121), 3000)
|
||||
if 0 < forbiddenCount {
|
||||
util.PushErrMsg(fmt.Sprintf(Conf.Language(255), forbiddenCount), 5000)
|
||||
} else {
|
||||
util.PushMsg(Conf.Language(121), 3000)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue