增加线上接口
This commit is contained in:
@@ -2,6 +2,6 @@ ENV = 'production'
|
|||||||
|
|
||||||
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
|
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
|
||||||
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
|
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
|
||||||
VUE_APP_BASE_API = 'api'
|
VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn'
|
||||||
# 如果接口是 http 形式, wss 需要改为 ws
|
# 如果接口是 http 形式, wss 需要改为 ws
|
||||||
VUE_APP_WS_API = 'wss://123.56.110.252
|
VUE_APP_WS_API = 'wss://123.56.110.252
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
|
// baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/',
|
||||||
|
baseURL: process.env.VUE_APP_BASE_API, // api 的 base_url
|
||||||
timeout: Config.timeout // 请求超时时间
|
timeout: Config.timeout // 请求超时时间
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -19,9 +20,9 @@ service.interceptors.request.use(
|
|||||||
config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
config.headers['Content-Type'] = 'application/json'
|
config.headers['Content-Type'] = 'application/json'
|
||||||
config.headers['loginName']='admin'
|
config.headers['loginName'] = 'admin'
|
||||||
config.headers['token']='eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6Ik1HIiwiZXhwIjoxNjkwMTgwNzE2LCJ1c2VySWQiOiIyNDQiLCJpYXQiOjE2ODg3MDk0ODcsImxvZ2luTmFtZSI6ImFkbWluIn0.lqxxvv2-FcecQngMBorz4MpkB3mIJQDG-IUULQyV-KQ'
|
config.headers['token'] = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6Ik1HIiwiZXhwIjoxNjkwMTgwNzE2LCJ1c2VySWQiOiIyNDQiLCJpYXQiOjE2ODg3MDk0ODcsImxvZ2luTmFtZSI6ImFkbWluIn0.lqxxvv2-FcecQngMBorz4MpkB3mIJQDG-IUULQyV-KQ'
|
||||||
config.headers["userId"]='244'
|
config.headers["userId"] = '244'
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@@ -39,7 +40,7 @@ service.interceptors.response.use(
|
|||||||
if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
|
if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.readAsText(error.response.data, 'utf-8')
|
reader.readAsText(error.response.data, 'utf-8')
|
||||||
reader.onload = function(e) {
|
reader.onload = function (e) {
|
||||||
const errorMsg = JSON.parse(reader.result).message
|
const errorMsg = JSON.parse(reader.result).message
|
||||||
Notification.error({
|
Notification.error({
|
||||||
title: errorMsg,
|
title: errorMsg,
|
||||||
|
|||||||
Reference in New Issue
Block a user