久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何讓 My Electron Auto 更新程序工作?

How to get My Electron Auto updater to work?(如何讓 My Electron Auto 更新程序工作?)
本文介紹了如何讓 My Electron Auto 更新程序工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當我在我的 Github Repro 中發布新更新時,我正在嘗試讓我的 Electron Vue.js 應用程序自行更新.

I'm trying to get my Electron Vue.js aplication to update itself when i release a new update in my Github Repro.

我正在使用electron-builder"打包我的應用程序.這是我的 package.json

I'm packing my app using "electron-builder" and here is my package.json

我一直在關注 本指南,但沒有成功.

I was following this guide but it didn't work.

這是位于 src/main/index.js 頂部的更新程序部分的代碼.

This is the Code for the updater part which is located at the top of the src/main/index.js.

const { app, autoUpdater, dialog } = require('electron')
const server = "https://hazel.scarvite.now.sh/"
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
autoUpdater.setFeedURL(feed)

setInterval(() => {
    autoUpdater.checkForUpdates()
}, 60000)

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
    const dialogOpts = {
        type: 'info',
        buttons: ['Restart', 'Not Now. On next Restart'],
        title: 'Update',
        message: process.platform === 'win32' ? releaseNotes : releaseName,
        detail: 'A New Version has been Downloaded. Restart Now to Complete the Update.'
    }

    dialog.showMessageBox(dialogOpts).then((returnValue) => {
        if (returnValue.response === 0) autoUpdater.quitAndInstall()
    })
})

autoUpdater.on('error', message => {
    console.error('There was a problem updating the application')
    console.error(message)
})

希望大家能幫幫我

推薦答案

經過一番掙扎,我想通了.原來我使用的 zeit.co 服務器沒有發送 latest.yml.所以我們可以完全刪除

I Figured it out after a bit of an struggle. Turns out the zeit.co server i was using wasn't sending the latest.yml. So We can completely remove

const server = "https://hazel.scarvite.now.sh/"
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
autoUpdater.setFeedURL(feed)

我開始使用 github.我們還必須將自動更新器從電子(已棄用)更改為電子生成器的自動更新器.我們這樣導入它: const { autoUpdater } = require("electron-updater"); 別忘了 npm i electron-updater

and i started working with github instead. We also had to change the autoupdater from electron, as it is deprecated, to electron-builder's autoupdater instead. We imported it like this: const { autoUpdater } = require("electron-updater"); Don't forget to npm i electron-updater

在我的 Package.json 中,我更改了我的構建腳本,因此它將作為草稿直接發布到 github.node .electron-vue/build.js &&electron-builder -p 總是.

In my Package.json i changed my build script so it would directly publish to github as a draft.node .electron-vue/build.js && electron-builder -p always.

我也必須添加

"repository": {
    "type": "git",
    "url": "https://github.com/ScarVite/Example-Repro/"
},
    "publish": {
    "provider": "github",
    "releaseType": "release"
},
"build": {
    "productName": "Your App Name",
    "appId": "com.example.yourapp",
    "directories": {
        "output": "build"
    },
    "files": [
        "dist/electron/**/*"
    ],
    "win": {
        "icon": "build/icons/icon.ico",
    "publish": [
            "github"
        ]
    },

我在 app.on('ready') 中調用了 autoUpdater.checkForUpdatesAndNotify(); 并設置了一個間隔,所以它每 10 分鐘檢查一次

I called autoUpdater.checkForUpdatesAndNotify(); in my app.on('ready') and set a intervall, so it checks every 10 minutes

然后在 autoupdater 事件 update-downloaded 中,我發送了一個對話框,詢問用戶是否要立即或稍后重新啟動和更新應用程序.如果響應是現在我調用 autoUpdater.quitAndInstall() 并重新啟動.Autoupdater 會在您下次關閉應用時自動更新

Then on the autoupdater event update-downloaded i sent a dialog asking the user if they want to restart and update the app now or later. If the response was now i called autoUpdater.quitAndInstall() and it restarted. the Autoupdater updates the next time you close the app automatically

這篇關于如何讓 My Electron Auto 更新程序工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产欧美日韩精品一区 | 国产成人精品一区二区三区在线观看 | 成人国内精品久久久久一区 | 一区二区三区国产精品 | 国产午夜精品久久 | 亚洲国产91 | 欧美日韩1区2区 | 亚洲一在线 | 欧美日韩三区 | 精品欧美激情精品一区 | 自拍偷拍亚洲一区 | 精品久久国产 | 精品一区二区视频 | 欧美性大战久久久久久久蜜臀 | 国产乱码精品1区2区3区 | 亚洲男人网 | 成人a免费 | 四虎最新视频 | 国产情侣啪啪 | 亚洲va在线va天堂va狼色在线 | 午夜影院在线观看 | 久久久网 | 91资源在线播放 | 精品欧美乱码久久久久久1区2区 | 成人不卡 | 亚洲国产在| 成人亚洲在线 | 久久亚洲欧美日韩精品专区 | 国产视频一区二区三区四区五区 | 91一区 | 国产精品久久久久一区二区三区 | 成人免费网站www网站高清 | 青青草华人在线视频 | 亚洲精品美女在线观看 | 91视视频在线观看入口直接观看 | 欧美在线视频网站 | 久久综合香蕉 | 欧美v在线 | 日韩二区 | 天堂久久网 | 久久综合久久自在自线精品自 |