提交 756e3f8a authored 作者: longfei's avatar longfei

init

上级 304e0b49
NODE_ENV = 'production'
VUE_APP_CURRENTMODE = 'prod'
VUE_APP_BASEURL = '正式环境api地址'
\ No newline at end of file
NODE_ENV = 'development'
VUE_APP_CURRENTMODE = 'dev'
VUE_APP_BASEURL = '本地开发api地址'
\ No newline at end of file
NODE_ENV = 'test'
VUE_APP_CURRENTMODE = 'test'
VUE_APP_BASEURL = '测试环境api地址'
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"module": "esnext", "module": "esnext",
"baseUrl": "./", "baseUrl": "./",
"moduleResolution": "node", "moduleResolution": "node",
"jsx": "preserve",
"paths": { "paths": {
"@/*": [ "@/*": [
"src/*" "src/*"
......
差异被折叠。
...@@ -3,12 +3,15 @@ ...@@ -3,12 +3,15 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "dev": "vue-cli-service serve --mode development",
"build:test": "vue-cli-service build --mode test",
"build:prod": "vue-cli-service build --mode production",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.8.3", "core-js": "^3.8.3",
"element-ui": "^2.15.9",
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",
"vuex": "^3.6.2" "vuex": "^3.6.2"
......
...@@ -3,7 +3,11 @@ import App from './App.vue' ...@@ -3,7 +3,11 @@ import App from './App.vue'
import router from './router' import router from './router'
import store from './store' import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElementUI);
new Vue({ new Vue({
router, router,
......
/**** http.js ****/
// 导入封装好的axios实例
import request from './request'
const http = {
/**
* methods: 请求方式
* url 请求地址
* params 请求参数
*/
get(url, params) {
const config = {
method: 'get',
url: url
}
if (params) config.params = params
return request(config)
},
post(url, params) {
const config = {
method: 'post',
url: url
}
if (params) config.data = params
return request(config)
},
put(url, params) {
const config = {
method: 'put',
url: url
}
if (params) config.params = params
return request(config)
},
delete(url, params) {
const config = {
method: 'delete',
url: url
}
if (params) config.params = params
return request(config)
}
}
//导出
export default http
\ No newline at end of file
/**** request.js ****/
// 导入axios
import axios from 'axios'
// 使用element-ui Message做消息提醒
import { Message} from 'element-ui';
//1. 创建新的axios实例,
const service = axios.create({
// 公共接口--这里注意后面会讲
baseURL: process.env.BASE_API,
// 超时时间 单位是ms,这里设置了3s的超时时间
timeout: 3 * 1000
})
// 2.请求拦截器
service.interceptors.request.use(config => {
//发请求前做的一些处理,数据转化,配置请求头,设置token,设置loading等,根据需求去添加
config.data = JSON.stringify(config.data); //数据转化,也可以使用qs转换
config.headers = {
'Content-Type':'application/x-www-form-urlencoded' //配置请求头
}
//注意使用token的时候需要引入cookie方法或者用本地localStorage等方法,推荐js-cookie
// const token = getCookie('名称');//这里取token之前,你肯定需要先拿到token,存一下
// if(token){
// config.params = {'token':token} //如果要求携带在参数中
// config.headers.token= token; //如果要求携带在请求头中
// }
return config
}, error => {
Promise.reject(error)
})
// 3.响应拦截器
service.interceptors.response.use(
(response) => {
const res = response.data
if (response.config.responseType !== 'blob') {
if (res.code !== 0) {
Message({
message: res.msg || 'Error',
type: 'error',
duration: 3 * 1000,
})
return Promise.reject(new Error(res.msg || 'Error'))
} else {
return res
}
}
return res
},
(error) => {
let res = error.response
if (error.response) {
if (res.status == 401) {
Vue.prototype.parentFns.portal_logout()
}
}
return Promise.reject(error)
}
)
//4.导入文件
export default service
const { defineConfig } = require('@vue/cli-service') const {
defineConfig
} = require('@vue/cli-service')
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = defineConfig({ module.exports = defineConfig({
transpileDependencies: true transpileDependencies: true,
}) lintOnSave: true,
//启动时自动打开网页
devServer: {
host: 'localhost',
port: '8080',
open: true
},
publicPath: './',
chainWebpack: config => {
config
.plugin('html')
.tap(args => {
args[0].title = '贵州省精品展览展示平台'
return args
})
},
configureWebpack: config => {
const configuration = {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
// name: name,
resolve: {
alias: {
'@': resolve('src')
}
}
}
return configuration
},
// TODO:接口代理
})
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论