router.js
881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* @Date: 2022-10-28 14:34:22
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-01 13:27:09
* @FilePath: /swx/src/stores/router.js
* @Description: 缓存路由信息
*/
import { defineStore } from 'pinia'
/**
* @description 路由回跳信息(用于授权完成后的返回)
* - authRedirect.saveCurrentPagePath 会写入 url
* - authRedirect.returnToOriginalPage 会消费并清空 url
*/
export const routerStore = defineStore('router', {
state: () => {
return {
url: ''
}
},
actions: {
/**
* @description 记录回跳路径
* @param {string} path 页面路径(可带 query)
* @returns {void} 无返回值
*/
add(path) {
this.url = path
},
/**
* @description 清空回跳路径
* @returns {void} 无返回值
*/
remove() {
this.url = ''
}
}
})