diff --git a/app/overrides.d.ts b/app/overrides.d.ts index a730147d..1dd222c2 100644 --- a/app/overrides.d.ts +++ b/app/overrides.d.ts @@ -1,12 +1,5 @@ import 'vue-router' -declare module 'vuex' { - export * from 'vuex/types/index.d.ts' - export * from 'vuex/types/helpers.d.ts' - export * from 'vuex/types/logger.d.ts' - export * from 'vuex/types/vue.d.ts' -} - declare module 'vue-router' { interface RouteMeta { noAuth?: boolean diff --git a/app/package.json b/app/package.json index 120706c6..24dfcbf4 100644 --- a/app/package.json +++ b/app/package.json @@ -26,8 +26,7 @@ "vue": "^3.4.21", "vue-i18n": "^9.10.1", "vue-router": "^4.3.0", - "vue-showdown": "^4.2.0", - "vuex": "^4.1.0" + "vue-showdown": "^4.2.0" }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.4", diff --git a/app/src/main.ts b/app/src/main.ts index 92e1252d..ece197e6 100644 --- a/app/src/main.ts +++ b/app/src/main.ts @@ -9,7 +9,6 @@ import { useRequests } from './composables/useRequests' import { useSettings } from './composables/useSettings' import i18n from './i18n' import router from './router' -import store from './store' import '@/scss/main.scss' @@ -35,7 +34,6 @@ window.addEventListener('unhandledrejection', (e) => { onError(e.reason) }) -app.use(store) app.use(router) app.use(i18n) diff --git a/app/src/store/index.ts b/app/src/store/index.ts deleted file mode 100644 index 1aff8077..00000000 --- a/app/src/store/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { createStore } from 'vuex' - -import info from './info' -import settings from './settings' -import data from './data' - -export default createStore({ - state: settings.state, - mutations: settings.mutations, - actions: settings.actions, - getters: settings.getters, - modules: { - info, - data, - }, -}) diff --git a/app/src/store/settings.ts b/app/src/store/settings.ts deleted file mode 100644 index 8407b258..00000000 --- a/app/src/store/settings.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Settings module store. - * @module store/settings - */ - -import { setI18nLocale, setI18nFallbackLocale } from '@/i18n/helpers' -import supportedLocales from '@/i18n/supportedLocales' - -export default { - state: { - locale: localStorage.getItem('locale'), - fallbackLocale: localStorage.getItem('fallbackLocale'), - cache: localStorage.getItem('cache') !== 'false', - transitions: localStorage.getItem('transitions') !== 'false', - dark: localStorage.getItem('dark') === 'true', - experimental: localStorage.getItem('experimental') === 'true', - spinner: 'pacman', - }, - - mutations: { - SET_LOCALE(state, locale) { - localStorage.setItem('locale', locale) - state.locale = locale - }, - - SET_FALLBACKLOCALE(state, locale) { - localStorage.setItem('fallbackLocale', locale) - state.fallbackLocale = locale - }, - - SET_CACHE(state, boolean) { - localStorage.setItem('cache', boolean) - state.cache = boolean - }, - - SET_TRANSITIONS(state, boolean) { - localStorage.setItem('transitions', boolean) - state.transitions = boolean - }, - - SET_EXPERIMENTAL(state, boolean) { - localStorage.setItem('experimental', boolean) - state.experimental = boolean - }, - - SET_SPINNER(state, spinner) { - state.spinner = spinner - }, - - SET_DARK(state, boolean) { - localStorage.setItem('dark', boolean) - state.dark = boolean - document.documentElement.setAttribute( - 'data-bs-theme', - boolean ? 'dark' : 'light', - ) - }, - }, - - actions: { - UPDATE_LOCALE({ commit }, locale) { - return setI18nLocale(locale).then(() => { - commit('SET_LOCALE', locale) - }) - }, - - UPDATE_FALLBACKLOCALE({ commit }, locale) { - return setI18nFallbackLocale(locale).then(() => { - commit('SET_FALLBACKLOCALE', locale) - }) - }, - - UPDATE_DARK({ commit }, boolean) { - commit('SET_DARK', boolean) - }, - }, - - getters: { - locale: (state) => state.locale, - fallbackLocale: (state) => state.fallbackLocale, - cache: (state) => state.cache, - transitions: (state) => state.transitions, - dark: (state) => state.dark, - experimental: (state) => state.experimental, - spinner: (state) => state.spinner, - - availableLocales: () => { - return Object.entries(supportedLocales).map(([locale, { name }]) => { - return { value: locale, text: name } - }) - }, - }, -} diff --git a/app/src/store/utils.ts b/app/src/store/utils.ts deleted file mode 100644 index 448f9c65..00000000 --- a/app/src/store/utils.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { WritableComputedRef } from 'vue' -import { computed } from 'vue' -import { useStore } from 'vuex' - -import type { - AnyWritableComponents, - FormField, - FormFieldDict, -} from '@/types/form' - -export function useStoreGetters() { - const store = useStore() - return Object.fromEntries( - Object.keys(store.getters).map((getter) => [ - getter, - computed(() => store.getters[getter]), - ]), - ) -} - -/** - * Dynamicly generate computed properties from store with get/set and automatic commit/dispatch - */ -export function useMapStoreGetSet({ - commit = [], - dispatch = [], -}: { - commit: Extract[] - dispatch: Extract[] -}) { - const store = useStore() - type Types = { - [k in keyof FFD]: FFD[k] extends - | FormField - | undefined - ? MV - : any - } - return [...commit, ...dispatch].reduce( - (obj, prop) => { - obj[prop] = computed({ - get() { - return store.getters[prop] - }, - set(value) { - const isCommit = commit.includes(prop) - const key = (isCommit ? 'SET_' : 'UPDATE_') + prop.toUpperCase() - store[isCommit ? 'commit' : 'dispatch'](key, value) - }, - }) - return obj - }, - {} as { [k in keyof FFD]: WritableComputedRef }, - ) as { - [k in keyof FFD]: WritableComputedRef - } -} diff --git a/app/vite.config.ts b/app/vite.config.ts index 6a5d6bac..41844e4a 100644 --- a/app/vite.config.ts +++ b/app/vite.config.ts @@ -58,7 +58,7 @@ export default defineConfig(({ command, mode }) => { rollupOptions: { output: { manualChunks: (id) => { - // Circular import problems, this will merge vue/vuex/etc. and api together + // Circular import problems, this will merge core deps and api together if (!id.includes('node_modules') && id.includes('api/')) { return 'core' }