Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
8cf60829
Commit
8cf60829
authored
Jun 04, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy
parent
2f880304
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
66 deletions
+27
-66
src/components/search/index.js
+2
-4
src/setupProxy.js
+0
-34
src/utils/api-config.js
+0
-12
src/utils/api.js
+7
-13
src/utils/http.js
+15
-0
src/utils/index.js
+1
-1
src/utils/proxy-config.js
+2
-2
No files found.
src/components/search/index.js
View file @
8cf60829
import
React
,
{
PureComponent
}
from
'react'
;
import
SearchHead
from
'./searchHead'
import
Tag
from
'@common/Tag/index.js'
import
{
api
}
from
'@/utils'
import
{
config
}
from
'@/utils'
console
.
log
(
config
)
import
{
http
,
api
}
from
'@/utils'
import
'./index.scss'
;
...
...
@@ -18,7 +16,7 @@ class Search extends PureComponent {
}
async
componentDidMount
()
{
const
data
=
await
api
.
get
(
`/search
/search_hot_word`
)
const
data
=
await
http
.
get
(
`
${
api
[
'search-api'
]}
/search_hot_word`
)
console
.
log
(
data
)
}
...
...
src/setupProxy.js
View file @
8cf60829
const
config
=
require
(
'./utils/proxy-config'
)
const
proxy
=
require
(
'http-proxy-middleware'
)
const
target
=
'http://fast-test.julyedu.com'
module
.
exports
=
function
(
app
)
{
/*
app.use(proxy(
'/api',
{
target: 'http://fast-test.julyedu.com',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
})
)
*/
/*
app.use(proxy(
config.home.development,
{
target,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
})
)
*/
Object
.
keys
(
config
).
forEach
(
item
=>
{
app
.
use
(
proxy
(
config
[
item
][
'development'
],
{
...
...
@@ -44,8 +16,3 @@ module.exports = function (app) {
))
})
};
\ No newline at end of file
function
generateProxyConfig
(
config
)
{
}
src/utils/api-config.js
deleted
100644 → 0
View file @
2f880304
import
config
from
'./proxy-config'
let
apiConfig
=
{}
Object
.
keys
(
config
).
forEach
(
item
=>
{
if
(
item
!==
'proxy'
){
apiConfig
[
item
]
=
config
[
item
][
process
.
env
.
NODE_ENV
]
}
})
export
default
apiConfig
\ No newline at end of file
src/utils/api.js
View file @
8cf60829
import
axios
from
"axios"
;
import
qs
from
'qs'
import
config
from
'./proxy-config'
// export const BASE_URL = process.env.NODE_ENV === 'development' ? '/api' : 'https://api.julyedu.com'
let
api
=
{}
const
instance
=
axios
.
create
({
// baseURL: BASE_URL,
transformRequest
:
[
(
data
)
=>
qs
.
stringify
(
data
)
],
headers
:
{
HTTP_PLAT_FORM
:
5
,
HTTP_PLAT
:
5
Object
.
keys
(
config
).
forEach
(
item
=>
{
if
(
item
!==
'proxy'
){
api
[
item
]
=
config
[
item
][
process
.
env
.
NODE_ENV
]
}
})
export
default
instance
\ No newline at end of file
export
default
api
\ No newline at end of file
src/utils/http.js
0 → 100644
View file @
8cf60829
import
axios
from
"axios"
;
import
qs
from
'qs'
const
instance
=
axios
.
create
({
transformRequest
:
[
(
data
)
=>
qs
.
stringify
(
data
)
],
headers
:
{
HTTP_PLAT_FORM
:
5
,
HTTP_PLAT
:
5
}
})
export
default
instance
\ No newline at end of file
src/utils/index.js
View file @
8cf60829
export
{
default
as
http
}
from
'./http'
export
{
default
as
api
}
from
'./api'
export
{
default
as
config
}
from
'./api-config'
// 计算时间相差fn(过去距离当前时间)
export
const
computingTime
=
(
pastTime
)
=>
{
var
currentTime
=
(
new
Date
()).
getTime
(),
...
...
src/utils/proxy-config.js
View file @
8cf60829
...
...
@@ -5,8 +5,8 @@ const config = {
production
:
'https://m.julyedu.com'
,
proxy
:
{}
},
search
:
{
development
:
'/search'
,
'search-api'
:
{
development
:
'/search
-api
'
,
test
:
'https://search.julyedu.com'
,
production
:
'https://search.julyedu.com'
,
proxy
:
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment