Skip to content

Commit 2465c75

Browse files
committed
fix: type and lint error caused by vue-router
1 parent 0ba3f53 commit 2465c75

File tree

7 files changed

+251
-133
lines changed

7 files changed

+251
-133
lines changed

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
defineFlatConfigs,
44
} from '@nuxt/eslint-config/flat'
55
import playwright from 'eslint-plugin-playwright'
6-
import {} from 'eslint-flat-config-utils'
76

87
export default defineFlatConfigs(
98
createConfigForNuxt({

src/auto-imports.d.ts

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,90 +6,90 @@
66
// biome-ignore lint: disable
77
export {}
88
declare global {
9-
const EffectScope: typeof import('vue')['EffectScope']
10-
const Notify: typeof import('./stores/notification')['Notify']
11-
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
12-
const computed: typeof import('vue')['computed']
13-
const createApp: typeof import('vue')['createApp']
14-
const createPinia: typeof import('pinia')['createPinia']
15-
const customRef: typeof import('vue')['customRef']
16-
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
17-
const defineComponent: typeof import('vue')['defineComponent']
9+
const EffectScope: typeof import('vue').EffectScope
10+
const Notify: typeof import('./stores/notification').Notify
11+
const acceptHMRUpdate: typeof import('pinia').acceptHMRUpdate
12+
const computed: typeof import('vue').computed
13+
const createApp: typeof import('vue').createApp
14+
const createPinia: typeof import('pinia').createPinia
15+
const customRef: typeof import('vue').customRef
16+
const defineAsyncComponent: typeof import('vue').defineAsyncComponent
17+
const defineComponent: typeof import('vue').defineComponent
1818
const defineLoader: typeof import('vue-router/auto')['defineLoader']
1919
const definePage: typeof import('unplugin-vue-router/runtime')['definePage']
20-
const defineStore: typeof import('pinia')['defineStore']
21-
const effectScope: typeof import('vue')['effectScope']
22-
const getActivePinia: typeof import('pinia')['getActivePinia']
23-
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
24-
const getCurrentScope: typeof import('vue')['getCurrentScope']
25-
const getCurrentWatcher: typeof import('vue')['getCurrentWatcher']
26-
const h: typeof import('vue')['h']
27-
const inject: typeof import('vue')['inject']
28-
const isProxy: typeof import('vue')['isProxy']
29-
const isReactive: typeof import('vue')['isReactive']
30-
const isReadonly: typeof import('vue')['isReadonly']
31-
const isRef: typeof import('vue')['isRef']
32-
const isShallow: typeof import('vue')['isShallow']
33-
const mapActions: typeof import('pinia')['mapActions']
34-
const mapGetters: typeof import('pinia')['mapGetters']
35-
const mapState: typeof import('pinia')['mapState']
36-
const mapStores: typeof import('pinia')['mapStores']
37-
const mapWritableState: typeof import('pinia')['mapWritableState']
38-
const markRaw: typeof import('vue')['markRaw']
39-
const nextTick: typeof import('vue')['nextTick']
40-
const onActivated: typeof import('vue')['onActivated']
41-
const onBeforeMount: typeof import('vue')['onBeforeMount']
42-
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
43-
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
44-
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
45-
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
46-
const onDeactivated: typeof import('vue')['onDeactivated']
47-
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
48-
const onMounted: typeof import('vue')['onMounted']
49-
const onRenderTracked: typeof import('vue')['onRenderTracked']
50-
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
51-
const onScopeDispose: typeof import('vue')['onScopeDispose']
52-
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
53-
const onUnmounted: typeof import('vue')['onUnmounted']
54-
const onUpdated: typeof import('vue')['onUpdated']
55-
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
56-
const provide: typeof import('vue')['provide']
57-
const reactive: typeof import('vue')['reactive']
58-
const readonly: typeof import('vue')['readonly']
59-
const ref: typeof import('vue')['ref']
60-
const resolveComponent: typeof import('vue')['resolveComponent']
61-
const setActivePinia: typeof import('pinia')['setActivePinia']
62-
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
63-
const shallowReactive: typeof import('vue')['shallowReactive']
64-
const shallowReadonly: typeof import('vue')['shallowReadonly']
65-
const shallowRef: typeof import('vue')['shallowRef']
66-
const storeToRefs: typeof import('pinia')['storeToRefs']
67-
const toRaw: typeof import('vue')['toRaw']
68-
const toRef: typeof import('vue')['toRef']
69-
const toRefs: typeof import('vue')['toRefs']
70-
const toValue: typeof import('vue')['toValue']
71-
const triggerRef: typeof import('vue')['triggerRef']
72-
const unref: typeof import('vue')['unref']
73-
const useAppStore: typeof import('./stores/app')['useAppStore']
74-
const useAttrs: typeof import('vue')['useAttrs']
75-
const useCssModule: typeof import('vue')['useCssModule']
76-
const useCssVars: typeof import('vue')['useCssVars']
77-
const useDisplay: typeof import('vuetify')['useDisplay']
78-
const useId: typeof import('vue')['useId']
79-
const useLayout: typeof import('vuetify')['useLayout']
80-
const useLocale: typeof import('vuetify')['useLocale']
81-
const useModel: typeof import('vue')['useModel']
82-
const useNotificationStore: typeof import('./stores/notification')['useNotificationStore']
83-
const useRoute: typeof import('vue-router')['useRoute']
84-
const useRouter: typeof import('vue-router')['useRouter']
85-
const useRtl: typeof import('vuetify')['useRtl']
86-
const useSlots: typeof import('vue')['useSlots']
87-
const useTemplateRef: typeof import('vue')['useTemplateRef']
88-
const useTheme: typeof import('vuetify')['useTheme']
89-
const watch: typeof import('vue')['watch']
90-
const watchEffect: typeof import('vue')['watchEffect']
91-
const watchPostEffect: typeof import('vue')['watchPostEffect']
92-
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
20+
const defineStore: typeof import('pinia').defineStore
21+
const effectScope: typeof import('vue').effectScope
22+
const getActivePinia: typeof import('pinia').getActivePinia
23+
const getCurrentInstance: typeof import('vue').getCurrentInstance
24+
const getCurrentScope: typeof import('vue').getCurrentScope
25+
const getCurrentWatcher: typeof import('vue').getCurrentWatcher
26+
const h: typeof import('vue').h
27+
const inject: typeof import('vue').inject
28+
const isProxy: typeof import('vue').isProxy
29+
const isReactive: typeof import('vue').isReactive
30+
const isReadonly: typeof import('vue').isReadonly
31+
const isRef: typeof import('vue').isRef
32+
const isShallow: typeof import('vue').isShallow
33+
const mapActions: typeof import('pinia').mapActions
34+
const mapGetters: typeof import('pinia').mapGetters
35+
const mapState: typeof import('pinia').mapState
36+
const mapStores: typeof import('pinia').mapStores
37+
const mapWritableState: typeof import('pinia').mapWritableState
38+
const markRaw: typeof import('vue').markRaw
39+
const nextTick: typeof import('vue').nextTick
40+
const onActivated: typeof import('vue').onActivated
41+
const onBeforeMount: typeof import('vue').onBeforeMount
42+
const onBeforeRouteLeave: typeof import('vue-router').onBeforeRouteLeave
43+
const onBeforeRouteUpdate: typeof import('vue-router').onBeforeRouteUpdate
44+
const onBeforeUnmount: typeof import('vue').onBeforeUnmount
45+
const onBeforeUpdate: typeof import('vue').onBeforeUpdate
46+
const onDeactivated: typeof import('vue').onDeactivated
47+
const onErrorCaptured: typeof import('vue').onErrorCaptured
48+
const onMounted: typeof import('vue').onMounted
49+
const onRenderTracked: typeof import('vue').onRenderTracked
50+
const onRenderTriggered: typeof import('vue').onRenderTriggered
51+
const onScopeDispose: typeof import('vue').onScopeDispose
52+
const onServerPrefetch: typeof import('vue').onServerPrefetch
53+
const onUnmounted: typeof import('vue').onUnmounted
54+
const onUpdated: typeof import('vue').onUpdated
55+
const onWatcherCleanup: typeof import('vue').onWatcherCleanup
56+
const provide: typeof import('vue').provide
57+
const reactive: typeof import('vue').reactive
58+
const readonly: typeof import('vue').readonly
59+
const ref: typeof import('vue').ref
60+
const resolveComponent: typeof import('vue').resolveComponent
61+
const setActivePinia: typeof import('pinia').setActivePinia
62+
const setMapStoreSuffix: typeof import('pinia').setMapStoreSuffix
63+
const shallowReactive: typeof import('vue').shallowReactive
64+
const shallowReadonly: typeof import('vue').shallowReadonly
65+
const shallowRef: typeof import('vue').shallowRef
66+
const storeToRefs: typeof import('pinia').storeToRefs
67+
const toRaw: typeof import('vue').toRaw
68+
const toRef: typeof import('vue').toRef
69+
const toRefs: typeof import('vue').toRefs
70+
const toValue: typeof import('vue').toValue
71+
const triggerRef: typeof import('vue').triggerRef
72+
const unref: typeof import('vue').unref
73+
const useAppStore: typeof import('./stores/app').useAppStore
74+
const useAttrs: typeof import('vue').useAttrs
75+
const useCssModule: typeof import('vue').useCssModule
76+
const useCssVars: typeof import('vue').useCssVars
77+
const useDisplay: typeof import('vuetify').useDisplay
78+
const useId: typeof import('vue').useId
79+
const useLayout: typeof import('vuetify').useLayout
80+
const useLocale: typeof import('vuetify').useLocale
81+
const useModel: typeof import('vue').useModel
82+
const useNotificationStore: typeof import('./stores/notification').useNotificationStore
83+
const useRoute: typeof import('vue-router').useRoute
84+
const useRouter: typeof import('vue-router').useRouter
85+
const useRtl: typeof import('vuetify').useRtl
86+
const useSlots: typeof import('vue').useSlots
87+
const useTemplateRef: typeof import('vue').useTemplateRef
88+
const useTheme: typeof import('vuetify').useTheme
89+
const watch: typeof import('vue').watch
90+
const watchEffect: typeof import('vue').watchEffect
91+
const watchPostEffect: typeof import('vue').watchPostEffect
92+
const watchSyncEffect: typeof import('vue').watchSyncEffect
9393
}
9494
// for type re-export
9595
declare global {

src/components/layout/AppDrawer.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const drawer = computed({
1414
},
1515
})
1616
const rail = computed(() => !drawerStored.value && !mobile.value)
17-
routes.sort((a, b) => (a.meta?.drawerIndex ?? 99) - (b.meta?.drawerIndex ?? 98))
17+
const sortedRoutes = routes.toSorted(
18+
(a, b) => (a.meta?.drawerIndex ?? 99) - (b.meta?.drawerIndex ?? 98),
19+
)
1820
1921
drawerStored.value = lgAndUp.value && width.value !== 1280
2022
</script>
@@ -47,7 +49,11 @@ drawerStored.value = lgAndUp.value && width.value !== 1280
4749
</v-list>
4850
</template>
4951
<v-list nav density="compact">
50-
<AppDrawerItem v-for="route in routes" :key="route.name" :item="route" />
52+
<AppDrawerItem
53+
v-for="route in sortedRoutes"
54+
:key="route.name"
55+
:item="route"
56+
/>
5157
</v-list>
5258
<v-spacer />
5359
<template #append>

src/components/layout/AppDrawerItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { RouteRecordRaw } from 'vue-router/auto'
2+
import type { RouteRecordRaw } from 'vue-router'
33
44
const { level = 0, item } = defineProps<{
55
level?: number
@@ -14,7 +14,7 @@ const visibleChildrenNum = computed(() => visibleChildren.value?.length || 0)
1414
const isItem = computed(() => !item.children || visibleChildrenNum.value <= 1)
1515
const title = toRef(() => item.meta?.title)
1616
const icon = toRef(() => item.meta?.icon)
17-
// @ts-expect-error unknown type miss match
17+
// @ts-expect-error unknown type mismatch
1818
const to = computed<RouteRecordRaw>(() => ({
1919
name: item.name || visibleChildren.value?.[0]?.name,
2020
}))

src/plugins/router.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { createRouter, createWebHistory } from 'vue-router/auto'
1+
/* eslint-disable import/no-duplicates */
2+
import { createRouter, createWebHistory } from 'vue-router'
23
import { routes } from 'vue-router/auto-routes'
34
import { setupLayouts } from 'virtual:meta-layouts'
45

56
export default createRouter({
67
history: createWebHistory(import.meta.env.BASE_URL),
7-
routes: setupLayouts(routes),
8+
routes: setupLayouts(routes as any),
89
})

0 commit comments

Comments
 (0)