Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-website-ssr-template
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liguokang
xiaomai-website-ssr-template
Commits
7dd2e318
Commit
7dd2e318
authored
Jul 29, 2021
by
liguokang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
🎨
parent
e71de27c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
32 deletions
+10
-32
common/utils/request.js
+5
-24
common/webConfigs.js
+1
-3
next.config.js
+3
-2
script.js
+1
-3
No files found.
common/utils/request.js
View file @
7dd2e318
import
axios
from
'axios'
;
import
{
load
as
cookieLoad
,
save
as
cookieSave
}
from
'react-cookies'
;
const
{
webDomain
,
apiDomain
}
=
require
(
'./common/webConfigs'
);
// 创建axios实例
let
serverPath
=
window
.
CONFIG
.
server
;
if
(
SERVER
)
{
serverPath
=
SERVER
;
}
let
serverPath
=
apiDomain
;
const
service
=
axios
.
create
({
baseURL
:
serverPath
,
// api 的 base_url
...
...
@@ -41,15 +38,7 @@ service.interceptors.response.use(
// 坚决禁止在response中做业务异常操作
const
rejectCode
=
[];
if
(
code
<
200
||
code
>
300
)
{
if
(
code
==
418
)
{
window
.
location
.
href
=
'https://www.xiaomai5.com/maintain.html'
;
}
else
if
(
code
==
401
||
code
==
403
)
{
User
.
loginIn
();
}
else
{
processHttpError
(
response
);
}
return
data
;
// return Promise.reject(new Error('error'));
processHttpError
(
response
);
}
else
{
if
(
rejectCode
.
indexOf
(
code
)
>
-
1
)
{
console
.
table
({
...
...
@@ -58,22 +47,14 @@ service.interceptors.response.use(
errorInfo
:
message
||
result
,
path
:
response
.
config
.
url
,
});
//
return Promise.reject(data);
return
Promise
.
reject
(
data
);
}
return
data
;
}
},
(
error
)
=>
{
let
code
=
0
;
try
{
code
=
error
.
response
.
data
.
status
;
if
(
code
==
418
)
{
window
.
location
.
href
=
'https://www.xiaomai5.com/maintain.html'
;
}
else
if
(
code
==
401
||
code
==
403
)
{
User
.
loginIn
();
}
else
{
processHttpError
(
error
.
response
);
}
processHttpError
(
error
.
response
);
}
catch
(
e
)
{
if
(
error
.
toString
().
indexOf
(
'Error: timeout'
)
!==
-
1
)
{
console
.
table
({
...
...
common/webConfigs.js
View file @
7dd2e318
...
...
@@ -2,15 +2,13 @@
* @Author: liguokang
* @Date: 2021-07-29 16:19:43
* @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:
37:35
* @LastEditTime: 2021-07-29 16:
46:20
* @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/
const
DEPLOY_ENV
=
process
.
env
.
DEPLOY_ENV
;
console
.
log
(
DEPLOY_ENV
,
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
);
const
webDomain
=
{
dev
:
'https://dev.xiaomai5.com/'
,
rc
:
'https://rc.xiaomai5.com/'
,
...
...
next.config.js
View file @
7dd2e318
...
...
@@ -2,7 +2,7 @@
* @Author: liguokang
* @Date: 2021-07-14 20:36:28
* @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:
34:27
* @LastEditTime: 2021-07-29 16:
45:28
* @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -27,13 +27,14 @@ module.exports = withLessExcludeAntd({
return
Object
.
assign
({
'/'
:
{
page
:
'/'
},
'/404.html'
:
{
page
:
'/404'
},
'/wheatSchool.html'
:
{
page
:
'/wheatSchool'
},
});
},
webpack
(
config
,
options
)
{
config
.
resolve
.
alias
[
'@'
]
=
path
.
join
(
__dirname
,
'common'
);
config
.
resolve
.
alias
[
'components'
]
=
path
.
join
(
__dirname
,
'components'
);
config
.
resolve
.
alias
[
'static'
]
=
path
.
join
(
__dirname
,
'static'
);
config
.
plugins
.
push
(
new
webpack
.
DefinePlugin
({
'process.env'
:
{
...
...
script.js
View file @
7dd2e318
...
...
@@ -2,7 +2,7 @@
* @Author: liguokang
* @Date: 2021-07-29 16:14:30
* @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:4
1:2
2
* @LastEditTime: 2021-07-29 16:4
6:1
2
* @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -13,8 +13,6 @@ const { webDomain, apiDomain } = require('./common/webConfigs');
const
readStream
=
fs
.
createReadStream
(
'./sitemap/sitemap.html'
,
{
encoding
:
'utf8'
});
const
writeStream
=
fs
.
createWriteStream
(
'./dist/sitemap.html'
,
{
encoding
:
'utf8'
});
console
.
log
(
webConfigs
,
'11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
);
readStream
.
on
(
'data'
,
(
data
)
=>
{
let
reData
=
data
.
replace
(
/https
\:\/\/
www
\.
xiaomai5
\.
com
\/
/g
,
webDomain
);
reData
=
reData
.
replace
(
/https
\:\/\/
heimdall
\.
xiaomai5
\.
com
\/
/g
,
apiDomain
);
...
...
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