浏览代码

fix(network): #3751 清空网络组件缓存数据

Lind 3 年之前
父节点
当前提交
5dbe558a0b
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/pages/link/Type/Save/index.tsx

+ 6 - 1
src/pages/link/Type/Save/index.tsx

@@ -160,7 +160,8 @@ const Save = observer(() => {
   );
 
   useEffect(() => {
-    Store.subscribe('current-network-data', (data) => {
+    const subscription = Store.subscribe('current-network-data', (data) => {
+      if (!data) return;
       form.readPretty = true;
       const _data = _.cloneDeep(data);
       // 处理一下集群模式数据
@@ -169,6 +170,10 @@ const Save = observer(() => {
       }
       form.setValues(_data);
     });
+    return () => {
+      subscription.unsubscribe();
+      Store.set('current-network-data', undefined);
+    };
   }, []);
 
   const SchemaField = createSchemaField({