feat [front]: add store and manage loading

This commit is contained in:
Alice 2022-04-06 00:57:31 +02:00
parent 6cd090591b
commit 1ab6d112c0
5 changed files with 49 additions and 0 deletions

View file

@ -18,6 +18,7 @@ export default defineNuxtConfig({
},
css: ["@/css/app.sass"],
buildModules: ["@pinia/nuxt"],
vite: {
css: {
preprocessorOptions: {

View file

@ -14,6 +14,7 @@
"typescript": "^4.6.2"
},
"devDependencies": {
"@pinia/nuxt": "^0.1.8",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@vue/eslint-config-standard": "^6.1.0",
@ -24,6 +25,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.5.0",
"nuxt3": "^3.0.0-27447229.20f3171",
"pinia": "^2.0.13",
"sass": "^1.49.9",
"sass-loader": "10"
}

View file

@ -0,0 +1,21 @@
import { defineStore } from "pinia"
export const useLoadingStore = defineStore("loading", {
state: () => <{ [key: string]: "loading" | "done" | "error" }>{},
actions: {
markLoading(key: string) {
this.$patch({ [key]: "loading" })
},
markDone(key: string) {
this.$patch({ [key]: "done" })
},
markError(key: string) {
this.$patch({ [key]: "error" })
},
},
getters: {
isLoading: (state) => {
return (key: string) => state[key] === "loading"
},
},
})

View file

@ -520,6 +520,13 @@
vite "^2.8.6"
vite-node "^0.6.1"
"@pinia/nuxt@^0.1.8":
version "0.1.8"
resolved "https://registry.yarnpkg.com/@pinia/nuxt/-/nuxt-0.1.8.tgz#457a87b0f39ae47a1306e08ab7d4d390b30b48c9"
integrity sha512-+M1GH/4XQdooOulPL7aYzli6UE1R5rWJtgcPhx2/97yYRLhKZvuIT33OauUCjYZ+tQVs8lyKfzt6S2agqzcmWg==
dependencies:
vue-demi "*"
"@rollup/plugin-alias@^3.1.9":
version "3.1.9"
resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-3.1.9.tgz#a5d267548fe48441f34be8323fb64d1d4a1b3fdf"
@ -835,6 +842,11 @@
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.1.3.tgz#a44c52e8fa6d22f84db3abdcdd0be5135b7dd7cf"
integrity sha512-79InfO2xHv+WHIrH1bHXQUiQD/wMls9qBk6WVwGCbdwP7/3zINtvqPNMtmSHXsIKjvUAHc8L0ouOj6ZQQRmcXg==
"@vue/devtools-api@^6.1.4":
version "6.1.4"
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.1.4.tgz#b4aec2f4b4599e11ba774a50c67fa378c9824e53"
integrity sha512-IiA0SvDrJEgXvVxjNkHPFfDx6SXw0b/TUkqMcDZWNg9fnCAHbTpoo59YfJ9QLFkwa3raau5vSlRVzMSLDnfdtQ==
"@vue/eslint-config-standard@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@vue/eslint-config-standard/-/eslint-config-standard-6.1.0.tgz#b362ba67c86caa4e7b44481c2303c9dccc2dc037"
@ -3853,6 +3865,14 @@ pify@^2.3.0:
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw=
pinia@^2.0.13:
version "2.0.13"
resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.0.13.tgz#6656fc290dae120a9f0cb2f5c520df400d41b8c5"
integrity sha512-B7rSqm1xNpwcPMnqns8/gVBfbbi7lWTByzS6aPZ4JOXSJD4Y531rZHDCoYWBwLyHY/8hWnXljgiXp6rRyrofcw==
dependencies:
"@vue/devtools-api" "^6.1.4"
vue-demi "*"
pkg-types@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/pkg-types/-/pkg-types-0.3.2.tgz#1b3244b561745591035517475bc8af9c5e089e47"
@ -5055,6 +5075,11 @@ vue-bundle-renderer@^0.3.5:
dependencies:
bundle-runner "^0.0.1"
vue-demi@*:
version "0.12.5"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.12.5.tgz#8eeed566a7d86eb090209a11723f887d28aeb2d1"
integrity sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==
vue-eslint-parser@^8.0.1, vue-eslint-parser@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-8.3.0.tgz#5d31129a1b3dd89c0069ca0a1c88f970c360bd0d"