diff --git a/src/pages/panel/MePage.vue b/src/pages/panel/MePage.vue
new file mode 100644
index 0000000..507d6fe
--- /dev/null
+++ b/src/pages/panel/MePage.vue
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
我的
+
这是一个自动路由注册的示例页面
+
路径将自动转换为 /panel/me
+
+
+
+
+
+
diff --git a/src/router/index.ts b/src/router/index.ts
index 3f9d5d7..32a25ef 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -35,6 +35,32 @@ function getComponentNameFromPath(filePath: string): string {
return filePath.split("/").pop() || "";
}
+/**
+ * Generate route path from full file path, preserving directory structure
+ * @param filePath Full path to the component file (e.g., "@/pages/test/AbcPage.vue")
+ * @returns Route path (e.g., "/test/abc")
+ */
+function generateRoutePathFromFilePath(filePath: string): string {
+ // Remove the "@/pages" prefix and get the relative path
+ const relativePath = filePath.replace(/^@\/pages\//, "");
+
+ // Split into directory parts and filename
+ const pathParts = relativePath.split("/");
+ const fileName = pathParts.pop() || "";
+ const directories = pathParts.splice(3);
+
+ // Transform the filename using existing logic
+ const transformedFileName = formatPathFromComponentName(fileName);
+
+ // Combine directory path with transformed filename
+ const fullPath =
+ directories.length > 0
+ ? `/${directories.join("/")}/${transformedFileName}`
+ : `/${transformedFileName}`;
+
+ return fullPath;
+}
+
/**
* Generate routes from page components using Vite's import.meta.glob
* @returns Array of route configurations
@@ -46,7 +72,7 @@ function generateRoutesFromPages(): RouteRecordRaw[] {
for (const path in pages) {
const componentName = getComponentNameFromPath(path);
- const routePath = `/${formatPathFromComponentName(componentName)}`;
+ const routePath = generateRoutePathFromFilePath(path);
// Special case for home page
const finalPath = routePath.toLowerCase() === "/home" ? "/" : routePath;