Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: define types, router 4 support #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

reslear
Copy link

@reslear reslear commented Jun 17, 2021

No description provided.

@grafikri grafikri marked this pull request as ready for review June 17, 2021 08:34

export default (datas?: any) => async (to: Route, from: Route, next: NavigationGuardNext) => {
// TODO: refactor
declare interface RouterMiddlewareContext {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach is not true. Because this line restricts the developer from being sent custom data to the middleware.

Copy link
Author

@reslear reslear Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course, need like declare module 'name'
for example vue router meta

declare module 'vue-router' {
  interface RouteMeta {
    // is optional
    isAdmin?: boolean
    // must be declared by every route
    requiresAuth: boolean
  }
}

but i don't understand how it works, need investigate, maybe you help?

@grafikri
Copy link
Owner

By the way, Maybe I will mark this repository as deprecated(after released a new version and more good interface) because I found a bug for chained middlewares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants