公众号登录调试

This commit is contained in:
Jason
2022-09-15 15:54:12 +08:00
parent e71a5ab805
commit 4d3b0adb5e
50 changed files with 49 additions and 48 deletions

View File

@@ -2,8 +2,8 @@ import { BACK_URL } from '@/enums/cacheEnums'
import { useUserStore } from '@/stores/user'
import { getToken } from '@/utils/auth'
import cache from '@/utils/cache'
import { generateRoutes } from './transformPages'
export const routes = generateRoutes()
import { routes } from './routes'
const whiteList = ['register', 'login', 'forget_pwd']
const list = ['navigateTo', 'redirectTo', 'reLaunch', 'switchTab']
list.forEach((item) => {
@@ -34,12 +34,11 @@ export function setupRouter() {
// #ifdef H5
const app = getApp()
app.$router.afterEach((to: any, from: any) => {
console.log(to, from)
const index = whiteList.findIndex((item) => to.path.includes(item))
const index = whiteList.findIndex((item) => from.path.includes(item) || from.path === '/')
const userStore = useUserStore()
if (index == -1 && !userStore.isLogin) {
//保存登录前的路径
cache.set(BACK_URL, to.fullPath)
cache.set(BACK_URL, from.fullPath)
}
})

View File

@@ -43,3 +43,5 @@ function getSubPackagesRoutes(pagesJson: any) {
export function generateRoutes() {
return getPagesRoutes(PagesJSON.pages).concat(getSubPackagesRoutes(PagesJSON))
}
export const routes = generateRoutes()