mirror of https://github.com/Fabio286/antares.git
refactor: removed pinia ipc plugins
This commit is contained in:
parent
fd5dca2450
commit
2a7433da16
|
@ -1,13 +1,17 @@
|
|||
'use strict';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { createApp } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import '@mdi/font/css/materialdesignicons.css';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import '@/scss/main.scss';
|
||||
import { VueMaskDirective } from 'v-mask';
|
||||
|
||||
import { useApplicationStore } from '@/stores/application';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { useNotificationsStore } from '@/stores/notifications';
|
||||
|
||||
import App from '@/App.vue';
|
||||
import { pinia } from '@/stores';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
// https://github.com/probil/v-mask/issues/498#issuecomment-827027834
|
||||
|
@ -20,9 +24,58 @@ const vMaskV3 = {
|
|||
|
||||
createApp(App)
|
||||
.directive('mask', vMaskV3)
|
||||
.use(pinia)
|
||||
.use(createPinia())
|
||||
.use(i18n)
|
||||
.mount('#app');
|
||||
|
||||
const { locale } = useSettingsStore();
|
||||
i18n.global.locale = locale;
|
||||
|
||||
// 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;
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// @ts-check
|
||||
import { createPinia } from 'pinia';
|
||||
import { ipcUpdates } from './plugins/ipcUpdates';
|
||||
import { ipcShortcuts } from './plugins/ipcShortcuts';
|
||||
import { ipcExceptions } from './plugins/ipcExceptions';
|
||||
|
||||
const pinia = createPinia();
|
||||
pinia
|
||||
.use(ipcUpdates)
|
||||
.use(ipcShortcuts)
|
||||
.use(ipcExceptions);
|
||||
|
||||
export { pinia };
|
|
@ -1,7 +0,0 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export function ipcExceptions ({ store }) {
|
||||
ipcRenderer.on('unhandled-exception', (event, error) => {
|
||||
store.notifications.addNotification({ status: 'error', message: error.message });
|
||||
});
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export function ipcShortcuts ({ store }) {
|
||||
ipcRenderer.on('toggle-preferences', () => {
|
||||
store.application.showSettingModal('general');
|
||||
});
|
||||
|
||||
ipcRenderer.on('open-updates-preferences', () => {
|
||||
store.application.showSettingModal('update');
|
||||
ipcRenderer.send('check-for-updates');
|
||||
});
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export function ipcUpdates ({ store }) {
|
||||
ipcRenderer.on('checking-for-update', () => {
|
||||
store.application.updateStatus = 'checking';
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-available', () => {
|
||||
store.application.updateStatus = 'available';
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-not-available', () => {
|
||||
store.application.updateStatus = 'noupdate';
|
||||
});
|
||||
|
||||
ipcRenderer.on('check-failed', () => {
|
||||
store.application.updateStatus = 'nocheck';
|
||||
});
|
||||
|
||||
ipcRenderer.on('no-auto-update', () => {
|
||||
store.application.updateStatus = 'disabled';
|
||||
});
|
||||
|
||||
ipcRenderer.on('download-progress', (event, data) => {
|
||||
store.application.updateStatus = 'downloading';
|
||||
store.application.downloadprogress = data.percent;
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-downloaded', () => {
|
||||
store.application.updateStatus = 'downloaded';
|
||||
});
|
||||
|
||||
ipcRenderer.on('link-to-download', () => {
|
||||
store.application.updateStatus = 'link';
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue