Commit ad8aece5 by hank

merge

parents 492b637f 2af77db9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
ENV = 'development' ENV = 'development'
# base api # 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_APP_BASE_API_MOCK = '/dev-api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable, # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
ENV = 'production' ENV = 'production'
# base api # 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 = { ...@@ -26,7 +26,7 @@ const users = {
export default [ export default [
// user login // user login
{ {
url: '/user/login', url: '/publics/login',
type: 'post', type: 'post',
response: config => { response: config => {
const { username } = config.body const { username } = config.body
...@@ -49,7 +49,7 @@ export default [ ...@@ -49,7 +49,7 @@ export default [
// get user info // get user info
{ {
url: '/user/info\.*', url: '/publics/get/info\.*',
type: 'get', type: 'get',
response: config => { response: config => {
const { token } = config.query const { token } = config.query
...@@ -64,15 +64,14 @@ export default [ ...@@ -64,15 +64,14 @@ export default [
} }
return { return {
code: 20000, info
data: info
} }
} }
}, },
// user logout // user logout
{ {
url: '/user/logout', url: '/publics/logout',
type: 'post', type: 'post',
response: _ => { response: _ => {
return { return {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"scripts": { "scripts": {
"dev": "vue-cli-service serve", "dev": "vue-cli-service serve",
"build:prod": "vue-cli-service build", "build:prod": "vue-cli-service build",
"build:test": "vue-cli-service build --mode test",
"build:stage": "vue-cli-service build --mode staging", "build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview", "preview": "node build/index.js --preview",
"lint": "eslint --fix --ext .js,.vue src", "lint": "eslint --fix --ext .js,.vue src",
......
import request from '@/utils/requestMock.js' import request from '@/utils/request'
export function login(data) { export function login(data) {
return request({ return request({
url: '/user/login', url: '/publics/login',
method: 'post', method: 'post',
data data
}) })
...@@ -10,7 +10,7 @@ export function login(data) { ...@@ -10,7 +10,7 @@ export function login(data) {
export function getInfo(token) { export function getInfo(token) {
return request({ return request({
url: '/user/info', url: '/publics/get/info',
method: 'get', method: 'get',
params: { token } params: { token }
}) })
...@@ -18,7 +18,7 @@ export function getInfo(token) { ...@@ -18,7 +18,7 @@ export function getInfo(token) {
export function logout() { export function logout() {
return request({ return request({
url: '/user/logout', url: '/publics/logout',
method: 'post' method: 'post'
}) })
} }
...@@ -35,8 +35,8 @@ const actions = { ...@@ -35,8 +35,8 @@ const actions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => { login({ username: username.trim(), password: password }).then(response => {
const { data } = response const { data } = response
commit('SET_TOKEN', data.token) commit('SET_TOKEN', data)
setToken(data.token) setToken(data)
resolve() resolve()
}).catch(error => { }).catch(error => {
reject(error) reject(error)
...@@ -48,7 +48,7 @@ const actions = { ...@@ -48,7 +48,7 @@ const actions = {
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo(state.token).then(response => { getInfo(state.token).then(response => {
const { data } = response const data = response
if (!data) { if (!data) {
reject('Verification failed, please Login again.') reject('Verification failed, please Login again.')
......
...@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth' ...@@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests // withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout timeout: 10000000 // request timeout
}) })
// request interceptor // request interceptor
...@@ -44,7 +44,7 @@ service.interceptors.response.use( ...@@ -44,7 +44,7 @@ service.interceptors.response.use(
*/ */
response => { response => {
const res = response.data 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 the custom code is not 20000, it is judged as an error.
if (res.code !== '0' && res.code) { if (res.code !== '0' && res.code) {
Message({ Message({
......
...@@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth' ...@@ -5,7 +5,7 @@ import { getToken } from '@/utils/auth'
// create an axios instance // create an axios instance
const service = axios.create({ 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 // withCredentials: true, // send cookies when cross-domain requests
timeout: 10000 // request timeout 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