Commit 6ed5e071 by 胡悦

修改request

1 parent 448d808d
...@@ -15,10 +15,7 @@ console.log(apis) ...@@ -15,10 +15,7 @@ console.log(apis)
app.config.globalProperties.$axios = apis app.config.globalProperties.$axios = apis
setupStore(app) setupStore(app)
setupRouter(app) setupRouter(app)
const fetchConfig = function (isEnv = true) {
return window.fetch('https://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/config', {}).then(res => res.json())
}
app.config.globalProperties.$mockConfig = await fetchConfig()
router.isReady().then(() => { router.isReady().then(() => {
app.mount('#app') app.mount('#app')
}) })
......
const fetchConfig = function (isEnv = true) {
return window.fetch('https://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/config', {}).then(res => res.json())
}
const $mockConfig = await fetchConfig()
export default $mockConfig
\ No newline at end of file \ No newline at end of file
...@@ -3,6 +3,7 @@ import { ElMessage, ElMessageBox } from 'element-plus' ...@@ -3,6 +3,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import router, { resetRoute } from '../router' import router, { resetRoute } from '../router'
import qs from 'qs' import qs from 'qs'
import { createSign } from './util' import { createSign } from './util'
import $mockConfig from './config'
function getSession(key: string) { function getSession(key: string) {
let json: any = window.sessionStorage.getItem(key) let json: any = window.sessionStorage.getItem(key)
return JSON.parse(json) return JSON.parse(json)
...@@ -10,23 +11,21 @@ function getSession(key: string) { ...@@ -10,23 +11,21 @@ function getSession(key: string) {
export const PATH_URL: string = '/api' || import.meta.env.VITE_API_URL export const PATH_URL: string = '/api' || import.meta.env.VITE_API_URL
const { response = {}, request = {}, headers = {}, alert, sign, signWay = 'sha1', secret } = $mockConfig
// 配置新建一个axios 实例 // 配置新建一个axios 实例
const service: AxiosInstance = axios.create({ const service: AxiosInstance = axios.create({
baseURL: PATH_URL, baseURL: request.baseURL,
timeout: 50000, timeout: 50000,
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
const customer = { const customer = {
response: '1', response,
alert: '2', alert,
sign: { sign,
a: '10', secret,
b: '11' signWay
},
secret: '4',
signWay: '5',
// sessionId: headers.token // sessionId: headers.token
} }
// 添加请求拦截器 // 添加请求拦截器
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!