From f105fcebe651d9f244ea6de623cbd6c212335c8d Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Mon, 22 Sep 2025 16:53:22 +0800 Subject: [PATCH] add pinia colada delay plugin --- next-ui/.storybook/preview.ts | 8 +++++++- next-ui/package-lock.json | 13 +++++++++++++ next-ui/package.json | 1 + next-ui/src/plugins/index.ts | 8 +++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/next-ui/.storybook/preview.ts b/next-ui/.storybook/preview.ts index 43ce5749..2957e588 100644 --- a/next-ui/.storybook/preview.ts +++ b/next-ui/.storybook/preview.ts @@ -14,6 +14,7 @@ import { availableLocales } from '@/utils/i18n/locale-helper' import { localeDecorator } from './locale.decorator' import { vuetifyViewports } from './viewport' import { allModes } from './modes' +import { PiniaColadaDelay } from '@pinia/colada-plugin-delay' initialize( { @@ -76,7 +77,12 @@ setup((app) => { app.use(vueIntl) app.use(createPinia()) app.use(PiniaColada, { - plugins: [PiniaColadaAutoRefetch()], + plugins: [ + PiniaColadaAutoRefetch(), + PiniaColadaDelay({ + delay: 200, // default delay + }), + ], }) }) diff --git a/next-ui/package-lock.json b/next-ui/package-lock.json index 552a1c96..b5072731 100644 --- a/next-ui/package-lock.json +++ b/next-ui/package-lock.json @@ -11,6 +11,7 @@ "@formatjs/intl-localematcher": "^0.6.1", "@pinia/colada": "^0.17.5", "@pinia/colada-plugin-auto-refetch": "^0.2.2", + "@pinia/colada-plugin-delay": "^0.1.0", "@vueuse/core": "^13.9.0", "core-js": "^3.45.1", "marked": "^16.3.0", @@ -2119,6 +2120,18 @@ "@pinia/colada": ">=0.17.2" } }, + "node_modules/@pinia/colada-plugin-delay": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@pinia/colada-plugin-delay/-/colada-plugin-delay-0.1.0.tgz", + "integrity": "sha512-E7E0I/JN0R4BBDacbW54kyM6eyOWiUP8efIHDb2TSd38N40pOuiYobIXCJJYXeCei9WYij29Xa22QIxYXvOfBw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "@pinia/colada": ">=0.16.0" + } + }, "node_modules/@pinia/colada/node_modules/@vue/devtools-api": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-8.0.2.tgz", diff --git a/next-ui/package.json b/next-ui/package.json index 900d92c8..f6c74415 100644 --- a/next-ui/package.json +++ b/next-ui/package.json @@ -31,6 +31,7 @@ "@formatjs/intl-localematcher": "^0.6.1", "@pinia/colada": "^0.17.5", "@pinia/colada-plugin-auto-refetch": "^0.2.2", + "@pinia/colada-plugin-delay": "^0.1.0", "@vueuse/core": "^13.9.0", "core-js": "^3.45.1", "marked": "^16.3.0", diff --git a/next-ui/src/plugins/index.ts b/next-ui/src/plugins/index.ts index d671e853..548cdd86 100644 --- a/next-ui/src/plugins/index.ts +++ b/next-ui/src/plugins/index.ts @@ -10,6 +10,7 @@ import pinia from '../stores' import router from '../router' import { PiniaColada } from '@pinia/colada' import { PiniaColadaAutoRefetch } from '@pinia/colada-plugin-auto-refetch' +import { PiniaColadaDelay } from '@pinia/colada-plugin-delay' import { vueIntl } from '@/plugins/vue-intl' // Types @@ -27,7 +28,12 @@ export function registerPlugins(app: App) { .use(router) .use(pinia) .use(PiniaColada, { - plugins: [PiniaColadaAutoRefetch()], + plugins: [ + PiniaColadaAutoRefetch(), + PiniaColadaDelay({ + delay: 200, // default delay + }), + ], }) // register navigation guards