fix: 修改路由模式
This commit is contained in:
@@ -26,8 +26,12 @@ devWebpackConfig = merge(baseWebpackConfig, {
|
|||||||
devServer: {
|
devServer: {
|
||||||
clientLogLevel: 'warning',
|
clientLogLevel: 'warning',
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
|
index: indexHtml,
|
||||||
rewrites: [
|
rewrites: [
|
||||||
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, indexHtml) }
|
{
|
||||||
|
from: /.*/g,
|
||||||
|
to: '/ui/'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
hot: true,
|
hot: true,
|
||||||
|
|||||||
@@ -190,7 +190,8 @@ if (arg === 'html') {
|
|||||||
output: {
|
output: {
|
||||||
path: config.build.assetsRoot,
|
path: config.build.assetsRoot,
|
||||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
|
publicPath: '/'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
/* new GenerateAssetPlugin({
|
/* new GenerateAssetPlugin({
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ module.exports = {
|
|||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
'^/apis': '/' // 这里理解成用‘/api’代替target里面的地址,组件中我们调接口时直接用/api代替
|
'^/apis': '/' // 这里理解成用‘/api’代替target里面的地址,组件中我们调接口时直接用/api代替
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'/ui': {
|
||||||
|
target: '/', // 设置调用接口域名和端口号别忘了加http
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {
|
||||||
|
'^/ui': '/' // 这里理解成用‘/api’代替target里面的地址,组件中我们调接口时直接用/api代替
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Various Dev Server settings
|
// Various Dev Server settings
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ export default {
|
|||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
const herfSpiltArr = window.location.href.split('/')
|
const herfSpiltArr = window.location.href.split('/')
|
||||||
if (herfSpiltArr[3] !== '#') {
|
// if (herfSpiltArr[3] !== '#') {
|
||||||
herfSpiltArr[3] = '#'
|
// herfSpiltArr[3] = '#'
|
||||||
window.location.href = herfSpiltArr.join('/')
|
// window.location.href = herfSpiltArr.join('/')
|
||||||
}
|
// }
|
||||||
const Timestamp = new Date().getTime()
|
const Timestamp = new Date().getTime()
|
||||||
const url = 'static/config.json?Timestamp=' + Timestamp
|
const url = '/static/config.json?Timestamp=' + Timestamp
|
||||||
|
console.log(url)
|
||||||
const result = await this.$http.get(url) // 获取本地的config.json 判断是否需要清空localStorage 以及设备的宽 和 axios的baseUrl
|
const result = await this.$http.get(url) // 获取本地的config.json 判断是否需要清空localStorage 以及设备的宽 和 axios的baseUrl
|
||||||
this.$axios.defaults.baseURL = result.body.baseUrl
|
this.$axios.defaults.baseURL = result.body.baseUrl
|
||||||
const version = result.body.version
|
const version = result.body.version
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import Vue from 'vue'
|
|||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
export default new Router({
|
export default new Router({
|
||||||
|
hashbang: false,
|
||||||
|
history: true,
|
||||||
|
mode: 'history',
|
||||||
|
base: '/ui/',
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|||||||
Reference in New Issue
Block a user