Jelajahi Sumber

修改应用部署在子路径/twin上

wukai 3 bulan lalu
induk
melakukan
883b9ae9a1
4 mengubah file dengan 5 tambahan dan 5 penghapusan
  1. 1 1
      src/layout/components/Navbar.vue
  2. 1 1
      src/router/index.js
  3. 1 1
      src/utils/request.js
  4. 2 2
      vite.config.js

+ 1 - 1
src/layout/components/Navbar.vue

@@ -96,7 +96,7 @@ function logout() {
     type: 'warning'
   }).then(() => {
     userStore.logOut().then(() => {
-      location.href = '/index';
+      location.href = '/twin/index';
     })
   }).catch(() => { });
 }

+ 1 - 1
src/router/index.js

@@ -161,7 +161,7 @@ export const dynamicRoutes = [
 ]
 
 const router = createRouter({
-  history: createWebHistory(),
+  history: createWebHistory('/twin'),
   routes: constantRoutes,
   scrollBehavior(to, from, savedPosition) {
     if (savedPosition) {

+ 1 - 1
src/utils/request.js

@@ -87,7 +87,7 @@ service.interceptors.response.use(res => {
         ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
           isRelogin.show = false;
           useUserStore().logOut().then(() => {
-            location.href = '/index';
+            location.href = '/twin/index';
           })
       }).catch(() => {
         isRelogin.show = false;

+ 2 - 2
vite.config.js

@@ -10,7 +10,7 @@ export default defineConfig(({ mode, command }) => {
     // 部署生产环境和开发环境下的URL。
     // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上
     // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
-    base: VITE_APP_ENV === 'production' ? '/' : '/',
+    base: VITE_APP_ENV === 'production' ? '/twin/' : '/twin',
     plugins: createVitePlugins(env, command === 'build'),
     resolve: {
       // https://cn.vitejs.dev/config/#resolve-alias
@@ -31,7 +31,7 @@ export default defineConfig(({ mode, command }) => {
       proxy: {
         // https://cn.vitejs.dev/config/#server-proxy
         '/dev-api': {
-          target: 'http://localhost:8080',
+          target: 'http://192.168.66.133:8080',
           changeOrigin: true,
           rewrite: (p) => p.replace(/^\/dev-api/, '')
         }