From e706a1874d398be2ca03bad4eb139e252fe17a87 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Wed, 19 Jul 2023 09:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82=E9=80=82?= =?UTF-8?q?=E9=85=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 193 ++++++++++++++++++++++--------------------- src/main.js | 93 ++++++++++----------- src/utils/request.js | 121 +++++++++++++-------------- 3 files changed, 205 insertions(+), 202 deletions(-) diff --git a/config/index.js b/config/index.js index ad3108a..8f88119 100644 --- a/config/index.js +++ b/config/index.js @@ -1,96 +1,97 @@ -'use strict' -// Template version: 1.3.1 -// see http://vuejs-templates.github.io/webpack for documentation. - -const path = require('path') - -module.exports = { - // configureWebpack: { - // name:"wenhua", - // resolve: { - // alias: { - // '@': resolve('src'), - // 'views': resolve('src/views') - // } - // } - // }, - chainWebpack: config => { - // ...... - config.module - .rule('svg') - .exclude.add(resolve('../src/assets/icons/svg')) - .end(); - config.module - .rule('icons') - .test(/\.svg$/) - .include.add(resolve('../src/assets/icons/svg')) - .end() - .use('svg-sprite-loader') - .loader('svg-sprite-loader') - .options({ - symbolId: 'icon-[name]', - }) - .end() - }, - dev: { - - // Paths - assetsSubDirectory: 'static', - assetsPublicPath: '/', - proxyTable: {}, - - // Various Dev Server settings - host: 'localhost', // can be overwritten by process.env.HOST - port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined - autoOpenBrowser: false, - errorOverlay: true, - notifyOnErrors: true, - poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- - - - /** - * Source Maps - */ - - // https://webpack.js.org/configuration/devtool/#development - devtool: 'cheap-module-eval-source-map', - - // If you have problems debugging vue-files in devtools, - // set this to false - it *may* help - // https://vue-loader.vuejs.org/en/options.html#cachebusting - cacheBusting: true, - - cssSourceMap: true - }, - - build: { - // Template for index.html - index: path.resolve(__dirname, '../dist/index.html'), - - // Paths - assetsRoot: path.resolve(__dirname, '../dist'), - assetsSubDirectory: 'static', - assetsPublicPath: './', - - /** - * Source Maps - */ - - productionSourceMap: true, - // https://webpack.js.org/configuration/devtool/#production - devtool: '#source-map', - - // Gzip off by default as many popular static hosts such as - // Surge or Netlify already gzip all static assets for you. - // Before setting to `true`, make sure to: - // npm install --save-dev compression-webpack-plugin - productionGzip: false, - productionGzipExtensions: ['js', 'css'], - - // Run the build command with an extra argument to - // View the bundle analyzer report after build finishes: - // `npm run build --report` - // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report - } -} +'use strict' +// Template version: 1.3.1 +// see http://vuejs-templates.github.io/webpack for documentation. + +const path = require('path') + +module.exports = { + // configureWebpack: { + // name:"wenhua", + // resolve: { + // alias: { + // '@': resolve('src'), + // 'views': resolve('src/views') + // } + // } + // }, + chainWebpack: config => { + // ...... + config.module + .rule('svg') + .exclude.add(resolve('../src/assets/icons/svg')) + .end(); + config.module + .rule('icons') + .test(/\.svg$/) + .include.add(resolve('../src/assets/icons/svg')) + .end() + .use('svg-sprite-loader') + .loader('svg-sprite-loader') + .options({ + symbolId: 'icon-[name]', + }) + .end() + }, + dev: { + + // Paths + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: {}, + + // Various Dev Server settings + host: '0.0.0.0', // can be overwritten by process.env.HOST + //host: 'localhost', // can be overwritten by process.env.HOST + port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined + autoOpenBrowser: false, + errorOverlay: true, + notifyOnErrors: true, + poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- + + + /** + * Source Maps + */ + + // https://webpack.js.org/configuration/devtool/#development + devtool: 'cheap-module-eval-source-map', + + // If you have problems debugging vue-files in devtools, + // set this to false - it *may* help + // https://vue-loader.vuejs.org/en/options.html#cachebusting + cacheBusting: true, + + cssSourceMap: true + }, + + build: { + // Template for index.html + index: path.resolve(__dirname, '../dist/index.html'), + + // Paths + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: './', + + /** + * Source Maps + */ + + productionSourceMap: true, + // https://webpack.js.org/configuration/devtool/#production + devtool: '#source-map', + + // Gzip off by default as many popular static hosts such as + // Surge or Netlify already gzip all static assets for you. + // Before setting to `true`, make sure to: + // npm install --save-dev compression-webpack-plugin + productionGzip: false, + productionGzipExtensions: ['js', 'css'], + + // Run the build command with an extra argument to + // View the bundle analyzer report after build finishes: + // `npm run build --report` + // Set to `true` or `false` to always turn it on or off + bundleAnalyzerReport: process.env.npm_config_report + } +} diff --git a/src/main.js b/src/main.js index a418823..5a8191c 100644 --- a/src/main.js +++ b/src/main.js @@ -1,46 +1,47 @@ -// The Vue build version to load with the `import` command -// (runtime-only or standalone) has been set in webpack.base.conf with an alias. -import Vue from 'vue' -import App from './App' -import router from './router' -import Antd from 'ant-design-vue'; -import 'ant-design-vue/dist/antd.css'; -import echarts from "echarts"; - - -//引入svg组件 -// import IconSvg from './components/svgIcon' - -// //全局注册svg-icon -// Vue.component('svg-icon', IconSvg) - -Vue.use(Antd); -Vue.config.productionTip = false -Vue.prototype.$echarts = echarts; - -// Vue.prototype.$host = 'http://58.30.231.138:8899' - - // Vue.prototype.$host = 'http://10.24.4.156' - // Vue.prototype.$host = 'http://10.14.1.197:9090' - // Vue.prototype.$host = 'http://wenhua.xingtongworld.com/' //兴通测试 - -// Vue.prototype.$host = 'http://10.24.4.156' //正式服 - Vue.prototype.$host = 'http://10.14.1.197:9090' //javatest - - - - -// Vue.prototype.$host = 'http://127.0.0.1' - -router.beforeEach((to,from,next) => { - // console.log('beforeEach') - document.title = to.meta.title - next() -}) -/* eslint-disable no-new */ -new Vue({ - el: '#app', - router, - components: { App }, - template: '' -}) +// The Vue build version to load with the `import` command +// (runtime-only or standalone) has been set in webpack.base.conf with an alias. +import Vue from 'vue' +import App from './App' +import router from './router' +import Antd from 'ant-design-vue'; +import 'ant-design-vue/dist/antd.css'; +import echarts from "echarts"; + + +//引入svg组件 +// import IconSvg from './components/svgIcon' + +// //全局注册svg-icon +// Vue.component('svg-icon', IconSvg) + +Vue.use(Antd); +Vue.config.productionTip = false +Vue.prototype.$echarts = echarts; + +// Vue.prototype.$host = 'http://58.30.231.138:8899' + + // Vue.prototype.$host = 'http://10.24.4.156' + // Vue.prototype.$host = 'http://10.14.1.197:9090' + // Vue.prototype.$host = 'http://wenhua.xingtongworld.com/' //兴通测试 + +// Vue.prototype.$host = 'http://10.24.4.156' //正式服 +// Vue.prototype.$host = 'http://192.168.66.221' //javatest +// Vue.prototype.$host = 'http://10.14.1.197:9090' //javatest + + + + +// Vue.prototype.$host = 'http://127.0.0.1' + +router.beforeEach((to,from,next) => { + // console.log('beforeEach') + document.title = to.meta.title + next() +}) +/* eslint-disable no-new */ +new Vue({ + el: '#app', + router, + components: { App }, + template: '' +}) diff --git a/src/utils/request.js b/src/utils/request.js index cfb21d2..213dd1b 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,60 +1,61 @@ -import axios from 'axios'; -// axios.defaults.baseURL = '/api' -const service = axios.create({ - //process.env.NODE_ENV === 'development', //来判断是否开发环境 - // baseURL:process.env.NODE_ENV == 'production' ? 'https://yztapi.xingtongworld.com' : '/api/', - baseURL:process.env.NODE_ENV == 'production' ? '../' : 'http://10.14.1.197:9090', - // baseURL:'http://jiao.api.alpha.xingtongworld.com', - // baseURL:'http://58.30.231.138:8899', //测试服 - //baseURL:'http://10.24.4.156', //正式服 - - //baseURL:'http://10.14.1.197:9090', //新服 - // baseURL:'http://192.168.66.254:8080', - // baseURL:'http://10.14.1.197:9090', //java测试 - timeout: 5000, -}); - -service.interceptors.request.use( - config => { - let token = localStorage.getItem('wenhua_token'), - url = localStorage.getItem('wenhua_url') - if(token&&url){ - config.headers['token'] = token - config.headers['url'] = url - } - return config; - }, - error => { - console.log(error); - return Promise.reject(); - } -); - -service.interceptors.response.use( - response => { - // if (response.data.code === 302) { - // MessageBox.confirm('登录已超时,请重新登录', '退出', { - // confirmButtonText: '登录', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - // localStorage.removeItem('ms_username') - // localStorage.removeItem('token') - // // this.$router.push('/login'); - // location.reload() - - // }) - // } - if (response.status === 200) { - return response.data; - } else { - Promise.reject(); - } - }, - error => { - console.log(error); - return Promise.reject(); - } -); - -export default service; +import axios from 'axios'; +// axios.defaults.baseURL = '/api' +const service = axios.create({ + //process.env.NODE_ENV === 'development', //来判断是否开发环境 + // baseURL:process.env.NODE_ENV == 'production' ? 'https://yztapi.xingtongworld.com' : '/api/', + //baseURL:process.env.NODE_ENV == 'production' ? '../' : 'http://192.168.66.221:8080', + // baseURL:process.env.NODE_ENV == 'production' ? '../' : 'http://10.14.1.197:9090', + // baseURL:'http://jiao.api.alpha.xingtongworld.com', + // baseURL:'http://58.30.231.138:8899', //测试服 + baseURL:'http://10.24.4.156', //正式服 + + //baseURL:'http://10.14.1.197:9090', //新服 + // baseURL:'http://192.168.66.254:8080', + // baseURL:'http://10.14.1.197:9090', //java测试 + timeout: 5000, +}); + +service.interceptors.request.use( + config => { + let token = localStorage.getItem('wenhua_token'), + url = localStorage.getItem('wenhua_url') + if(token&&url){ + config.headers['token'] = token + config.headers['url'] = url + } + return config; + }, + error => { + console.log(error); + return Promise.reject(); + } +); + +service.interceptors.response.use( + response => { + // if (response.data.code === 302) { + // MessageBox.confirm('登录已超时,请重新登录', '退出', { + // confirmButtonText: '登录', + // cancelButtonText: '取消', + // type: 'warning' + // }).then(() => { + // localStorage.removeItem('ms_username') + // localStorage.removeItem('token') + // // this.$router.push('/login'); + // location.reload() + + // }) + // } + if (response.status === 200) { + return response.data; + } else { + Promise.reject(); + } + }, + error => { + console.log(error); + return Promise.reject(); + } +); + +export default service;