Browse Source

fix: local sync crashed when connecting failed

master
smallstonesk 4 years ago
parent
commit
e1b1be402e
  1. 2
      packages/core/src/mods/header/connectStatus/editModal.tsx
  2. 2
      packages/core/src/mods/header/connectStatus/index.module.less
  3. 20
      packages/core/src/mods/header/connectStatus/index.tsx

2
packages/core/src/mods/header/connectStatus/editModal.tsx

@ -32,8 +32,8 @@ const EditModal: React.FC<IEditorModalProps> = props => {
// events
const onClickOk = (): void => {
formRef.current && formRef.current.validateFields().then((formValues) => {
onOk();
updateLocalConfig(formValues as ILocalConfig);
onOk();
}).catch(err => {
console.log(err.message);
});

2
packages/core/src/mods/header/connectStatus/index.module.less

@ -5,7 +5,7 @@
align-items: center;
margin-right: 20px;
.error {
.tag {
cursor: pointer;
}
}

20
packages/core/src/mods/header/connectStatus/index.tsx

@ -49,7 +49,7 @@ const ConnectStatus: React.FC<IProps> = (props) => {
};
const confirmToSync = () => {
syncLocal().then(data => {
const {dsl} = data;
const {dsl} = data || {};
dsl && Modal.confirm({
title: '本地连接成功,是否将数据同步至当前项目?',
onOk() {
@ -75,18 +75,16 @@ const ConnectStatus: React.FC<IProps> = (props) => {
confirmToSync();
};
let tagText = '本地连接失败 点击修改配置';
if(status === Status.connected) {
tagText = [projectName, '本地连接成功'].join(' ');
}
return (
<div className={styles.container}>
{status === Status.connected && (
<Tag color={'success'}>
{[projectName, '本地连接成功'].join(' ')}
</Tag>
)}
{status === Status.disconnected && (
<Tag className={styles.error} color={'error'} onClick={onOpenEditModal}>
</Tag>
)}
<Tag className={styles.tag} color={status} onClick={onOpenEditModal}>
{tagText}
</Tag>
<EditModal
visible={visible}
onOk={onOk}

Loading…
Cancel
Save