diff --git a/nezha-fronted/build/webpack.dev.conf.js b/nezha-fronted/build/webpack.dev.conf.js index ed7f7cd31..fdc5b0e87 100644 --- a/nezha-fronted/build/webpack.dev.conf.js +++ b/nezha-fronted/build/webpack.dev.conf.js @@ -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, diff --git a/nezha-fronted/build/webpack.prod.conf.js b/nezha-fronted/build/webpack.prod.conf.js index aee6b4268..1f159c4f3 100644 --- a/nezha-fronted/build/webpack.prod.conf.js +++ b/nezha-fronted/build/webpack.prod.conf.js @@ -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({ diff --git a/nezha-fronted/config/index.js b/nezha-fronted/config/index.js index 4215b1ba8..ce7a6fd73 100644 --- a/nezha-fronted/config/index.js +++ b/nezha-fronted/config/index.js @@ -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 diff --git a/nezha-fronted/src/entrance/app/App.vue b/nezha-fronted/src/entrance/app/App.vue index 9949d28d3..e995500be 100644 --- a/nezha-fronted/src/entrance/app/App.vue +++ b/nezha-fronted/src/entrance/app/App.vue @@ -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 diff --git a/nezha-fronted/src/router/index.js b/nezha-fronted/src/router/index.js index 6273f44b3..d8f39c453 100644 --- a/nezha-fronted/src/router/index.js +++ b/nezha-fronted/src/router/index.js @@ -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: '/',