diff --git a/src/common/globalRouter.js b/src/common/globalRouter.js index 9b80e07..df4220f 100644 --- a/src/common/globalRouter.js +++ b/src/common/globalRouter.js @@ -22,4 +22,35 @@ const $globalRouter = createRouter({ $globalExpandRouter($globalRouter, routes); // 添加路由扩展 +$globalRouter.beforeEach((to, from, next) => { + // 在这里进行身份验证、权限检查等 + // ... + if (null != to.query) { + for (let key in to.query) { + if (typeof to.query[key] === 'number' && !Number.isNaN(to.query[key])) { + if (to.query[key].toString().length > 9) { + to.query[key] = 0; + console.log(to.query[key]); + } + } + } + } + + if (null != to.params) { + for (let key in to.params) { + if (typeof to.params[key] === 'number' && !Number.isNaN(to.params[key])) { + if (to.params[key].toString().length > 9) { + to.params[key] = 0; + console.log(to.params[key]); + } + } + } + } + // 必须调用next()来resolve这个钩子。 + // 可以传递'next()'、'next(false)'或者'next("/path")'来控制路由 + next(); // 允许路由继续 + // next(false); // 中断路由,并且不跳转到任何地方 + // next("/path"); // 中断路由,并跳转到指定的路径 +}); + export { $globalRouter }; diff --git a/src/components/carousel-card/index.vue b/src/components/carousel-card/index.vue index c8acc01..5c80a6c 100644 --- a/src/components/carousel-card/index.vue +++ b/src/components/carousel-card/index.vue @@ -1,16 +1,16 @@ - - - \ No newline at end of file + \ No newline at end of file