Commit 3de2d1f0 authored by 李纪文's avatar 李纪文

fix: 功能跳转方法

parent 7a9988a3
......@@ -13,7 +13,7 @@ import TopRotatingTool from './js/RotatingTool';
import BarLink from './js/BarLink';
import WaterFlowControlView from './js/WaterFlowControlView';
import { getSketchPadList, getSketchPadContent, getPointAddress, getHistoryInfo } from './apis';
import { deepCopy, hexToRgba, textStyle, querySkipUrl } from './js/utils';
import { deepCopy, hexToRgba, textStyle, querySkipUrl, isJson } from './js/utils';
import './index.less';
const goJS = go.GraphObject.make;
......@@ -794,12 +794,14 @@ const ConfigurationView = (props) => {
};
/** **************************************跳转方法****************************************** */
const menuJumpMethod = (node) => {
const menuJumpMethod = (data) => {
const opRule = JSON.parse(data.opRule);
const widget = opRule && opRule.widget ? opRule.widget : '';
const params =
opRule && opRule.params ? (isJson(opRule.params) && JSON.parse(opRule.params)) || {} : {};
const list = querySkipUrl(globalConfig?.widgets || [], widget);
if (!list || !widget) return false;
window.history.pushState({}, null, `/civbase/${list.product || 'civweb4'}/${list.url}`);
window.history.pushState(params, null, `/civbase/${list.product || 'civweb4'}/${list.url}`);
};
/** **************************************历史模态渲染****************************************** */
......
......@@ -33,6 +33,7 @@ import {
hexSwitch,
textStyle,
querySkipUrl,
isJson,
} from './js/utils';
import './index.less';
......@@ -1177,9 +1178,11 @@ const ConfigurationView = (props) => {
const menuJumpMethod = (data) => {
const opRule = JSON.parse(data.opRule);
const widget = opRule && opRule.widget ? opRule.widget : '';
const params =
opRule && opRule.params ? (isJson(opRule.params) && JSON.parse(opRule.params)) || {} : {};
const list = querySkipUrl(globalConfig?.widgets || [], widget);
if (!list || !widget) return false;
window.history.pushState({}, null, `/civbase/${list.product || 'civweb4'}/${list.url}`);
window.history.pushState(params, null, `/civbase/${list.product || 'civweb4'}/${list.url}`);
};
/** **************************************跳转方法****************************************** */
......
......@@ -98,3 +98,24 @@ export const querySkipUrl = (data, id) => {
}
return res;
};
// 判断是否是json
export const isJson = (text) => {
if (
/^[\],:{}\s]*$/.test(
text
.replace(/\\["\\/bfnrtu]/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''),
)
) {
try {
JSON.parse(text);
} catch (e) {
return false;
}
return true;
} else {
return false;
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment