當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript electron.autoUpdater類代碼示例

本文整理匯總了TypeScript中electron.autoUpdater的典型用法代碼示例。如果您正苦於以下問題:TypeScript autoUpdater類的具體用法?TypeScript autoUpdater怎麽用?TypeScript autoUpdater使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了autoUpdater類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getServerUrl

    server.listen(0, '127.0.0.1', () => {
      serverUrl = getServerUrl(server);

      autoUpdater.on('error', (error: Error) => {
        logger.error('autoUpdater: error', getPrintableError(error));
        reject(error);
      });
      autoUpdater.on('update-downloaded', () => {
        logger.info('autoUpdater: update-downloaded event fired');
        shutdown(server, logger);
        resolve();
      });

      autoUpdater.setFeedURL({
        url: serverUrl,
        headers: { 'Cache-Control': 'no-cache' },
      });
      autoUpdater.checkForUpdates();
    });
開發者ID:WhisperSystems,項目名稱:Signal-Desktop,代碼行數:19,代碼來源:macos.ts

示例2: constructor

  constructor(window: BrowserWindow) {
    if (isDev()) {
      return
    }

    if (os.platform() !== "darwin") {
      return
    }

    const version = app.getVersion()
    autoUpdater.addListener("update-available", (event: any) => {
      log("A new update is available")
    })
    autoUpdater.addListener("update-downloaded", (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => {
      notify("A new update is ready to install", `Version ${releaseName} is downloaded and will be automatically installed on Quit`)
    })
    autoUpdater.addListener("error", (error: any) => {
      log(error)
    })
    autoUpdater.addListener("checking-for-update", (event: any) => {
      log("checking-for-update")
    })
    autoUpdater.addListener("update-not-available", () => {
      log("update-not-available")
    })
    autoUpdater.setFeedURL(`https://${UPDATE_SERVER_HOST}/update/${os.platform()}_${os.arch()}/${version}`)

    window.webContents.once("did-frame-finish-load", (event: any) => {
      autoUpdater.checkForUpdates()
    })
  }
開發者ID:agozie,項目名稱:onshape-desktop-shell,代碼行數:31,代碼來源:AppUpdater.ts

示例3: constructor

    constructor(window: Electron.BrowserWindow) {
        if (isDev()) {
            log.info(`isDev() true, auto-updater disabled`);
            return;
        }

        const version = app.getVersion();
        const feedUrl = `https://${UPDATE_SERVER_HOST}/update/${os.platform()}/${version}`;

        try {
            autoUpdater.setFeedURL(feedUrl);
        } catch (err) {
            log.info(`autoUpdater.setFeedURL failed: ${err}`);
            return;
        }

        autoUpdater.addListener("update-available", (event: any) => {
            log.info("A new update is available");
        });
        autoUpdater.addListener(
            "update-downloaded",
            (event: any, releaseNotes: string, releaseName: string, releaseDate: string, updateURL: string) => {
                notify(
                    window,
                    "A new update is ready to install",
                    `Version ${releaseName} is downloaded and will be automatically installed on Quit`
                );
            }
        );
        autoUpdater.addListener("error", (error: any) => {
            // auto-updater fails a lot because builds are not being signed yet, just ignore
            //
            // if (error.message === "Can not find Squirrel") {
            //     return;
            // }
            // log.error(error.stack ? error.stack : error.toString());
        });
        autoUpdater.addListener("checking-for-update", (event: any) => {
            log.info("checking-for-update");
        });
        autoUpdater.addListener("update-not-available", () => {
            log.info("update-not-available");
        });
        ipcMain.on("brackets-app-ready", () => {
            autoUpdater.checkForUpdates();
        });
    }
開發者ID:Real-Currents,項目名稱:brackets,代碼行數:47,代碼來源:auto-updater.ts

示例4: setupAutoUpdater

    function setupAutoUpdater():void {
        // Don't even attempt to write the auto update unless we are on a system that supports it. 
        // Which as of the time of this comment only is windows. 
        if (!canAutoupdate()) return;
        autoUpdater.addListener("update-available", function () {
            win.webContents.send("update-info", "UPDATE.AVAILABLE");
        });
        autoUpdater.addListener("update-downloaded", function () {
            win.webContents.send("update-info", "UPDATE.DOWNLOADED");
        });
        autoUpdater.addListener("error", function (error:any) {
            console.log(error);
            win.webContents.send("update-error", error);
        });
        autoUpdater.addListener("checking-for-update", function () {
            win.webContents.send("update-info", "UPDATE.CHECKING_FOR_UPDATE");
        });
        autoUpdater.addListener("update-not-available", function () {
            win.webContents.send("update-info", "UPDATE.NOT_AVAILABLE");
        });

        var feedUrl:string = "";
        if (platform() == "win32") {
            feedUrl = "http://zlepper.dk:3215/update/win";
            if (arch() == "x64") {
                console.log("64x windows detected.");
                feedUrl += "64"
            } else {
                feedUrl += "32"
            }
        }

        feedUrl += "/" + app.getVersion();

        // The feed url was not set for some reason, so we'll not attempt to get any update package.
        if (feedUrl == "") {
            return;
        }
        autoUpdater.setFeedURL(feedUrl);
        autoUpdater.checkForUpdates();
    }
開發者ID:fcpwiz,項目名稱:go-modpack-packer,代碼行數:41,代碼來源:main.ts

示例5:

 ipcMain.on("restart", () => {
     autoUpdater.quitAndInstall();
 });
開發者ID:zlepper,項目名稱:go-modpack-packer,代碼行數:3,代碼來源:IpcHandlers.ts

示例6:

 ipcMain.on("brackets-app-ready", () => {
     autoUpdater.checkForUpdates();
 });
開發者ID:Real-Currents,項目名稱:brackets,代碼行數:3,代碼來源:auto-updater.ts

示例7: checkDownloadAndInstall

async function checkDownloadAndInstall(
  getMainWindow: () => BrowserWindow,
  messages: MessagesType,
  logger: LoggerType
) {
  if (isChecking) {
    return;
  }

  logger.info('checkDownloadAndInstall: checking for update...');
  try {
    isChecking = true;

    const result = await checkForUpdates(logger);
    if (!result) {
      return;
    }

    const { fileName: newFileName, version: newVersion } = result;
    if (fileName !== newFileName || !version || gt(newVersion, version)) {
      deleteCache(updateFilePath, logger);
      fileName = newFileName;
      version = newVersion;
      updateFilePath = await downloadUpdate(fileName, logger);
    }

    const publicKey = hexToBinary(getFromConfig('updatesPublicKey'));
    const verified = verifySignature(updateFilePath, version, publicKey);
    if (!verified) {
      // Note: We don't delete the cache here, because we don't want to continually
      //   re-download the broken release. We will download it only once per launch.
      throw new Error(
        `checkDownloadAndInstall: Downloaded update did not pass signature verification (version: '${version}'; fileName: '${fileName}')`
      );
    }

    try {
      await handToAutoUpdate(updateFilePath, logger);
    } catch (error) {
      const readOnly = 'Cannot update while running on a read-only volume';
      const message: string = error.message || '';
      if (message.includes(readOnly)) {
        logger.info('checkDownloadAndInstall: showing read-only dialog...');
        await showReadOnlyDialog(getMainWindow(), messages);
      } else {
        logger.info(
          'checkDownloadAndInstall: showing general update failure dialog...'
        );
        await showCannotUpdateDialog(getMainWindow(), messages);
      }

      throw error;
    }

    // At this point, closing the app will cause the update to be installed automatically
    //   because Squirrel has cached the update file and will do the right thing.

    logger.info('checkDownloadAndInstall: showing update dialog...');
    const shouldUpdate = await showUpdateDialog(getMainWindow(), messages);
    if (!shouldUpdate) {
      return;
    }

    logger.info('checkDownloadAndInstall: calling quitAndInstall...');
    markShouldQuit();
    autoUpdater.quitAndInstall();
  } catch (error) {
    logger.error('checkDownloadAndInstall: error', getPrintableError(error));
  } finally {
    isChecking = false;
  }
}
開發者ID:WhisperSystems,項目名稱:Signal-Desktop,代碼行數:72,代碼來源:macos.ts

示例8:

 window.webContents.once("did-frame-finish-load", (event: any) => {
   autoUpdater.checkForUpdates()
 })
開發者ID:agozie,項目名稱:onshape-desktop-shell,代碼行數:3,代碼來源:AppUpdater.ts


注:本文中的electron.autoUpdater類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。