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

fix: 功能跳转方法

parent 7a9988a3
...@@ -13,7 +13,7 @@ import TopRotatingTool from './js/RotatingTool'; ...@@ -13,7 +13,7 @@ import TopRotatingTool from './js/RotatingTool';
import BarLink from './js/BarLink'; import BarLink from './js/BarLink';
import WaterFlowControlView from './js/WaterFlowControlView'; import WaterFlowControlView from './js/WaterFlowControlView';
import { getSketchPadList, getSketchPadContent, getPointAddress, getHistoryInfo } from './apis'; 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'; import './index.less';
const goJS = go.GraphObject.make; const goJS = go.GraphObject.make;
...@@ -794,12 +794,14 @@ const ConfigurationView = (props) => { ...@@ -794,12 +794,14 @@ const ConfigurationView = (props) => {
}; };
/** **************************************跳转方法****************************************** */ /** **************************************跳转方法****************************************** */
const menuJumpMethod = (node) => { const menuJumpMethod = (data) => {
const opRule = JSON.parse(data.opRule); const opRule = JSON.parse(data.opRule);
const widget = opRule && opRule.widget ? opRule.widget : ''; 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); const list = querySkipUrl(globalConfig?.widgets || [], widget);
if (!list || !widget) return false; 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 { ...@@ -33,6 +33,7 @@ import {
hexSwitch, hexSwitch,
textStyle, textStyle,
querySkipUrl, querySkipUrl,
isJson,
} from './js/utils'; } from './js/utils';
import './index.less'; import './index.less';
...@@ -1177,9 +1178,11 @@ const ConfigurationView = (props) => { ...@@ -1177,9 +1178,11 @@ const ConfigurationView = (props) => {
const menuJumpMethod = (data) => { const menuJumpMethod = (data) => {
const opRule = JSON.parse(data.opRule); const opRule = JSON.parse(data.opRule);
const widget = opRule && opRule.widget ? opRule.widget : ''; 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); const list = querySkipUrl(globalConfig?.widgets || [], widget);
if (!list || !widget) return false; 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) => { ...@@ -98,3 +98,24 @@ export const querySkipUrl = (data, id) => {
} }
return res; 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