Commit b9b5b7ef authored by 皮倩雯's avatar 皮倩雯

fix: '网关配置优化'

parent ee832ee1
Pipeline #67119 passed with stages
......@@ -95,8 +95,8 @@ const GlobalHeaderRight = props => {
return {
breadcrumbName: matchRoute?.name,
path: matchRoute.path,
component: matchRoute.component,
path: matchRoute?.path,
component: matchRoute?.component,
};
};
const itemRender = (route, params, routes, paths) => {
......
......@@ -22,12 +22,16 @@ const AddModal = props => {
const [loading, setLoading] = useState(false);
const [current, setCurrent] = useState(false);
const [advanced, setAdvanced] = useState(0);
const [hidden, setHidden] = useState(false);
const [form] = Form.useForm();
useEffect(() => {
if (visible) {
console.log(keepData);
if (type === 'edit') {
let data = ['CityServer', 'IOT', 'CivData', 'GIS'];
if (data.indexOf(pickItem.key) != -1) {
setHidden(true);
}
let aa = pickItem.methods.replace(/\s/g, '');
form.setFieldsValue({
UpstreamPathTemplate: pickItem.upstreamPathTemplate,
......@@ -79,6 +83,7 @@ const AddModal = props => {
form.setFieldsValue({ IsAuthentication: true });
}
} else {
setHidden(false);
form.resetFields();
setAdvanced(0);
setCurrent(false);
......@@ -237,7 +242,12 @@ const AddModal = props => {
},
]}
>
<Input allowClear style={{ width: '100%' }} placeholder="示例:/PandaOMS/PandaOMS/{url}" />
<Input
allowClear
style={{ width: '100%' }}
placeholder="示例:/PandaOMS/PandaOMS/{url}"
disabled={hidden}
/>
</Item>
<Item
label="下游路由模板"
......@@ -259,7 +269,7 @@ const AddModal = props => {
},
]}
>
<Input allowClear placeholder="示例:/{url}" />
<Input allowClear placeholder="示例:/{url}" disabled={hidden} />
</Item>
<Item
label="上游请求方式"
......@@ -271,7 +281,7 @@ const AddModal = props => {
},
]}
>
<Checkbox.Group options={plainOptions} style={{ display: 'flex' }} />
<Checkbox.Group options={plainOptions} style={{ display: 'flex' }} disabled={hidden} />
</Item>
<Item
label="下游服务地址"
......@@ -287,8 +297,12 @@ const AddModal = props => {
</Item>
<Item label="身份认证" name="IsAuthentication">
<Radio.Group>
<Radio value={true}>开启</Radio>
<Radio value={false}>关闭</Radio>
<Radio value={true} disabled={hidden}>
开启
</Radio>
<Radio value={false} disabled={hidden}>
关闭
</Radio>
</Radio.Group>
</Item>
<Item
......@@ -302,6 +316,9 @@ const AddModal = props => {
{
validator: (rule, value) => {
let aa = form.getFieldValue().Key;
if (!/^[^\u4e00-\u9fa5]{1,10}$/g.test(aa)) {
return Promise.reject('不允许输入中文');
}
if (type === 'edit') {
if (keepData.indexOf(aa) !== -1 && pickItem.key !== aa) {
return Promise.reject('关键字已存在');
......@@ -315,7 +332,7 @@ const AddModal = props => {
},
]}
>
<Input allowClear />
<Input allowClear disabled={hidden} />
</Item>
<Row>
<Col span={8}>
......@@ -338,7 +355,7 @@ const AddModal = props => {
name="Priority"
labelCol={{ span: 12 }}
>
<InputNumber min={0} max={10} defaultValue={0} />
<InputNumber min={0} max={10} defaultValue={0} disabled={hidden} />
</Item>
</Col>
<Col span={16}>
......
......@@ -26,6 +26,7 @@ import {
SyncOutlined,
SearchOutlined,
} from '@ant-design/icons';
import { useHistory } from 'react-router-dom';
import styles from './gateWay.less';
import {
GetGateWay,
......@@ -54,7 +55,8 @@ const GateConfig = () => {
const [checkVisible, setCheckVisible] = useState(false);
const [pickItem, setPickItem] = useState('');
const [type, setType] = useState('');
const [keepData, setKeepData] = useState([]); // 保存关键字
const history = useHistory();
const [keepData, setKeepData] = useState([]); // 保存内置关键字
const { Search } = Input;
const OperateNginx = checked => {
......@@ -64,6 +66,7 @@ const GateConfig = () => {
UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) {
console.log(localStorage.getItem('token'));
// localStorage.removeItem('token');
window.globalConfig = {
...window.globalConfig,
access_token: localStorage.getItem('token'),
......@@ -72,6 +75,41 @@ const GateConfig = () => {
};
setFlag(flag + 1);
message.success('设置成功');
// const key = 'authrizeFail';
// notification.warning({
// key,
// title: '提示',
// message: '授权失败,即将跳转到登录页',
// duration: 2,
// });
// setTimeout(() => {
// history.push(`/user/login`);
// }, 2000);
const key = 'authrizeFail';
const btn = (
<Button
type="primary"
size="small"
onClick={() => {
notification.close(key);
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}}
>
确定
</Button>
);
if (!/\/user\/login$/.test(window.location.pathname)) {
notification.warning({
key,
title: '提示',
message: '授权失败,即将跳转到登录页',
duration: 2,
btn,
});
setTimeout(() => {
window.location.href = `/${process.env.PUBLIC_PATH || 'civmanage'}/user/login`;
}, 2000);
}
} else {
message.error('设置失败');
}
......@@ -179,7 +217,43 @@ const GateConfig = () => {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)} <Tag color="cyan">万能模板</Tag>
{searchStyle1(text)}{' '}
<Tag color="cyan" style={{ marginRight: '0px' }}>
万能模板
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'IOT') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="purple" style={{ marginRight: '0px' }}>
物联
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'CivData') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="green" style={{ marginRight: '0px' }}>
中台
</Tag>
</span>
</Tooltip>
);
} else if (record.key === 'GIS') {
return (
<Tooltip placement="top" title={text}>
<span>
{searchStyle1(text)}{' '}
<Tag color="volcano" style={{ marginRight: '0px' }}>
GIS
</Tag>
</span>
</Tooltip>
);
......@@ -195,19 +269,32 @@ const GateConfig = () => {
},
},
{
title: '上游路由模板',
title: '上游服务地址',
dataIndex: 'upstreamPathTemplate',
key: 'upstreamPathTemplate',
align: 'center',
ellipsis: true,
render: (text, record) => (
<span>
<Tooltip placement="top" title={text}>
{searchStyle(text)}
<Tooltip placement="top" title={`上游路由模板:${text}`}>
{window.location.origin + `/PandaCore/GateWay${text}`}
</Tooltip>
</span>
),
},
// {
// title: '上游路由模板',
// dataIndex: 'upstreamPathTemplate',
// key: 'upstreamPathTemplate',
// align: 'center',
// ellipsis: true,
// render: (text, record) => (
// <span>
// <Tooltip placement="top" title={text}>
// {searchStyle(text)}
// </Tooltip>
// </span>
// ),
// },
{
title: '上游请求方式',
dataIndex: 'methods',
......@@ -229,29 +316,29 @@ const GateConfig = () => {
key: 'url',
align: 'center',
ellipsis: true,
width: 200,
render: (text, record) => (
<span>
<Tooltip placement="top" title={text}>
{text}
</Tooltip>
</span>
),
},
{
title: '下游路由模板',
dataIndex: 'downstreamPathTemplate',
key: 'downstreamPathTemplate',
ellipsis: true,
align: 'center',
render: (text, record) => (
<span>
<Tooltip placement="top" title={text}>
{text}
<Tooltip placement="top" title={`下游路由模板:${record.downstreamPathTemplate}`}>
{`${text}${record.downstreamPathTemplate}`}
</Tooltip>
</span>
),
},
// {
// title: '下游路由模板',
// dataIndex: 'downstreamPathTemplate',
// key: 'downstreamPathTemplate',
// ellipsis: true,
// width: 150,
// align: 'center',
// render: (text, record) => (
// <span>
// <Tooltip placement="top" title={text}>
// {text}
// </Tooltip>
// </span>
// ),
// },
{
title: '开启身份认证',
dataIndex: 'isAuthentication',
......@@ -271,6 +358,7 @@ const GateConfig = () => {
dataIndex: 'priority',
key: 'priority',
align: 'center',
width: 100,
render: (text, record) => {
console.log(text);
return (
......@@ -287,6 +375,7 @@ const GateConfig = () => {
key: 'action',
width: 100,
align: 'center',
fixed: 'right',
render: record => {
if (record.key != 'CityServer') {
return (
......
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