You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shop-pc/middleware/redirect.js

11 lines
324 B

export default function ({ app, route, redirect }) {
if (!app.store.state.token) {
// 未登录直接打开需要登录的页面,跳转首页
const needLoginPage = [/\/account/, /\/cart/];
const result = needLoginPage.some((item) => item.test(route.path));
if (result) {
redirect("/");
}
}
}