CzRger 5 months ago
parent
commit
046b3856e9

+ 0 - 1
.env.development

@@ -5,4 +5,3 @@ NODE_ENV = development
 VITE_TITLE = 测试路由
 
 # 基础路径
-VITE_BASE = 'trb'

+ 0 - 1
.env.production

@@ -5,4 +5,3 @@ NODE_ENV = production
 VITE_TITLE = 测试路由
 
 # 基础路径
-VITE_BASE = 'trb'

+ 1 - 1
src/router/index.ts

@@ -10,7 +10,7 @@ const routes = [
 ]
 
 const router = createRouter({
-    history: createWebHistory(import.meta.env.BASE_URL),
+    history: createWebHistory(),
     routes,
 });
 

+ 16 - 5
src/router/modules/static.ts

@@ -1,13 +1,24 @@
 // 不需要菜单管理配置的路由
 const staticRouter = [
   {
+    path: '/index',
+    name: 'index',
+    component: () => import('@/views/global/index.vue'),
+  },
+  {
     path: '/a',
-    name: 'login',
+    name: 'a',
     component: () => import('@/views/global/a.vue'),
-    meta: {
-      title: '登录',
-      noToken: true
-    }
+  },
+  {
+    path: '/b',
+    name: 'b',
+    component: () => import('@/views/global/b.vue'),
+  },
+  {
+    path: '/c',
+    name: 'c',
+    component: () => import('@/views/global/c.vue'),
   },
 ]
 export default staticRouter

+ 6 - 3
src/views/global/a.vue

@@ -1,14 +1,17 @@
 <template>
-  <div style="font-size: 400px">
-    aaa
+  <div style="font-size: 600px">
+    aaaaa
   </div>
 </template>
 
 <script setup lang="ts">
 import {getCurrentInstance, reactive} from "vue";
+import {useRouter} from "vue-router";
 
+const router = useRouter()
 const {proxy} = getCurrentInstance()
-const state: any = reactive({})
+const state: any = reactive({
+})
 </script>
 
 <style lang="scss" scoped>

+ 18 - 0
src/views/global/b.vue

@@ -0,0 +1,18 @@
+<template>
+  <div style="font-size: 600px">
+    bbbbb
+  </div>
+</template>
+
+<script setup lang="ts">
+import {getCurrentInstance, reactive} from "vue";
+import {useRouter} from "vue-router";
+
+const router = useRouter()
+const {proxy} = getCurrentInstance()
+const state: any = reactive({
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 18 - 0
src/views/global/c.vue

@@ -0,0 +1,18 @@
+<template>
+  <div style="font-size: 600px">
+    ccccc
+  </div>
+</template>
+
+<script setup lang="ts">
+import {getCurrentInstance, reactive} from "vue";
+import {useRouter} from "vue-router";
+
+const router = useRouter()
+const {proxy} = getCurrentInstance()
+const state: any = reactive({
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 33 - 0
src/views/global/index.vue

@@ -0,0 +1,33 @@
+<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/>
+  </div>
+</template>
+
+<script setup lang="ts">
+import {getCurrentInstance, reactive} from "vue";
+import {useRouter} from "vue-router";
+
+const router = useRouter()
+const {proxy} = getCurrentInstance()
+const state: any = reactive({
+  val: ''
+})
+const routerToLink = (url) => {
+  router.push(url)
+}
+const windowToLink = (url) => {
+  window.open(url, "_blank");
+}
+const locationToLink = (url) => {
+  window.location.replace(url);
+
+}
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 24 - 24
vite.config.ts

@@ -40,7 +40,7 @@ export default defineConfig({
       promiseImportName: i => `__tla_${i}`
     })
   ],
-  // base: '/smart-search-web/',
+  base: './',
   resolve: {
     alias: {
       '@': resolve(__dirname, 'src'),
@@ -80,29 +80,29 @@ export default defineConfig({
       },
     }
   },
-  css: {
-    postcss: {
-      plugins: [
-        postcsspxtoviewport({
-          unitToConvert: 'px',
-          viewportWidth: 1920,
-          unitPrecision: 5, // 单位转换后保留的精度
-          propList: ['*'], // 能转化为vw的属性列表
-          viewportUnit: 'vw', // 希望使用的视口单位
-          fontViewportUnit: 'vw', // 字体使用的视口单位
-          selectorBlackList: ['ignore-'], // 需要忽略的CSS选择器,不会转为视口单位,使用原有的px等单位。
-          minPixelValue: 1, // 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
-          mediaQuery: true, // 媒体查询里的单位是否需要转换单位
-          replace: true, //  是否直接更换属性值,而不添加备用属性
-          exclude: [], // 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
-          include: [], // 如果设置了include,那将只有匹配到的文件才会被转换
-          landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
-          landscapeUnit: 'vw', // 横屏时使用的单位
-          landscapeWidth: 1628, // 横屏时使用的视口宽度
-        }),
-      ]
-    }
-  },
+  // css: {
+  //   postcss: {
+  //     plugins: [
+  //       postcsspxtoviewport({
+  //         unitToConvert: 'px',
+  //         viewportWidth: 1920,
+  //         unitPrecision: 5, // 单位转换后保留的精度
+  //         propList: ['*'], // 能转化为vw的属性列表
+  //         viewportUnit: 'vw', // 希望使用的视口单位
+  //         fontViewportUnit: 'vw', // 字体使用的视口单位
+  //         selectorBlackList: ['ignore-'], // 需要忽略的CSS选择器,不会转为视口单位,使用原有的px等单位。
+  //         minPixelValue: 1, // 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
+  //         mediaQuery: true, // 媒体查询里的单位是否需要转换单位
+  //         replace: true, //  是否直接更换属性值,而不添加备用属性
+  //         exclude: [], // 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
+  //         include: [], // 如果设置了include,那将只有匹配到的文件才会被转换
+  //         landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
+  //         landscapeUnit: 'vw', // 横屏时使用的单位
+  //         landscapeWidth: 1628, // 横屏时使用的视口宽度
+  //       }),
+  //     ]
+  //   }
+  // },
   build: {
     outDir: "smart-search-web",
     rollupOptions: {//分包优化