mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-04-06 03:57:53 +08:00
Merge dffbd9047f6303f51228580b7f619a3509b7d6ed into 6858a9ad67483025f6a9432a926beb9327037be3
This commit is contained in:
commit
ea314451c8
@ -51,6 +51,7 @@ module.exports = app => {
|
|||||||
extended: true
|
extended: true
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const initMockStartIndex = app._router.stack.length
|
||||||
const mockRoutes = registerRoutes(app)
|
const mockRoutes = registerRoutes(app)
|
||||||
var mockRoutesLength = mockRoutes.mockRoutesLength
|
var mockRoutesLength = mockRoutes.mockRoutesLength
|
||||||
var mockStartIndex = mockRoutes.mockStartIndex
|
var mockStartIndex = mockRoutes.mockStartIndex
|
||||||
@ -63,7 +64,7 @@ module.exports = app => {
|
|||||||
if (event === 'change' || event === 'add') {
|
if (event === 'change' || event === 'add') {
|
||||||
try {
|
try {
|
||||||
// remove mock routes stack
|
// remove mock routes stack
|
||||||
app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
app._router.stack.splice(initMockStartIndex, mockRoutesLength)
|
||||||
|
|
||||||
// clear routes cache
|
// clear routes cache
|
||||||
unregisterRoutes()
|
unregisterRoutes()
|
||||||
@ -71,6 +72,8 @@ module.exports = app => {
|
|||||||
const mockRoutes = registerRoutes(app)
|
const mockRoutes = registerRoutes(app)
|
||||||
mockRoutesLength = mockRoutes.mockRoutesLength
|
mockRoutesLength = mockRoutes.mockRoutesLength
|
||||||
mockStartIndex = mockRoutes.mockStartIndex
|
mockStartIndex = mockRoutes.mockStartIndex
|
||||||
|
const newRoutes = app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
||||||
|
app._router.stack.splice(initMockStartIndex, 0, ...newRoutes)
|
||||||
|
|
||||||
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user