valentichu преди 1 година
родител
ревизия
5c299fd2d1
променени са 7 файла, в които са добавени 51 реда и са изтрити 54 реда
  1. 0 0
      lib/index.js
  2. 20 8
      src/App.jsx
  3. 2 4
      src/api/alarm.js
  4. 19 20
      src/entry.jsx
  5. 5 11
      src/pages/Alarm/components/complex.jsx
  6. 0 2
      src/pages/Alarm/components/complex.module.less
  7. 5 9
      src/pages/Alarm/components/easy.jsx

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
lib/index.js


+ 20 - 8
src/App.jsx

@@ -1,14 +1,26 @@
-import React, { useEffect, useMemo, useState } from "react";
-import { EasyConfig, ComplexConfig } from "./entry";
+import React, { useEffect, useMemo, useState, useRef } from "react";
+import Alarm from "./entry";
 
 function Home(props) {
+  const compRef = useRef(null);
+
   return (
-    <EasyConfig
-      editId={-1}
-      onConfirm={() => {
-        console.log(1);
-      }}
-    ></EasyConfig>
+    <>
+      <Alarm.ComplexConfig
+        ref={compRef}
+        editId={-1}
+        onConfirm={() => {
+          console.log(1);
+        }}
+      ></Alarm.ComplexConfig>
+      <button
+        onClick={() => {
+          console.log(compRef);
+        }}
+      >
+        测试
+      </button>
+    </>
   );
 }
 

+ 2 - 4
src/api/alarm.js

@@ -1,9 +1,6 @@
 import axios from "axios";
 const config = {
-  baseURL:
-    process.env.NODE_ENV === "development"
-      ? "http://192.168.1.109:32080"
-      : window.location.origin,
+  baseURL: "http://192.168.1.109:32080",
   // baseURL: '/api/aragron',
   noNeedInterceptor: false,
   headers: {
@@ -27,6 +24,7 @@ export async function searchPoint(data) {
     data,
     config
   );
+  console.log(res)
   return res.statusText ? res.data : res;
 }
 

+ 19 - 20
src/entry.jsx

@@ -18,7 +18,7 @@ import "dayjs/locale/zh-cn";
 import dayjs from "dayjs";
 dayjs.locale("zh-cn");
 
-export const EasyConfig = forwardRef((props, ref) => {
+const EasyConfig = forwardRef((props, ref) => {
   const { editId = -1, onConfirm } = props;
   const compRef = useRef(null);
 
@@ -30,15 +30,11 @@ export const EasyConfig = forwardRef((props, ref) => {
     }
   }, [themeName]);
 
-  useImperativeHandle(
-    ref,
-    () => {
-      return {
-        fetchData: compRef.ok(),
-      };
-    },
-    []
-  );
+  useImperativeHandle(ref, () => {
+    return {
+      ok: compRef?.current?.ok,
+    };
+  });
 
   return (
     <ThemeWrapper setThemeName={setThemeName}>
@@ -57,7 +53,7 @@ export const EasyConfig = forwardRef((props, ref) => {
   );
 });
 
-export const ComplexConfig = forwardRef((props, ref) => {
+const ComplexConfig = forwardRef((props, ref) => {
   const { editId = -1, onConfirm } = props;
   const compRef = useRef(null);
 
@@ -69,15 +65,13 @@ export const ComplexConfig = forwardRef((props, ref) => {
     }
   }, [themeName]);
 
-  useImperativeHandle(
-    ref,
-    () => {
-      return {
-        fetchData: compRef.ok(),
-      };
-    },
-    []
-  );
+  useImperativeHandle(ref, () => {
+    return {
+      ok: compRef?.current?.ok,
+    };
+  });
+
+  console.log(compRef);
 
   return (
     <ThemeWrapper setThemeName={setThemeName}>
@@ -95,3 +89,8 @@ export const ComplexConfig = forwardRef((props, ref) => {
     </ThemeWrapper>
   );
 });
+
+export default {
+  EasyConfig,
+  ComplexConfig,
+};

+ 5 - 11
src/pages/Alarm/components/complex.jsx

@@ -126,15 +126,11 @@ const Complex = (props, ref) => {
     props.onConfirm();
   };
 
-  useImperativeHandle(
-    ref,
-    () => {
-      return {
-        ok: onModalOk,
-      };
-    },
-    [onModalOk]
-  );
+  useImperativeHandle(ref, () => {
+    return {
+      ok: onModalOk,
+    };
+  });
 
   const symbClick = (e) => {
     let innerText = e.target.innerText;
@@ -196,8 +192,6 @@ const Complex = (props, ref) => {
     form.resetFields();
   };
 
-  console.log(styles);
-
   return (
     <div className={styles.wrapper}>
       <div className="main">

+ 0 - 2
src/pages/Alarm/components/complex.module.less

@@ -40,8 +40,6 @@
     .main {
       display: flex;
       width: 100%;
-      padding-left: 16px;
-      padding-right: 16px;
 
       .left {
         width: 60%;

+ 5 - 9
src/pages/Alarm/components/easy.jsx

@@ -239,15 +239,11 @@ const Easy = (props, ref) => {
     }
   };
 
-  useImperativeHandle(
-    ref,
-    () => {
-      return {
-        ok: onModalOk,
-      };
-    },
-    [onModalOk]
-  );
+  useImperativeHandle(ref, () => {
+    return {
+      ok: onModalOk,
+    };
+  });
 
   useEffect(() => {
     onSearch("");

Някои файлове не бяха показани, защото твърде много файлове са промени