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