Compare commits
3 Commits
3272734986
...
6ec8879127
| Author | SHA1 | Date |
|---|---|---|
|
|
6ec8879127 | 4 months ago |
|
|
46453c6082 | 4 months ago |
|
|
ba1311ae59 | 4 months ago |
8 changed files with 62 additions and 25 deletions
@ -0,0 +1,33 @@ |
|||||
|
import router from './router' |
||||
|
import { userStStore } from './stores/user' |
||||
|
import { useCounterStore } from './stores/counter' |
||||
|
import NProgress from 'nprogress' // progress bar
|
||||
|
import '@/components/nprogress.css' // progress bar style
|
||||
|
|
||||
|
NProgress.configure({ showSpinner: false }) // NProgress Configuration
|
||||
|
|
||||
|
// 登录页面
|
||||
|
const loginRoutePath = '/login' |
||||
|
// 白名单
|
||||
|
const whiteList = [loginRoutePath] |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// 路由守卫
|
||||
|
router.beforeEach((to, from, next) => { |
||||
|
NProgress.start() // start progress bar
|
||||
|
|
||||
|
// // 获取用户store实例
|
||||
|
const userStore = useCounterStore() |
||||
|
// console.log(userStore.token,"user token")
|
||||
|
|
||||
|
// // 检查token
|
||||
|
// console.log("check token")
|
||||
|
|
||||
|
}) |
||||
|
|
||||
|
// 路由守卫
|
||||
|
router.afterEach((to, from) => { |
||||
|
NProgress.done() // finish progress bar
|
||||
|
}) |
||||
@ -1,16 +0,0 @@ |
|||||
import { defineStore } from 'pinia' |
|
||||
|
|
||||
export const useCounterStore = defineStore({ |
|
||||
id: 'counter', |
|
||||
state: () => ({ |
|
||||
counter: 0 |
|
||||
}), |
|
||||
getters: { |
|
||||
doubleCount: (state) => state.counter * 2 |
|
||||
}, |
|
||||
actions: { |
|
||||
increment() { |
|
||||
this.counter++ |
|
||||
} |
|
||||
} |
|
||||
}) |
|
||||
Loading…
Reference in new issue