From cf823c26eeb7c2db56ab7c120f3d40dff487397b Mon Sep 17 00:00:00 2001 From: cc500 <2014434568@qq.com> Date: Sun, 23 Feb 2025 16:03:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?1.=E8=AF=AD=E4=B9=89=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=8A=9F=E8=83=BD=E5=85=A8=E9=83=A8=E8=B0=83?= =?UTF-8?q?=E9=80=9A=202.=E4=BF=AE=E6=94=B9=20initCopilot=20=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=89=8D=E7=BD=AE=E5=9C=A8=20DialogueView=20=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/index.vue | 53 ++++++-- src/store/account.ts | 5 +- src/views/api/index.vue | 35 ++--- src/views/dialogue/Copilot.vue | 77 +---------- .../dialogue/components/DialogueSession.vue | 127 +----------------- src/views/dialogue/dialogueView.vue | 33 ++++- 6 files changed, 101 insertions(+), 229 deletions(-) diff --git a/src/components/Upload/index.vue b/src/components/Upload/index.vue index 667955d..b79a5d7 100644 --- a/src/components/Upload/index.vue +++ b/src/components/Upload/index.vue @@ -5,15 +5,14 @@ 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 { Codemirror } from 'vue-codemirror'; -import { onMounted } from 'vue'; import { api } from 'src/apis'; import { IconChevronDown } from '@computing/opendesign-icons'; -const handleCreateapi = (data: any) => { +const handleCreateapi = () => { api .createOrUpdateApi({ - serviceId: '', - data, + serviceId: props.serviceId||'', + data:yamlToJsonContent.value, }) .then(res => { getServiceJson.value = res[1].result.apis; @@ -59,14 +58,27 @@ const handleClose = () => { emits('closeDrawer'); }; -const uploadtype = ref(props.type); +const handleEditClose = () => { + //清空数据 + // getServiceYaml.value = ''; + // yamlToJsonContent.value = ''; + // getServiceJson.value = ''; + emits('closeDrawer'); +}; +const handleEdit = () => { + //edit数据 + editable.value = true; +}; + +const uploadtype = ref(props.type); const getServiceYaml = ref(''); const yamlToJsonContent = ref(''); const getServiceJson = ref(''); const imageUrl = ref(''); const progressVal = ref(0); const uploadDone = ref(false); +const editable = ref(false); // 上传前检查 const beforeUpload = async (file: ElFile) => { const isYaml = file.type === 'application/x-yaml' || file.type === 'text/yaml'; // 也可能遇到 text/yaml 类型 @@ -85,7 +97,6 @@ const beforeUpload = async (file: ElFile) => { }); return false; } - try { const reader = new FileReader(); reader.onload = async event => { @@ -146,18 +157,37 @@ const doPreview = (e: Event) => { e.stopPropagation(); }; +const getServiceYamlFun = async (id: string) => { + await api.querySingleApiData({serviceId:id,edit:true}).then((res) => { + if(res) { + getServiceYaml.value = jsYaml.dump(res[1]?.result.data); + } + }) +} +const handleChange = (payload) => { + yamlToJsonContent.value = jsYaml.load(payload); + setTimeout(() => { + payload.view.scrollDOM.scrollTop = 0; + }, 100); +}; watch( () => props, () => { getServiceJson.value = props.getServiceJson; getServiceYaml.value = props.getServiceYaml; if (props.type === 'edit' && props) { - console.log('edit'); - // getServiceYamlFun(props.serviceId); + getServiceYamlFun(props.serviceId); } }, { immediate: true, deep: true }, ); + +watch( + () => getServiceYaml, + () => { + yamlToJsonContent.value = jsYaml.load(getServiceYaml.value); + } +)