Explorar el Código

fix: 个人中心bug

wzyyy hace 3 años
padre
commit
2096f67b86

+ 2 - 2
config/proxy.ts

@@ -9,8 +9,8 @@
 export default {
   dev: {
     '/jetlinks': {
-      // target: 'http://192.168.32.44:8844/',
-      // ws: 'ws://192.168.32.44:8844/',
+      // target: 'http://192.168.32.8:8844/',
+      // ws: 'ws://192.168.32.8:8844/',
       target: 'http://120.79.18.123:8844/',
       ws: 'ws://120.79.18.123:8844/',
       // target: 'http://192.168.66.5:8844/',

+ 3 - 3
src/components/RightContent/AvatarDropdown.tsx

@@ -1,5 +1,5 @@
 import React, { useCallback } from 'react';
-import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
+import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
 import { Avatar, Menu, Spin } from 'antd';
 import { history, useModel } from 'umi';
 import { stringify } from 'querystring';
@@ -87,7 +87,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
           })}
         </Menu.Item>
       )}
-      {menu && (
+      {/* {menu && (
         <Menu.Item key="settings">
           <SettingOutlined />
           {intl.formatMessage({
@@ -95,7 +95,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
             defaultMessage: '个人设置',
           })}
         </Menu.Item>
-      )}
+      )} */}
       {menu && <Menu.Divider />}
 
       <Menu.Item key="logout">

+ 2 - 2
src/pages/account/Center/edit/infoEdit.tsx

@@ -65,12 +65,12 @@ const InfoEdit = (props: Props) => {
         <Row gutter={[24, 24]}>
           <Col span={12}>
             <Form.Item label="角色" name="role">
-              <Input placeholder="请输入姓名" disabled />
+              <Input placeholder="请输入角色" disabled />
             </Form.Item>
           </Col>
           <Col span={12}>
             <Form.Item label="部门" name="org">
-              <Input placeholder="请输入用户名" disabled />
+              <Input placeholder="请输入部门" disabled />
             </Form.Item>
           </Col>
         </Row>

+ 25 - 1
src/pages/account/Center/index.tsx

@@ -21,10 +21,12 @@ import InfoEdit from './edit/infoEdit';
 import PasswordEdit from './edit/passwordEdit';
 import Service from '@/pages/account/Center/service';
 import moment from 'moment';
+import { useModel } from 'umi';
 
 export const service = new Service();
 
 const Center = () => {
+  const { initialState, setInitialState } = useModel('@@initialState');
   const [data, setData] = useState<any>();
   const [imageUrl, setImageUrl] = useState<string>('');
   // const [loading, setLoading] = useState<boolean>(false)
@@ -42,6 +44,7 @@ const Center = () => {
 
   const uploadProps: UploadProps = {
     showUploadList: false,
+    accept: 'image/jpeg,image/png',
     action: `/${SystemConst.API_BASE}/file/static`,
     headers: {
       'X-Access-Token': Token.get(),
@@ -79,6 +82,12 @@ const Center = () => {
     service.getUserDetail().subscribe((res) => {
       setData(res.result);
       setImageUrl(res.result.avatar);
+      // setInitialState({
+      //   ...initialState,
+      //   currentUser:{
+
+      //   }
+      // })
     });
   };
   const saveInfo = (parms: UserDetail) => {
@@ -102,7 +111,6 @@ const Center = () => {
   const getBindInfo = () => {
     service.bindInfo().then((res) => {
       if (res.status === 200) {
-        console.log(res);
         setBindList(res.result);
       }
     });
@@ -121,6 +129,22 @@ const Center = () => {
     getBindInfo();
   }, []);
 
+  useEffect(() => {
+    if (data?.name) {
+      const item = {
+        ...initialState?.currentUser?.user,
+        name: data.name,
+      };
+      setInitialState({
+        ...initialState,
+        currentUser: {
+          ...initialState?.currentUser,
+          user: item,
+        },
+      });
+    }
+  }, [data]);
+
   return (
     <PageContainer>
       <Card>

+ 4 - 5
src/pages/link/Channel/Modbus/Access/index.tsx

@@ -48,7 +48,7 @@ const Access = () => {
     },
     {
       title: '读取起始位置',
-      dataIndex: 'address',
+      render: (record: any) => <>{record.codecConfig?.readIndex}</>,
     },
     {
       title: '读取长度',
@@ -243,7 +243,7 @@ const Access = () => {
             onChange={(e) => {
               setDeviceId(e);
               const items = bindList.find((item: any) => item.id === e);
-              setProductId(items[0].productId);
+              setProductId(items[0]?.productId);
               setParam({
                 terms: [{ column: 'deviceId', value: e }],
               });
@@ -298,15 +298,14 @@ const Access = () => {
                       </PermissionButton>
                       <div style={{ marginLeft: 10 }}>
                         <Input.Search
-                          placeholder="请输入属性"
+                          placeholder="请输入属性ID"
                           allowClear
                           onSearch={(value) => {
                             console.log(value);
                             if (value) {
                               setParam({
                                 terms: [
-                                  { column: 'deviceId', value: deviceId },
-                                  { column: 'property', value: `%${value}%`, termType: 'like' },
+                                  { column: 'metadataId', value: `%${value}%`, termType: 'like' },
                                 ],
                               });
                             } else {

+ 1 - 1
src/pages/link/Channel/Opcua/Access/index.tsx

@@ -240,7 +240,7 @@ const Access = () => {
             onChange={(e) => {
               setDeviceId(e);
               const items = bindList.find((item: any) => item.deviceId === e);
-              setProductId(items[0].productId);
+              setProductId(items[0]?.productId);
               setParam({
                 terms: [{ column: 'deviceId', value: e }],
               });

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

@@ -127,7 +127,7 @@ const Login: React.FC = () => {
     setLoading(true);
     Service.login({ expires: loginRef.current.expires, verifyKey: captcha.key, ...data }).subscribe(
       {
-        next: async (userInfo: UserInfo) => {
+        next: async (userInfo) => {
           Token.set(userInfo.token);
           await fetchUserInfo();
           goto();

+ 6 - 6
src/pages/user/Login/user.d.ts

@@ -33,11 +33,11 @@ type Permission = {
 };
 
 type UserInfo = {
-  userId: string;
+  userId?: string;
   user: Partial<UserBase>;
-  token: string;
-  roles: Role[];
-  permissions: Partial<Permission>[];
-  expires: number;
-  currentAuthority: string[];
+  token?: string;
+  roles?: Role[];
+  permissions?: Partial<Permission>[];
+  expires?: number;
+  currentAuthority?: string[];
 };