Skip to content

Commit e488cb4

Browse files
committed
perf: add pinia storeToRefs auto import config
1 parent 0b2f922 commit e488cb4

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

auto-imports.d.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ declare global {
115115
const shallowReactive: typeof import('vue')['shallowReactive']
116116
const shallowReadonly: typeof import('vue')['shallowReadonly']
117117
const shallowRef: typeof import('vue')['shallowRef']
118+
const storeToRefs: typeof import('pinia')['storeToRefs']
118119
const syncRef: typeof import('@vueuse/core')['syncRef']
119120
const syncRefs: typeof import('@vueuse/core')['syncRefs']
120121
const templateRef: typeof import('@vueuse/core')['templateRef']
@@ -270,8 +271,8 @@ declare global {
270271
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
271272
const useRequest: typeof import('@uni-helper/uni-use')['useRequest']
272273
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
273-
const useRoute: typeof import('@uni-helper/uni-use')['useRoute']
274-
const useRouter: typeof import('@uni-helper/uni-use')['useRouter']
274+
const useRoute: typeof import('uni-use-router')['useRoute']
275+
const useRouter: typeof import('uni-use-router')['useRouter']
275276
const useSSRWidth: typeof import('@vueuse/core')['useSSRWidth']
276277
const useScanCode: typeof import('@uni-helper/uni-use')['useScanCode']
277278
const useScreenBrightness: typeof import('@uni-helper/uni-use')['useScreenBrightness']
@@ -468,6 +469,7 @@ declare module 'vue' {
468469
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
469470
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
470471
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
472+
readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
471473
readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>
472474
readonly syncRefs: UnwrapRef<typeof import('@vueuse/core')['syncRefs']>
473475
readonly templateRef: UnwrapRef<typeof import('@vueuse/core')['templateRef']>
@@ -623,8 +625,8 @@ declare module 'vue' {
623625
readonly useRefHistory: UnwrapRef<typeof import('@vueuse/core')['useRefHistory']>
624626
readonly useRequest: UnwrapRef<typeof import('@uni-helper/uni-use')['useRequest']>
625627
readonly useResizeObserver: UnwrapRef<typeof import('@vueuse/core')['useResizeObserver']>
626-
readonly useRoute: UnwrapRef<typeof import('@uni-helper/uni-use')['useRoute']>
627-
readonly useRouter: UnwrapRef<typeof import('@uni-helper/uni-use')['useRouter']>
628+
readonly useRoute: UnwrapRef<typeof import('uni-use-router')['useRoute']>
629+
readonly useRouter: UnwrapRef<typeof import('uni-use-router')['useRouter']>
628630
readonly useSSRWidth: UnwrapRef<typeof import('@vueuse/core')['useSSRWidth']>
629631
readonly useScanCode: UnwrapRef<typeof import('@uni-helper/uni-use')['useScanCode']>
630632
readonly useScreenBrightness: UnwrapRef<typeof import('@uni-helper/uni-use')['useScreenBrightness']>

src/components/TheCounter.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
import { useCounterStore } from '~/stores/counter'
33
44
const counter = useCounterStore()
5+
6+
const { count } = storeToRefs(counter)
57
</script>
68

79
<template>
810
<div flex items-center justify-center gap-8>
911
<div class="count-btn" @click="counter.dec()">
1012
-
1113
</div>
12-
<span font-mono>{{ counter.count }}</span>
14+
<span font-mono>{{ count }}</span>
1315
<div class="count-btn" @click="counter.inc()">
1416
+
1517
</div>

vite.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ export default defineConfig(async () => {
5959
'uni-app',
6060
'@vueuse/core',
6161
uniuseAutoImports(),
62+
{
63+
pinia: ['storeToRefs'],
64+
},
65+
/**
66+
* uni-use-router 更加贴全 vue-router 的跳转方式
67+
* @see https://github.com/Ares-Chang/uni-use-router
68+
*/
69+
{
70+
'uni-use-router': ['useRoute', 'useRouter'],
71+
},
6272
],
6373
dts: true,
6474
dirs: [

0 commit comments

Comments
 (0)