1.调整接口测试页面bug

2.整理项目结构,修改配置文件中对应项目名称上下文
This commit is contained in:
shuanglin 2025-01-06 15:43:10 +08:00
parent 818395f124
commit f515e897e9
11 changed files with 162 additions and 55 deletions

View File

@ -9,10 +9,10 @@ VUE_APP_PUBLIC_PATH = '/interface/'
VUE_APP_HOST = 'http://localhost:7055/'
# index页面
VUE_APP_HOST_INDEX = 'http://localhost:7070/interface/'
# y9home接口
VUE_APP_CONTEXT = 'http://localhost:7055/interfacePlatform/'
# 后端请求路径
VUE_APP_CONTEXT = 'http://localhost:7055/interfaceManager/'
# 执行转发节点入口接口
VUE_APP_NODE_CONTEXT = 'http://localhost:7055/interfacePlatform/'
VUE_APP_NODE_CONTEXT = 'http://localhost:7055/interfaceExecute/'
# kernel-log接口
VUE_APP_LOG_URL = 'http://localhost:7055/log/'
# sso接口

View File

@ -58,13 +58,25 @@ export const saveInterfaceInfo = async (data) => {
* @returns
*/
export const testInterface = async (data) => {
return await nodeRequest({
url: "/api/rest/interface/testInterface",
method: 'POST',
JSON:true,
cType: false,
data
});
if(data.isResponseFile){
return await nodeRequest({
url: "/api/rest/interface/testInterface",
method: 'POST',
JSON:true,
cType: false,
isDowFile: true,
responseType:'blob',
data
});
}else{
return await nodeRequest({
url: "/api/rest/interface/testInterface",
method: 'POST',
JSON:true,
cType: false,
data
});
}
};
/**

View File

@ -20,6 +20,7 @@ import { $y9_SSO } from '@/main';
// 创建一个axios实例
function y9Request(baseUrl = '') {
let requestList = new Set();
let isDowFile = false;
const service = axios.create({
baseURL: import.meta.env.VUE_APP_NODE_CONTEXT,
@ -46,7 +47,7 @@ function y9Request(baseUrl = '') {
config.headers['Authorization'] = 'Bearer ' + access_token;
}
config.headers['Accept'] = '*/*'
isDowFile = config.isDowFile;
return config;
},
(error) => {
@ -69,7 +70,7 @@ function y9Request(baseUrl = '') {
res = response;
}
const { code } = res;
if (code !== 0) {
if (code!=undefined && code !== 0) {
// 获取替换后的字符串
const reqUrl = response.config.url.split('?')[0].replace(response.config.baseURL, '');
const noVerifyBool = settings.ajaxResponseNoVerifyUrl.includes(reqUrl);
@ -126,6 +127,9 @@ function y9Request(baseUrl = '') {
}
} else {
if(isDowFile){
return response;
}
return res;
}
},

View File

@ -117,7 +117,7 @@ const fetchTableData = async (
} else {
dataRef.value = [];
pagination.value.total = 0;
ElMessage.error(errorMessage);
// ElMessage.error(errorMessage);
}
} finally {
pagination.value.loading = false;
@ -149,11 +149,11 @@ async function fetchOverviewData() {
overviewData.value.stopCount = res.data.stopCount || 0;
overviewData.value.runningCount = res.data.runningCount || 0;
} else {
ElMessage.error('获取接口概况数据失败');
// ElMessage.error('');
}
} catch (error) {
console.error('获取接口概况数据失败:', error);
// console.error(':', error);
}
};
@ -164,10 +164,10 @@ async function fetchRunningCountData() {
runningCountData.value.normalCount = res.data.normalCount || 0
runningCountData.value.abnormalCount = res.data.abnormalCount || 0
} else {
ElMessage.error('获取接口运行状态数据失败');
// ElMessage.error('');
}
} catch (error) {
console.error('获取接口运行状态数据失败:', error);
// console.error(':', error);
}
};
@ -182,10 +182,10 @@ const fetchTrendData = async () => {
};
updateTrendChart();
} else {
ElMessage.error('获取接口趋势图数据失败');
// ElMessage.error('');
}
} catch (error) {
console.error('获取接口趋势图数据失败:', error);
// console.error(':', error);
}
};
@ -199,11 +199,11 @@ async function fetchLogOverviewData() {
logOverviewData.value.todayAllTotal = res.data.todayAllTotal || 0;
logOverviewData.value.todayAllErrorTotal = res.data.todayAllErrorTotal || 0;
} else {
ElMessage.error('获取日志概况数据失败');
// ElMessage.error('');
}
} catch (error) {
console.error('获取日志概况数据失败:', error);
// console.error(':', error);
}
};

View File

