Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
vite-integral
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6ed5e071
authored
Aug 03, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改request
1 parent
448d808d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
src/main.ts
src/utils/config.ts
src/utils/request.ts
src/main.ts
View file @
6ed5e07
...
@@ -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'
)
})
})
...
...
src/utils/config.ts
0 → 100644
View file @
6ed5e07
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
src/utils/request.ts
View file @
6ed5e07
...
@@ -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
.
base
URL
,
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
}
}
// 添加请求拦截器
// 添加请求拦截器
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment