fix(nuxt): only remove one item from middleware (#21730)

This commit is contained in:
Daniel Roe 2023-06-25 17:40:12 +01:00 committed by GitHub
parent 6b8cb97d54
commit c72bc95473
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,10 @@ export default defineComponent({
nuxtApp.hook('page:finish', indicator.finish)
nuxtApp.hook('vue:error', indicator.finish)
onBeforeUnmount(() => {
globalMiddleware.splice(globalMiddleware.indexOf(indicator.start, 1))
const index = globalMiddleware.indexOf(indicator.start)
if (index >= 0) {
globalMiddleware.splice(index, 1)
}
indicator.clear()
})