LulumiProject / lulumi-browser

Lulumi-browser is a lightweight browser coded with Vue.js 2 and Electron.
Apache License 2.0
437 stars 90 forks source link

there are some bug when I copy image and save image #41

Closed YeYongFen closed 6 years ago

YeYongFen commented 6 years ago

when I copy image , new Iamge() throw a CROS error. and "save image " function does work. And I find a solution in brave-broswer project. maybe it can help you

https://electronjs.org/docs/api/web-contents#contentscopyimageatx-y

https://electronjs.org/docs/api/web-contents#contentscopyimageatx-y

qazbnm456 commented 6 years ago

Hi @yyf1994gggg , thanks for reporting this and giving me the possible solution. BTW, could you please give me the link that I can reproduce the problem you mentioned? Thank you.

YeYongFen commented 6 years ago

123

the error above appear in development environment ,maybe it will be fine In the production environment

I look up the doc, I found an easier way to do this contents.copyImageAt(x, y) && contents.downloadURL(url)

        menu.append(new MenuItem({
            label: i18n.t("Menu.copyImage"),
            click:  () => {
                let webContent = this.webview.getWebContents();
                webContent.copyImageAt(this.options.x,this.options.y)
            },
        }));       
        menu.append(new MenuItem({
            label: i18n.t("Menu.saveImageAs"),
            click:  () => {
                let webContent = this.webview.getWebContents();
                webContent.downloadURL(this.options.srcURL)
            },
        })); 
qazbnm456 commented 6 years ago

@yyf1994gggg Okay, I know the problem you're facing exactly. It's because you wanna load images from remote sites, the main BrowserWindow will serve files from origin: localhost no matter it's in development or production mode, however. That is, you'll be denied to load any file from the remote site since it violates the CORS rule.

To conclude, the best way to load images into the BrowserWindow is to host them from local.

qazbnm456 commented 6 years ago

To the explanation aboved, I'm about to close the issue. Please don't be hesitated to ask me to reopen it if you've found another problem. Thank you!