@ -835,6 +835,7 @@ let ruleFormConfig = ref({
],
interfaceType: [{ required: true, message: computed(() => t('接口类型不能为空')), trigger: 'blur' }],
interfaceMethod: [{ required: true, message: computed(() => t('请求方式不能为空')), trigger: 'blur' }],
isResponseFile: [{ required: true, message: computed(() => t('是否返回文件不能为空')), trigger: 'blur' }],
networkAgreement: [{ required: true, message: computed(() => t('网络协议不能为空')), trigger: 'blur' }],
head: [{ required: true, message: computed(() => t('接口负责人不能为空')), trigger: 'blur' }],
headPhone: [{ required: true, message: computed(() => t('接口负责人联系方式不能为空')), trigger: 'blur' }
@ -917,6 +918,18 @@ let ruleFormConfig = ref({
}
}
},
{
type: 'select',
label: computed(() => t('是否返回文件')),
prop: 'isResponseFile',
props: {
options: [
//
{ label: computed(() => t('是')), value: true },
{ label: computed(() => t('否')), value: false }
]
}
},
{
type: 'slot',
label: computed(() => t('是否限流')),

View File

@ -725,6 +725,7 @@ let ruleFormConfig = ref({
],
interfaceType:[{required: true, message: computed(() => t('接口类型不能为空')), trigger: 'blur'}],
interfaceMethod:[{required: true, message: computed(() => t('请求方式不能为空')), trigger: 'blur'}],
isResponseFile: [{ required: true, message: computed(() => t('是否返回文件不能为空')), trigger: 'blur' }],
networkAgreement:[{required: true, message: computed(() => t('网络协议不能为空')), trigger: 'blur'}],
head:[{required: true, message: computed(() => t('接口负责人不能为空')), trigger: 'blur'}],
headPhone:[{required: true, message: computed(() => t('负责人联系方式不能为空')), trigger: 'blur'}
@ -810,6 +811,18 @@ let ruleFormConfig = ref({
}
}
},
{
type: 'select',
label: computed(() => t('是否返回文件')),
prop: 'isResponseFile',
props: {
options: [
//
{ label: computed(() => t('是')), value: true },
{ label: computed(() => t('否')), value: false }
]
}
},
{
type: 'slot',
label: computed(() => t('是否限流')),
@ -875,7 +888,7 @@ let ruleFormConfig = ref({
}
systemList.value.push(item)
}
ruleFormConfig.value.itemList[10].props.options = systemList.value
ruleFormConfig.value.itemList[11].props.options = systemList.value
})
}
}

View File

