antares/src/renderer/index.ts

82 lines
2.2 KiB
TypeScript
Raw Normal View History

2020-05-04 17:33:50 +02:00
'use strict';
2022-05-08 00:12:23 +02:00
import { ipcRenderer } from 'electron';
2022-04-30 16:11:44 +02:00
import { createApp } from 'vue';
2022-05-08 00:12:23 +02:00
import { createPinia } from 'pinia';
import '@mdi/font/css/materialdesignicons.css';
import 'leaflet/dist/leaflet.css';
2020-05-07 17:45:04 +02:00
import '@/scss/main.scss';
2022-04-30 00:47:37 +02:00
import { VueMaskDirective } from 'v-mask';
2022-05-08 00:12:23 +02:00
import { useApplicationStore } from '@/stores/application';
2022-04-30 00:47:37 +02:00
import { useSettingsStore } from '@/stores/settings';
2022-05-08 00:12:23 +02:00
import { useNotificationsStore } from '@/stores/notifications';
2020-05-04 17:33:50 +02:00
import App from '@/App.vue';
2020-05-25 15:37:59 +02:00
import i18n from '@/i18n';
2020-04-30 17:48:53 +02:00
2022-04-30 00:47:37 +02:00
// https://github.com/probil/v-mask/issues/498#issuecomment-827027834
const vMaskV2 = VueMaskDirective;
const vMaskV3 = {
beforeMount: vMaskV2.bind,
updated: vMaskV2.componentUpdated,
unmounted: vMaskV2.unbind
};
2022-04-22 17:45:12 +02:00
2022-04-27 18:23:05 +02:00
createApp(App)
2022-04-30 00:47:37 +02:00
.directive('mask', vMaskV3)
2022-05-08 00:12:23 +02:00
.use(createPinia())
2022-04-27 18:23:05 +02:00
.use(i18n)
.mount('#app');
2022-04-30 00:47:37 +02:00
const { locale } = useSettingsStore();
i18n.global.locale = locale;
2022-05-08 00:12:23 +02:00
// IPC exceptions
ipcRenderer.on('unhandled-exception', (event, error) => {
useNotificationsStore().addNotification({ status: 'error', message: error.message });
});
// IPC app updates
ipcRenderer.on('checking-for-update', () => {
useApplicationStore().updateStatus = 'checking';
});
ipcRenderer.on('update-available', () => {
useApplicationStore().updateStatus = 'available';
});
ipcRenderer.on('update-not-available', () => {
useApplicationStore().updateStatus = 'noupdate';
});
ipcRenderer.on('check-failed', () => {
useApplicationStore().updateStatus = 'nocheck';
});
ipcRenderer.on('no-auto-update', () => {
useApplicationStore().updateStatus = 'disabled';
});
ipcRenderer.on('download-progress', (event, data) => {
useApplicationStore().updateStatus = 'downloading';
useApplicationStore().downloadProgress = data.percent;
2022-05-08 00:12:23 +02:00
});
ipcRenderer.on('update-downloaded', () => {
useApplicationStore().updateStatus = 'downloaded';
});
ipcRenderer.on('link-to-download', () => {
useApplicationStore().updateStatus = 'link';
});
// IPC shortcuts
ipcRenderer.on('toggle-preferences', () => {
useApplicationStore().showSettingModal('general');
});
ipcRenderer.on('open-updates-preferences', () => {
useApplicationStore().showSettingModal('update');
ipcRenderer.send('check-for-updates');
});