From 00c633b04d9649490a0ccda45bd35a77844c6fdd Mon Sep 17 00:00:00 2001
From: cc500 <2014434568@qq.com>
Date: Sat, 22 Feb 2025 10:30:21 +0800
Subject: [PATCH 1/2] =?UTF-8?q?api=20=E9=A6=96=E9=A1=B5=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E5=AD=97?=
=?UTF-8?q?=E6=AE=B5=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/api/index.vue | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/views/api/index.vue b/src/views/api/index.vue
index f97c2cf8..88d81122 100644
--- a/src/views/api/index.vue
+++ b/src/views/api/index.vue
@@ -3,7 +3,7 @@
语义接口中心
-
+
@@ -183,9 +183,9 @@ const handleQueryApiList = (payload?: any) => {
...payload,
})
.then(res => {
- apiList.value = res[1]?.result.apilications;
+ apiList.value = res[1]?.result.services;
currentPage.value = res[1]?.result.currentPage;
- totalCount.value = res[1]?.result.totalapis;
+ totalCount.value = res[1]?.result.totalCount;
});
};
--
Gitee
From ef3b635d57e0de7784cd149ce4e1ddae9532893c Mon Sep 17 00:00:00 2001
From: cc500 <2014434568@qq.com>
Date: Sat, 22 Feb 2025 14:50:12 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E6=89=93=E9=80=9A?=
=?UTF-8?q?=E8=AF=AD=E4=B9=89=E6=8E=A5=E5=8F=A3=E4=B8=AD=E5=BF=83=E9=A6=96?=
=?UTF-8?q?=E9=A1=B5=E5=AF=B9=E4=BA=8E=E6=8E=A5=E5=8F=A3=E9=99=A4=E7=BC=96?=
=?UTF-8?q?=E8=BE=91=E5=A4=96=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/apis/paths/api.ts | 4 +-
src/apis/paths/type.ts | 22 ++++++
src/components/Upload/index.vue | 96 ++++++++++++++++----------
src/views/api/index.vue | 115 +++++++++++++++++---------------
4 files changed, 146 insertions(+), 91 deletions(-)
diff --git a/src/apis/paths/api.ts b/src/apis/paths/api.ts
index b274e528..e20012b6 100644
--- a/src/apis/paths/api.ts
+++ b/src/apis/paths/api.ts
@@ -29,8 +29,8 @@ export const createOrUpdateApi = (
* @param params
* @returns
*/
-export const querySingleApiData = (params: { serviceId: string }): Promise<[any, FcResponse | undefined]> => {
- return get(`/api/service/${params.serviceId}`);
+export const querySingleApiData = (params: { serviceId: string,edit?: boolean}): Promise<[any, FcResponse | undefined]> => {
+ return get(`/api/service/${params.serviceId}`,{edit: params.edit});
};
/**
diff --git a/src/apis/paths/type.ts b/src/apis/paths/type.ts
index 3659c300..da2409c2 100644
--- a/src/apis/paths/type.ts
+++ b/src/apis/paths/type.ts
@@ -173,3 +173,25 @@ export interface CreateOrUpdateApiParamsType {
*/
[property: string]: any;
}
+
+/**
+ * serviceApiData, 获取语义接口返回数据结构
+ */
+export interface serviceApiData{
+ /**
+ * 语义接口名称
+ */
+ name?: string;
+ /**
+ * 语义接口path
+ */
+ path?: string;
+ /**
+ * 语义接口描述
+ */
+ description?: string;
+ /**
+ * 对话轮次(1~10)
+ */
+ [property: string]: any;
+}
diff --git a/src/components/Upload/index.vue b/src/components/Upload/index.vue
index 90accc46..667955d3 100644
--- a/src/components/Upload/index.vue
+++ b/src/components/Upload/index.vue
@@ -3,30 +3,21 @@ import { ElMessage } from 'element-plus';
import { ref, watch } from 'vue';
import * as jsYaml from 'js-yaml';
import { IconUpload, IconVisible, IconDelete } from '@computing/opendesign-icons';
-import type {
- UploadFile,
- ElUploadProgressEvent,
- ElFile,
-} from 'element-plus/es/components/upload/src/upload.type';
+import type { UploadFile, ElUploadProgressEvent, ElFile } from 'element-plus/es/components/upload/src/upload.type';
import { Codemirror } from 'vue-codemirror';
import { onMounted } from 'vue';
import { api } from 'src/apis';
-
-const handleUploadMyFile = (options: any) => {
- console.log(options);
-};
+import { IconChevronDown } from '@computing/opendesign-icons';
const handleCreateapi = (data: any) => {
- console.log(data);
api
.createOrUpdateApi({
- serviceId:'',
- data
+ serviceId: '',
+ data,
})
.then(res => {
- console.log(res);
- getYamlJson.value = res.data;
- uploadtype.value = 'get';
+ getServiceJson.value = res[1].result.apis;
+ uploadtype.value = 'get';
});
};
@@ -43,6 +34,18 @@ const props = defineProps({
type: Function,
default: () => {},
},
+ serviceId: {
+ type: String,
+ default: '',
+ },
+ getServiceJson: {
+ type: String,
+ default: '',
+ },
+ getServiceYaml: {
+ type: String,
+ default: '',
+ },
});
const emits = defineEmits<{
(e: 'closeDrawer'): void;
@@ -50,17 +53,17 @@ const emits = defineEmits<{
const handleClose = () => {
//清空数据
- yamlContent.value = '';
+ getServiceYaml.value = '';
yamlToJsonContent.value = '';
- getYamlJson.value = '';
+ getServiceJson.value = '';
emits('closeDrawer');
};
const uploadtype = ref(props.type);
-const yamlContent = ref('tt:123');
+const getServiceYaml = ref('');
const yamlToJsonContent = ref('');
-const getYamlJson = ref('');
+const getServiceJson = ref('');
const imageUrl = ref('');
const progressVal = ref(0);
const uploadDone = ref(false);
@@ -86,12 +89,10 @@ const beforeUpload = async (file: ElFile) => {
try {
const reader = new FileReader();
reader.onload = async event => {
- yamlContent.value = event.target?.result as string;
+ getServiceYaml.value = event.target?.result as string;
//yaml 展示
- console.log('YAML Content:', yamlContent);
try {
- // emits('changeAction',"edit");
- yamlToJsonContent.value = jsYaml.load(yamlContent.value);
+ yamlToJsonContent.value = jsYaml.load(getServiceYaml.value);
uploadtype.value = 'edit';
} catch (yamlParseError) {
console.error('Error parsing YAML to JSON:', yamlParseError);
@@ -112,7 +113,7 @@ const beforeUpload = async (file: ElFile) => {
reader.onloadend = () => resolve(); // 当读取完成时解决 Promise
reader.onerror = error => reject(error); // 如果出错则拒绝 Promise
});
- return true;
+ return true;
} catch (error) {
console.error('Error during file upload process:', error);
ElMessage({
@@ -139,18 +140,24 @@ const handleSuccess = (res: ElUploadProgressEvent, file: UploadFile) => {
};
const doDelete = (e: Event) => {
e.stopPropagation();
- console.log('click Delete');
- imageUrl.value = '';
uploadDone.value = false;
};
const doPreview = (e: Event) => {
e.stopPropagation();
};
-onMounted(() => {
- console.log(props);
-});
-
+watch(
+ () => props,
+ () => {
+ getServiceJson.value = props.getServiceJson;
+ getServiceYaml.value = props.getServiceYaml;
+ if (props.type === 'edit' && props) {
+ console.log('edit');
+ // getServiceYamlFun(props.serviceId);
+ }
+ },
+ { immediate: true, deep: true },
+);
{
-