基本实现了订单、购物车、商品等模块,商城v1.0

This commit is contained in:
puzvv
2025-12-20 20:41:30 +08:00
parent 57fe499080
commit bde3870243
12 changed files with 2008 additions and 19 deletions

View File

@@ -30,10 +30,10 @@ function formatPathFromComponentName(name: string): string {
* @param filePath Path to the component file
* @returns Component name without extension
*/
function getComponentNameFromPath(filePath: string): string {
// Get the file name from the path
return filePath.split("/").pop() || "";
}
// function getComponentNameFromPath(filePath: string): string {
// // Get the file name from the path
// return filePath.split("/").pop() || "";
// }
/**
* Generate route path from full file path, preserving directory structure
@@ -71,15 +71,17 @@ function generateRoutesFromPages(): RouteRecordRaw[] {
const pages = import.meta.glob("@/pages/**/*.vue");
for (const path in pages) {
const componentName = getComponentNameFromPath(path);
// const componentName = getComponentNameFromPath(path);
const routePath = generateRoutePathFromFilePath(path);
// Special case for home page
const finalPath = routePath.toLowerCase() === "/home" ? "/" : routePath;
const finalPath = routePath.toLowerCase().endsWith("/home")
? routePath.slice(0, -5)
: routePath;
routes.push({
path: finalPath,
name: componentName,
name: routePath,
component: pages[path],
});
}
@@ -97,6 +99,11 @@ const extraRoutes: RouteRecordRaw[] = [
name: "UserProfile",
component: () => import("@/pages/user/ProfilePage.vue"),
},
{
path: "/product/detail/:id",
name: "ProductDetail",
component: () => import("@/pages/product/DetailPage.vue"),
},
// 可以在这里添加其他需要特殊配置的路由
];