xieyonghong 3 лет назад
Родитель
Сommit
f02db72c48

+ 4 - 0
src/app.tsx

@@ -241,6 +241,10 @@ const MenuItemIcon = (
 // ProLayout 支持的api https://procomponents.ant.design/components/layout
 export const layout: RunTimeLayoutConfig = ({ initialState }) => {
   // console.log({ ...initialState });
+  // let ico:any = document.querySelector('link[rel="icon"]')
+  // if(ico!==null){
+  //   ico.href='https://t9.baidu.com/it/u=2615841454,1925018474&fm=218&app=126&size=f242,150&n=0&f=JPEG&fmt=auto?s=A0B46032495267E15A7D35CE000070A2&sec=1657645200&t=b98ebc7ac3073c248e57894e899d7ac1'
+  // }
   return {
     navTheme: 'light',
     headerTheme: 'light',

+ 17 - 4
src/pages/device/components/Metadata/Import/index.tsx

@@ -7,6 +7,7 @@ import type { ISchema } from '@formily/json-schema';
 import FMonacoEditor from '@/components/FMonacoEditor';
 import FUpload from '@/components/Upload';
 import { service } from '@/pages/device/Product';
+import { service as deviceService } from '@/pages/device/Instance';
 import { useParams } from 'umi';
 import { Store } from 'jetlinks-store';
 import SystemConst from '@/utils/const';
@@ -19,6 +20,7 @@ import { DeviceMetadata } from '@/pages/device/Product/typings';
 interface Props {
   visible: boolean;
   close: () => void;
+  type: 'product' | 'device';
 }
 
 const Import = (props: Props) => {
@@ -190,7 +192,7 @@ const Import = (props: Props) => {
     const old = JSON.parse(InstanceModel.detail?.metadata || '{}');
     const fid = _.map(InstanceModel.detail?.features || [], 'id');
     if (fid.includes('eventNotModifiable')) {
-      obj.events = old?.event || [];
+      obj.events = old?.events || [];
     }
     if (fid.includes('propertyNotModifiable')) {
       obj.properties = old?.properties || [];
@@ -205,16 +207,27 @@ const Import = (props: Props) => {
       service.convertMetadata('from', 'alink', data.import).subscribe({
         next: async (meta) => {
           onlyMessage('导入成功');
-          await service.modify(param.id, { metadata: JSON.stringify(operateLimits(meta)) });
+          if (props?.type === 'device') {
+            await deviceService.modify(param.id, { metadata: JSON.stringify(operateLimits(meta)) });
+          } else {
+            await service.modify(param.id, { metadata: JSON.stringify(operateLimits(meta)) });
+          }
         },
         error: () => {
           onlyMessage('发生错误!', 'error');
         },
       });
     } else {
-      const resp = await service.modify(param.id, {
+      const params = {
+        id: param.id,
         metadata: JSON.stringify(operateLimits(JSON.parse(data[data?.type] || '{}'))),
-      });
+      };
+      let resp: any = undefined;
+      if (props?.type === 'device') {
+        resp = await deviceService.modify(param.id, params);
+      } else {
+        resp = await service.modify(param.id, params);
+      }
       if (resp.status === '200') {
         onlyMessage('导入成功');
       }

+ 1 - 1
src/pages/device/components/Metadata/index.tsx

@@ -138,7 +138,7 @@ const Metadata = observer((props: Props) => {
           <BaseMetadata target={props.type} type={'tags'} permission={permission} />
         </Tabs.TabPane>
       </Tabs>
-      <Import visible={visible} close={() => setVisible(false)} />
+      <Import visible={visible} type={props.type} close={() => setVisible(false)} />
       <Cat visible={cat} close={() => setCat(false)} type={props.type} />
     </div>
   );

+ 1 - 1
src/pages/document.ejs

@@ -13,7 +13,7 @@
       content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
     />
     <title>Jetlinks</title>
-    <link rel="icon" href="<%= context.config.publicPath + 'favicon.ico' %>" type="image/x-icon" />
+    <link rel="icon" id="ico" href="<%= context.config.publicPath + 'favicon.ico' %>" type="image/x-icon" />
   </head>
   <body>
     <noscript>

+ 22 - 12
src/pages/home/index.tsx

@@ -22,18 +22,18 @@ const Home = () => {
     comprehensive: <Comprehensive />,
   };
 
-  useEffect(() => {
-    service.queryView().then((resp) => {
-      setLoading(false);
-      if (resp.status === 200) {
-        if (resp.result.length == 0) {
-          setCurrent('init');
-        } else {
-          setCurrent(resp.result[0]?.content);
-        }
-      }
-    });
-  }, []);
+  // useEffect(() => {
+  //   service.queryView().then((resp) => {
+  //     // setLoading(false);
+  //     if (resp.status === 200) {
+  //       if (resp.result.length == 0) {
+  //         setCurrent('init');
+  //       } else {
+  //         setCurrent(resp.result[0]?.content);
+  //       }
+  //     }
+  //   });
+  // }, []);
   useEffect(() => {
     service.userDetail().then((res) => {
       if (res.status === 200) {
@@ -49,6 +49,16 @@ const Home = () => {
           .then((response) => {
             if (response.status === 200) {
               setDetail(response.result?.data);
+              service.queryView().then((resp) => {
+                setLoading(false);
+                if (resp.status === 200) {
+                  if (resp.result.length == 0) {
+                    setCurrent('init');
+                  } else {
+                    setCurrent(resp.result[0]?.content);
+                  }
+                }
+              });
             }
           });
       }

+ 1 - 1
src/pages/link/AccessConfig/Detail/Media/index.tsx

@@ -381,7 +381,7 @@ const Media = (props: Props) => {
                   'x-component': 'ArrayCollapse',
                   'x-decorator': 'FormItem',
                   items: {
-                    type: 'void',
+                    type: 'object',
                     'x-component': 'ArrayCollapse.CollapsePanel',
                     'x-component-props': {
                       header: '节点',

+ 6 - 1
src/pages/notice/Config/Log/index.tsx

@@ -114,7 +114,12 @@ const Log = observer(() => {
           pageSize: 5,
         }}
         columns={columns}
-        request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
+        request={async (params) =>
+          service.getHistoryLog(state.current?.id || '', {
+            ...params,
+            sorts: [{ name: 'notifyTime', order: 'desc' }],
+          })
+        }
       />
     </Modal>
   );

+ 6 - 1
src/pages/notice/Template/Log/index.tsx

@@ -118,7 +118,12 @@ const Log = observer(() => {
         }
         params={param}
         columns={columns}
-        request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
+        request={async (params) =>
+          service.getHistoryLog(state.current?.id || '', {
+            ...params,
+            sorts: [{ name: 'notifyTime', order: 'desc' }],
+          })
+        }
       />
     </Modal>
   );

+ 7 - 1
src/pages/user/Login/index.tsx

@@ -56,9 +56,15 @@ const Login: React.FC = () => {
   const getCode = () => {
     delete loginForm.values?.verifyCode;
     loginRef.current = loginForm.values;
+    // setLoading(false);
     Service.captchaConfig()
       .pipe(
-        filter((r) => r.enabled),
+        filter((r) => {
+          if (!r.enabled) {
+            setLoading(false);
+          }
+          return r.enabled;
+        }),
         mergeMap(Service.getCaptcha),
         catchError(() => message.error('系统开小差,请稍后重试')),
       )