解决以子路径方式部署时的两个问题:1、登录后跳转到404页面 2、退出登录后直接跳转到/index页面,而不带子路径前缀

pull/410/head
mccreexu 4 months ago
parent 725033e361
commit 828aaeacc7

@ -102,7 +102,9 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.href = '/index' // 使 BASE_PATH
const basePath = process.env.VUE_APP_BASE_PATH || '/'; //
location.href = `${basePath}index`;
}) })
}).catch(() => {}) }).catch(() => {})
} }

@ -178,6 +178,9 @@ Router.prototype.replace = function push(location) {
export default new Router({ export default new Router({
mode: 'history', // 去掉url中的# mode: 'history', // 去掉url中的#
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
base: process.env.NODE_ENV === "production" ? "/" : "/",
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes routes: constantRoutes
}) })

@ -7,6 +7,10 @@ import { tansParams, blobValidate } from "@/utils/ruoyi"
import cache from '@/plugins/cache' import cache from '@/plugins/cache'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
// 默认情况下Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
export const BASE_PATH = '/'
let downloadLoadingInstance let downloadLoadingInstance
// 是否显示重新登录 // 是否显示重新登录
export let isRelogin = { show: false } export let isRelogin = { show: false }

Loading…
Cancel
Save