Skip to content

Commit b2b1f85

Browse files
committed
pinia store 改为自动导入
1 parent a5acb60 commit b2b1f85

File tree

19 files changed

+10
-33
lines changed

19 files changed

+10
-33
lines changed

plop-templates/store/index.hbs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const use{{ properCase name }}Store = defineStore(
1+
export const use{{ properCase name }}Store = defineStore(
22
// 唯一ID
33
'{{ camelCase name }}',
44
() => {
@@ -9,5 +9,3 @@ const use{{ properCase name }}Store = defineStore(
99
}
1010
},
1111
)
12-
13-
export default use{{ properCase name }}Store

plop-templates/store/prompt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
const actions = [
2020
{
2121
type: 'add',
22-
path: 'src/store/modules/{{camelCase name}}.ts',
22+
path: 'src/store/{{camelCase name}}.ts',
2323
templateFile: 'plop-templates/store/index.hbs',
2424
},
2525
]

src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup lang="ts">
2-
import useKeepAliveStore from '@/store/modules/keepAlive'
3-
import useSettingsStore from '@/store/modules/settings'
42
import eventBus from '@/utils/eventBus'
53
import Provider from './ui/provider/index.vue'
64

src/api/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import axios from 'axios'
22
// import qs from 'qs'
33
import { toast } from 'vue-sonner'
4-
import useUserStore from '@/store/modules/user'
54

65
// 请求重试配置
76
const MAX_RETRY_COUNT = 3 // 最大重试次数

src/router/guards.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { Router } from 'vue-router/auto'
22
import { useNProgress } from '@vueuse/integrations/useNProgress'
3-
import useKeepAliveStore from '@/store/modules/keepAlive'
4-
import useSettingsStore from '@/store/modules/settings'
5-
import useUserStore from '@/store/modules/user'
63
import '@/assets/styles/nprogress.css'
74

85
// 鉴权

src/store/index.ts

100755100644
File mode changed.

src/store/modules/keepAlive.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const useKeepAliveStore = defineStore(
1+
export const useKeepAliveStore = defineStore(
22
// 唯一ID
33
'keepAlive',
44
() => {
@@ -38,5 +38,3 @@ const useKeepAliveStore = defineStore(
3838
}
3939
},
4040
)
41-
42-
export default useKeepAliveStore

src/store/modules/settings.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Settings } from '#/global'
22
import settingsDefault from '@/settings'
33

4-
const useSettingsStore = defineStore(
4+
export const useSettingsStore = defineStore(
55
// 唯一ID
66
'settings',
77
() => {
@@ -75,5 +75,3 @@ const useSettingsStore = defineStore(
7575
}
7676
},
7777
)
78-
79-
export default useSettingsStore

src/store/modules/user.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import apiUser from '@/api/modules/user'
22
import router from '@/router'
33

4-
const useUserStore = defineStore(
4+
export const useUserStore = defineStore(
55
// 唯一ID
66
'user',
77
() => {
@@ -66,5 +66,3 @@ const useUserStore = defineStore(
6666
}
6767
},
6868
)
69-
70-
export default useUserStore

src/types/auto-imports.d.ts

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ declare global {
1414
const customRef: typeof import('vue')['customRef']
1515
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
1616
const defineComponent: typeof import('vue')['defineComponent']
17-
const definePage: typeof import('unplugin-vue-router/runtime')['definePage']
1817
const defineStore: typeof import('pinia')['defineStore']
1918
const effectScope: typeof import('vue')['effectScope']
2019
const getActivePinia: typeof import('pinia')['getActivePinia']
@@ -72,13 +71,16 @@ declare global {
7271
const useCssVars: typeof import('vue')['useCssVars']
7372
const useGlobalProperties: typeof import('../utils/composables/useGlobalProperties')['default']
7473
const useId: typeof import('vue')['useId']
74+
const useKeepAliveStore: typeof import('../store/modules/keepAlive')['useKeepAliveStore']
7575
const useLink: typeof import('vue-router/auto')['useLink']
7676
const useModel: typeof import('vue')['useModel']
7777
const usePage: typeof import('../utils/composables/usePage')['default']
7878
const useRoute: typeof import('vue-router')['useRoute']
7979
const useRouter: typeof import('vue-router')['useRouter']
80+
const useSettingsStore: typeof import('../store/modules/settings')['useSettingsStore']
8081
const useSlots: typeof import('vue')['useSlots']
8182
const useTemplateRef: typeof import('vue')['useTemplateRef']
83+
const useUserStore: typeof import('../store/modules/user')['useUserStore']
8284
const watch: typeof import('vue')['watch']
8385
const watchEffect: typeof import('vue')['watchEffect']
8486
const watchPostEffect: typeof import('vue')['watchPostEffect']

0 commit comments

Comments
 (0)