main.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <style type="text/css">
  6. body {
  7. width: 100%;
  8. height: 100%;
  9. margin: 0;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <script type="text/javascript">
  15. document.write(`<p>App launches.</p>`);
  16. const { NsisCompatUpdater } = require('nsis-compat-updater');
  17. const updater = new NsisCompatUpdater('http://127.0.0.1:8080/versions.nsis.json', nw.App.manifest.version, 'x86');
  18. updater.checkForUpdates()
  19. .then((version) => {
  20. document.write(`<p>Version: ${ version }</p>`);
  21. if(version && confirm(`New version of ${ version.version } is available, download now?`)) {
  22. return updater.downloadUpdate(version.version)
  23. .then((path) => {
  24. document.write(`<p>Path: ${ path }</p>`);
  25. if(confirm(`New version of ${ version.version } is downloaded, install now?`)) {
  26. return updater.quitAndInstall(path);
  27. }
  28. else {
  29. return updater.installWhenQuit(path);
  30. }
  31. });
  32. }
  33. else {
  34. nw.Window.open('./app/index.html', {
  35. width: 640,
  36. height: 480,
  37. new_instance: true,
  38. });
  39. nw.Window.get().close();
  40. }
  41. })
  42. .catch((err) => {
  43. document.write(`<p>[ERROR] ${ err.message }</p>`);
  44. });
  45. </script>
  46. </body>
  47. </html>