From 81e3f777819c65e841cd27b10c5074d9a99762ea Mon Sep 17 00:00:00 2001 From: wulibaibao <13366578180@163.com> Date: Thu, 8 Dec 2022 11:28:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Product/TestProduct/EnterEnv.tsx | 81 +++++++++++++++++++ src/pages/Product/TestProduct/ProductCard.tsx | 25 +++--- src/pages/Product/TestProduct/services.ts | 4 +- 3 files changed, 96 insertions(+), 14 deletions(-) create mode 100644 src/pages/Product/TestProduct/EnterEnv.tsx diff --git a/src/pages/Product/TestProduct/EnterEnv.tsx b/src/pages/Product/TestProduct/EnterEnv.tsx new file mode 100644 index 0000000..78bd631 --- /dev/null +++ b/src/pages/Product/TestProduct/EnterEnv.tsx @@ -0,0 +1,81 @@ +import React from "react"; +import { Form, Modal, Input, Space, Row, Button } from "antd"; + +const EnterEnv: React.ForwardRefRenderFunction = (props, ref) => { + const { onOk, onCancel } = props + const [open, setOpen] = React.useState(false) + + const [form] = Form.useForm() + + React.useImperativeHandle(ref, () => ({ + show() { + setOpen(true) + } + })) + + const handleCancel = () => { + setOpen(false) + form.resetFields() + onCancel?.() + } + + const handleOk = () => { + form.validateFields() + .then(async (values) => { + onOk?.(values) + .then(() => { + console.log("ok") + handleCancel() + }) + }) + } + + return ( + + + + + + + } + > +
+ ({ + validator(rule, value) { + if (value) { + const reg = /^(\w+=((('[^']+'|"[^"]+")|.+)( |\n)))*\w+=(('[^']+'|"[^"]+")|.+)$/ + return reg.test(value) ? + Promise.resolve() : + Promise.reject('格式:key=value,多个用空格或换行分割'); + } + else + return Promise.resolve() + }, + }) + ]} + > + + +
+
+ ) +} + +export default React.forwardRef(EnterEnv) \ No newline at end of file diff --git a/src/pages/Product/TestProduct/ProductCard.tsx b/src/pages/Product/TestProduct/ProductCard.tsx index 1f07c0d..c2aa4d3 100644 --- a/src/pages/Product/TestProduct/ProductCard.tsx +++ b/src/pages/Product/TestProduct/ProductCard.tsx @@ -7,6 +7,7 @@ import { CardCls } from "../styled" import { history, useAccess } from "@umijs/max" import { deleteOneProduct, runOneProduct } from "./services" import DeleteModal from '@/pages/Outline/components/DeleteModal'; +import EnterEnv from "./EnterEnv" /* @ts-ignore */ const HoverMenu = styled(Menu)` @@ -44,6 +45,7 @@ const ProductCard: React.FC = ({ const access = useAccess() const editRef = React.useRef(null) as any const deleteModalRef = React.useRef(null) as any + const enterEnvRef = React.useRef(null) as any const handleDeleteProduct = async () => { const { code, msg } = await deleteOneProduct(id) @@ -58,8 +60,8 @@ const ProductCard: React.FC = ({ } } - const hanldeRun = async () => { - const { code, msg } = await runOneProduct(id) + const hanldeRun = async (params: any) => { + const { code, msg } = await runOneProduct({ ...params, test_product_id: id }) if (code !== 200) return message.error(msg) history.push(`/product/record`) } @@ -86,15 +88,13 @@ const ProductCard: React.FC = ({ overlay={ } > @@ -120,7 +120,7 @@ const ProductCard: React.FC = ({ - @@ -128,6 +128,7 @@ const ProductCard: React.FC = ({ + ) } diff --git a/src/pages/Product/TestProduct/services.ts b/src/pages/Product/TestProduct/services.ts index 0789520..1b4db81 100644 --- a/src/pages/Product/TestProduct/services.ts +++ b/src/pages/Product/TestProduct/services.ts @@ -32,8 +32,8 @@ export const deleteOneProduct = async (test_product_id: string | number) => { return request(`/api/product/${test_product_id}`, { method: 'delete' }); }; -export const runOneProduct = async (test_product_id: string | number | number) => { - return request(`/api/product/run/${test_product_id}`); +export const runOneProduct = async (data: any) => { + return request(`/api/product/run/`, { method: "post", data }); }; export const queryCategoryList = async () => { -- Gitee From a2a4b8b5d37410084b5b7eef617a8d782edc4ecd Mon Sep 17 00:00:00 2001 From: wulibaibao <13366578180@163.com> Date: Thu, 8 Dec 2022 16:28:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4btn=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Product/TestProduct/ProductCard.tsx | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/pages/Product/TestProduct/ProductCard.tsx b/src/pages/Product/TestProduct/ProductCard.tsx index c2aa4d3..40d1cda 100644 --- a/src/pages/Product/TestProduct/ProductCard.tsx +++ b/src/pages/Product/TestProduct/ProductCard.tsx @@ -1,7 +1,7 @@ import { Dropdown, Space, Tag, Typography, Menu, Divider, Button, Row, Col, message } from "antd" import React from "react" import styled from "styled-components" -import { MoreOutlined } from "@ant-design/icons" +import { MoreOutlined, DownOutlined } from "@ant-design/icons" import EditProduct from "@/pages/Product/TestProduct/CreateProduct" import { CardCls } from "../styled" import { history, useAccess } from "@umijs/max" @@ -60,7 +60,7 @@ const ProductCard: React.FC = ({ } } - const hanldeRun = async (params: any) => { + const hanldeRun = async (params?: any) => { const { code, msg } = await runOneProduct({ ...params, test_product_id: id }) if (code !== 200) return message.error(msg) history.push(`/product/record`) @@ -70,6 +70,13 @@ const ProductCard: React.FC = ({ refresh?.() } + const handleClickMenu = ({ key }: any) => { + switch (key) { + case "run": return hanldeRun() + case "enter_env_run": return enterEnvRef.current?.show() + } + } + return ( = ({ - + + + 直接运行 + + + 写入配置并运行 + + + } + > + + -- Gitee