From 272b470aa0974cc0b1326e5e670fb3098bf5de10 Mon Sep 17 00:00:00 2001 From: luckyasme <807254037@qq.com> Date: Tue, 22 Apr 2025 20:07:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96bug=E6=8D=89=E8=99=AB?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/doc/DocBugDialog.vue | 32 ++++++++++++------- app/.vitepress/src/utils/common.ts | 5 +-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/.vitepress/src/components/doc/DocBugDialog.vue b/app/.vitepress/src/components/doc/DocBugDialog.vue index 49b7635d0..98acb1568 100644 --- a/app/.vitepress/src/components/doc/DocBugDialog.vue +++ b/app/.vitepress/src/components/doc/DocBugDialog.vue @@ -19,19 +19,17 @@ import { useMessage, } from '@opensig/opendesign'; -import { useRoute } from 'vitepress'; +import { useData } from 'vitepress'; import type { DocsBugParamsT } from '@/@types/type-feedback'; import { submitDocsBug } from '@/api/api-feedback'; import { useLocale } from '@/composables/useLocale'; -import { useSearchingStore } from '@/stores/common'; const message = useMessage(); const { t, locale } = useLocale(); -const searchStore = useSearchingStore(); -const route = useRoute(); +const { page } = useData(); const props = defineProps({ modelValue: { @@ -168,15 +166,9 @@ const issueTemplate = (data: DocsBugParamsT) => { }; const submitBug = (results: FieldResultT[]) => { - // 获取要提交的文件的路径 - const path = route.path.replace(`/${locale.value}/`, '/').replace('html', 'md'); - const regR = /[\r\n]+/g; const first = formData.fragment.split(regR)[0]; - const urlArr = route.path.split('/'); - const title = urlArr[urlArr.length - 1].replace('.html', ''); - if (results.find((item) => item?.type === 'danger')) { return; } else { @@ -193,10 +185,26 @@ const submitBug = (results: FieldResultT[]) => { if (res.code === 200) { emit('update:modelValue', false); if (submitType.value === 'issue') { - window.open(`https://gitee.com/openeuler/docs/issues/new?issue%5Bassignee_id%5D=0&issue%5Bmilestone_id%5D=0&title=文档捉虫&description=${body}`); + window.open( + window.location.pathname.includes('/openstack/') + ? `https://gitee.com/openeuler/openstack-docs/issues/new?issue%5Bassignee_id%5D=0&issue%5Bmilestone_id%5D=0&title=文档捉虫&description=${body}` + : `https://gitee.com/openeuler/docs/issues/new?issue%5Bassignee_id%5D=0&issue%5Bmilestone_id%5D=0&title=文档捉虫&description=${body}` + ); } else { + let pathname = window.location.pathname; + if (pathname.endsWith('.html')) { + pathname = pathname.replace('.html', '.md'); + } else if (pathname.endsWith('/')) { + pathname = `${pathname}index.md`; + } else { + pathname = `${pathname}.md`; + } + + const [_, lang, __, branch, ...others] = pathname.split('/'); window.open( - `https://gitee.com/-/ide/project/openeuler/docs/edit/${searchStore.version}/-/docs/${locale.value}/docs/${path}?search=${first}&title=文档捉虫-openEuler ${searchStore.version}-${title}&description=${formData.description}&message=${formData.description}&label_names=文档捉虫` + pathname.includes('/openstack/') + ? `https://gitee.com/-/ide/project/openeuler/openstack-docs/edit/openEuler-${branch}/-/docs/${lang}/${others.slice(3).join('/')}?search=${first}&title=文档捉虫-openEuler ${branch}-${page.value.title}&description=${formData.description}&message=${formData.description}&label_names=文档捉虫` + : `https://gitee.com/-/ide/project/openeuler/docs/edit/${branch}/-/docs/${lang}/${others.join('/')}?search=${first}&title=文档捉虫-openEuler ${branch}-${page.value.title}&description=${formData.description}&message=${formData.description}&label_names=文档捉虫` ); } } diff --git a/app/.vitepress/src/utils/common.ts b/app/.vitepress/src/utils/common.ts index bce3530e6..5231cb248 100644 --- a/app/.vitepress/src/utils/common.ts +++ b/app/.vitepress/src/utils/common.ts @@ -103,10 +103,11 @@ export const getGiteeUrl = () => { if (pathname.endsWith('.html')) { pathname = pathname.replace('.html', '.md'); } else if (pathname.endsWith('/')) { - pathname = `${pathname}/index.md`; + pathname = `${pathname}index.md`; + } else { + pathname = `${pathname}.md`; } - // 分支文档内容 const [_, lang, __, branch, ...others] = pathname.split('/'); return pathname.includes('/openstack/') -- Gitee