mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-14 14:32:10 +08:00
fix: 修正大屏预览界面,添加query参数的时候ID获取异常
http://localhost:3000/#/chart/preview/792622755697790976?t=123 并把参数放入sessionStorage,后续动态接口可以使用 例如动态请求参数中使用javascript: return window.sessionStorage.getItem('t')
This commit is contained in:
parent
23e459de94
commit
3caaa52ff6
@ -169,7 +169,24 @@ export const fetchRouteParams = () => {
|
|||||||
*/
|
*/
|
||||||
export const fetchRouteParamsLocation = () => {
|
export const fetchRouteParamsLocation = () => {
|
||||||
try {
|
try {
|
||||||
return document.location.hash.split('/').pop() || ''
|
// http://localhost:3000/#/chart/preview/792622755697790976?t=123
|
||||||
|
// 修正大屏预览界面,添加query参数的时候ID获取异常。
|
||||||
|
const url = document.location.hash
|
||||||
|
const queryIndex = url.indexOf('?')
|
||||||
|
if (queryIndex > 0) {
|
||||||
|
const queryUrl = url.substring(queryIndex+1)
|
||||||
|
const queryParams = queryUrl.split('&')
|
||||||
|
// 并把参数放入sessionStorage,后续动态接口可以使用
|
||||||
|
// 例如请求参数中使用javascript: return window.sessionStorage.getItem('t')
|
||||||
|
queryParams.forEach((str: string) => {
|
||||||
|
const kv = str.split('=')
|
||||||
|
if (kv.length === 2) window.sessionStorage.setItem(kv[0], kv[1])
|
||||||
|
})
|
||||||
|
const uri = url.substring(0, queryIndex)
|
||||||
|
return uri.split('/').pop() || ''
|
||||||
|
} else {
|
||||||
|
return url.split('/').pop() || ''
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window['$message'].warning('查询路由信息失败,请联系管理员!')
|
window['$message'].warning('查询路由信息失败,请联系管理员!')
|
||||||
return ''
|
return ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user