From 7d3d33ef7e45126e8726e4e857778d3dfb8f24d7 Mon Sep 17 00:00:00 2001 From: "Mr.Dat" Date: Fri, 23 Jan 2026 15:17:24 +0700 Subject: [PATCH] refactor: reorganize imports and replace fetchPlans with useSWRV for data fetching --- src/lib/swr/use-swrv.ts | 36 ++++++++++----------- src/routes/plans/Plans.vue | 65 ++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/lib/swr/use-swrv.ts b/src/lib/swr/use-swrv.ts index 8230ca4..5f6a490 100644 --- a/src/lib/swr/use-swrv.ts +++ b/src/lib/swr/use-swrv.ts @@ -19,26 +19,26 @@ * ||| / // * ||| / */ +import { tinyassert } from "@hiogawa/utils"; import { - reactive, - watch, - ref, - toRefs, + getCurrentInstance, + inject, + isReadonly, + isRef, // isRef, onMounted, - onUnmounted, - getCurrentInstance, - isReadonly, onServerPrefetch, - isRef, + onUnmounted, + reactive, + ref, + toRefs, useSSRContext, - type FunctionPlugin, - inject -} from 'vue' -import webPreset from './lib/web-preset' -import SWRVCache from './cache' -import type { IConfig, IKey, IResponse, fetcherFn, revalidateOptions } from './types' -import { tinyassert } from "@hiogawa/utils"; + watch, + type FunctionPlugin +} from 'vue'; +import SWRVCache from './cache'; +import webPreset from './lib/web-preset'; +import type { IConfig, IKey, IResponse, fetcherFn, revalidateOptions } from './types'; type StateRef = { data: Data, error: Error, isValidating: boolean, isLoading: boolean, revalidate: Function, key: any @@ -183,7 +183,7 @@ function useSWRV(...args: any[]): IResponse= 1) { key = args[0] @@ -211,7 +211,7 @@ function useSWRV(...args: any[]): IResponse = defaultConfig): FunctionPl // app.provide('swrv', useSWRV) app.provide('swrv-config', swrvConfig) } -export { mutate } +export { mutate }; export default useSWRV diff --git a/src/routes/plans/Plans.vue b/src/routes/plans/Plans.vue index 53ce321..a9ad210 100644 --- a/src/routes/plans/Plans.vue +++ b/src/routes/plans/Plans.vue @@ -1,20 +1,19 @@