Bläddra i källkod

修改路由模式

zjs_project 2 veckor sedan
förälder
incheckning
f582d829ac
3 ändrade filer med 9 tillägg och 7 borttagningar
  1. 3 3
      src/layout/default/components/header/user-drop-down.vue
  2. 3 2
      src/router/index.ts
  3. 3 2
      vite.config.ts

+ 3 - 3
src/layout/default/components/header/user-drop-down.vue

@@ -3,17 +3,17 @@
         <div class="flex items-center">
             <el-avatar :size="34" :src="userInfo.avatar" />
             <div class="ml-3 mr-1">{{ userInfo.nickname }}</div>
-            <icon name="el-icon-ArrowDown" />
+            <!-- <icon name="el-icon-ArrowDown" /> -->
         </div>
 
-        <template #dropdown>
+        <!-- <template #dropdown>
             <el-dropdown-menu>
                 <router-link to="/user/setting">
                     <el-dropdown-item>个人设置</el-dropdown-item>
                 </router-link>
                 <el-dropdown-item command="logout">退出登录</el-dropdown-item>
             </el-dropdown-menu>
-        </template>
+        </template> -->
     </el-dropdown>
 </template>
 

+ 3 - 2
src/router/index.ts

@@ -1,4 +1,4 @@
-import { createRouter, createWebHistory, RouterView, type RouteRecordRaw } from 'vue-router'
+import { createRouter, createWebHashHistory, RouterView, type RouteRecordRaw } from 'vue-router'
 import { MenuEnum } from '@/enums/appEnums'
 import { isExternal } from '@/utils/validate'
 import { constantRoutes, INDEX_ROUTE_NAME, LAYOUT } from './routes'
@@ -103,7 +103,8 @@ export function resetRouter() {
 }
 
 const router = createRouter({
-    history: createWebHistory(import.meta.env.BASE_URL),
+    // history: createWebHistory(import.meta.env.BASE_URL),
+    history: createWebHashHistory(),
     routes: constantRoutes
 })
 

+ 3 - 2
vite.config.ts

@@ -11,9 +11,10 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
 import vueSetupExtend from 'vite-plugin-vue-setup-extend'
 // https://vitejs.dev/config/
 export default defineConfig({
-    // base: '/admin/',
+    base: './', // 修改为相对路径
     server: {
-        host: '0.0.0.0'
+        host: '0.0.0.0',
+        cors: true // 允许跨域
     },
     plugins: [
         vue(),