Skip to content

Commit

Permalink
update v2.0.1 code
Browse files Browse the repository at this point in the history
  • Loading branch information
liuguanglei committed Sep 4, 2023
1 parent 1af351b commit 87946d7
Show file tree
Hide file tree
Showing 27 changed files with 233 additions and 247 deletions.
2 changes: 1 addition & 1 deletion config/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const REQUEST_TIMEOUT = 10000; // 请求超时时间 单位毫秒
export const APP_VERSION = '7.0.0';
export const APP_VERSION = '2.0.1';

// 是否使用OSS服务做文件存储, 若不使用, 会走另外一个文件本地存储服务filer-server的逻辑
export const USE_OSS = true;
Expand Down
1 change: 0 additions & 1 deletion config/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const RD_BASE_URL = RD_BaseURL[NODE_ENV];
export const RD_WEBSOCKET_URL = RD_websocketUrl[NODE_ENV];
export const RD_ADMIN_URL = RD_AdminURL[NODE_ENV];


export default {
RD_BASE_URL,
RD_WEBSOCKET_URL,
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"jsonpath": "^1.1.1",
"jspdf": "^2.5.1",
"mockjs": "^1.1.0",
"module2apipostfull": "^0.0.10",
"module2apipostfull": "^0.0.41",
"mousetrap": "^1.6.5",
"mousetrap-global-bind": "^1.1.0",
"node-polyfill-webpack-plugin": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/Request/body/body.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.apipost-req-wrapper{
padding-bottom: 80px;
.select-filetype{
border-radius: 3px;
min-width: 0;
Expand Down
1 change: 1 addition & 0 deletions src/components/Request/requestPanel/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const RequestWrapper = styled.div`
// padding-left: 0;
height: 100%;
overflow: auto;
padding-bottom: 50px;
// overflow-y: hidden;
.system-header {
margin: 0 0 8px 0;
Expand Down
10 changes: 5 additions & 5 deletions src/components/ServicePreUrl/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const ServicePreUrl = (props) => {
<Select disabled={from === 'auto_report'} value={service_name ? service_name : ''} onChange={(e) => {
let item = serviceList.find(item => item.service_name === e);
if (item) {
const { content, service_name, env_id } = item;
onChange('service_id', e);
const { content, service_name, env_id, service_id } = item;
onChange('service_id', service_id);
onChange('pre_url', content)
onChange('service_name', service_name);
if (from !== 'apis') {
Expand All @@ -98,10 +98,10 @@ const ServicePreUrl = (props) => {
</Tooltip>
:
<Select disabled={from === 'auto_report'} placeholder={t('placeholder.selectService')} onChange={(e) => {
let item = serviceList.find(item => item.service_name === service_name);
let item = serviceList.find(item => item.service_name === e);
if (item) {
const { content, service_name, env_id } = item;
onChange('service_id', e);
const { content, service_name, env_id, service_id } = item;
onChange('service_id', service_id);
onChange('pre_url', content)
onChange('service_name', service_name);
if (from !== 'apis') {
Expand Down
2 changes: 1 addition & 1 deletion src/components/response/responsePanel/assert/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import NotResponse from '../notResponse';
const ResAssert = (props) => {
const { data } = props;

const assert = data.assert || [];
const assert = data && data.assert && data.assert.assertion_msgs ? data.assert.assertion_msgs : [];
const { t } = useTranslation();
return (
<div className='res-assert can-copy'>
Expand Down
10 changes: 5 additions & 5 deletions src/components/response/responsePanel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ const ResPonsePanel = (props) => {
id: '5',
title: (
<div style={{ position: 'relative' }}>
<span style={{ marginRight: ((response_data && response_data.assertion) || (scene_result && scene_result.assertion)) ? '8px' : 0 }}>{t('apis.resAssert')}</span>
<span style={{ marginRight: ((response_data && response_data.assert && response_data.assert.assertion_msgs) || (scene_result && scene_result.assert && scene_result.assert.assertion_msgs)) ? '8px' : 0 }}>{t('apis.resAssert')}</span>
{
response_data ?
response_data && response_data.assertion
response_data && response_data.assert && response_data.assert.assertion_msgs
?
(
response_data.assertion.filter(item => !item.is_succeed).length > 0
response_data.assert.assertion_msgs.filter(item => !item.is_succeed).length > 0
? <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#f00', position: 'absolute' }}></p>
: <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#0f0', position: 'absolute' }}></p>
)
: <></>
: scene_result && scene_result.assertion
: scene_result && scene_result.assert && scene_result.assert.assertion_msgs
?
(
scene_result.assertion.filter(item => !item.is_succeed).length > 0
scene_result.assert.assertion_msgs.filter(item => !item.is_succeed).length > 0
? <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#f00', position: 'absolute' }}></p>
: <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#0f0', position: 'absolute' }}></p>
)
Expand Down
7 changes: 3 additions & 4 deletions src/components/response/responsePanel/regex/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import NotResponse from '../notResponse';

const ResRegex = (props) => {
const { data } = props;
const regex = data.regex || [];
const regex = data && data.regex && data.regex.regs ? data.regex.regs : [];
const [regexList, setRegexList] = useState([]);
const _regexList = [];
const { t } = useTranslation();
if (regex) {

regex.forEach(item => {
for (let i in item) {
_regexList.push(`${i}=${item[i]}`)
}
_regexList.push(`${item.key}=${item.value}`)
})
}



// useEffect(() => {

// }, [regex]);
Expand Down
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<link rel="stylesheet" name="apt-template-link" href="/skins/dark.css" />
<link rel="stylesheet" name="apt-font-link" href="/font/font-100.css" />
<script src="https://static.geetest.com/v4/gt4.js"></script>
<!-- <script src="/js/socket.io.4.4.1.min.js"></script> -->
<style type="text/css">
.preloader {
position: fixed;
Expand Down
2 changes: 1 addition & 1 deletion src/modals/CommonFunc/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ const CommonFunction = (props) => {
)
};

export default CommonFunction;
export default CommonFunction;
4 changes: 3 additions & 1 deletion src/modals/SceneConfig/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ const SceneConfig = (props) => {
const { originFile: { size, name } } = files[0];
const nameType = name.split('.')[1];

const { protocol, hostname } = window.location;

if (fileList.filter(item => item.name === name).length > 0) {
Message("error", t('message.filenameRepeat'));
return;
Expand Down Expand Up @@ -850,7 +852,7 @@ const SceneConfig = (props) => {
document.body.removeChild(a);
}


const getTableData = (tab) => {
let lastDataList = [
{ is_checked: 1, key: '', value: '' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import RealTimeResult from "@components/response/responsePanel/result";
import ResAssert from "@components/response/responsePanel/assert";
import ResRegex from "@components/response/responsePanel/regex";
import { Tabs } from '@arco-design/web-react';
import { isArray } from "lodash";

const { TabPane } = Tabs;

Expand All @@ -32,12 +33,12 @@ const DubboResponse = () => {
id: '2',
title: (
<div style={{ position: 'relative' }}>
<span style={{ marginRight: (response_data && response_data.assert) ? '8px' : 0 }}>{t('apis.resAssert')}</span>
<span style={{ marginRight: (response_data && response_data.assert && response_data.assert.assertion_msgs && response_data.assert.assertion_msgs.length > 0) ? '8px' : 0 }}>{t('apis.resAssert')}</span>
{
response_data && response_data.assert
response_data && response_data.assert && response_data.assert.assertion_msgs && response_data.assert.assertion_msgs.length > 0
?
(
response_data.assert.filter(item => !item.is_succeed).length > 0
response_data.assert.assertion_msgs.filter(item => !item.is_succeed).length > 0
? <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#f00', position: 'absolute' }}></p>
: <p style={{ 'min-width': '6px', 'min-height': '6px', borderRadius: '50%', top: '0', right: '0', backgroundColor: '#0f0', position: 'absolute' }}></p>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const SqlAssertResult = (props) => {
const { t } = useTranslation();

const sql_detail = data || {};
const assert = isArray(sql_detail.assert) ? sql_detail.assert : [];
const assert = sql_detail && sql_detail.assert && sql_detail.assert.assertion_msgs ? sql_detail.assert.assertion_msgs : [];

return (
<div className="res-assert can-copy">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ const SqlRegularResult = (props) => {
const { t } = useTranslation();

const sql_detail = data || {};
const regex = isArray(sql_detail.regex) ? sql_detail.regex : [];
const regex = sql_detail && sql_detail.regex && sql_detail.regex.regs ? sql_detail.regex.regs : [];

const _regex = [];

if (regex && regex.length > 0) {
regex.forEach(item => {
for (let i in item) {
_regex.push(`${i}=${item[i]}`)
}
_regex.push(`${item.key}=${item.value}`)
})
}

return (
<div className="res-regex can-copy">
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
import React, { useState, useEffect } from "react";
import './index.less';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { Table } from 'adesign-react';
import { isArray } from "lodash";
import { Table } from '@arco-design/web-react';
import { isJSON } from '@utils';

const SqlResult = (props) => {
const { data: datas } = props;


const { t } = useTranslation();

const [columns, setColumns] = useState([]);
const [data, setData] = useState([]);
const [isErr, setIsErr] = useState(false);

function arrayToTable(array) {
// 定义一个空数组来存储columns
let columns = [];
// 定义一个空数组来存储data
let data = [];
// 遍历输入数组的每个子元素
for (let i = 0; i < array.length; i++) {
// 获取当前子元素的Key和Value
let key = array[i].Key;
let value = array[i].Value;
// 将Key作为一个对象添加到columns数组中,对象的title属性为Key,dataIndex属性为Key,key属性为i
columns.push({ title: key, dataIndex: key, key: i });
// 遍历Value数组的每个元素
for (let j = 0; j < value.length; j++) {
// 如果data数组的第j个元素不存在,就创建一个空对象
if (!data[j]) {
data[j] = {};
}
// 将Value数组的第j个元素作为一个属性添加到data数组的第j个对象中,属性的键为Key,值为Value
data[j][key] = value[j];
}
const getTextWidth = (text) => {
const span = document.createElement('span');
span.innerText = text;
span.style.fontSize = '14px';
document.body.appendChild(span);
let width = span.offsetWidth;
document.body.removeChild(span);

console.log(text, width);

return width + 52;
}

const arrayToTable = (array) => {
// 获取数据的 key 数组,即表头的字段
const keys = Object.keys(array);

// 找到最长的列的长度
const maxColumnLength = keys.reduce((max, key) => Math.max(max, array[key].length), 0);

// 转换为 datas 格式
const data = [];
for (let i = 0; i < maxColumnLength; i++) {
const rowData = {};
keys.forEach((key) => {
rowData[key] = array[key][i] || ''; // 处理数据不足的情况,缺少数据时使用空字符串填充
});
data.push(rowData);
}
// 对columns数组按照key属性进行升序排序
columns.sort((a, b) => a.key - b.key);
// 返回一个包含columns和data的对象

// 转换为 columns 格式
const columns = keys.map((key) => {
return {
title: key,
dataIndex: key,
width: getTextWidth(key)
};
});

return { columns, data };
}

Expand All @@ -48,27 +56,38 @@ const SqlResult = (props) => {
useEffect(() => {
if (datas) {
const { response_body } = datas;
if (isArray(response_body)) {
setIsErr(false);
const { columns, data } = arrayToTable(isArray(response_body) ? response_body : []);
if (isJSON(response_body)) {
const { columns, data } = arrayToTable(JSON.parse(response_body));
setColumns(columns);
setData(data);
} else {
setIsErr(true);
setColumns([]);
setData([]);
}
}
}, [datas]);


return (
<div className="sql-result">
{
datas ? isArray(datas.response_body) ? <Table showBorder hasPadding={false} columns={columns} data={data} /> : datas.response_body : ''
datas ?
isJSON(datas.response_body) ?
<Table
border
borderCell
columns={columns}
data={data}
scroll={{
x: 800,
y: 250
}}
pagination={false}
/>
: datas.response_body
: ''
}
</div>
);
};

export default SqlResult;
export default SqlResult;
Loading

0 comments on commit 87946d7

Please sign in to comment.