Commit ad8aece5 by hank

merge

parents 492b637f 2af77db9
......@@ -2,7 +2,7 @@
ENV = 'development'
# base api
VUE_APP_BASE_API = 'https://manager.bdideal.com'
VUE_APP_BASE_API = 'http://39.97.179.60:8092'
VUE_APP_BASE_API_MOCK = '/dev-api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
......
......@@ -2,5 +2,5 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = '/prod-api'
VUE_APP_BASE_API = 'https://manager.bdideal.com'
# just a flag
ENV = 'production'
# base api
VUE_APP_BASE_API = 'http://39.97.179.60:8092'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -26,7 +26,7 @@ const users = {
export default [
// user login
{
url: '/user/login',
url: '/publics/login',
type: 'post',
response: config => {
const { username } = config.body
......@@ -49,7 +49,7 @@ export default [
// get user info
{
url: '/user/info\.*',
url: '/publics/get/info\.*',
type: 'get',
response: config => {
const { token } = config.query
......@@ -64,15 +64,14 @@ export default [
}
return {
code: 20000,
data: info
info
}
}
},
// user logout
{
url: '/user/logout',
url: '/publics/logout',
type: 'post',
response: _ => {
return {
......
......@@ -7,6 +7,7 @@
"scripts": {
"dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build",
"build:test": "vue-cli-service build --mode test",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --fix --ext .js,.vue src",
......
import request from '@/utils/requestMock.js'
import request from '@/utils/request'
export function login(data) {
return request({
url: '/user/login',
url: '/publics/login',
method: 'post',
data
})
......@@ -10,7 +10,7 @@ export function login(data) {
export function getInfo(token) {
return request({
url: '/user/info',
url: '/publics/get/info',
method: 'get',
params: { token }
})
......@@ -18,7 +18,7 @@ export function getInfo(token) {
export function logout() {
return request({
url: '/user/logout',
url: '/publics/logout',
method: 'post'
})
}
......@@ -35,8 +35,8 @@ const actions = {
return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => {
const { data } = response
commit('SET_TOKEN', data.token)
setToken(data.token)
commit('SET_TOKEN', data)
setToken(data)
resolve()
}).catch(error => {
reject(error)
......@@ -48,7 +48,7 @@ const actions = {
getInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo(state.token).then(response => {
const { data } = response
const data = response
if (!data) {
reject('Verification failed, please Login again.')
......
......@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout
timeout: 10000000 // request timeout
})
// request interceptor
......@@ -44,7 +44,7 @@ service.interceptors.response.use(
*/
response => {
const res = response.data
console.log(res.code, res.code !== 'undefined', String(res.code))
console.log(res.code, res.code !== '0', String(res.code))
// if the custom code is not 20000, it is judged as an error.
if (res.code !== '0' && res.code) {
Message({
......
......@@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth'
// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API_MOCK, // url = base url + request url
baseURL: process.env.VUE_APP_BASE_API_MOCK || '', // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment