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

fix: '网关配置优化'

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