@ -130,6 +130,8 @@ import { useRoute } from 'vue-router';
import { nextTick } from 'vue';
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css'
import y9_storage from '@/utils/storage';
import settings from '@/settings';
//
const fontSizeObj: any = inject('sizeObjInfo');
@ -611,7 +613,7 @@ let ruleFormConfig = ref({
interfaceMethod: [{ required: true, message: computed(() => t('请求方式不能为空')), trigger: 'blur' }],
networkAgreement: [{ required: true, message: computed(() => t('网络协议不能为空')), trigger: 'blur' }],
head: [{ required: true, message: computed(() => t('接口负责人不能为空')), trigger: 'blur' }],
isResponseFile: [{ required: true, message: computed(() => t('是否返回文件')), trigger: 'blur' }],
isResponseFile: [{ required: true, message: computed(() => t('是否返回文件不能为空')), trigger: 'blur' }],
headPhone: [{ required: true, message: computed(() => t('接口负责人联系方式不能为空')), trigger: 'blur' }
, { validator: validatePhone, trigger: 'blur' }
],
@ -688,11 +690,10 @@ let ruleFormConfig = ref({
label: computed(() => t('是否返回文件')),
prop: 'isResponseFile',
props: {
disabled: true,
options: [
//
{ label: computed(() => t('是')), value: 'true' },
{ label: computed(() => t('否')), value: 'false' }
{ label: computed(() => t('是')), value: true },
{ label: computed(() => t('否')), value: false }
]
}
},
@ -904,10 +905,10 @@ function confirDialog(type) {
async function addDialog() {
ruleFormConfig.value.model = {}
ruleFormConfig.value.model.networkAgreement = "http"
ruleFormConfig.value.model.interfaceUrl = "192.168.31.94:7055/interfacePlatform/openInterface/test"
ruleFormConfig.value.model.interfaceUrl = "127.0.0.1:7055/interfaceExecute/openInterface/forward"
ruleFormConfig.value.model.interfaceType = "Rest"
ruleFormConfig.value.model.interfaceMethod = "post"
ruleFormConfig.value.model.isResponseFile = "false"
ruleFormConfig.value.model.isResponseFile = true
initFormData()
let res = await getInterfaceId()
ruleFormConfig.value.model.id = res.data
@ -1196,25 +1197,45 @@ const submitData = () => {
}
data.reqParameters = JSON.stringify(reqData)
let res = await testInterface(
data
);
if (data.isResponseFile == "true") {
const a = document.createElement('a')
a.href = URL.createObjectURL(new Blob(res, { type: 'application/octet-stream' }))
//
const contentDisposition = res.headers.get('Content-Disposition');
let fileName = '流文件';
if (contentDisposition && contentDisposition.includes('attachment')) {
const match = contentDisposition.match(/filename="(["]*)"/);
if (match) {
fileName = match;
}
}
a.download = fileName
a.click()
const access_token = y9_storage.getObjectItem(settings.siteTokenKey, 'access_token');
if (data.isResponseFile) {
let contentDisposition = "";
fetch(import.meta.env.VUE_APP_NODE_CONTEXT + 'api/rest/interface/testInterface', {
method: 'POST',
body: JSON.stringify(data),
headers: new Headers({
'Authorization': 'Bearer ' + access_token,
'Content-Type':'application/json',
'Accept':'*/*'
}),
})
.then(res => {
contentDisposition = res.headers.get("content-disposition")
return res.blob()})
.then(data => {
const blobUrl = window.URL.createObjectURL(data);
const a = document.createElement('a');
let fileName = '流文件';
if (contentDisposition && contentDisposition.includes('attachment')) {
const match = contentDisposition.match(/filename="?([^";]*)"?/);
if (match) {
fileName = decodeURIComponent(match[1]);
}
console.log(match)
}
a.download = fileName;
a.href = blobUrl;
a.click();
loading.value = false
window.URL.revokeObjectURL(blobUrl);
});
} else {
let res = await testInterface(
data
);
if (res.code == 0) {
ElMessage({

View File

@ -0,0 +1,45 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.risesoft</groupId>
<artifactId>y9-digitalbase</artifactId>
<version>v9.6.8-SNAPSHOT</version>
<relativePath/>
</parent>
<artifactId>y9-module-interface</artifactId>
<packaging>pom</packaging>
<name>y9-module-interface</name>
<description>InterfacePlatform Engine y9-module-interface project parent pom.xml file</description>
<modules>
<module>risenet-y9boot-support-interface-jpa-repository</module>
<module>risenet-y9boot-webapp-interface-platform-execute</module>
<module>risenet-y9boot-webapp-interface-platform-manager</module>
</modules>
<profiles>
<profile>
<id>deploy-maven-central</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<configuration>
<excludeArtifacts>
<artifact>risenet-y9boot-webapp-interface-platform-execute</artifact>
<artifact>risenet-y9boot-webapp-interface-platform-manager</artifact>
</excludeArtifacts>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -5,7 +5,7 @@ server:
error:
include-message: always
servlet:
context-path: /interfacePlatform
context-path: /interfaceExecute
register-default-servlet: true
encoding:
charset: UTF-8
@ -17,7 +17,7 @@ server:
uri-encoding: UTF-8
spring:
application:
name: interfacePlatform
name: interfaceExecute
aop:
auto: false
proxy-target-class: false
@ -71,7 +71,7 @@ spring:
useGlobalDataSourceStat: true
validationQuery: SELECT 1 FROM DUAL
jmx:
default-domain: interfacePlatform
default-domain: interfaceExecute
jpa:
hibernate:
naming:
@ -125,8 +125,7 @@ spring:
maxFileSize: 200MB
maxRequestSize: 1000MB
y9:
interfacePath: /home
systemName: interfacePlatform
systemName: interfaceExecute
common:
idEnabled: 0
kafkaEnabled: false

View File

@ -221,7 +221,7 @@
</pluginRepositories>
<build>
<finalName>Y9-interfaceManagementPlatform</finalName>
<finalName>interfaceManager</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -5,7 +5,7 @@ server:
error:
include-message: always
servlet:
context-path: /interfacePlatform
context-path: /interfaceManager
register-default-servlet: true
encoding:
charset: UTF-8
@ -17,7 +17,7 @@ server:
uri-encoding: UTF-8
spring:
application:
name: interfacePlatform
name: interfaceManager
aop:
auto: false
proxy-target-class: false
@ -71,7 +71,7 @@ spring:
useGlobalDataSourceStat: true
validationQuery: SELECT 1 FROM DUAL
jmx:
default-domain: interfacePlatform
default-domain: interfaceManager
jpa:
hibernate:
naming:
@ -126,7 +126,7 @@ spring:
maxRequestSize: 1000MB
y9:
interfacePath: /home
systemName: interfacePlatform
systemName: interfaceManager
common:
idEnabled: 0
kafkaEnabled: false