Skip to content

Commit 1d8be63

Browse files
committed
fix(vue): stub clearError
1 parent 1902492 commit 1d8be63

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/runtime/inertia/stubs.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { ref, onScopeDispose } from 'vue'
22
import type { Ref, Plugin as VuePlugin } from 'vue'
33
import { createHooks } from 'hookable'
4-
4+
import { usePage, router } from '@inertiajs/vue3'
5+
import { useColorMode as useColorModeVueUse } from '@vueuse/core'
56
import appConfig from '#build/app.config'
67
import type { NuxtApp } from '#app'
7-
import { useColorMode as useColorModeVueUse } from '@vueuse/core'
8-
import { usePage } from '@inertiajs/vue3'
98

109
export { useHead } from '@unhead/vue'
10+
export { router as useRouter } from '@inertiajs/vue3'
1111

1212
export { useAppConfig } from '../vue/composables/useAppConfig'
1313
export { defineShortcuts } from '../composables/defineShortcuts'
@@ -16,15 +16,12 @@ export { useLocale } from '../composables/useLocale'
1616

1717
export const useRoute = () => {
1818
const page = usePage()
19+
1920
return {
2021
fullPath: page.url
2122
}
2223
}
2324

24-
export const useRouter = () => {
25-
26-
}
27-
2825
export const useColorMode = () => {
2926
if (!appConfig.colorMode) {
3027
return {
@@ -88,6 +85,10 @@ export function useRuntimeHook(name: string, fn: (...args: any[]) => void): void
8885
onScopeDispose(unregister)
8986
}
9087

88+
export function clearError(options: { redirect: string }) {
89+
return router.push({ url: options.redirect })
90+
}
91+
9192
export function defineNuxtPlugin(plugin: (nuxtApp: NuxtApp) => void) {
9293
return {
9394
install(app) {

src/runtime/vue/stubs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ref, onScopeDispose } from 'vue'
22
import type { Ref, Plugin as VuePlugin } from 'vue'
3+
import { useRouter } from 'vue-router'
34
import { createHooks } from 'hookable'
4-
5+
import { useColorMode as useColorModeVueUse } from '@vueuse/core'
56
import appConfig from '#build/app.config'
67
import type { NuxtApp } from '#app'
7-
import { useColorMode as useColorModeVueUse } from '@vueuse/core'
88

99
export { useHead } from '@unhead/vue'
1010
export { useRoute, useRouter } from 'vue-router'
@@ -77,6 +77,10 @@ export function useRuntimeHook(name: string, fn: (...args: any[]) => void): void
7777
onScopeDispose(unregister)
7878
}
7979

80+
export function clearError(options: { redirect: string }) {
81+
return useRouter().push(options.redirect)
82+
}
83+
8084
export function defineNuxtPlugin(plugin: (nuxtApp: NuxtApp) => void) {
8185
return {
8286
install(app) {

0 commit comments

Comments
 (0)