fix: temporary solution on MacOS for unsigned app updates

This commit is contained in:
Fabio Di Stasio 2021-11-03 14:46:13 +01:00
parent 17c6686163
commit c00fd1381f
7 changed files with 36 additions and 7 deletions

View File

@ -113,7 +113,6 @@ function startRenderer (callback) {
});
const server = new WebpackDevServer(compiler, {
static: path.join(__dirname, '../'),
hot: true,
port: 9080,
client: {

View File

@ -2,6 +2,7 @@ import { ipcMain } from 'electron';
import { autoUpdater } from 'electron-updater';
import Store from 'electron-store';
const persistentStore = new Store({ name: 'settings' });
const isMacOS = process.platform === 'darwin';
let mainWindow;
autoUpdater.allowPrerelease = persistentStore.get('allow_prerelease', true);
@ -11,6 +12,9 @@ export default () => {
mainWindow = event;
if (process.windowsStore || (process.platform === 'linux' && !process.env.APPIMAGE))
mainWindow.reply('no-auto-update');
else if (isMacOS) { // Temporary solution on MacOS for unsigned app updates
autoUpdater.autoDownload = false;
}
else {
autoUpdater.checkForUpdatesAndNotify().catch(() => {
mainWindow.reply('check-failed');
@ -28,7 +32,10 @@ export default () => {
});
autoUpdater.on('update-available', () => {
mainWindow.reply('update-available');
if (isMacOS)
mainWindow.reply('link-to-download');
else
mainWindow.reply('update-available');
});
autoUpdater.on('update-not-available', () => {

View File

@ -396,7 +396,7 @@ export default {
return locales;
},
hasUpdates () {
return ['available', 'downloading', 'downloaded'].includes(this.updateStatus);
return ['available', 'downloading', 'downloaded', 'link'].includes(this.updateStatus);
},
workspace () {
return this.getWorkspace(this.selectedWorkspace);

View File

@ -29,12 +29,19 @@
{{ $t('message.checkForUpdates') }}
</button>
<button
v-if="updateStatus === 'downloaded'"
v-else-if="updateStatus === 'downloaded'"
class="btn btn-primary"
@click="restartToUpdate"
>
{{ $t('message.restartToInstall') }}
</button>
<button
v-else-if="updateStatus === 'link'"
class="btn btn-primary"
@click="openOutside('https://antares-sql.app/download.html')"
>
{{ $t('message.goToDownloadPage') }}
</button>
</div>
<div class="form-group mt-4">
<label class="form-switch d-inline-block disabled" @click.prevent="toggleAllowPrerelease">
@ -47,7 +54,7 @@
<script>
import { mapGetters, mapActions } from 'vuex';
import { ipcRenderer } from 'electron';
import { ipcRenderer, shell } from 'electron';
export default {
name: 'ModalSettingsUpdate',
@ -71,6 +78,8 @@ export default {
return this.$t('message.downloadingUpdate');
case 'downloaded':
return this.$t('message.updateDownloaded');
case 'link':
return this.$t('message.updateAvailable');
default:
return this.updateStatus;
}
@ -80,6 +89,9 @@ export default {
...mapActions({
changeAllowPrerelease: 'settings/changeAllowPrerelease'
}),
openOutside (link) {
shell.openExternal(link);
},
checkForUpdates () {
ipcRenderer.send('check-for-updates');
},

View File

@ -92,7 +92,7 @@ export default {
}
},
hasUpdates () {
return ['available', 'downloading', 'downloaded'].includes(this.updateStatus);
return ['available', 'downloading', 'downloaded', 'link'].includes(this.updateStatus);
}
},
methods: {

View File

@ -246,7 +246,8 @@ module.exports = {
thereIsNoQueriesYet: 'There is no queries yet',
searchForQueries: 'Search for queries',
killProcess: 'Kill process',
closeTab: 'Close tab'
closeTab: 'Close tab',
goToDownloadPage: 'Go to download page'
},
faker: {
address: 'Address',

View File

@ -4,23 +4,33 @@ export default store => {
ipcRenderer.on('checking-for-update', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'checking');
});
ipcRenderer.on('update-available', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'available');
});
ipcRenderer.on('update-not-available', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'noupdate');
});
ipcRenderer.on('check-failed', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'nocheck');
});
ipcRenderer.on('no-auto-update', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'disabled');
});
ipcRenderer.on('download-progress', (event, data) => {
store.commit('application/CHANGE_UPDATE_STATUS', 'downloading');
store.commit('application/CHANGE_PROGRESS_PERCENTAGE', data.percent);
});
ipcRenderer.on('update-downloaded', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'downloaded');
});
ipcRenderer.on('link-to-download', () => {
store.commit('application/CHANGE_UPDATE_STATUS', 'link');
});
};