// src/main.js import { createApp } from 'vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import zhCn from 'element-plus/es/locale/lang/zh-cn' // 获取当前页面名称 function getCurrentPage() { const path = window.location.pathname console.log('Current path:', path) let page = 'landingManagement' // 默认页面 if (path.includes('/pages/')) { page = path.split('/pages/').pop().replace('.html', '') } else if (path.endsWith('.html')) { page = path.split('/').pop().replace('.html', '') } console.log('Detected page:', page) return page } // 动态加载对应的 Vue 组件 async function bootstrap() { const pageName = getCurrentPage() console.log('Loading page:', pageName) try { // 动态导入所有 admin 目录下的 Vue 文件 const modules = import.meta.glob('./views/admin/*.vue') const modulePath = `./views/admin/${pageName}.vue` console.log('Looking for module:', modulePath) console.log('Available modules:', Object.keys(modules)) if (modules[modulePath]) { const module = await modules[modulePath]() console.log('Module loaded successfully') // 创建并挂载应用 const app = createApp(module.default) app.use(ElementPlus, { locale: zhCn }) app.mount('#app') console.log('App mounted successfully') } else { console.error(`Page ${pageName} not found`) // 显示错误页面 const app = createApp({ template: `
页面 ${pageName} 不存在
可用页面: ${Object.keys(modules).map(m => m.replace('./views/admin/', '').replace('.vue', '')).join(', ')}
错误: ${error.message}
请检查控制台获取详细信息