tianyunperfect 5 năm trước cách đây
mục cha
commit
2c6d7ba4c4

+ 21 - 6
config/config.ts

@@ -1,20 +1,22 @@
 // https://umijs.org/config/
-import { defineConfig, utils } from 'umi';
+import {defineConfig, utils} from 'umi';
 import defaultSettings from './defaultSettings';
 import proxy from './proxy';
 import webpackPlugin from './plugin.config';
-const { winPath } = utils; // preview.pro.ant.design only do not use in your production ;
+
+const {winPath} = utils; // preview.pro.ant.design only do not use in your production ;
 // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
 
-const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, REACT_APP_ENV, GA_KEY } = process.env;
+const {ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, REACT_APP_ENV, GA_KEY} = process.env;
 export default defineConfig({
-  history: { type: 'hash' }, // 默认是 browser
+
+  history: {type: 'hash'}, // 默认是 browser
   hash: true,
   antd: {},
   analytics: GA_KEY
     ? {
-        ga: GA_KEY,
-      }
+      ga: GA_KEY,
+    }
     : false,
   dva: {
     hmr: true,
@@ -169,4 +171,17 @@ export default defineConfig({
   },
   proxy: proxy[REACT_APP_ENV || 'dev'],
   chainWebpack: webpackPlugin,
+
+  // scripts: [
+  //   'https://unpkg.com/react@16.8.6/umd/react.production.min.js',
+  //   'https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js',
+  //   'https://unpkg.com/bizcharts@3.5.5/umd/BizCharts.min.js',
+  //   'https://cdn.bootcss.com/antd/4.0.0/antd.min.js',
+  // ],
+  // externals: {
+  //   react: 'React',
+  //   antd: 'antd',
+  //   'react-dom': 'ReactDOM',
+  //   bizcharts: 'BizCharts',
+  // },
 });

+ 3 - 1
config/plugin.config.ts

@@ -30,7 +30,9 @@ const webpackPlugin = (config: IWebpackChainConfig) => {
       chunks: 'async',
       name: 'vendors',
       maxInitialRequests: Infinity,
-      minSize: 0,
+      minSize: 30000,
+      minChunks: 3,
+      automaticNameDelimiter: '.',
       cacheGroups: {
         vendors: {
           test: (module: { context: string }) => {

+ 0 - 25
src/pages/ListTableList/components/CreateForm.tsx

@@ -1,25 +0,0 @@
-import React from 'react';
-import { Modal } from 'antd';
-
-interface CreateFormProps {
-  modalVisible: boolean;
-  onCancel: () => void;
-}
-
-const CreateForm: React.FC<CreateFormProps> = (props) => {
-  const { modalVisible, onCancel } = props;
-
-  return (
-    <Modal
-      destroyOnClose
-      title="新建规则"
-      visible={modalVisible}
-      onCancel={() => onCancel()}
-      footer={null}
-    >
-      {props.children}
-    </Modal>
-  );
-};
-
-export default CreateForm;

+ 0 - 214
src/pages/ListTableList/components/UpdateForm.tsx

@@ -1,214 +0,0 @@
-import React, { useState} from 'react';
-import { Form, Button, DatePicker, Input, Modal, Radio, Select, Steps } from 'antd';
-
-import { TableListItem } from '../data.d';
-
-export interface FormValueType extends Partial<TableListItem> {
-  target?: string;
-  template?: string;
-  type?: string;
-  time?: string;
-  frequency?: string;
-}
-
-export interface UpdateFormProps {
-  onCancel: (flag?: boolean, formVals?: FormValueType) => void;
-  onSubmit: (values: FormValueType) => void;
-  updateModalVisible: boolean;
-  values: Partial<TableListItem>;
-}
-const FormItem = Form.Item;
-const { Step } = Steps;
-const { TextArea } = Input;
-const { Option } = Select;
-const RadioGroup = Radio.Group;
-
-export interface UpdateFormState {
-  formVals: FormValueType;
-  currentStep: number;
-}
-
-const formLayout = {
-  labelCol: { span: 7 },
-  wrapperCol: { span: 13 },
-};
-
-const UpdateForm: React.FC<UpdateFormProps> = (props) => {
-  const [formVals, setFormVals] = useState<FormValueType>({
-    name: props.values.name,
-    desc: props.values.desc,
-    key: props.values.key,
-    target: '0',
-    template: '0',
-    type: '1',
-    time: '',
-    frequency: 'month',
-  });
-
-  const [currentStep, setCurrentStep] = useState<number>(0);
-
-  const [form] = Form.useForm();
-
-  const {
-    onSubmit: handleUpdate,
-    onCancel: handleUpdateModalVisible,
-    updateModalVisible,
-    values,
-  } = props;
-
-  const forward = () => setCurrentStep(currentStep + 1);
-
-  const backward = () => setCurrentStep(currentStep - 1);
-
-  const handleNext = async () => {
-    const fieldsValue = await form.validateFields();
-
-    setFormVals({ ...formVals, ...fieldsValue });
-
-    if (currentStep < 2) {
-      forward();
-    } else {
-      handleUpdate(formVals);
-    }
-  };
-
-  const renderContent = () => {
-    if (currentStep === 1) {
-      return (
-        <>
-          <FormItem name="target" label="监控对象">
-            <Select style={{ width: '100%' }}>
-              <Option value="0">表一</Option>
-              <Option value="1">表二</Option>
-            </Select>
-          </FormItem>
-          <FormItem name="template" label="规则模板">
-            <Select style={{ width: '100%' }}>
-              <Option value="0">规则模板一</Option>
-              <Option value="1">规则模板二</Option>
-            </Select>
-          </FormItem>
-          <FormItem name="type" label="规则类型">
-            <RadioGroup>
-              <Radio value="0">强</Radio>
-              <Radio value="1">弱</Radio>
-            </RadioGroup>
-          </FormItem>
-        </>
-      );
-    }
-    if (currentStep === 2) {
-      return (
-        <>
-          <FormItem
-            name="time"
-            label="开始时间"
-            rules={[{ required: true, message: '请选择开始时间!' }]}
-          >
-            <DatePicker
-              style={{ width: '100%' }}
-              showTime
-              format="YYYY-MM-DD HH:mm:ss"
-              placeholder="选择开始时间"
-            />
-          </FormItem>
-          <FormItem name="frequency" label="调度周期">
-            <Select style={{ width: '100%' }}>
-              <Option value="month">月</Option>
-              <Option value="week">周</Option>
-            </Select>
-          </FormItem>
-        </>
-      );
-    }
-    return (
-      <>
-        <FormItem
-          name="name"
-          label="规则名称"
-          rules={[{ required: true, message: '请输入规则名称!' }]}
-        >
-          <Input placeholder="请输入" />
-        </FormItem>
-        <FormItem
-          name="desc"
-          label="规则描述"
-          rules={[{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }]}
-        >
-          <TextArea rows={4} placeholder="请输入至少五个字符" />
-        </FormItem>
-      </>
-    );
-  };
-
-  const renderFooter = () => {
-    if (currentStep === 1) {
-      return (
-        <>
-          <Button style={{ float: 'left' }} onClick={backward}>
-            上一步
-          </Button>
-          <Button onClick={() => handleUpdateModalVisible(false, values)}>取消</Button>
-          <Button type="primary" onClick={() => handleNext()}>
-            下一步
-          </Button>
-        </>
-      );
-    }
-    if (currentStep === 2) {
-      return (
-        <>
-          <Button style={{ float: 'left' }} onClick={backward}>
-            上一步
-          </Button>
-          <Button onClick={() => handleUpdateModalVisible(false, values)}>取消</Button>
-          <Button type="primary" onClick={() => handleNext()}>
-            完成
-          </Button>
-        </>
-      );
-    }
-    return (
-      <>
-        <Button onClick={() => handleUpdateModalVisible(false, values)}>取消</Button>
-        <Button type="primary" onClick={() => handleNext()}>
-          下一步
-        </Button>
-      </>
-    );
-  };
-
-  return (
-    <Modal
-      width={640}
-      bodyStyle={{ padding: '32px 40px 48px' }}
-      destroyOnClose
-      title="规则配置"
-      visible={updateModalVisible}
-      footer={renderFooter()}
-      onCancel={() => handleUpdateModalVisible()}
-    >
-      <Steps style={{ marginBottom: 28 }} size="small" current={currentStep}>
-        <Step title="基本信息" />
-        <Step title="配置规则属性" />
-        <Step title="设定调度周期" />
-      </Steps>
-      <Form
-        {...formLayout}
-        form={form}
-        initialValues={{
-          target: formVals.target,
-          template: formVals.template,
-          type: formVals.type,
-          frequency: formVals.frequency,
-          name: formVals.name,
-          desc: formVals.desc,
-        }}
-      >
-        {renderContent()}
-      </Form>
-    </Modal>
-  );
-};
-
-export default UpdateForm;

+ 0 - 35
src/pages/ListTableList/data.d.ts

@@ -1,35 +0,0 @@
-export interface TableListItem {
-  key: number;
-  disabled?: boolean;
-  href: string;
-  avatar: string;
-  name: string;
-  owner: string;
-  desc: string;
-  callNo: number;
-  status: number;
-  updatedAt: Date;
-  createdAt: Date;
-  progress: number;
-}
-
-export interface TableListPagination {
-  total: number;
-  pageSize: number;
-  current: number;
-}
-
-export interface TableListData {
-  list: TableListItem[];
-  pagination: Partial<TableListPagination>;
-}
-
-export interface TableListParams {
-  sorter?: string;
-  status?: string;
-  name?: string;
-  desc?: string;
-  key?: number;
-  pageSize?: number;
-  currentPage?: number;
-}

+ 0 - 232
src/pages/ListTableList/index.tsx

@@ -1,232 +0,0 @@
-import { DownOutlined, PlusOutlined } from '@ant-design/icons';
-import { Button, Divider, Dropdown, Menu, message } from 'antd';
-import React, { useState, useRef } from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
-import { SorterResult } from 'antd/es/table/interface';
-
-import CreateForm from './components/CreateForm';
-import UpdateForm, { FormValueType } from './components/UpdateForm';
-import { TableListItem } from './data.d';
-import { queryRule, updateRule, addRule, removeRule } from './service';
-
-/**
- * 添加节点
- * @param fields
- */
-const handleAdd = async (fields: TableListItem) => {
-  const hide = message.loading('正在添加');
-  try {
-    await addRule({ ...fields });
-    hide();
-    message.success('添加成功');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('添加失败请重试!');
-    return false;
-  }
-};
-
-/**
- * 更新节点
- * @param fields
- */
-const handleUpdate = async (fields: FormValueType) => {
-  const hide = message.loading('正在配置');
-  try {
-    await updateRule({
-      name: fields.name,
-      desc: fields.desc,
-      key: fields.key,
-    });
-    hide();
-
-    message.success('配置成功');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('配置失败请重试!');
-    return false;
-  }
-};
-
-/**
- *  删除节点
- * @param selectedRows
- */
-const handleRemove = async (selectedRows: TableListItem[]) => {
-  const hide = message.loading('正在删除');
-  if (!selectedRows) return true;
-  try {
-    await removeRule({
-      key: selectedRows.map((row) => row.key),
-    });
-    hide();
-    message.success('删除成功,即将刷新');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('删除失败,请重试');
-    return false;
-  }
-};
-
-const TableList: React.FC<{}> = () => {
-  const [sorter, setSorter] = useState<string>('');
-  const [createModalVisible, handleModalVisible] = useState<boolean>(false);
-  const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
-  const [stepFormValues, setStepFormValues] = useState({});
-  const actionRef = useRef<ActionType>();
-  const columns: ProColumns<TableListItem>[] = [
-    {
-      title: '规则名称',
-      dataIndex: 'name',
-      rules: [
-        {
-          required: true,
-          message: '规则名称为必填项',
-        },
-      ],
-    },
-    {
-      title: '描述',
-      dataIndex: 'desc',
-      valueType: 'textarea',
-    },
-    {
-      title: '服务调用次数',
-      dataIndex: 'callNo',
-      sorter: true,
-      hideInForm: true,
-      renderText: (val: string) => `${val} 万`,
-    },
-    {
-      title: '状态',
-      dataIndex: 'status',
-      hideInForm: true,
-      valueEnum: {
-        0: { text: '关闭', status: 'Default' },
-        1: { text: '运行中', status: 'Processing' },
-        2: { text: '已上线', status: 'Success' },
-        3: { text: '异常', status: 'Error' },
-      },
-    },
-    {
-      title: '上次调度时间',
-      dataIndex: 'updatedAt',
-      sorter: true,
-      valueType: 'dateTime',
-      hideInForm: true,
-    },
-    {
-      title: '操作',
-      dataIndex: 'option',
-      valueType: 'option',
-      render: (_, record) => (
-        <>
-          <a
-            onClick={() => {
-              handleUpdateModalVisible(true);
-              setStepFormValues(record);
-            }}
-          >
-            配置
-          </a>
-          <Divider type="vertical" />
-          <a href="">订阅警报</a>
-        </>
-      ),
-    },
-  ];
-
-  return (
-    <PageHeaderWrapper>
-      <ProTable<TableListItem>
-        headerTitle="查询表格"
-        actionRef={actionRef}
-        rowKey="key"
-        onChange={(_, _filter, _sorter) => {
-          const sorterResult = _sorter as SorterResult<TableListItem>;
-          if (sorterResult.field) {
-            setSorter(`${sorterResult.field}_${sorterResult.order}`);
-          }
-        }}
-        params={{
-          sorter,
-        }}
-        toolBarRender={(action, { selectedRows }) => [
-          <Button type="primary" onClick={() => handleModalVisible(true)}>
-            <PlusOutlined /> 新建
-          </Button>,
-          selectedRows && selectedRows.length > 0 && (
-            <Dropdown
-              overlay={
-                <Menu
-                  onClick={async (e) => {
-                    if (e.key === 'remove') {
-                      await handleRemove(selectedRows);
-                      action.reload();
-                    }
-                  }}
-                  selectedKeys={[]}
-                >
-                  <Menu.Item key="remove">批量删除</Menu.Item>
-                  <Menu.Item key="approval">批量审批</Menu.Item>
-                </Menu>
-              }
-            >
-              <Button>
-                批量操作 <DownOutlined />
-              </Button>
-            </Dropdown>
-          ),
-        ]}
-
-        request={(params) => queryRule(params)}
-        columns={columns}
-        rowSelection={{}}
-      />
-      <CreateForm onCancel={() => handleModalVisible(false)} modalVisible={createModalVisible}>
-        <ProTable<TableListItem, TableListItem>
-          onSubmit={async (value) => {
-            const success = await handleAdd(value);
-            if (success) {
-              handleModalVisible(false);
-              if (actionRef.current) {
-                actionRef.current.reload();
-              }
-            }
-          }}
-          rowKey="key"
-          type="form"
-          columns={columns}
-          rowSelection={{}}
-        />
-
-      </CreateForm>
-      {stepFormValues && Object.keys(stepFormValues).length ? (
-        <UpdateForm
-          onSubmit={async (value) => {
-            const success = await handleUpdate(value);
-            if (success) {
-              handleUpdateModalVisible(false);
-              setStepFormValues({});
-              if (actionRef.current) {
-                actionRef.current.reload();
-              }
-            }
-          }}
-          onCancel={() => {
-            handleUpdateModalVisible(false);
-            setStepFormValues({});
-          }}
-          updateModalVisible={updateModalVisible}
-          values={stepFormValues}
-        />
-      ) : null}
-    </PageHeaderWrapper>
-  );
-};
-
-export default TableList;

+ 0 - 38
src/pages/ListTableList/service.ts

@@ -1,38 +0,0 @@
-import request from '@/utils/request';
-import { TableListParams, TableListItem } from './data.d';
-
-export async function queryRule(params?: TableListParams) {
-  return request('/api/rule', {
-    params,
-  });
-}
-
-export async function removeRule(params: { key: number[] }) {
-  return request('/api/rule', {
-    method: 'POST',
-    data: {
-      ...params,
-      method: 'delete',
-    },
-  });
-}
-
-export async function addRule(params: TableListItem) {
-  return request('/api/rule', {
-    method: 'POST',
-    data: {
-      ...params,
-      method: 'post',
-    },
-  });
-}
-
-export async function updateRule(params: TableListParams) {
-  return request('/api/rule', {
-    method: 'POST',
-    data: {
-      ...params,
-      method: 'update',
-    },
-  });
-}

+ 5 - 0
src/pages/Memory/components/UpdateForm.tsx

@@ -4,6 +4,7 @@ import {TableListItem} from '../../MemoryList/data.d';
 import Quill from "@/pages/Memory/components/Quill";
 import service from "@/pages/Memory/service";
 import {useSingleState} from "nice-hooks";
+import {getTextFromHtml} from "@/utils/utils";
 
 // 表单特殊字段
 export interface FormValueType extends Partial<TableListItem> {
@@ -70,6 +71,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
         <Button
           type="primary"
           onClick={async () => {
+            if (getTextFromHtml(formValues.front + formValues.back).length <= 1) {
+              message.info("你是不是没有输入文字?");
+              return;
+            }
             if (formValues.front.length >= 3000 || formValues.back.length >= 3000) {
               message.info("文字太长了,减少一些吧!");
               return;

+ 9 - 0
src/pages/Memory/index.tsx

@@ -210,6 +210,15 @@ const TableList: React.FC<{}> = () => {
                 >
                   简单
                 </Button>
+                <span> </span>
+                <Button
+                  type="primary"
+                  onClick={async () => {
+                    memoryRes(await service.delay(memory));
+                  }}
+                >
+                  搁置
+                </Button>
                 <p/>
                 <div>
                   <Button

+ 1 - 0
src/pages/Memory/service.ts

@@ -15,4 +15,5 @@ export default {
   restart: api.post("/api/memory/restart"),
   noMemory: api.post("/api/memory/noMemory"),
   delete: api.post("/api/memory/delete"),
+  delay: api.post("/api/memory/delay"),
 };

+ 0 - 6
src/pages/MemoryList/_mock.ts

@@ -10,12 +10,6 @@ const genList = (current: number, pageSize: number) => {
   for (let i = 0; i < pageSize; i += 1) {
     const index = (current - 1) * 10 + i;
     tableListDataSource.push({
-      msg: "为学者日益", success: "成功",
-      id: index,
-      serviceIp: `${index}name`,
-      modelName: `${index}name`,
-      modelVersion: `${new Date()}`,
-      currentVersion: `${new Date()}`
     });
   }
   tableListDataSource.reverse();

+ 28 - 10
src/pages/MemoryList/index.tsx

@@ -1,4 +1,4 @@
-import {Divider, message, Tooltip} from 'antd';
+import {Divider, message, Modal, Tooltip} from 'antd';
 import React, {useRef, useState} from 'react';
 import {PageHeaderWrapper} from '@ant-design/pro-layout';
 import ProTable, {ActionType, ProColumns} from '@ant-design/pro-table';
@@ -6,7 +6,8 @@ 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";
+import {getTextFromHtml, minuteToDay} from "@/utils/utils";
+import {ExclamationCircleOutlined} from "@ant-design/icons/lib";
 
 
 /**
@@ -27,10 +28,7 @@ const handleRemove = async (fields: TableListItem) => {
   }
 };
 
-const getTextFromHtml = (html: string) => {
-  let reg = /<\/?.+?\/?>/g;
-  return html.replace(reg, '').replace(/&nbsp;/g,'')
-}
+
 
 const TableList: React.FC<{}> = () => {
   const [sorter, setSorter] = useState<string>('');
@@ -38,6 +36,16 @@ const TableList: React.FC<{}> = () => {
   const [formValues, setFormValues] = useState({});
   const actionRef = useRef<ActionType>();
 
+  const { confirm } = Modal;
+
+  const deleteMemory = async (record:any) => {
+    await handleRemove(record);
+    if (actionRef.current) {
+      actionRef.current.reload();
+    }
+
+  };
+
   const columns: ProColumns<TableListItem>[] = [
     {
       title: '正面',
@@ -105,10 +113,20 @@ const TableList: React.FC<{}> = () => {
           <Divider type="vertical"/>
           <a
             onClick={async () => {
-              await handleRemove(record);
-              if (actionRef.current) {
-                actionRef.current.reload();
-              }
+              confirm({
+                title: '确定删除吗?',
+                icon: <ExclamationCircleOutlined />,
+                content: '删除后无法恢复',
+                okText: '确定',
+                okType: 'danger',
+                cancelText: '取消',
+                onOk() {
+                  deleteMemory(record);
+                },
+                onCancel() {
+                  console.log('Cancel');
+                },
+              });
             }}
           >
             删除

+ 0 - 53
src/pages/ModelList/_mock.ts

@@ -1,53 +0,0 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
-import {Request, Response} from 'express';
-import {parse} from 'url';
-import {TableListItem, TableListParams} from './data.d';
-
-// mock tableListDataSource
-const genList = (current: number, pageSize: number) => {
-  const tableListDataSource: TableListItem[] = [];
-
-  for (let i = 0; i < pageSize; i += 1) {
-    const index = (current - 1) * 10 + i;
-    tableListDataSource.push({
-      id: index,
-      modelName: `${index}name`,
-      modelFile: `${index}name`,
-      vocabFile: `${index}name`,
-      labelFile: `${index}name`,
-      mustTag: ``,
-      mustNotTag: ``,
-      onlyWord: `true`,
-      modelType: 0,
-    });
-  }
-  tableListDataSource.reverse();
-  return tableListDataSource;
-};
-
-const tableListDataSource = genList(1, 100);
-
-function getModels(req: Request, res: Response, u: string) {
-  let realUrl = u;
-  if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
-    realUrl = req.url;
-  }
-  const {current = 1, pageSize = 10} = req.query;
-  const params = (parse(realUrl, true).query as unknown) as TableListParams;
-
-  const dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
-
-  const result = {
-    data: dataSource,
-    total: tableListDataSource.length,
-    success: true,
-    pageSize,
-    current: parseInt(`${params.currentPage}`, 10) || 1,
-  };
-
-  return res.json(result);
-}
-
-export default {
-  'GET /api/model': getModels,
-};

+ 0 - 25
src/pages/ModelList/components/CreateForm.tsx

@@ -1,25 +0,0 @@
-import React from 'react';
-import { Modal } from 'antd';
-
-interface CreateFormProps {
-  modalVisible: boolean;
-  onCancel: () => void;
-}
-
-const CreateForm: React.FC<CreateFormProps> = (props) => {
-  const { modalVisible, onCancel } = props;
-
-  return (
-    <Modal
-      destroyOnClose
-      title="新建规则"
-      visible={modalVisible}
-      onCancel={() => onCancel()}
-      footer={null}
-    >
-      {props.children}
-    </Modal>
-  );
-};
-
-export default CreateForm;

+ 0 - 89
src/pages/ModelList/components/QueryForm.tsx

@@ -1,89 +0,0 @@
-import React, { useState } from 'react';
-import { Button, Form, Input, Modal } from 'antd';
-import service from '../service';
-
-const { TextArea } = Input;
-
-// 表单特殊字段
-export interface FormValueType {
-  modelName?: string;
-  queryStr?: string;
-}
-
-export interface FormProps {
-  onCancel: (flag?: boolean) => void;
-  // onSubmit: (values: FormValueType) => void;
-  modalVisible: boolean;
-  values: FormValueType;
-}
-
-const FormItem = Form.Item;
-
-const formLayout = {
-  labelCol: { span: 7 },
-  wrapperCol: { span: 13 },
-};
-
-const QueryForm: React.FC<FormProps> = (props) => {
-  const [resultStr, setResultStr] = useState('');
-
-  const [form] = Form.useForm();
-
-  const query = async () => {
-    const fields = await form.validateFields();
-    const result = await service.query(fields);
-    setResultStr(result);
-  };
-
-  const {
-    // onSubmit: handleUpdate,
-    onCancel: cancelModalVisible,
-    modalVisible,
-    values,
-  } = props;
-
-  const renderFooter = () => {
-    return (
-      <>
-        <Button onClick={() => cancelModalVisible()}>取消</Button>
-        <Button type="primary" onClick={() => query()}>
-          查询
-        </Button>
-      </>
-    );
-  };
-
-  return (
-    <Modal
-      width={640}
-      bodyStyle={{ padding: '32px 40px 48px' }}
-      destroyOnClose
-      title="相似度查询"
-      visible={modalVisible}
-      footer={renderFooter()}
-      onCancel={() => cancelModalVisible()}
-    >
-      <Form {...formLayout} form={form} initialValues={values}>
-        <FormItem
-          name="modelName"
-          label="模型名称"
-          rules={[{ required: true, message: '请输入规则名称!' }]}
-        >
-          <Input placeholder="请输入" readOnly />
-        </FormItem>
-        <FormItem
-          name="queryStr"
-          label="查询文字"
-          rules={[{ required: true, message: '请输入规则名称!' }]}
-        >
-          <Input placeholder="请输入" />
-        </FormItem>
-        <FormItem label="查询结果">
-          <TextArea value={resultStr} rows={4} readOnly />
-        </FormItem>
-      </Form>
-    </Modal>
-  );
-};
-
-export default QueryForm;

+ 0 - 145
src/pages/ModelList/components/UpdateForm.tsx

@@ -1,145 +0,0 @@
-import React, { useState } from 'react';
-import { Button, Form, Input, message, Modal, Radio, Upload } from 'antd';
-import { TableListItem } from '../data.d';
-import { UploadOutlined } from '@ant-design/icons';
-
-// 表单特殊字段
-export interface FormValueType extends Partial<TableListItem> {}
-
-export interface UpdateFormProps {
-  onCancel: (flag?: boolean, formVals?: FormValueType) => void;
-  onSubmit: (values: FormValueType) => void;
-  updateModalVisible: boolean;
-  values: Partial<TableListItem>;
-}
-
-const FormItem = Form.Item;
-
-const formLayout = {
-  labelCol: { span: 7 },
-  wrapperCol: { span: 13 },
-};
-
-const UpdateForm: React.FC<UpdateFormProps> = (props) => {
-  const [formVals, setFormVals] = useState<FormValueType>(props.values);
-
-  const [form] = Form.useForm();
-
-  const {
-    onSubmit: handleUpdate,
-    onCancel: handleUpdateModalVisible,
-    updateModalVisible,
-    values,
-  } = props;
-
-  const submit = async () => {
-    const fieldsValue = await form.validateFields();
-    const newValue = { ...formVals, ...fieldsValue };
-    setFormVals(newValue);
-    handleUpdate(newValue);
-  };
-
-  const modelFileProps = {
-    action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
-    // @ts-ignore
-    onChange(info) {
-      if (info.file.status === 'done') {
-        setFormVals({ ...formVals, ...{ modelFile: info.file.response.url } });
-        message.success(`file uploaded successfully`);
-      } else if (info.file.status === 'error') {
-        message.error(`file upload failed.`);
-      }
-    },
-  };
-  const vocabFileProps = {
-    action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
-    // @ts-ignore
-    onChange(info) {
-      if (info.file.status === 'done') {
-        setFormVals({ ...formVals, ...{ vocabFile: info.file.response.url } });
-        message.success(`file uploaded successfully`);
-      } else if (info.file.status === 'error') {
-        message.error(`file upload failed.`);
-      }
-    },
-  };
-  const labelFileProps = {
-    action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
-    // @ts-ignore
-    onChange(info) {
-      if (info.file.status === 'done') {
-        setFormVals({ ...formVals, ...{ labelFile: info.file.response.url } });
-        message.success(`file uploaded successfully`);
-      } else if (info.file.status === 'error') {
-        message.error(`file upload failed.`);
-      }
-    },
-  };
-
-  const renderFooter = () => {
-    return (
-      <>
-        <Button onClick={() => handleUpdateModalVisible(false, values)}>取消</Button>
-        <Button type="primary" onClick={() => submit()}>
-          提交
-        </Button>
-      </>
-    );
-  };
-
-  return (
-    <Modal
-      width={640}
-      bodyStyle={{ padding: '32px 40px 48px' }}
-      destroyOnClose
-      title="配置模型"
-      visible={updateModalVisible}
-      footer={renderFooter()}
-      onCancel={() => handleUpdateModalVisible()}
-    >
-      <Form {...formLayout} form={form} initialValues={formVals}>
-        <FormItem
-          name="modelName"
-          label="模型名称"
-          rules={[{ required: true, message: '请输入规则名称!' }]}
-        >
-          <Input placeholder="请输入" />
-        </FormItem>
-
-        <FormItem
-          name="modelType"
-          label="模型类型"
-          rules={[{ required: true, message: '请选择模型类型!' }]}
-        >
-          <Radio.Group>
-            <Radio.Button value="0">aubert</Radio.Button>
-            <Radio.Button value="1">blstm</Radio.Button>
-          </Radio.Group>
-        </FormItem>
-        <FormItem label="模型文件">
-          <Upload {...modelFileProps}>
-            <Button>
-              <UploadOutlined /> Upload
-            </Button>
-          </Upload>
-        </FormItem>
-        <FormItem label="词向量文件">
-          <Upload {...vocabFileProps}>
-            <Button>
-              <UploadOutlined /> Upload
-            </Button>
-          </Upload>
-        </FormItem>
-        <FormItem label="标签文件">
-          <Upload {...labelFileProps}>
-            <Button>
-              <UploadOutlined /> Upload
-            </Button>
-          </Upload>
-        </FormItem>
-      </Form>
-    </Modal>
-  );
-};
-
-export default UpdateForm;

+ 0 - 33
src/pages/ModelList/data.d.ts

@@ -1,33 +0,0 @@
-// 表单
-export interface TableListItem {
-  id?: number;
-  modelName: string;
-  modelFile: string;
-  vocabFile: string;
-  labelFile: string;
-  mustTag: string;
-  mustNotTag: string;
-  onlyWord: string;
-  modelType: number;
-}
-// 分页参数
-export interface TableListPagination {
-  total: number;
-  pageSize: number;
-  current: number;
-}
-// 返回的分页数据
-export interface TableListData {
-  list: TableListItem[];
-  pagination: Partial<TableListPagination>;
-}
-// 查询参数
-export interface TableListParams {
-  sorter?: string;
-  status?: string;
-  name?: string;
-  desc?: string;
-  id?: number;
-  pageSize?: number;
-  currentPage?: number;
-}

+ 0 - 3
src/pages/ModelList/index.less

@@ -1,3 +0,0 @@
-.upload{
-  display: inline;
-}

+ 0 - 280
src/pages/ModelList/index.tsx

@@ -1,280 +0,0 @@
-import { PlusOutlined } from '@ant-design/icons';
-import { Button, Divider, message, Modal, Radio } from 'antd';
-import React, { useRef, useState } from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
-import { SorterResult } from 'antd/es/table/interface';
-import { TableListItem } from './data.d';
-import service from './service';
-import QueryForm from '@/pages/ModelList/components/QueryForm';
-
-/**
- * 添加节点
- * @param fields
- */
-const handleAdd = async (fields: TableListItem) => {
-  const hide = message.loading('正在添加');
-  try {
-    await service.addModel({ ...fields });
-    hide();
-    message.success('添加成功');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('添加失败请重试!');
-    return false;
-  }
-};
-
-/**
- * 更新节点
- * @param fields
- */
-const handleUpdate = async (fields: TableListItem) => {
-  const hide = message.loading('正在配置');
-  try {
-    await service.updateModel(fields);
-    hide();
-    message.success('配置成功');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('配置失败请重试!');
-    return false;
-  }
-};
-
-/**
- *  删除节点
- * @param fields
- */
-const handleRemove = async (fields: TableListItem) => {
-  const hide = message.loading('正在删除');
-  try {
-    await service.removeModel(fields);
-    hide();
-    message.success('删除成功,即将刷新');
-    return true;
-  } catch (error) {
-    hide();
-    message.error('删除失败,请重试');
-    return false;
-  }
-};
-
-const TableList: React.FC<{}> = () => {
-  const [sorter, setSorter] = useState<string>('');
-  const [modelVisible, setModalVisible] = useState<boolean>(false);
-  const [formValues, setFormValues] = useState({});
-  const actionRef = useRef<ActionType>();
-  const [queryVisible, setQueryVisible] = useState<boolean>(false);
-
-  const columns: ProColumns<TableListItem>[] = [
-    {
-      title: '模型类型',
-      dataIndex: 'modelType',
-      hideInSearch: true,
-      rules: [
-        {
-          required: true,
-          message: '模型类型为必填项',
-        },
-      ],
-      renderFormItem: () => {
-        return (
-          <Radio.Group>
-            <Radio value={0}>albert</Radio>
-            <Radio value={1}>Blstm</Radio>
-          </Radio.Group>
-        );
-      },
-      valueEnum: {
-        0: { text: 'albert' },
-        1: { text: 'Blstm' },
-      },
-    },
-    {
-      title: '模型名称',
-      dataIndex: 'modelName',
-      rules: [
-        {
-          required: true,
-          message: '模型名称为必填项',
-        },
-      ],
-    },
-    {
-      title: '模型文件',
-      dataIndex: 'modelFile',
-      hideInSearch: true,
-      rules: [
-        {
-          required: true,
-          message: '模型名称为必填项',
-        },
-      ],
-    },
-    {
-      title: '向量文件',
-      dataIndex: 'vocabFile',
-      hideInSearch: true,
-      rules: [
-        {
-          required: true,
-          message: '词向量文件为必填项',
-        },
-      ],
-    },
-    {
-      title: '标签文件',
-      dataIndex: 'labelFile',
-      hideInSearch: true,
-      rules: [
-        {
-          required: true,
-          message: '标签文件为必填项',
-        },
-      ],
-    },
-    {
-      title: '必包含',
-      dataIndex: 'mustTag',
-      hideInSearch: true,
-    },
-    {
-      title: '必不包含',
-      dataIndex: 'mustNotTag',
-      hideInSearch: true,
-    },
-    {
-      title: '纯文本',
-      dataIndex: 'onlyWord',
-      hideInSearch: true,
-      renderFormItem: () => {
-        return (
-          <Radio.Group>
-            <Radio value="true">是</Radio>
-            <Radio value="false">否</Radio>
-          </Radio.Group>
-        );
-      },
-      valueEnum: {
-        true: { text: '是' },
-        false: { text: '否' },
-      },
-    },
-
-    {
-      title: '操作',
-      dataIndex: 'option',
-      valueType: 'option',
-      render: (_, record) => (
-        <>
-          <a
-            onClick={() => {
-              setModalVisible(true);
-              setFormValues(record);
-              console.log(record);
-            }}
-          >
-            配置
-          </a>
-          <Divider type="vertical" />
-          <a
-            onClick={() => {
-              handleRemove(record);
-              console.log(record);
-            }}
-          >
-            删除
-          </a>
-          <Divider type="vertical" />
-          <a
-            onClick={() => {
-              setQueryVisible(true);
-              setFormValues(record);
-              console.log(record);
-            }}
-          >
-            查询
-          </a>
-        </>
-      ),
-    },
-  ];
-
-  return (
-    <PageHeaderWrapper>
-      <ProTable<TableListItem>
-        headerTitle="查询表格"
-        actionRef={actionRef}
-        rowKey="id"
-        onChange={(_, _filter, _sorter) => {
-          const sorterResult = _sorter as SorterResult<TableListItem>;
-          if (sorterResult.field) {
-            setSorter(`${sorterResult.field}_${sorterResult.order}`);
-          }
-        }}
-        pagination={{
-          defaultPageSize: 10,
-        }}
-        params={{
-          sorter,
-        }}
-        /* eslint-disable */
-        toolBarRender={(action, { selectedRows }) => [
-          <Button
-            type="primary"
-            onClick={() => {
-              setModalVisible(true);
-              setFormValues({});
-            }}
-          >
-            <PlusOutlined /> 新建
-          </Button>,
-        ]}
-        request={(params) => service.queryModel(params)}
-        columns={columns}
-        rowSelection={{}}
-      />
-      <Modal
-        destroyOnClose
-        title={'id' in formValues ? '编辑' : '新建'}
-        visible={modelVisible}
-        onCancel={() => setModalVisible(false)}
-        footer={null}
-      >
-        <ProTable<TableListItem, TableListItem>
-          onSubmit={async (value) => {
-            let success = false;
-            if (value.id) {
-              success = await handleAdd(value);
-            } else {
-              success = await handleUpdate(value);
-            }
-
-            if (success) {
-              setModalVisible(false);
-              if (actionRef.current) {
-                actionRef.current.reload();
-              }
-            }
-          }}
-          rowKey="id"
-          type="form"
-          columns={columns}
-          rowSelection={{}}
-          form={{ initialValues: formValues }}
-        />
-      </Modal>
-
-      <QueryForm
-        onCancel={() => setQueryVisible(false)}
-        modalVisible={queryVisible}
-        values={formValues}
-      />
-    </PageHeaderWrapper>
-  );
-};
-
-export default TableList;

+ 0 - 9
src/pages/ModelList/service.ts

@@ -1,9 +0,0 @@
-import api from '@/utils/api';
-
-export default {
-  queryModel: api.get('/api/model'),
-  removeModel: api.post('/api/rule'),
-  addModel: api.post('/api/rule'),
-  updateModel: api.post('/api/rule'),
-  query: api.post('/api/rule'),
-};

+ 0 - 60
src/pages/ServiceList/_mock.ts

@@ -1,60 +0,0 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
-import { Request, Response } from 'express';
-import { parse } from 'url';
-import { TableListItem, TableListParams } from './data.d';
-
-// mock tableListDataSource
-const genList = (current: number, pageSize: number) => {
-  const tableListDataSource: TableListItem[] = [];
-
-  for (let i = 0; i < pageSize; i += 1) {
-    const index = (current - 1) * 10 + i;
-    tableListDataSource.push({
-      msg: "为学者日益", success: "成功",
-      id: index,
-      serviceIp: `${index}name`,
-      modelName: `${index}name`,
-      modelVersion: `${new Date()}`,
-      currentVersion: `${new Date()}`
-    });
-  }
-  tableListDataSource.reverse();
-  return tableListDataSource;
-};
-
-const tableListDataSource = genList(1, 100);
-
-function getModels(req: Request, res: Response, u: string) {
-  let realUrl = u;
-  if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
-    realUrl = req.url;
-  }
-  const { current = 1, pageSize = 10 } = req.query;
-  const params = (parse(realUrl, true).query as unknown) as TableListParams;
-
-  // @ts-ignore
-  const dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
-
-  const result = {
-    data: dataSource,
-    total: tableListDataSource.length,
-    success: true,
-    pageSize,
-    current: parseInt(`${params.currentPage}`, 10) || 1,
-  };
-
-  return res.json(result);
-}
-
-function success(req: Request, res: Response, u: string) {
-  const result = {
-    data: "ok",
-    success: true,
-  };
-  return res.json(result);
-}
-
-export default {
-  'GET /service/queryList': getModels,
-  'POST /service/forceUpdate': success,
-};

+ 0 - 31
src/pages/ServiceList/data.d.ts

@@ -1,31 +0,0 @@
-// 表单
-export interface TableListItem {
-  id?: number;
-  serviceIp: string;
-  modelName: string;
-  modelVersion: Date;
-  currentVersion: Date;
-  success:string;
-  msg:string;
-}
-// 分页参数
-export interface TableListPagination {
-  total: number;
-  pageSize: number;
-  current: number;
-}
-// 返回的分页数据
-export interface TableListData {
-  list: TableListItem[];
-  pagination: Partial<TableListPagination>;
-}
-// 查询参数
-export interface TableListParams {
-  sorter?: string;
-  status?: string;
-  name?: string;
-  desc?: string;
-  id?: number;
-  pageSize?: number;
-  currentPage?: number;
-}

+ 0 - 6
src/pages/ServiceList/index.less

@@ -1,6 +0,0 @@
-.upload {
-  display: inline;
-}
-.red{
-  color: red;
-}

+ 0 - 151
src/pages/ServiceList/index.tsx

@@ -1,151 +0,0 @@
-import { message, Tooltip, Radio } from 'antd';
-import React, { useRef, useState } from 'react';
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
-import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
-import { SorterResult } from 'antd/es/table/interface';
-import { TableListItem } from './data.d';
-import service from './service';
-import styles from './index.less'
-
-/**
- * 更新节点
- * @param fields
- */
-const handleUpdate = async (fields: TableListItem) => {
-  const hide = message.loading('正在配置');
-  try {
-    const data = await service.forceUpdateModel(fields);
-    hide();
-    message.success('配置成功');
-    return data.success;
-  } catch (error) {
-    hide();
-    message.error('配置失败请重试!');
-    return false;
-  }
-};
-
-const TableList: React.FC<{}> = () => {
-  const [sorter, setSorter] = useState<string>('');
-  const actionRef = useRef<ActionType>();
-
-  const columns: ProColumns<TableListItem>[] = [
-    {
-      title: '服务IP',
-      dataIndex: 'serviceIp',
-      width: 150,
-      copyable: true,
-    },
-    {
-      title: '模型名称',
-      dataIndex: 'modelName',
-      width: 150,
-      copyable: true,
-    },
-    {
-      title: '模型版本',
-      dataIndex: 'modelVersion',
-      valueType: 'dateTime',
-      width: 200,
-      hideInSearch: true,
-    },
-    {
-      title: '当前版本',
-      dataIndex: 'currentVersion',
-      valueType: 'dateTime',
-      width: 220,
-      hideInSearch: true,
-      render: (text, row)=>{
-        if (row.currentVersion < row.modelVersion) {
-           return (<div className={styles.red}>{text} :待更新</div>)
-        }
-        return (<div>{text}</div>)
-
-      }
-    },
-    {
-      title: '启动状态',
-      dataIndex: 'success',
-      copyable: true,
-      width: 100,
-      renderFormItem: () => {
-        return (
-          <Radio.Group>
-            <Radio value="成功">成功</Radio>
-            <Radio value="失败">失败</Radio>
-          </Radio.Group>
-        );
-      },
-      valueEnum: {
-        "成功": { text: "成功", status: 'Success' },
-        "失败": { text: "失败", status: 'Error' }
-      },
-    },
-    {
-      title: '启动信息',
-      dataIndex: 'msg',
-      hideInSearch: true,
-      valueType: 'text',
-      width: 200,
-      render: (text, row) => {
-        if (!text) {
-          row.msg = '';
-        }
-
-        return (<>
-          <Tooltip title={row.msg}>
-            <span>{row.msg.substring(0, 10)}</span>
-          </Tooltip>
-        </>);
-      },
-    },
-    {
-      title: '操作',
-      dataIndex: 'option',
-      width: 100,
-      valueType: 'option',
-      render: (_, record,index,action) => (
-        <>
-          <a
-            onClick={async () => {
-              const success = await handleUpdate(record);
-              if (success) {
-                await action.reload();
-              }
-              console.log(record);
-            }}
-          >
-            强制更新
-          </a>
-        </>
-      ),
-    },
-  ];
-
-  return (
-    <PageHeaderWrapper>
-      <ProTable<TableListItem>
-        headerTitle="查询表格"
-        actionRef={actionRef}
-        rowKey="id"
-        onChange={(_, _filter, _sorter) => {
-          const sorterResult = _sorter as SorterResult<TableListItem>;
-          if (sorterResult.field) {
-            setSorter(`${sorterResult.field}_${sorterResult.order}`);
-          }
-        }}
-        pagination={{
-          defaultPageSize: 10,
-        }}
-        params={{
-          sorter,
-        }}
-        request={(params) => service.queryList(params)}
-        columns={columns}
-        rowSelection={{}}
-      />
-    </PageHeaderWrapper>
-  );
-};
-
-export default TableList;

+ 0 - 6
src/pages/ServiceList/service.ts

@@ -1,6 +0,0 @@
-import api from '@/utils/api';
-
-export default {
-  queryList: api.get('/service/queryList'),
-  forceUpdateModel: api.get('/service/forceUpdate'),
-};

+ 2 - 0
src/pages/user/login/index.tsx

@@ -8,6 +8,7 @@ import LoginFrom from './components/Login';
 
 import styles from './style.less';
 
+// @ts-ignore
 const {Tab, UserName, Password, Mobile, Captcha, Submit} = LoginFrom;
 
 interface LoginProps {
@@ -30,6 +31,7 @@ const LoginMessage: React.FC<{
 );
 
 const Login: React.FC<LoginProps> = (props) => {
+  // @ts-ignore
   const {userLogin = {}, submitting} = props;
   // const {status, type: loginType} = userLogin;
   // const [autoLogin, setAutoLogin] = useState(true);

+ 13 - 1
src/utils/utils.ts

@@ -64,7 +64,10 @@ export const getRouteAuthority = (path: string, routeData: Route[]) => {
   return authorities;
 };
 
-
+/**
+ * change minute to day hour
+ * @param minutes
+ */
 export const minuteToDay = (minutes: number) => {
   const day = parseInt(String(minutes / 60 / 24));
   const hour = parseInt(String(minutes / 60 % 24));
@@ -81,3 +84,12 @@ export const minuteToDay = (minutes: number) => {
   }
   return StatusMinuteStr;
 }
+
+/**
+ * 去除html标签
+ * @param html
+ */
+export const getTextFromHtml = (html: string) => {
+  let reg = /<\/?.+?\/?>/g;
+  return html.replace(reg, '').replace(/&nbsp;/g,'')
+}