CzRger 5 months ago
parent
commit
b6808d7dbd
4 changed files with 9 additions and 8 deletions
  1. 1 0
      .gitignore
  2. 2 2
      src/router/index.ts
  3. 5 5
      src/views/global/index.vue
  4. 1 1
      vite.config.ts

+ 1 - 0
.gitignore

@@ -23,3 +23,4 @@ dist-ssr
 *.sln
 *.sw?
 smart-search-web/
+test-router-build/

+ 2 - 2
src/router/index.ts

@@ -6,16 +6,16 @@ import Temp404 from '@/views/global/temp/404.vue'
 const routes = [
     ...staticRouter,
     { path: '/:pathMatch(.*)*', name: 'NotFound', component: Temp404 },
-    { path: '', redirect: '/web' },
 ]
 
 const router = createRouter({
-    history: createWebHistory(),
+    history: createWebHistory(import.meta.env.BASE_URL),
     routes,
 });
 
 router.beforeEach((to, from , next) => {
     next()
+    console.log(router)
 })
 
 export default router;

+ 5 - 5
src/views/global/index.vue

@@ -1,10 +1,10 @@
 <template>
   <div>
     <h1>index</h1>
-    <el-input v-model="state.val"/><br/>
-    <el-button @click="routerToLink('/b')">路由跳转到{{state.val}}</el-button><br/>
-    <el-button @click="windowToLink('/b')">window打开{{state.val}}</el-button><br/>
-    <el-button @click="locationToLink('/b')">重定向到{{state.val}}</el-button><br/>
+<!--    <el-input v-model="state.val"/><br/>-->
+    <el-button @click="routerToLink('/' + state.val)">路由跳转到{{state.val}}</el-button><br/>
+    <el-button @click="windowToLink('/' + state.val)">window打开{{state.val}}</el-button><br/>
+    <el-button @click="locationToLink('/' + state.val)">重定向到{{state.val}}</el-button><br/>
     <div style="width: 200px;height: 100px;" v-loading="state.loadingCode">
       <img style="width: 100%;height: 100%;" class="__hover" :src="state.codeBase64" @click="getCode"/>
     </div>
@@ -21,7 +21,7 @@ const {proxy} = getCurrentInstance()
 const state: any = reactive({
   codeBase64: '',
   loadingCode: false,
-  val: '',
+  val: 'b',
 })
 const routerToLink = (url) => {
   router.push(url)

+ 1 - 1
vite.config.ts

@@ -40,7 +40,7 @@ export default defineConfig({
       promiseImportName: i => `__tla_${i}`
     })
   ],
-  base: './',
+  base: './trb',
   resolve: {
     alias: {
       '@': resolve(__dirname, 'src'),