-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chenxj
committed
Jan 14, 2019
1 parent
5f28dbf
commit ad77bfd
Showing
19 changed files
with
619 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
[*.{js,jsx,ts,tsx,vue}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
NODE_ENV = 'production' | ||
VUE_APP_CURRENTMODE = 'stage' | ||
outputDir = 'stage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VUE_APP_CURRENTMODE = 'development' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_CURRENTMODE = 'production' | ||
outputDir = 'docs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
module.exports = { | ||
presets: [ | ||
'@vue/app' | ||
] | ||
} | ||
], | ||
"plugins": [["import", { | ||
"libraryName": "iview", | ||
"libraryDirectory": "src/components" | ||
}]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Vuex from 'vuex' | ||
import Vue from 'vue' | ||
import user from './modules/user' | ||
|
||
Vue.use(Vuex) | ||
|
||
const state = { | ||
userInfo: { | ||
name: 'root-暂无' | ||
} | ||
} | ||
const getters = { | ||
userInfo: state => { | ||
return state.userInfo | ||
} | ||
} | ||
const mutations = { | ||
setUserInfo (state, data) { | ||
state.userInfo = data | ||
} | ||
} | ||
|
||
const myStore = new Vuex.Store({ | ||
modules: { | ||
user | ||
}, | ||
state, | ||
getters, | ||
mutations | ||
}) | ||
|
||
export default myStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import user1 from './user1' | ||
|
||
const state = { | ||
userInfo: { | ||
name: 'user-暂无' | ||
} | ||
} | ||
const getters = { | ||
userInfo: state => { | ||
return state.userInfo | ||
} | ||
} | ||
const mutations = { | ||
setUserInfo (state, data) { | ||
state.userInfo = data | ||
} | ||
} | ||
const actions = { | ||
async getUserInfo (context) { | ||
let result = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
context.commit('setUserInfo', { name: 'Abiel' }) | ||
resolve({ name: 'Abiel' }) | ||
}, 1000) | ||
}) | ||
return result | ||
} | ||
} | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
mutations, | ||
getters, | ||
actions, | ||
modules: { | ||
user1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const state = { | ||
userInfo: { | ||
name: 'user-暂无' | ||
} | ||
} | ||
const getters = { | ||
userInfo: state => { | ||
return state.userInfo | ||
} | ||
} | ||
const mutations = { | ||
setUserInfo (state, data) { | ||
state.userInfo = data | ||
} | ||
} | ||
const actions = { | ||
async getUserInfo (context) { | ||
let result = await new Promise((resolve) => { | ||
setTimeout(() => { | ||
context.commit('setUserInfo', { name: 'Abiel' }) | ||
resolve({ name: 'Abiel' }) | ||
}, 1000) | ||
}) | ||
return result | ||
} | ||
} | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
mutations, | ||
getters, | ||
actions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import axios from 'axios' | ||
// import Router from '../router' | ||
|
||
axios.interceptors.request.use(config => { | ||
return config | ||
}, error => { | ||
return Promise.reject(error) | ||
}) | ||
|
||
axios.interceptors.response.use(response => { | ||
/* 检测某种状态进行重定向 | ||
if (response.status === 302) { | ||
Router.push({ | ||
name: 'home' | ||
}) | ||
} */ | ||
return response | ||
}, error => { | ||
return Promise.resolve(error.response) | ||
}) | ||
|
||
const checkStatus = response => { | ||
// loading | ||
// 如果http状态码正常,则直接返回数据 | ||
if (response && (response.status === 200 || response.status === 304 || response.status === 400)) { | ||
return response.data | ||
// 如果不需要除了data之外的数据,可以直接 return response.data | ||
} | ||
// 异常状态下,把错误信息返回去 | ||
return { | ||
status: -404, | ||
msg: '网络异常' | ||
} | ||
} | ||
|
||
function checkCode (res) { | ||
// 如果code异常(这里已经包括网络错误,服务器错误,后端抛出的错误),可以弹出一个错误提示,告诉用户 | ||
if (res.status === -404) { | ||
// console.log(res.msg) | ||
} | ||
if (res.data && (!res.data.success)) { | ||
// console.log(res) | ||
// console.log(res.data.msg) | ||
} | ||
return res | ||
} | ||
|
||
export default { | ||
postForm (url, data) { | ||
return axios({ | ||
method: 'post', | ||
baseURL: 'https://you.host.com', | ||
url, | ||
data: data, | ||
timeout: 10000, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest', | ||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' | ||
} | ||
}).then( | ||
(response) => { | ||
return checkStatus(response) | ||
} | ||
).then( | ||
(res) => { | ||
return checkCode(res) | ||
} | ||
) | ||
}, | ||
postJson (url, params) { | ||
return axios({ | ||
method: 'get', | ||
baseURL: '', | ||
url, | ||
params, // get 请求时带的参数 | ||
timeout: 10000, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest', | ||
'Content-Type': 'application/json; charset=UTF-8' | ||
} | ||
}).then( | ||
(response) => { | ||
return checkStatus(response) | ||
} | ||
).then( | ||
(res) => { | ||
return checkCode(res) | ||
} | ||
) | ||
}, | ||
|
||
get (url, params) { | ||
return axios({ | ||
method: 'get', | ||
baseURL: '', | ||
url, | ||
params, // get 请求时带的参数 | ||
timeout: 10000, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest' | ||
} | ||
}).then( | ||
(response) => { | ||
return checkStatus(response) | ||
} | ||
).then( | ||
(res) => { | ||
return checkCode(res) | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.