i'm building a node-webkit application i have made a link to quit
<span onClick="func App.quit()" title="Close">X</span>
but when i click it it says
Uncaught ReferenceError: require is not defined
What i am doing wrong here?
i do not understand why i am getting this error
i did added
var gui = require('nw.gui')
gui.quit()
</script>
i have to say in my packjage.js i open a url so all the javascripts are loaded from that url those javascript are not local on my device
The quit API is gui.App.quit() but not gui.quit().
Node-Webkit has 2 JS context, so if you use <script> tag to load JS from remote site, it will run in browser's JS context, as we know, require works in Node.js context. Read this page to get more info.
as tinyproxy already mentioned, use require('nw.gui').App to manage application lifecycle. to minimize window and other window operation as well as listening to window-related events, use require('nw.gui').Window.get() as described here: node-webkit Window. For example, to minimize current window:
var gui = require('nw.gui');
var win = gui.Window.get();
win.minimize();
Related
I am making an app in Electron with Nuxt 2 and I want to open another window in witch I want to use components from ./components folder. Along those components I would want to use the Vuetify instance that I have in the main window so the design will be the same.
Communication between windows will be don with ipcMain and ipcRenderer.
How should I make the html file that I load when the secondary window is created ? What should be in there ?
I do not want to load the entire app and use only a route. The app is pretty bight and it would be just a waste of resources.
Also I use electron builder for production builds and a http server for dev builds.
Thank you.
i am trying to automate tests for 'lens' electron based desktop application.i was following this link enter link description here to setup the test for electron app.This link expects a 'mainwindowurl' but application doesn't have any main page, but testcafe give suggestion of the mainwindowurl as an error so tried it works but am not convinced with the suggrstion urls ,but same way want to give fixture page url on the test what should be the url should i need to give? then have got one more error ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.Please can you guys suggest what to do?
Each and every Electron application has to navigate to a page after opening a window.
I guess that the mentioned Lens app is an Kubernetes IDE: https://github.com/lensapp/lens.
This app uses the BrowserWindow.loadURL function to navigate to the main page:
https://github.com/lensapp/lens/blob/a61425124f18b1cc2d8a507084a472029acc3e6b/src/main/window-manager.ts#L101.
Digging the code a bit more, I found that the main window URL is just localhost with some port:
https://github.com/lensapp/lens/blob/a61425124f18b1cc2d8a507084a472029acc3e6b/src/main/window-manager.ts#L33.
I guess it is possible to determine or set the port number by looking at the code a bit more or asking Lens developers about it.
I have a client written in Vue.js and an API written in .NET core, the API also expose the static pages of the distribution of the vue.js client, the all thing is running on localhost and will stay that way.
When the server is up and running it's also opens a browser tab with the website URL on localhost, I made that with 2 methods: launchBrowser in the launchSettings or using Process.start(URL).
I would like that when the tab is closed the server will shutdown as well.
I have tried the following methods:
getting the process of the tab and detect close ( but every browser handle the tab process differently) - didn't work
using beforeunload and unload event in the client and send HTTP GET request to the server:
created() {
window.addEventListener('beforeunload', () => {
const request = new XMLHttpRequest();
request.open("GET", URL, false);
request.send();
});
}
it didn't work
check in the visual studio Tools -> Options -> Web Projects "Stop debugger when browser windows is closed, close browser when debugging stops", but when I publish the application the settings and launchSettings is not working ( only in the IDE )
Anyone have any idea on how to solve it?
You could try the following strategy
Create a separate launcher script.
The Launcher script launches the server in the background and stores it PID.
The Launcher now spawns a browser-process in foreground/blocking mode.
When the browser is closed (all tabs are closed) it will return control to the launcher script
Now you can kill the server with the PID you stored previously.
I wanted to run a NoFlo application. I created a noflo component in json fomat and then I tried to run it with the following command:
./node_modules/.bin/noflo-nodejs --graph graphs/Number_game.json.
I got the following error:
NoFlo runtime is now listening at ws://192.168.43.64:3569 Browsers
will reject connections from HTTPS pages to unsecured WebSockets You
can use insecure version of the IDE, or enable secure WebSockets with
--tls-key and --tls-cert options Live IDE URL: http://app.flowhub.io/#runtime/endpoint?protocol%3Dwebsocket%26address%3Dws%3A%2F%2F192.168.43.64%3A3569%26id%3D173bb627-f1df-48cf-80da-d2b72546c08c%26secret%3Dtupiqiyoma
Component interaction/ListenChange not available with base C:\Users\DELL\Desktop\my-app
Can someone please help me with this issue?
(Sorry I can post images related to it because I am a new user)
noflo-interaction components are only available for browser environment. So they're not visible to noflo-nodejs.
I've been working with a business partner to get an insurance app working on a Windows 8 tablet and have come across some interesting behavior that I can't explain.
I have managed to recreate the problem using a very simple use case and it appears to fail in the browser as well as when deployed as an app.
To re-create
Create a simple WL Hello World app with no JavaScript libraries
Deploy it to the development server
Open up an IE 10 browser and launch the WL Console.
Run this app using "Preview as Common Resources" and it should work fine (showing the default Hello Worklight)
click F12 to launch the IE debugger and then refresh the browser, click on the show console button to verify there were no errors
Add a WL.Client.connect(...) call into the wlCommonInit method
...
WL.Client.connect({
onSuccess: function(data) {
console.log("connection Successful");
},
onFailure: function(err) {
console.log("Connection FAILED: " + JSON.stringify(err) );
}
});
Save and re-run the app and it fails with an InvalidStateError (verify with F12 debugger)
Open up either a Chrome or Firefox browser to the WL Console page and click the "Preview as Common Resources" and open the developer tools for either and the console shows the connect call succeeding.
Is this a known problem or is there something that I've missed?
The ultimate goal is to deliver a Windows 8.1 tablet app however every time we tried to run the app it failed with this error. After some debugging I thought maybe it has something to do with the OS and tried to replicate it in just the browser with minimum code.
Through testing I've found that the basic Hello Worklight app with a WL.Client.connect() fails on IE but works on other browsers.
So I'm thinking if I get it working in IE browser, then that fix will be good for the tablet app as well.
Any pointers or guidance would be appreciated.
Note I am using WL v6.2 (6.2.0.00-20140915-1601)
Tested on Windows 7 - IE 10.0.9200.17089
Tested on Windows 8.1 - IE 11.0.9600.16663
The error I get is
HTML1300: Navigation occurred.
File: index.html
wlclient init started
before: initOptions.onSuccess
Request [/Connect/apps/services/api/Connect/common/init]
console.trace()
at __log (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:4882:31)
at Anonymous function (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:5240:7)
at createRequestHeaders (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3200:17)
at sendRequest (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3266:18)
at initialize (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:3172:17)
at klass (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:524:4)
at sendInitRequest (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:7870:5)
at connect (http://192.168.80.167:10080/Connect/apps/services/preview/Connect/common/0/default/worklight/worklight.js:7879:3)
SCRIPT5022: InvalidStateError
File: worklight.js, Line: 1055, Column: 3
Uncaught Exception: InvalidStateError at (compiled_code):1055
For future readers, this problem was resolved by moving to a newer fixpack release v6.2.0.00-20141002