久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产高清视频一区 | 久久不射电影网 | 国产精品中文 | 欲色av| 成人做爰9片免费看网站 | 国产激情一区二区三区 | 日韩精品福利 | 欧美精品福利视频 | 亚洲精品久久久一区二区三区 | 91久久久久 | 久久精品亚洲精品国产欧美 | 亚洲第一天堂无码专区 | 成人在线视频网址 | 成人精品一区二区 | 91tv在线观看 | 欧美一级在线观看 | 欧美综合自拍 | 精品99久久| 操操网站| 亚洲免费人成在线视频观看 | 男人天堂国产 | 日本不卡视频在线播放 | 四虎精品在线 | 久久九| 欧美成人精品在线观看 | 国产精品欧美一区喷水 | 午夜性色a√在线视频观看9 | 人人人干 | 日韩中文字幕 | 成人久久 | 久久国产欧美日韩精品 | av永久| 久久久噜噜噜久久中文字幕色伊伊 | 成人精品一区二区三区中文字幕 | 九热在线| 一区二区电影 | 91热爆在线观看 | 福利一区二区在线 | 亚洲精品国产综合区久久久久久久 | www.成人免费视频 | 免费视频中文字幕 |