Skip to content

Commit 9f0b939

Browse files
authored
feat: change main vuetify plugins logic (#184)
1 parent 5af4ca2 commit 9f0b939

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default defineNuxtRouteMiddleware((to) => {
2+
// eslint-disable-next-line no-console
3+
console.log('global middleware', to.path, useNuxtApp().$vuetify)
4+
})

playground/middleware/vuetify.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default defineNuxtRouteMiddleware((to) => {
2+
// eslint-disable-next-line no-console
3+
console.log('middleware', to.path, useNuxtApp().$vuetify)
4+
})

playground/pages/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import { ssrClientHintsConfiguration } from 'virtual:vuetify-ssr-client-hints-configuration'
44
import prependAvatar from '~/assets/logo.svg'
55
6+
definePageMeta({
7+
middleware: 'vuetify',
8+
})
9+
610
const value = reactive<{
711
name1?: string
812
name2?: string

src/runtime/plugins/vuetify-sync.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import type { createVuetify } from 'vuetify'
22
import { configureVuetify } from './config'
3-
import { defineNuxtPlugin, useNuxtApp } from '#imports'
3+
import { defineNuxtPlugin } from '#imports'
44
import type { Plugin } from '#app'
55

66
const plugin: Plugin<{
77
vuetify: ReturnType<typeof createVuetify>
88
}> = defineNuxtPlugin({
99
name: 'vuetify:configuration:plugin',
1010
enforce: 'post',
11-
// i18n runtime plugin is async
11+
// @ts-expect-error i18n plugin missing on build time
12+
dependsOn: ['i18n:plugin'],
13+
// i18n runtime plugin can be async
1214
parallel: false,
13-
setup() {
14-
useNuxtApp().hook('app:created', configureVuetify)
15+
async setup() {
16+
await configureVuetify()
1517
},
1618
})
1719

src/runtime/plugins/vuetify.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { createVuetify } from 'vuetify'
22
import { configureVuetify } from './config'
3-
import { defineNuxtPlugin, useNuxtApp } from '#imports'
3+
import { defineNuxtPlugin } from '#imports'
44
import type { Plugin } from '#app'
55

66
const plugin: Plugin<{
77
vuetify: ReturnType<typeof createVuetify>
88
}> = defineNuxtPlugin({
99
name: 'vuetify:configuration:plugin',
1010
enforce: 'post',
11-
setup() {
12-
useNuxtApp().hook('app:created', configureVuetify)
11+
async setup() {
12+
await configureVuetify()
1313
},
1414
})
1515

0 commit comments

Comments
 (0)