forked from d2-projects/d2-admin
-
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.
axios封装 Former-commit-id: 4dc0646a8509fe9cb6c5218e9dfc864b0af59143 [formerly eaee9b788f359a10ad0b8b199dcdd8c82765855f] [formerly 4dc0646a8509fe9cb6c5218e9dfc864b0af59143 [formerly eaee9b788f359a10ad0b8b199dcdd8c82765855f] [formerly 4dc0646a8509fe9cb6c5218e9dfc864b0af59143 [formerly eaee9b788f359a10ad0b8b199dcdd8c82765855f] [formerly eaee9b788f359a10ad0b8b199dcdd8c82765855f [formerly 0dad015 [formerly 97a660059b807afdf8c0c518d4f40be4ce7eceec]]]]] Former-commit-id: 95e753d Former-commit-id: 2e567e9 Former-commit-id: 37e5cef6e554af37fc7d55785552160ff086c03d [formerly 14edcd31bc67642337f8eddf2ec7cbdec23ecc2c] Former-commit-id: 08a71cba6653878d9accae5a7ecfcf1122d3515a Former-commit-id: a1731726720512ae8a5a7fd5973f4c90a62ac448 Former-commit-id: 3838dfd576136f0ac217d9a97d631f9a88191d31 Former-commit-id: fa2416a4c270dce89a33e0486569374c5c7b6a63 Former-commit-id: b03e226c26ea5495e1d7d6a2206b89c8f4e17815
- Loading branch information
1 parent
5df0073
commit bc2027d
Showing
15 changed files
with
111 additions
and
25 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,4 +1,5 @@ | ||
# 所有环境 | ||
|
||
# 页面 title 前缀 | ||
VUE_APP_TITLE=D2Admin | ||
VUE_APP_TITLE=D2Admin | ||
VUE_APP_API=/api/ |
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,16 @@ | ||
import request from '@/plugin/axios' | ||
|
||
export function ComponentsMarkdownBase (url) { | ||
return request({ | ||
baseURL: process.env.BASE_URL, | ||
url, | ||
method: 'get' | ||
}) | ||
} | ||
|
||
export function ComponentsMarkdownApi (url) { | ||
return request({ | ||
url, | ||
method: 'get' | ||
}) | ||
} |
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,9 @@ | ||
import request from '@/plugin/axios' | ||
|
||
export function BusinessTable1List (data) { | ||
return request({ | ||
url: '/demo/business/table/1', | ||
method: 'post', | ||
data | ||
}) | ||
} |
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,8 @@ | ||
import request from '@/plugin/axios' | ||
|
||
export function PluginMocksAjax () { | ||
return request({ | ||
url: '/demo/plugins/mock/ajax', | ||
method: 'get' | ||
}) | ||
} |
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,9 @@ | ||
import request from '@/plugin/axios' | ||
|
||
export function AccountLogin (data) { | ||
return request({ | ||
url: '/login', | ||
method: 'post', | ||
data | ||
}) | ||
} |
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 +1 @@ | ||
87fff7214e7b64123842f1f52b649a8af614eb46 | ||
bfee5e91a3b150e04d9f24695061f6f3e7c59342 |
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 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 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,6 +1,6 @@ | ||
<template> | ||
<d2-container> | ||
<template slot="header">异步加载文件</template> | ||
<d2-markdown :url="`${$baseUrl}markdown/demo.md`"/> | ||
<d2-markdown url="markdown/demo.md"/> | ||
</d2-container> | ||
</template> |
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 |
---|---|---|
@@ -1,13 +1,45 @@ | ||
import axios from 'axios' | ||
import { Message } from 'element-ui' | ||
import util from '@/libs/util' | ||
|
||
axios.interceptors.response.use(res => { | ||
return res.data | ||
}, err => { | ||
return Promise.reject(err) | ||
// create an axios instance | ||
const service = axios.create({ | ||
baseURL: process.env.VUE_APP_API, | ||
timeout: 5000 // 请求超时时间 | ||
}) | ||
|
||
export default { | ||
install (Vue, options) { | ||
Vue.prototype.$axios = axios | ||
// request interceptor | ||
service.interceptors.request.use( | ||
config => { | ||
// Do something before request is sent | ||
const token = util.cookies.get('token') | ||
if (token && token !== 'undefined') { | ||
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改 | ||
config.headers['X-Token'] = token | ||
} | ||
return config | ||
}, | ||
error => { | ||
// Do something with request error | ||
console.log(error) // for debug | ||
Promise.reject(error) | ||
} | ||
} | ||
) | ||
|
||
// respone interceptor | ||
service.interceptors.response.use( | ||
response => { | ||
return response.data | ||
}, | ||
error => { | ||
console.log('err' + error) // for debug | ||
Message({ | ||
message: error.message, | ||
type: 'error', | ||
duration: 5 * 1000 | ||
}) | ||
return Promise.reject(error) | ||
} | ||
) | ||
|
||
export default service |
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