Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跨域上传图片的问题--对image-dialog.js部分源码有疑问 #844

Open
thep0y opened this issue Jul 27, 2020 · 0 comments
Open

跨域上传图片的问题--对image-dialog.js部分源码有疑问 #844

thep0y opened this issue Jul 27, 2020 · 0 comments

Comments

@thep0y
Copy link

@thep0y thep0y commented Jul 27, 2020

图片
从源码的第162行可以看出,如果没有开启跨域上传,服务端返回的json中的image-url会被填充到dialog.find("[data-url]")中,但如果开启了跨域上传,则不会有任何操作,直接返回一个false
这让我感觉很疑惑,是不是跨域的代码没写完,还是还有其他的代码用来管理跨域上传操作?因为根据当下的代码进行操作时,跨域上传图片成功后,仅仅是服务端上传了一张图片,前端的iframe标签中也能看到服务端返回的json数据(这里的json数据也有问题,服务端只能返回plain格式的符合json格式的数据,直接传json格式会报错。),但前端的行为到此为止了,不会向#test-editor中填写图片链接,也不会在上传图片的弹窗的form里的input[data-url]标签里填图片链接,总而言之,就是什么也不做。
这让我很抓狂,昨天一直以为是我的哪步操作出了问题,于是不停地改golang、javascript,都无法解决。
万般无奈之下看了看源码,在我粗浅的js认知中,我认为源码是有问题的,跨域上传图片的操作在这个源码中无法完成,于是我注销了162行对跨域的判断,也就是说,不管是不是跨域,上传图片成功后,都会将服务端返回的image-url填写到input[data-url]中。
代码修改完后,终于可以正常地跨域上传图片了。

只需注销三行代码即可,见下图:
图片

如有谬误,请指正。因为我真心觉得我的这个操作并不是很完美。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.