tianyunperfect преди 5 години
родител
ревизия
3de1efa26a
променени са 4 файла, в които са добавени 32 реда и са изтрити 5 реда
  1. 2 0
      bin/push.sh
  2. 2 1
      src/pages/MemoryList/index.tsx
  3. 6 0
      src/pages/Setting/index.tsx
  4. 22 4
      src/utils/utils.ts

+ 2 - 0
bin/push.sh

@@ -1,3 +1,5 @@
+umi build
+
 remote=root@www.tianyunperfect.cn
 
 # 在本地执行的代码,比如上传文件到服务器 scp 本地文件 user@ip:远程目录

+ 2 - 1
src/pages/MemoryList/index.tsx

@@ -6,6 +6,7 @@ import {SorterResult} from 'antd/es/table/interface';
 import {TableListItem} from './data.d';
 import service from './service';
 import UpdateForm from "@/pages/Memory/components/UpdateForm";
+import {minuteToDay} from "@/utils/utils";
 
 
 /**
@@ -74,7 +75,7 @@ const TableList: React.FC<{}> = () => {
       hideInForm: true,
       render: (text, row) => {
         return (<>
-          <span>{text + "分钟"}</span>
+          <span>{minuteToDay(row.period)}</span>
         </>);
       }
     },

+ 6 - 0
src/pages/Setting/index.tsx

@@ -50,6 +50,11 @@ const TableList: React.FC<{}> = () => {
   const [form2] = Form.useForm();
 
   const nameExist = async () => {
+    const userName = form2.getFieldValue("userName");
+    if (userName == null || userName.length <= 6) {
+      message.error("密码长度不够6位");
+      return false;
+    }
     const res = await service.nameExist({userName: form2.getFieldValue("userName")});
     if (res.success) {
       setSuccess(InputState.success);
@@ -103,6 +108,7 @@ const TableList: React.FC<{}> = () => {
             name="userName"
             hasFeedback
             validateStatus={success}
+            rules={[{required: true, message: '请输入用户名!'}]}
           >
             <Input />
           </Form.Item>

+ 22 - 4
src/utils/utils.ts

@@ -1,6 +1,6 @@
-import { parse } from 'querystring';
+import {parse} from 'querystring';
 import pathRegexp from 'path-to-regexp';
-import { Route } from '@/models/connect';
+import {Route} from '@/models/connect';
 
 /* eslint no-useless-escape:0 import/prefer-default-export:0 */
 const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
@@ -16,7 +16,7 @@ export const isAntDesignPro = (): boolean => {
 
 // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
 export const isAntDesignProOrDev = (): boolean => {
-  const { NODE_ENV } = process.env;
+  const {NODE_ENV} = process.env;
   if (NODE_ENV === 'development') {
     return true;
   }
@@ -35,7 +35,7 @@ export const getAuthorityFromRouter = <T extends Route>(
   pathname: string,
 ): T | undefined => {
   const authority = router.find(
-    ({ routes, path = '/' }) =>
+    ({routes, path = '/'}) =>
       (path && pathRegexp(path).exec(pathname)) ||
       (routes && getAuthorityFromRouter(routes, pathname)),
   );
@@ -63,3 +63,21 @@ export const getRouteAuthority = (path: string, routeData: Route[]) => {
   });
   return authorities;
 };
+
+
+export const minuteToDay = (minutes: number) => {
+  const day = parseInt(String(minutes / 60 / 24));
+  const hour = parseInt(String(minutes / 60 % 24));
+  const min = parseInt(String(minutes % 60));
+  let StatusMinuteStr = "";
+  if (day > 0) {
+    StatusMinuteStr = day + "天";
+  }
+  if (hour > 0) {
+    StatusMinuteStr += hour + "小时";
+  }
+  if (min > 0) {
+    StatusMinuteStr += parseFloat(String(min)) + "分钟";
+  }
+  return StatusMinuteStr;
+}