-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(update):add download process bar
- Loading branch information
Showing
12 changed files
with
366 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
export default { | ||
updateTitle: { | ||
zh: '新版本更新', | ||
en: 'New Version Update', | ||
ja: '新しいバージョンの更新', | ||
tr: 'Yeni Sürüm Güncellemesi', | ||
hu: 'Új verzió frissítés', | ||
}, | ||
ignoreVersion: { | ||
zh: '忽略此版本', | ||
en: 'Ignore this version', | ||
ja: 'このバージョンを無視する', | ||
tr: 'Bu sürümü yoksay', | ||
hu: 'Figyelmen kívül hagyás', | ||
}, | ||
nextRemind: { | ||
zh: '以后提醒', | ||
en: 'Remind me later', | ||
ja: '後でリマインドする', | ||
tr: 'Daha sonra hatırlat', | ||
hu: 'Később emlékeztessen', | ||
}, | ||
update: { | ||
zh: '更新', | ||
en: 'Update', | ||
ja: '更新', | ||
tr: 'Güncelle', | ||
hu: 'Frissítés', | ||
}, | ||
downloadProgress: { | ||
zh: '下载进度', | ||
en: 'Download Progress', | ||
ja: 'ダウンロード進行状況', | ||
tr: 'İndirme İlerlemesi', | ||
hu: 'Letöltési Előrehaladás', | ||
}, | ||
downloading: { | ||
zh: '正在下载更新...', | ||
en: 'Downloading update...', | ||
ja: '更新をダウンロード中...', | ||
tr: 'Güncelleme indiriliyor...', | ||
hu: 'Frissítés letöltése...', | ||
}, | ||
downloaded: { | ||
zh: '下载完毕,点击安装并重启', | ||
en: 'Download completed. Click to install and restart', | ||
ja: 'ダウンロードが完了しました。クリックしてインストールして再起動してください', | ||
tr: 'İndirme tamamlandı. Kurmak ve yeniden başlatmak için tıklayın', | ||
hu: 'Letöltés kész. Kattintson a telepítéshez és az újraindításhoz', | ||
}, | ||
cancel: { | ||
zh: '取消更新', | ||
en: 'Cancel update', | ||
ja: '更新をキャンセル', | ||
tr: 'Güncellemeyi iptal et', | ||
hu: 'Frissítés megszakítása', | ||
}, | ||
install: { | ||
zh: '安装并重启', | ||
en: 'Install and Restart', | ||
ja: 'インストールして再起動', | ||
tr: 'Kur ve Yeniden Başlat', | ||
hu: 'Telepítés és újraindítás', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { BrowserWindow, IpcMain, IpcMainEvent, ipcMain } from 'electron' | ||
import version from '@/version' | ||
import { getCurrentLang, versionDetail } from './updateChecker' | ||
import { resolve } from 'path' | ||
const { autoUpdater } = require('electron-updater') | ||
const Store = require('electron-store') | ||
const electronStore = new Store() | ||
|
||
export const autoDownload = (event: IpcMainEvent, updateDatail: versionDetail, language: string) => { | ||
const downloadUrl = `https://www.emqx.com/${language}/downloads/MQTTX/${updateDatail.version}` | ||
autoUpdater.setFeedURL(downloadUrl) | ||
autoUpdater.autoDownload = false | ||
autoUpdater.autoInstallOnAppQuit = false | ||
autoUpdater.checkForUpdatesAndNotify() | ||
autoUpdater.on('update-available', () => { | ||
autoUpdater.downloadUpdate() | ||
}) | ||
autoUpdater.on('error', (e: any) => { | ||
console.log(e) | ||
}) | ||
autoUpdater.on('download-progress', (progressObj: any) => { | ||
event.sender.send('downloadProgressPercent', progressObj.percent) | ||
}) | ||
autoUpdater.on('update-downloaded', () => { | ||
event.sender.send('downloadProgressPercent', 100) | ||
}) | ||
ipcMain.on('toQuitAndInstall', () => { | ||
electronStore.set('isShow', true) | ||
autoUpdater.quitAndInstall() | ||
}) | ||
ipcMain.on('cancelDownload', () => { | ||
autoUpdater.removeAllListeners() | ||
autoUpdater.autoDownload = false | ||
autoUpdater.autoInstallOnAppQuit = false | ||
autoUpdater.autoCheckForUpdates = false | ||
}) | ||
} | ||
|
||
export async function createUpdateWindow() { | ||
const updateWindow = new BrowserWindow({ | ||
width: 600, | ||
height: 500, | ||
webPreferences: { | ||
nodeIntegration: true, | ||
contextIsolation: false, | ||
enableRemoteModule: true, | ||
}, | ||
}) | ||
const language: string = await getCurrentLang() | ||
let link: string = 'https://mqttx.app' | ||
link = language === 'zh' ? `${link}/zh` : link | ||
updateWindow.loadURL(`${link}/changelogs/v${version}`) | ||
electronStore.set('isShow', false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.