mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-14 06:22:10 +08:00
Pre Merge pull request !134 from guo_ddt/master-fetch
This commit is contained in:
commit
c344f953ae
@ -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 ''
|
||||||
@ -203,7 +220,7 @@ export const loginCheck = () => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* * 预览地址
|
* * 预览地址
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const previewPath = (id?: string | number) => {
|
export const previewPath = (id?: string | number) => {
|
||||||
const { origin, pathname } = document.location
|
const { origin, pathname } = document.location
|
||||||
|
Loading…
x
Reference in New Issue
Block a user