diff --git a/app/.vitepress/src/components/doc/DocBugDialog.vue b/app/.vitepress/src/components/doc/DocBugDialog.vue index 49b7635d0957eee36a5aebd8e05a6ed1ebf0f89d..98acb1568c1cc90133dd1d19cc372156ee261c0f 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 bce3530e60a96d9c78f9dbb56110804e14c7e587..5231cb2489f2bd4ec8b53f1b50b3b8e96e94def5 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/')