Explorar el Código

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

Lind hace 3 años
padre
commit
5dbe558a0b
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  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(() => {
   useEffect(() => {
-    Store.subscribe('current-network-data', (data) => {
+    const subscription = Store.subscribe('current-network-data', (data) => {
+      if (!data) return;
       form.readPretty = true;
       form.readPretty = true;
       const _data = _.cloneDeep(data);
       const _data = _.cloneDeep(data);
       // 处理一下集群模式数据
       // 处理一下集群模式数据
@@ -169,6 +170,10 @@ const Save = observer(() => {
       }
       }
       form.setValues(_data);
       form.setValues(_data);
     });
     });
+    return () => {
+      subscription.unsubscribe();
+      Store.set('current-network-data', undefined);
+    };
   }, []);
   }, []);
 
 
   const SchemaField = createSchemaField({
   const SchemaField = createSchemaField({