mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
chore: rm remaning stores and vuex
This commit is contained in:
parent
de3c680d75
commit
1b14c78195
7 changed files with 2 additions and 178 deletions
7
app/overrides.d.ts
vendored
7
app/overrides.d.ts
vendored
|
@ -1,12 +1,5 @@
|
||||||
import 'vue-router'
|
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' {
|
declare module 'vue-router' {
|
||||||
interface RouteMeta {
|
interface RouteMeta {
|
||||||
noAuth?: boolean
|
noAuth?: boolean
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
"vue-i18n": "^9.10.1",
|
"vue-i18n": "^9.10.1",
|
||||||
"vue-router": "^4.3.0",
|
"vue-router": "^4.3.0",
|
||||||
"vue-showdown": "^4.2.0",
|
"vue-showdown": "^4.2.0"
|
||||||
"vuex": "^4.1.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.0.4",
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { useRequests } from './composables/useRequests'
|
||||||
import { useSettings } from './composables/useSettings'
|
import { useSettings } from './composables/useSettings'
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
|
||||||
|
|
||||||
import '@/scss/main.scss'
|
import '@/scss/main.scss'
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ window.addEventListener('unhandledrejection', (e) => {
|
||||||
onError(e.reason)
|
onError(e.reason)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use(store)
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
|
||||||
|
|
|
@ -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,
|
|
||||||
},
|
|
||||||
})
|
|
|
@ -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 }
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -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<FFD extends FormFieldDict>({
|
|
||||||
commit = [],
|
|
||||||
dispatch = [],
|
|
||||||
}: {
|
|
||||||
commit: Extract<keyof FFD, string>[]
|
|
||||||
dispatch: Extract<keyof FFD, string>[]
|
|
||||||
}) {
|
|
||||||
const store = useStore()
|
|
||||||
type Types = {
|
|
||||||
[k in keyof FFD]: FFD[k] extends
|
|
||||||
| FormField<AnyWritableComponents, infer MV>
|
|
||||||
| undefined
|
|
||||||
? MV
|
|
||||||
: any
|
|
||||||
}
|
|
||||||
return [...commit, ...dispatch].reduce(
|
|
||||||
(obj, prop) => {
|
|
||||||
obj[prop] = computed<Types[typeof prop]>({
|
|
||||||
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<any> },
|
|
||||||
) as {
|
|
||||||
[k in keyof FFD]: WritableComputedRef<Types[k]>
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -58,7 +58,7 @@ export default defineConfig(({ command, mode }) => {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
manualChunks: (id) => {
|
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/')) {
|
if (!id.includes('node_modules') && id.includes('api/')) {
|
||||||
return 'core'
|
return 'core'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue