🎨 改进浏览器剪藏扩展转换本地图片 https://github.com/siyuan-note/siyuan/issues/7464
This commit is contained in:
parent
9dd686c58c
commit
ca0affb42b
2 changed files with 7 additions and 2 deletions
|
@ -35,7 +35,11 @@ func netImg2LocalAssets(c *gin.Context) {
|
|||
}
|
||||
|
||||
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 {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
@ -70,7 +70,7 @@ func DocImageAssets(rootID string) (ret []string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func NetImg2LocalAssets(rootID string) (err error) {
|
||||
func NetImg2LocalAssets(rootID, originalURL string) (err error) {
|
||||
tree, err := loadTreeByBlockID(rootID)
|
||||
if nil != err {
|
||||
return
|
||||
|
@ -138,6 +138,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||
}
|
||||
util.PushUpdateMsg(msgId, fmt.Sprintf(Conf.Language(119), u), 15000)
|
||||
request := httpclient.NewBrowserRequest()
|
||||
request.SetHeader("Referer", originalURL)
|
||||
resp, reqErr := request.Get(u)
|
||||
if nil != reqErr {
|
||||
logging.LogErrorf("download net img [%s] failed: %s", u, reqErr)
|
||||
|
|
Loading…
Add table
Reference in a new issue