-
-
-
-
-
-
-
+
-
-
diff --git a/src/main.ts b/src/main.ts
index 4a2541f..f73434a 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,6 +1,18 @@
-import { createApp } from 'vue'
-import './style.css'
+// src/main.ts
+import { ViteSSG } from 'vite-ssg'
+import { createWebHistory } from 'vue-router'
import App from './App.vue'
-import './styles/reset.css' // 引入重置样式
+import routes from './router/routes'
+import './style.css'
-createApp(App).mount('#app')
+export const createApp = ViteSSG(
+ App,
+ {
+ history: createWebHistory(),
+ routes
+ },
+ ctx => {
+ // 确保路由插件被安装
+ ctx.app.use(ctx.router) // 关键修改点
+ }
+)
diff --git a/src/router/index.ts b/src/router/index.ts
new file mode 100644
index 0000000..a1ce10b
--- /dev/null
+++ b/src/router/index.ts
@@ -0,0 +1,20 @@
+// src/router/index.ts
+import { createRouter, createWebHistory } from 'vue-router'
+import routes from './routes'
+
+const router = createRouter({
+ history: createWebHistory(),
+ routes,
+ scrollBehavior(_to, _from, savedPosition) {
+ // 添加下划线标记未使用参数
+ return savedPosition || { top: 0 }
+ }
+})
+
+router.beforeEach((_to, _from, next) => {
+ // 添加下划线
+ // document.title = to.meta.title || '极简官网' // 确保meta.title类型正确
+ next()
+})
+
+export default router
diff --git a/src/router/routes.ts b/src/router/routes.ts
new file mode 100644
index 0000000..3496a35
--- /dev/null
+++ b/src/router/routes.ts
@@ -0,0 +1,31 @@
+// src/router/routes.ts
+import type { RouteRecordRaw } from 'vue-router' // 添加type关键字
+import Home from '@/views/Home.vue'
+import About from '@/views/About.vue'
+
+const routes: RouteRecordRaw[] = [
+ {
+ path: '/',
+ name: 'Home',
+ component: Home,
+ meta: {
+ title: '首页 - 极简官网' // 明确指定title为string类型
+ } as { title: string } // 强制类型断言
+ },
+ {
+ path: '/about',
+ name: 'About',
+ component: About,
+ meta: {
+ title: '关于我们 - 极简官网'
+ } as { title: string }
+ },
+ {
+ path: '/:pathMatch(.*)*',
+ name: 'NotFound',
+ component: () => import('@/views/NotFound.vue'),
+ meta: { title: '404 - 页面不存在' } as { title: string }
+ }
+]
+
+export default routes
diff --git a/src/views/About.vue b/src/views/About.vue
new file mode 100644
index 0000000..8080add
--- /dev/null
+++ b/src/views/About.vue
@@ -0,0 +1,18 @@
+
+
+
关于我们
+
我们是一家专注于极简设计的科技公司。
+
返回首页
+
+
+
+
+
+
diff --git a/src/views/Contact.vue b/src/views/Contact.vue
new file mode 100644
index 0000000..15f3cfa
--- /dev/null
+++ b/src/views/Contact.vue
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/src/views/Home.vue b/src/views/Home.vue
new file mode 100644
index 0000000..8ec1fad
--- /dev/null
+++ b/src/views/Home.vue
@@ -0,0 +1,18 @@
+
+
+
欢迎来到极简官网
+
这是首页内容,展示公司核心信息。
+
了解更多关于我们
+
+
+
+
+
+
diff --git a/src/views/NotFound.vue b/src/views/NotFound.vue
new file mode 100644
index 0000000..74053fb
--- /dev/null
+++ b/src/views/NotFound.vue
@@ -0,0 +1,9 @@
+
+
+
+
404 - 页面不存在
+ 返回首页
+
+
+
+
diff --git a/tsconfig.node.json b/tsconfig.node.json
index 5eee59c..6e68380 100644
--- a/tsconfig.node.json
+++ b/tsconfig.node.json
@@ -6,9 +6,10 @@
"ES2022",
"DOM",
],
+ "baseUrl": "./",
"paths": {
"@/*": [
- "./src/*"
+ "src/*"
]
// 添加路径别名
},