diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts index 84edacd..7f0dd7a 100644 --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -5,15 +5,15 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] - const aircraftModule: typeof import('./store/index')['aircraftModule'] + const aircraftModule: typeof import('./store/aircraft')['aircraftModule'] const computed: typeof import('vue')['computed'] const createApp: typeof import('vue')['createApp'] const customRef: typeof import('vue')['customRef'] const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] - const dialogModule: typeof import('./store/index')['dialogModule'] + const dialogModule: typeof import('./store/dialog')['dialogModule'] const effectScope: typeof import('vue')['effectScope'] - const flightboxStatusModule: typeof import('./store/index')['flightboxStatusModule'] + const flightboxStatusModule: typeof import('./store/flightboxStatus')['flightboxStatusModule'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] const getCurrentScope: typeof import('vue')['getCurrentScope'] const h: typeof import('vue')['h'] @@ -22,7 +22,7 @@ declare global { const isReactive: typeof import('vue')['isReactive'] const isReadonly: typeof import('vue')['isReadonly'] const isRef: typeof import('vue')['isRef'] - const loadingModule: typeof import('./store/index')['loadingModule'] + const loadingModule: typeof import('./store/loading')['loadingModule'] const markRaw: typeof import('vue')['markRaw'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] @@ -48,7 +48,7 @@ declare global { const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] - const snackbarModule: typeof import('./store/index')['snackbarModule'] + const snackbarModule: typeof import('./store/snackbar')['snackbarModule'] const toRaw: typeof import('vue')['toRaw'] const toRef: typeof import('vue')['toRef'] const toRefs: typeof import('vue')['toRefs'] @@ -61,12 +61,12 @@ declare global { const useRoute: typeof import('vue-router')['useRoute'] const useRouter: typeof import('vue-router')['useRouter'] const useSlots: typeof import('vue')['useSlots'] - const userModule: typeof import('./store/index')['userModule'] + const userModule: typeof import('./store/user')['userModule'] const watch: typeof import('vue')['watch'] const watchEffect: typeof import('vue')['watchEffect'] const watchPostEffect: typeof import('vue')['watchPostEffect'] const watchSyncEffect: typeof import('vue')['watchSyncEffect'] - const websocketModule: typeof import('./store/index')['websocketModule'] + const websocketModule: typeof import('./store/websocket')['websocketModule'] } // for type re-export declare global { diff --git a/src/services/WS.ts b/src/services/WS.ts index 589691e..07ca147 100644 --- a/src/services/WS.ts +++ b/src/services/WS.ts @@ -1,5 +1,4 @@ import { env } from '@/vanillaTS/env'; -import { userModule } from '@/store'; export class CreateWs { #ws?: WebSocket; diff --git a/src/services/axios.ts b/src/services/axios.ts index 0545e76..07656ba 100644 --- a/src/services/axios.ts +++ b/src/services/axios.ts @@ -1,6 +1,5 @@ import { env } from '@/vanillaTS/env'; import { snackError, snackReset } from './snack'; -import { userModule, websocketModule } from '@/store'; import Axios, { AxiosError, type AxiosInstance } from 'axios'; // Some kind of dirty work around for strict axios typing? diff --git a/src/services/snack.ts b/src/services/snack.ts index 0d5ed39..5ea187d 100644 --- a/src/services/snack.ts +++ b/src/services/snack.ts @@ -1,5 +1,4 @@ import { mdiAlertCircle, mdiCheckCircleOutline } from '@mdi/js'; -import { snackbarModule } from '@/store'; import type { TSnack } from '@/types'; export const snackSuccess = async ({ message = 'Success', icon = mdiCheckCircleOutline, timeout=5000, loading=false }: TSnack): Promise => { diff --git a/src/store/modules/aircraft.ts b/src/store/aircraft.ts similarity index 92% rename from src/store/modules/aircraft.ts rename to src/store/aircraft.ts index b2632de..8591547 100644 --- a/src/store/modules/aircraft.ts +++ b/src/store/aircraft.ts @@ -2,7 +2,7 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; import type { TAdsbdb } from '@/types'; -export const aircraftStore = defineStore(ModuleName.AIRCRAFT, { +export const aircraftModule = defineStore(ModuleName.AIRCRAFT, { state: () => ({ _current_flights: [] as Array, diff --git a/src/store/modules/dialog.ts b/src/store/dialog.ts similarity index 87% rename from src/store/modules/dialog.ts rename to src/store/dialog.ts index f91152e..5c1b3ad 100644 --- a/src/store/modules/dialog.ts +++ b/src/store/dialog.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; -export const dialogStore = defineStore(ModuleName.DIALOG, { +export const dialogModule = defineStore(ModuleName.DIALOG, { state: () => ({ imgSrc: '', diff --git a/src/store/modules/flightboxStatus.ts b/src/store/flightboxStatus.ts similarity index 90% rename from src/store/modules/flightboxStatus.ts rename to src/store/flightboxStatus.ts index c63a58a..045d406 100644 --- a/src/store/modules/flightboxStatus.ts +++ b/src/store/flightboxStatus.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; -export const flightboxStatusStore = defineStore(ModuleName.FLIGHTBOX_STATUS, { +export const flightboxStatusModule = defineStore(ModuleName.FLIGHTBOX_STATUS, { state: () => ({ api_version: '', diff --git a/src/store/index.ts b/src/store/index.ts deleted file mode 100644 index b914243..0000000 --- a/src/store/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { aircraftStore } from '@/store/modules/aircraft'; -import { dialogStore } from '@/store/modules/dialog'; -import { flightboxStatusStore } from '@/store/modules/flightboxStatus'; -import { loadingStore } from '@/store/modules/loading'; -import { snackbarStore } from '@/store/modules/snackbar'; -import { userStore } from '@/store/modules/user'; -import { websocketStore } from '@/store/modules/websocket'; - -export const aircraftModule = aircraftStore; -export const dialogModule = dialogStore; -export const flightboxStatusModule = flightboxStatusStore; -export const loadingModule = loadingStore; -export const snackbarModule = snackbarStore; -export const userModule = userStore; -export const websocketModule = websocketStore; \ No newline at end of file diff --git a/src/store/modules/loading.ts b/src/store/loading.ts similarity index 77% rename from src/store/modules/loading.ts rename to src/store/loading.ts index c0437f9..06e45a6 100644 --- a/src/store/modules/loading.ts +++ b/src/store/loading.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; -export const loadingStore = defineStore(ModuleName.LOADING, { +export const loadingModule = defineStore(ModuleName.LOADING, { state: () => ({ loading: false, diff --git a/src/store/modules/snackbar.ts b/src/store/snackbar.ts similarity index 88% rename from src/store/modules/snackbar.ts rename to src/store/snackbar.ts index 98207df..c506762 100644 --- a/src/store/modules/snackbar.ts +++ b/src/store/snackbar.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; -export const snackbarStore = defineStore(ModuleName.SNACKBAR, { +export const snackbarModule = defineStore(ModuleName.SNACKBAR, { state: () => ({ icon: '', diff --git a/src/store/modules/user.ts b/src/store/user.ts similarity index 56% rename from src/store/modules/user.ts rename to src/store/user.ts index 41e266d..86ec126 100644 --- a/src/store/modules/user.ts +++ b/src/store/user.ts @@ -1,16 +1,16 @@ -import { aircraftStore } from './aircraft'; +import { aircraftModule } from './aircraft'; import { defineStore } from 'pinia'; -import { dialogStore } from './dialog'; -import { flightboxStatusStore } from './flightboxStatus'; -import { loadingStore } from './loading'; +import { dialogModule } from './dialog'; +import { flightboxStatusModule } from './flightboxStatus'; +import { loadingModule } from './loading'; import { ModuleName } from '@/types/enum_module'; import { snackError } from '@/services/snack'; -import { websocketStore } from './websocket'; +import { websocketModule } from './websocket'; // import { useRoute, useRouter } from 'vue-router'; import { getActivePinia } from 'pinia'; import { FrontendRoutes } from '@/types/enum_routes'; -export const userStore = defineStore(ModuleName.USER, { +export const userModule = defineStore(ModuleName.USER, { state: () => ({ authenticated: false, @@ -19,11 +19,11 @@ export const userStore = defineStore(ModuleName.USER, { actions: { logout (message?: string): void { this.authenticated = false; - loadingStore().set_loading(false); - flightboxStatusStore().$reset(); - aircraftStore().$reset(); - websocketStore().closeWS(); - dialogStore().$reset(); + loadingModule().set_loading(false); + flightboxStatusModule().$reset(); + aircraftModule().$reset(); + websocketModule().closeWS(); + dialogModule().$reset(); if (message) snackError({ message }); getActivePinia()?.router().push(FrontendRoutes.LOGIN); }, diff --git a/src/store/modules/websocket.ts b/src/store/websocket.ts similarity index 82% rename from src/store/modules/websocket.ts rename to src/store/websocket.ts index 78dc738..320d209 100644 --- a/src/store/modules/websocket.ts +++ b/src/store/websocket.ts @@ -1,11 +1,11 @@ import { defineStore } from 'pinia'; import { ModuleName } from '@/types/enum_module'; -import { userStore } from './user'; +import { userModule } from './user'; import type { TWSToServer } from '@/types'; import { ws } from '@/services/WS'; -export const websocketStore = defineStore(ModuleName.WEBSOCKET, { +export const websocketModule = defineStore(ModuleName.WEBSOCKET, { state: () => ({ connected: false @@ -19,7 +19,7 @@ export const websocketStore = defineStore(ModuleName.WEBSOCKET, { }, openWs (password: string): void { - const user_store = userStore(); + const user_store = userModule(); if (!user_store.authenticated) return; ws.openWs(password); ws.connection?.addEventListener('open', () => {