|
@@ -1,4 +1,4 @@
|
|
|
-import type { RouteLocationRaw } from "vue-router";
|
|
|
+import type { RouteLocationNamedRaw, RouteLocationRaw } from "vue-router";
|
|
|
|
|
|
export interface TOP_DATA {
|
|
|
id: number;
|
|
@@ -11,20 +11,48 @@ export const topData: TOP_DATA[] = [
|
|
|
{
|
|
|
id: 2,
|
|
|
name: "Visit",
|
|
|
- routeParams: { name: "Visit", params: { id: 8 } },
|
|
|
+ routeParams: { name: "Visit", params: { id: "8" } },
|
|
|
children: [
|
|
|
- { routeParams: "/Layout/Visit/8", id: 2.8, name: "Calendar" },
|
|
|
{
|
|
|
- routeParams: "/Layout/Visit/1",
|
|
|
+ routeParams: { name: "Visit", params: { id: "8" } },
|
|
|
+ id: 2.8,
|
|
|
+ name: "Calendar",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "1" } },
|
|
|
id: 2.1,
|
|
|
name: "Hours, Direction & Admission",
|
|
|
},
|
|
|
- { routeParams: "/Layout/Visit/2", id: 2.2, name: "Reservation" },
|
|
|
- { routeParams: "/Layout/Visit/3", id: 2.3, name: "Floor Plans" },
|
|
|
- { routeParams: "/Layout/Visit/4", id: 2.4, name: "Audio Guide & Tour" },
|
|
|
- { routeParams: "/Layout/Visit/5", id: 2.5, name: "Accessibility" },
|
|
|
- { routeParams: "/Layout/Visit/6", id: 2.6, name: "Café & Shop" },
|
|
|
- { routeParams: "/Layout/Visit/7", id: 2.7, name: "Visitor Guidelines" },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "2" } },
|
|
|
+ id: 2.2,
|
|
|
+ name: "Reservation",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "3" } },
|
|
|
+ id: 2.3,
|
|
|
+ name: "Floor Plans",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "4" } },
|
|
|
+ id: 2.4,
|
|
|
+ name: "Audio Guide & Tour",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "5" } },
|
|
|
+ id: 2.5,
|
|
|
+ name: "Accessibility",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "6" } },
|
|
|
+ id: 2.6,
|
|
|
+ name: "Café & Shop",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "Visit", params: { id: "7" } },
|
|
|
+ id: 2.7,
|
|
|
+ name: "Visitor Guidelines",
|
|
|
+ },
|
|
|
],
|
|
|
},
|
|
|
{
|
|
@@ -33,22 +61,22 @@ export const topData: TOP_DATA[] = [
|
|
|
routeParams: { name: "Exhibitions" },
|
|
|
children: [
|
|
|
{
|
|
|
- routeParams: "/Layout/Exhibitions/Current",
|
|
|
+ routeParams: { name: "ExhibitionsCurrent" },
|
|
|
id: 3.1,
|
|
|
name: "Current Exhibitions",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Exhibitions/Permanent",
|
|
|
+ routeParams: { name: "ExhibitionsPermanent" },
|
|
|
id: 3.2,
|
|
|
name: "Permanent Exhibitions",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Exhibitions/Past",
|
|
|
+ routeParams: { name: "ExhibitionsPast" },
|
|
|
id: 3.3,
|
|
|
name: "Past Exhibitions",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Exhibitions/Overseas",
|
|
|
+ routeParams: { name: "ExhibitionsOverseas" },
|
|
|
id: 3.4,
|
|
|
name: "Overseas Exhibitions",
|
|
|
},
|
|
@@ -57,56 +85,66 @@ export const topData: TOP_DATA[] = [
|
|
|
{
|
|
|
id: 4,
|
|
|
name: "Collections",
|
|
|
- routeParams: { name: "Collections", params: { type: "Bronzes" } },
|
|
|
+ routeParams: { name: "Collections" },
|
|
|
children: [
|
|
|
- { routeParams: "/Layout/Collections/Bronzes", id: 4.1, name: "Bronzes" },
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Ceramics",
|
|
|
- id: 4.2,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Bronzes" } },
|
|
|
+ id: 4.01,
|
|
|
+ name: "Bronzes",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Ceramics" } },
|
|
|
+ id: 4.02,
|
|
|
name: "Ceramics",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Buddhist",
|
|
|
- id: 4.3,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Buddhist" } },
|
|
|
+ id: 4.03,
|
|
|
name: "Buddhist Statues",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Jadewares",
|
|
|
- id: 4.4,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Jadewares" } },
|
|
|
+ id: 4.04,
|
|
|
name: "Jadewares",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Calligraphies",
|
|
|
- id: 4.5,
|
|
|
+ routeParams: {
|
|
|
+ name: "CollectionsList",
|
|
|
+ params: { name: "Calligraphies" },
|
|
|
+ },
|
|
|
+ id: 4.05,
|
|
|
name: "Calligraphies",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Paintings",
|
|
|
- id: 4.6,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Paintings" } },
|
|
|
+ id: 4.06,
|
|
|
name: "Paintings",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Gold",
|
|
|
- id: 4.7,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Gold" } },
|
|
|
+ id: 4.07,
|
|
|
name: "Gold & Silverwares",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Coins",
|
|
|
- id: 4.8,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Coins" } },
|
|
|
+ id: 4.08,
|
|
|
name: "Coins & Banknotes",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Brocades",
|
|
|
- id: 4.9,
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Brocades" } },
|
|
|
+ id: 4.09,
|
|
|
name: "Brocades & Embroideries",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Cultural",
|
|
|
+ routeParams: { name: "CollectionsList", params: { name: "Cultural" } },
|
|
|
id: 4.1,
|
|
|
name: "Cultural Supplies",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Collections/Miscellaneous",
|
|
|
+ routeParams: {
|
|
|
+ name: "CollectionsList",
|
|
|
+ params: { name: "Miscellaneous" },
|
|
|
+ },
|
|
|
id: 4.11,
|
|
|
name: "Miscellaneous",
|
|
|
},
|
|
@@ -140,12 +178,12 @@ export const topData: TOP_DATA[] = [
|
|
|
routeParams: { name: "Publications" },
|
|
|
children: [
|
|
|
{
|
|
|
- routeParams: "/Layout/Publications/Magazines",
|
|
|
+ routeParams: { name: "PuMagazines" },
|
|
|
id: 6.1,
|
|
|
name: "Magazines",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Publications/Catalogues",
|
|
|
+ routeParams: { name: "PuCatalogues" },
|
|
|
id: 6.2,
|
|
|
name: "Exhibition Catalogues",
|
|
|
},
|
|
@@ -184,12 +222,12 @@ export const topData: TOP_DATA[] = [
|
|
|
name: "Ways to Give",
|
|
|
children: [
|
|
|
{
|
|
|
- routeParams: "/Layout/Join/GiveInfo?id=4",
|
|
|
+ routeParams: { name: "JoinGi" },
|
|
|
id: 7.21,
|
|
|
name: "Individuals",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: "/Layout/Join/GiveInfo?id=5",
|
|
|
+ routeParams: { name: "JoinGi" },
|
|
|
id: 7.22,
|
|
|
name: "Corporations Institutions",
|
|
|
},
|
|
@@ -200,28 +238,67 @@ export const topData: TOP_DATA[] = [
|
|
|
{
|
|
|
id: 8,
|
|
|
name: "About",
|
|
|
- routeParams: { name: "About" },
|
|
|
+ routeParams: { name: "AboutIndex" },
|
|
|
children: [
|
|
|
{
|
|
|
- routeParams: { name: "About", query: { scroll: 0 } },
|
|
|
+ routeParams: { name: "AboutIndex", query: { scroll: "0" } },
|
|
|
id: 8.1,
|
|
|
name: "From the Director",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: { name: "About", query: { scroll: 1 } },
|
|
|
+ routeParams: { name: "AboutIndex", query: { scroll: "1" } },
|
|
|
id: 8.2,
|
|
|
name: "History",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: { name: "About", query: { scroll: 2 } },
|
|
|
+ routeParams: { name: "AboutIndex", query: { scroll: "2" } },
|
|
|
id: 8.3,
|
|
|
name: "Partners & Connections",
|
|
|
},
|
|
|
{
|
|
|
- routeParams: { name: "About", query: { scroll: 3 } },
|
|
|
+ routeParams: { name: "AboutIndex", query: { scroll: "3" } },
|
|
|
id: 8.4,
|
|
|
name: "Contact",
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
];
|
|
|
+
|
|
|
+export const findIndexes = (
|
|
|
+ data: TOP_DATA[],
|
|
|
+ targetName: string,
|
|
|
+ query: Record<string, any>,
|
|
|
+ params: Record<string, any>,
|
|
|
+ parentIndex: number[] = []
|
|
|
+) => {
|
|
|
+ const result: number[][] = [];
|
|
|
+
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const item = data[i];
|
|
|
+ const currentIndex = [...parentIndex, item.id];
|
|
|
+ const routeParams = item.routeParams as RouteLocationNamedRaw | undefined;
|
|
|
+
|
|
|
+ if (
|
|
|
+ routeParams?.name === targetName &&
|
|
|
+ (routeParams?.query
|
|
|
+ ? JSON.stringify(routeParams.query) === JSON.stringify(query)
|
|
|
+ : true) &&
|
|
|
+ (routeParams?.params
|
|
|
+ ? JSON.stringify(routeParams.params) === JSON.stringify(params)
|
|
|
+ : true)
|
|
|
+ ) {
|
|
|
+ if (currentIndex.length === 2) {
|
|
|
+ result.push(currentIndex);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.children) {
|
|
|
+ result.push(
|
|
|
+ ...findIndexes(item.children, targetName, query, params, currentIndex)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+};
|