refactor(router): 重构路由配置和页面跳转逻辑
- 将路由历史模式从createWebHistory改为createWebHashHistory - 调整首页和启动页的路由路径 - 简化404页面,移除多余的操作按钮和链接 - 移除Masters页面的卡片背景色
Showing
4 changed files
with
13 additions
and
54 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-10-30 10:29:15 | 2 | * @Date: 2025-10-30 10:29:15 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-10-30 20:53:14 | 4 | + * @LastEditTime: 2025-11-01 21:12:36 |
| 5 | * @FilePath: /stdj_h5/src/router/index.js | 5 | * @FilePath: /stdj_h5/src/router/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| 8 | -import { createRouter, createWebHistory } from 'vue-router' | 8 | +import { createRouter, createWebHashHistory } from 'vue-router' |
| 9 | import Home from '../views/Home.vue' | 9 | import Home from '../views/Home.vue' |
| 10 | 10 | ||
| 11 | const routes = [ | 11 | const routes = [ |
| 12 | { | 12 | { |
| 13 | - path: '/', | 13 | + path: '/splash', |
| 14 | name: 'Splash', | 14 | name: 'Splash', |
| 15 | component: () => import('../views/Splash.vue') | 15 | component: () => import('../views/Splash.vue') |
| 16 | }, | 16 | }, |
| 17 | { | 17 | { |
| 18 | - path: '/home', | 18 | + path: '/', |
| 19 | name: 'Home', | 19 | name: 'Home', |
| 20 | component: Home | 20 | component: Home |
| 21 | }, | 21 | }, |
| ... | @@ -52,7 +52,7 @@ const routes = [ | ... | @@ -52,7 +52,7 @@ const routes = [ |
| 52 | ] | 52 | ] |
| 53 | 53 | ||
| 54 | const router = createRouter({ | 54 | const router = createRouter({ |
| 55 | - history: createWebHistory(), | 55 | + history: createWebHashHistory('/index.html'), |
| 56 | routes, | 56 | routes, |
| 57 | scrollBehavior(to, from, savedPosition) { | 57 | scrollBehavior(to, from, savedPosition) { |
| 58 | if (savedPosition) { | 58 | if (savedPosition) { | ... | ... |
| ... | @@ -166,7 +166,6 @@ onMounted(async () => { | ... | @@ -166,7 +166,6 @@ onMounted(async () => { |
| 166 | /* 卡片 */ | 166 | /* 卡片 */ |
| 167 | .item-card { | 167 | .item-card { |
| 168 | position: relative; | 168 | position: relative; |
| 169 | - background: #fff; | ||
| 170 | border: 2px solid #6B4102; | 169 | border: 2px solid #6B4102; |
| 171 | overflow: hidden; | 170 | overflow: hidden; |
| 172 | transition: transform 0.2s ease; | 171 | transition: transform 0.2s ease; | ... | ... |
| 1 | +<!-- | ||
| 2 | + * @Date: 2025-10-30 10:32:36 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-11-01 21:08:44 | ||
| 5 | + * @FilePath: /stdj_h5/src/views/NotFound.vue | ||
| 6 | + * @Description: 文件描述 | ||
| 7 | +--> | ||
| 1 | <template> | 8 | <template> |
| 2 | <div class="not-found-container"> | 9 | <div class="not-found-container"> |
| 3 | <div class="not-found-content"> | 10 | <div class="not-found-content"> |
| ... | @@ -14,53 +21,6 @@ | ... | @@ -14,53 +21,6 @@ |
| 14 | <h1 class="text-2xl font-bold text-gray-800 mb-2">页面不存在</h1> | 21 | <h1 class="text-2xl font-bold text-gray-800 mb-2">页面不存在</h1> |
| 15 | <p class="text-gray-600 mb-8">抱歉,您访问的页面不存在或已被删除</p> | 22 | <p class="text-gray-600 mb-8">抱歉,您访问的页面不存在或已被删除</p> |
| 16 | </div> | 23 | </div> |
| 17 | - | ||
| 18 | - <!-- 操作按钮 --> | ||
| 19 | - <div class="not-found-actions space-y-4"> | ||
| 20 | - <van-button | ||
| 21 | - type="primary" | ||
| 22 | - round | ||
| 23 | - block | ||
| 24 | - @click="goHome" | ||
| 25 | - class="mb-4" | ||
| 26 | - > | ||
| 27 | - 返回首页 | ||
| 28 | - </van-button> | ||
| 29 | - | ||
| 30 | - <van-button | ||
| 31 | - plain | ||
| 32 | - round | ||
| 33 | - block | ||
| 34 | - @click="goBack" | ||
| 35 | - > | ||
| 36 | - 返回上页 | ||
| 37 | - </van-button> | ||
| 38 | - </div> | ||
| 39 | - | ||
| 40 | - <!-- 建议链接 --> | ||
| 41 | - <div class="suggested-links mt-8"> | ||
| 42 | - <p class="text-sm text-gray-500 mb-4">您可能想要访问:</p> | ||
| 43 | - <div class="space-y-2"> | ||
| 44 | - <van-cell | ||
| 45 | - title="首页" | ||
| 46 | - is-link | ||
| 47 | - @click="$router.push('/')" | ||
| 48 | - icon="home-o" | ||
| 49 | - /> | ||
| 50 | - <van-cell | ||
| 51 | - title="组件演示" | ||
| 52 | - is-link | ||
| 53 | - @click="$router.push('/demo')" | ||
| 54 | - icon="apps-o" | ||
| 55 | - /> | ||
| 56 | - <van-cell | ||
| 57 | - title="关于我们" | ||
| 58 | - is-link | ||
| 59 | - @click="$router.push('/about')" | ||
| 60 | - icon="info-o" | ||
| 61 | - /> | ||
| 62 | - </div> | ||
| 63 | - </div> | ||
| 64 | </div> | 24 | </div> |
| 65 | </div> | 25 | </div> |
| 66 | </template> | 26 | </template> | ... | ... |
| ... | @@ -44,7 +44,7 @@ const enterApp = () => { | ... | @@ -44,7 +44,7 @@ const enterApp = () => { |
| 44 | isExiting.value = true | 44 | isExiting.value = true |
| 45 | // 等待淡出动画完成后跳转 | 45 | // 等待淡出动画完成后跳转 |
| 46 | setTimeout(() => { | 46 | setTimeout(() => { |
| 47 | - router.push('/home') | 47 | + router.push('/') |
| 48 | }, 500) | 48 | }, 500) |
| 49 | } | 49 | } |
| 50 | 50 | ... | ... |
-
Please register or login to post a comment