mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
fix routes bug order
This commit is contained in:
parent
bf857e94bb
commit
8661c57e88
@ -256,6 +256,8 @@ function createRoutes (files, srcDir) {
|
|||||||
// Order Routes path
|
// Order Routes path
|
||||||
parent.push(route)
|
parent.push(route)
|
||||||
parent.sort((a, b) => {
|
parent.sort((a, b) => {
|
||||||
|
if (!a.path.length || a.path === '/') { return -1 }
|
||||||
|
if (!b.path.length || b.path === '/') { return 1 }
|
||||||
var res = 0
|
var res = 0
|
||||||
var _a = a.path.split('/')
|
var _a = a.path.split('/')
|
||||||
var _b = b.path.split('/')
|
var _b = b.path.split('/')
|
||||||
@ -268,10 +270,10 @@ function createRoutes (files, srcDir) {
|
|||||||
res = y - z
|
res = y - z
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = (res === 0) ? 1 : res
|
res = (res === 0) ? -1 : res
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return res === 0 ? ((_a.length === _b.length) ? _a[_max].length - _b[_max].length : -1) : res
|
return res === 0 ? ((_a.length === _b.length) ? _a[_max].length - _b[_max].length : _b.length - _a.length) : res
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return cleanChildrenRoutes(routes)
|
return cleanChildrenRoutes(routes)
|
||||||
|
Loading…
Reference in New Issue
Block a user