antares/src/renderer/index.ts

99 lines
2.7 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 { VueMaskDirective } from 'v-mask';
2022-11-28 15:11:29 +01:00
import * as FloatingVue from 'floating-vue';
import '@mdi/font/css/materialdesignicons.css';
2022-11-28 15:11:29 +01:00
import 'floating-vue/dist/style.css';
import 'leaflet/dist/leaflet.css';
2020-05-07 17:45:04 +02:00
import '@/scss/main.scss';
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';
2022-07-16 12:01:37 +02:00
import { useConsoleStore } from '@/stores/console';
2020-05-04 17:33:50 +02:00
import App from '@/App.vue';
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)
2022-11-28 15:11:29 +01:00
.use(FloatingVue)
2022-04-27 18:23:05 +02:00
.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 });
});
2022-07-16 12:01:37 +02:00
// IPC query logs
ipcRenderer.on('query-log', (event, logRecord) => {
useConsoleStore().putLog(logRecord);
});
ipcRenderer.on('toggle-console', () => {
useConsoleStore().toggleConsole();
});
2022-05-08 00:12:23 +02:00
// 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');
});
ipcRenderer.on('update-shortcuts', (event, shortcuts) => {
useSettingsStore().updateShortcuts(shortcuts);
});