nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.38k stars 3.88k forks source link

nw.App.argv missing actual args on Mac #7783

Open ww-k opened 3 years ago

ww-k commented 3 years ago

NWJS Version : 0.55.0 Operating System : Mac

Expected behavior

nw.App.argv contain actual args

How to reproduce

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>demo</title>
</head>

<body>
    <script>
        const win = nw.Window.get();
        win.showDevTools();
        console.log('app start', nw.App.argv)
        nw.App.on('open', args => {
            console.log('app open fired', args);
        });
    </script>

</html>

open nwjs with index.html

Mac

open /Applications/nwjs.app xxx

Devtool console result: app start []

Windows

start D:\nwjs\nw.exe xxx

Devtool console result: app start [xxx]

bluthen commented 3 years ago

I've been calling the nw executable directly with arguments. However have you tried the --args argument with open? I don't have a mac to try it this second. I thought you have to use the --args argument with open. open /Applications/nwjs.app --args xxx

https://ss64.com/osx/open.html

ww-k commented 3 years ago

I've been calling the nw executable directly with arguments. However have you tried the --args argument with open? I don't have a mac to try it this second. I thought you have to use the --args argument with open. open /Applications/nwjs.app --args xxx

https://ss64.com/osx/open.html

This can get xxx on Mac, and get ['--args', 'xxx'] on Windows. But this example not match my sence.

I want call nwjs on browser by use url protocal. eg:

<a href="test-call-nwjs://xxx/yyy">call nwjs</a>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>demo</title>
</head>
<body>
    <script>
        const win = nw.Window.get();
        win.showDevTools();
        console.log('app start', nw.App.argv)
        nw.App.on('open', args => {
            console.log('app open fired', args);
        });
    </script>

</html>

Mac

Devtool console result: app start []

Windows

Devtool console result: app start ['test-call-nwjs://xxx/yyy']