|
4 | 4 | q-tooltip.text-body2(anchor="top middle" self="bottom middle") Mode sombre/clair |
5 | 5 | q-btn.q-px-sm(flat stretch icon="mdi-frequently-asked-questions" :href="getQAndALink" target="_blank" :size="size") |
6 | 6 | q-tooltip.text-body2 Poser une question ou signaler un problème |
7 | | - q-btn.q-px-sm(flat stretch icon="mdi-help" href="https://libertech-fr.github.io/sesame-doc/" target="_blank" :size="size") |
| 7 | + q-btn.q-px-sm(flat stretch icon="mdi-help" :href="getDocumentationLink" target="_blank" :size="size") |
8 | 8 | q-tooltip.text-body2 Aide et Documentation |
9 | 9 | </template> |
10 | 10 |
|
11 | 11 | <script lang="ts"> |
| 12 | +import { computed } from 'vue' |
| 13 | +import { useRoute } from 'vue-router' |
| 14 | +
|
12 | 15 | export default defineNuxtComponent({ |
13 | 16 | name: 'HelpButtonsComponent', |
14 | 17 | props: { |
@@ -46,9 +49,62 @@ export default defineNuxtComponent({ |
46 | 49 | updateAvailable?: boolean |
47 | 50 | }>('daemonVersion', {}) |
48 | 51 |
|
| 52 | + const route = useRoute() |
| 53 | +
|
| 54 | + const docsBaseUrl = 'https://libertech-fr.github.io/sesame-doc' |
| 55 | +
|
| 56 | + const getRoutePatternPath = () => { |
| 57 | + const matched = route.matched ?? [] |
| 58 | + if (matched.length === 0) return route.path |
| 59 | +
|
| 60 | + // Vue Router stocke des segments dynamiques sous la forme `:param`. |
| 61 | + // On reconstruit un chemin complet avec ces placeholders pour pointer vers la doc. |
| 62 | + let pattern = '' |
| 63 | + for (const record of matched) { |
| 64 | + const p = record.path |
| 65 | + if (!p) continue |
| 66 | +
|
| 67 | + if (p === '/') { |
| 68 | + pattern = '/' |
| 69 | + continue |
| 70 | + } |
| 71 | +
|
| 72 | + if (p.startsWith('/')) { |
| 73 | + pattern = p |
| 74 | + } else { |
| 75 | + pattern = `${pattern.endsWith('/') ? pattern.slice(0, -1) : pattern}/${p}` |
| 76 | + } |
| 77 | + } |
| 78 | +
|
| 79 | + pattern = pattern.replace(/\/+/g, '/') |
| 80 | + pattern = pattern.replace(/:([A-Za-z0-9_]+)\([^/]*\)/g, ':$1') |
| 81 | + return pattern === '' ? '/' : pattern.startsWith('/') ? pattern : `/${pattern}` |
| 82 | + } |
| 83 | +
|
| 84 | + const collapseDynamicSegments = (path: string) => { |
| 85 | + if (path === '/') return '/' |
| 86 | + const segments = path.split('/').filter(Boolean) |
| 87 | +
|
| 88 | + const kept: string[] = [] |
| 89 | + for (const seg of segments) { |
| 90 | + if (seg.startsWith(':')) break |
| 91 | + kept.push(seg) |
| 92 | + } |
| 93 | +
|
| 94 | + return `/${kept.join('/')}` |
| 95 | + } |
| 96 | +
|
| 97 | + const getDocumentationLink = computed(() => { |
| 98 | + const pattern = getRoutePatternPath() |
| 99 | + const docRoute = collapseDynamicSegments(pattern) |
| 100 | + const docPath = docRoute === '/' ? '/pages/index.html' : `/pages${docRoute}.html` |
| 101 | + return `${docsBaseUrl}${docPath}` |
| 102 | + }) |
| 103 | +
|
49 | 104 | return { |
50 | 105 | orchestratorVersion, |
51 | 106 | daemonVersion, |
| 107 | + getDocumentationLink, |
52 | 108 | } |
53 | 109 | }, |
54 | 110 | methods: { |
|
0 commit comments