@shwfed/nuxt 0.1.56 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/app.vue +47 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useHead, useNuxtApp, useRouter, useRuntimeConfig } from "#app";
|
|
3
|
-
import { computed, ref } from "vue";
|
|
2
|
+
import { useHead, useNuxtApp, useRoute, useRouter, useRuntimeConfig } from "#app";
|
|
3
|
+
import { computed, onMounted, ref } from "vue";
|
|
4
4
|
import { CommandDialog, CommandInput, CommandList, CommandGroup, CommandEmpty, CommandItem } from "./ui/command";
|
|
5
5
|
import { TooltipProvider } from "./ui/tooltip";
|
|
6
6
|
import { Toaster } from "vue-sonner";
|
|
@@ -14,7 +14,12 @@ import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarMenu,
|
|
|
14
14
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible";
|
|
15
15
|
import Logo from "./logo.vue";
|
|
16
16
|
const { $dsl } = useNuxtApp();
|
|
17
|
-
const
|
|
17
|
+
const {
|
|
18
|
+
public: {
|
|
19
|
+
shwfed: config
|
|
20
|
+
},
|
|
21
|
+
app
|
|
22
|
+
} = useRuntimeConfig();
|
|
18
23
|
const props = defineProps({
|
|
19
24
|
navigation: { type: Array, required: false },
|
|
20
25
|
commands: { type: Array, required: false },
|
|
@@ -39,6 +44,7 @@ whenever(() => meta_k?.value, () => {
|
|
|
39
44
|
isCommandOpen.value = !isCommandOpen.value;
|
|
40
45
|
});
|
|
41
46
|
const router = useRouter();
|
|
47
|
+
const route = useRoute();
|
|
42
48
|
setGlobalDslContext(await props.dsl?.pipe(Effect.scoped).pipe(Effect.runPromise) ?? {});
|
|
43
49
|
function toNavigationKey(groupId, itemId) {
|
|
44
50
|
return groupId ? `${groupId}::${itemId}` : `::${itemId}`;
|
|
@@ -62,6 +68,25 @@ function findNavigationByKey(navList, key) {
|
|
|
62
68
|
}
|
|
63
69
|
return void 0;
|
|
64
70
|
}
|
|
71
|
+
function normalizePathForMatch(p) {
|
|
72
|
+
const trimmed = p.replace(/\/$/, "");
|
|
73
|
+
return trimmed === "" ? "/" : trimmed;
|
|
74
|
+
}
|
|
75
|
+
function findNavigationKeyByPath(navList, path) {
|
|
76
|
+
const normalized = normalizePathForMatch(path);
|
|
77
|
+
for (const el of navList) {
|
|
78
|
+
if (el.type === "item") {
|
|
79
|
+
if (el.external === true) continue;
|
|
80
|
+
if (normalizePathForMatch(el.target) === normalized) return toNavigationKey("", el.id);
|
|
81
|
+
} else {
|
|
82
|
+
for (const child of el.children) {
|
|
83
|
+
if (child.external === true) continue;
|
|
84
|
+
if (normalizePathForMatch(child.target) === normalized) return toNavigationKey(el.id, child.id);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
65
90
|
const palette = computed(() => {
|
|
66
91
|
const items = [];
|
|
67
92
|
for (const navigation2 of props.navigation ?? []) {
|
|
@@ -288,6 +313,24 @@ const tabs = useSessionStorage("navigation-tabs", /* @__PURE__ */ new Set(), {
|
|
|
288
313
|
const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
289
314
|
writeDefaults: false
|
|
290
315
|
});
|
|
316
|
+
onMounted(() => {
|
|
317
|
+
const baseRaw = app.baseURL ?? "/";
|
|
318
|
+
const base = baseRaw === "" || baseRaw === "/" ? "/" : baseRaw.replace(/\/*$/, "") + "/";
|
|
319
|
+
let pathToMatch;
|
|
320
|
+
if (base === "/") {
|
|
321
|
+
pathToMatch = route.path;
|
|
322
|
+
} else if (route.fullPath.startsWith(base)) {
|
|
323
|
+
const remainder = route.fullPath.slice(base.length) || "/";
|
|
324
|
+
pathToMatch = remainder.startsWith("/") ? remainder : `/${remainder}`;
|
|
325
|
+
} else {
|
|
326
|
+
pathToMatch = route.path;
|
|
327
|
+
}
|
|
328
|
+
const key = findNavigationKeyByPath(navigation.value, pathToMatch);
|
|
329
|
+
if (key !== void 0) {
|
|
330
|
+
tabs.value.add(key);
|
|
331
|
+
activeTab.value = key;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
291
334
|
useHead({
|
|
292
335
|
title: () => activeTab.value ? findNavigationByKey(navigation.value, activeTab.value)?.title ?? config.title : config.title
|
|
293
336
|
});
|
|
@@ -649,6 +692,7 @@ useHead({
|
|
|
649
692
|
>
|
|
650
693
|
{{ findNavigationByKey(navigation, tab)?.title ?? tab ?? "Unknown" }}
|
|
651
694
|
<button
|
|
695
|
+
v-if="tabs.size > 1"
|
|
652
696
|
type="button"
|
|
653
697
|
class="opacity-80 group-hover/tab:opacity-100 transition-opacity cursor-pointer text-zinc-500 hover:text-(--primary) duration-180"
|
|
654
698
|
@click.stop="() => {
|