zy-react-library 1.0.62 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ import { UPLOAD_FILE_TYPE_ENUM } from "../../../enum/uploadFile/gwj";
10
10
  import useGetFile from "../../../hooks/useGetFile";
11
11
  import { getLabelName } from "../../../utils";
12
12
  import { HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "../../../enum/hidden/gwj";
13
+ import useGetUrlQuery from "../../../hooks/useGetUrlQuery";
13
14
 
14
15
  /**
15
16
  * 隐患查看组件(港务局版本)
@@ -39,29 +40,27 @@ function HiddenInfo(props) {
39
40
  const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
40
41
  const [acceptImageFiles, setAcceptImageFiles] = useState([]);
41
42
  const { getFile } = useGetFile();
43
+ const query = useGetUrlQuery();
42
44
 
43
45
  const getData = async () => {
44
- const urlParams = new URLSearchParams(window.location.search);
45
- const queryId = urlParams.get(idKey);
46
- const queryHiddenId = urlParams.get(hiddenIdKey);
47
- request(`/hidden/hidden/${id || queryId}`, "get").then((res) => {
46
+ request(`/hidden/hidden/${id || query[idKey]}`, "get").then((res) => {
48
47
  setInfo(res.data);
49
48
  });
50
- const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || queryHiddenId });
49
+ const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || query[hiddenIdKey] });
51
50
  setHiddenImageFiles(hiddenImageFiles);
52
- const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || queryHiddenId });
51
+ const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || query[hiddenIdKey] });
53
52
  setHiddenVideoFiles(hiddenVideoFiles);
54
53
  const afterRectificationImageFiles = await getFile({
55
54
  eqType: UPLOAD_FILE_TYPE_ENUM["4"],
56
- eqForeignKey: hiddenId || queryHiddenId,
55
+ eqForeignKey: hiddenId || query[hiddenIdKey],
57
56
  });
58
57
  setAfterRectificationImageFiles(afterRectificationImageFiles);
59
58
  const rectificationPlanImageFiles = await getFile({
60
59
  eqType: UPLOAD_FILE_TYPE_ENUM["8"],
61
- eqForeignKey: hiddenId || queryHiddenId,
60
+ eqForeignKey: hiddenId || query[hiddenIdKey],
62
61
  });
63
62
  setRectificationPlanImageFiles(rectificationPlanImageFiles);
64
- const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || queryHiddenId });
63
+ const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || query[hiddenIdKey] });
65
64
  setAcceptImageFiles(acceptImageFiles);
66
65
  };
67
66
  useEffect(() => {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 获取路由参数
3
+ */
4
+ export default function useGetUrlQuery(): Record<string, any>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 获取路由参数
3
+ */
4
+ function useGetUrlQuery() {
5
+ const urlQuery = new URLSearchParams(window.location.search);
6
+
7
+ // 直接返回包含所有参数的对象
8
+ const queryParams = {};
9
+ for (const [key, value] of urlQuery.entries()) {
10
+ queryParams[key] = value;
11
+ }
12
+
13
+ return queryParams;
14
+ }
15
+
16
+ export default useGetUrlQuery;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.62",
4
+ "version": "1.0.63",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",