mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 19:59:08 +08:00
🎨 改进浏览器剪藏扩展转换本地图片 https://github.com/siyuan-note/siyuan/issues/7464
This commit is contained in:
parent
9dd686c58c
commit
ca0affb42b
@ -35,7 +35,11 @@ func netImg2LocalAssets(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
err := model.NetImg2LocalAssets(id)
|
var url string
|
||||||
|
if urlArg := arg["url"]; nil != urlArg {
|
||||||
|
url = urlArg.(string)
|
||||||
|
}
|
||||||
|
err := model.NetImg2LocalAssets(id, url)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
|
@ -70,7 +70,7 @@ func DocImageAssets(rootID string) (ret []string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NetImg2LocalAssets(rootID string) (err error) {
|
func NetImg2LocalAssets(rootID, originalURL string) (err error) {
|
||||||
tree, err := loadTreeByBlockID(rootID)
|
tree, err := loadTreeByBlockID(rootID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
@ -138,6 +138,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||||||
}
|
}
|
||||||
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(119), u), 15000)
|
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(119), u), 15000)
|
||||||
request := httpclient.NewBrowserRequest()
|
request := httpclient.NewBrowserRequest()
|
||||||
|
request.SetHeader("Referer", originalURL)
|
||||||
resp, reqErr := request.Get(u)
|
resp, reqErr := request.Get(u)
|
||||||
if nil != reqErr {
|
if nil != reqErr {
|
||||||
logging.LogErrorf("download net img [%s] failed: %s", u, reqErr)
|
logging.LogErrorf("download net img [%s] failed: %s", u, reqErr)
|
||||||
|
Loading…
Reference in New Issue
Block a user