vite-plugin-generoutes 0.2.3 → 0.2.5
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/index.js +4 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -79,24 +79,20 @@ function VitePluginGeneroutes(options = {}) {
|
|
|
79
79
|
filePath = slash(filePath);
|
|
80
80
|
const defineOptions = parseDefineOptions(filePath) || {};
|
|
81
81
|
defineOptionsCache.set(filePath, JSON.stringify(defineOptions));
|
|
82
|
-
const meta = defineOptions
|
|
82
|
+
const meta = defineOptions.meta || {};
|
|
83
83
|
if (meta.enabled === false)
|
|
84
84
|
return null;
|
|
85
85
|
const pathSegments = filePath.replace(`${pagesFolder}`, "").replace(".vue", "").replace("index", "").split("/").filter((item) => !!item && !/^\(.*\)$/.test(item));
|
|
86
|
-
const name = defineOptions
|
|
86
|
+
const name = defineOptions.name || pathSegments.map((item) => toPascalCase(item)).join("_") || "Index";
|
|
87
87
|
const component = `##/${filePath}##`;
|
|
88
88
|
const routePath = `/${pathSegments.map((item) => item.replace(/\[(.*?)\]/g, (_, p1) => p1 === "...all" ? ":pathMatch(.*)*" : p1.split(",").map((i) => `:${i}`).join("/"))).join("/")}`;
|
|
89
|
-
if (!("title" in meta))
|
|
90
|
-
meta.title = name;
|
|
91
|
-
if (!("show" in meta))
|
|
92
|
-
meta.show = true;
|
|
93
|
-
meta.keepAlive = !!defineOptions?.name && meta.keepAlive !== false;
|
|
94
89
|
return {
|
|
95
90
|
name,
|
|
96
91
|
path: routePath,
|
|
92
|
+
redirect: defineOptions.redirect,
|
|
97
93
|
component,
|
|
98
94
|
meta,
|
|
99
|
-
parent: defineOptions
|
|
95
|
+
parent: defineOptions.parent
|
|
100
96
|
};
|
|
101
97
|
}).filter(Boolean);
|
|
102
98
|
const { duplicateNames, duplicatePaths } = findDuplicateRoutes(routes);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-generoutes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.5",
|
|
5
5
|
"packageManager": "pnpm@9.1.1",
|
|
6
6
|
"description": "_description_",
|
|
7
7
|
"author": "Ronnie Zhang <zclzone@outlook.com>",
|
|
@@ -78,4 +78,4 @@
|
|
|
78
78
|
"lint-staged": {
|
|
79
79
|
"*": "eslint --fix"
|
|
80
80
|
}
|
|
81
|
-
}
|
|
81
|
+
}
|