Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ds147000
/
react-project-storage
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 49f614de
authored
Dec 22, 2020
by
杨周龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改基础配置获取逻辑
1 parent
44e4eefe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
29 deletions
package-lock.json
package.json
src/App.js
src/store/modules/baseConfig/index.js
package-lock.json
View file @
49f614d
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
"react-router-dom"
:
"^5.2.0"
,
"react-router-dom"
:
"^5.2.0"
,
"react-scripts"
:
"3.4.1"
,
"react-scripts"
:
"3.4.1"
,
"xbd-cookie"
:
"^0.5.11"
,
"xbd-cookie"
:
"^0.5.11"
,
"xbd-error-boundaries"
:
"^0.2.9"
,
"xbd-system-react"
:
"0.0.1"
"xbd-system-react"
:
"0.0.1"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
@@ -5998,6 +5999,15 @@
...
@@ -5998,6 +5999,15 @@
"is-arrayish"
:
"^0.2.1"
"is-arrayish"
:
"^0.2.1"
}
}
},
},
"node_modules/error-stack-parser"
:
{
"version"
:
"2.0.6"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/error-stack-parser/-/error-stack-parser-2.0.6.tgz"
,
"integrity"
:
"sha1-WpmnB716TFinl5AtSNgoA+3mqtg="
,
"license"
:
"MIT"
,
"dependencies"
:
{
"stackframe"
:
"^1.1.1"
}
},
"node_modules/es-abstract"
:
{
"node_modules/es-abstract"
:
{
"version"
:
"1.17.6"
,
"version"
:
"1.17.6"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/es-abstract/-/es-abstract-1.17.6.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/es-abstract/-/es-abstract-1.17.6.tgz"
,
...
@@ -16309,6 +16319,12 @@
...
@@ -16309,6 +16319,12 @@
"node"
:
">=0.10.0"
"node"
:
">=0.10.0"
}
}
},
},
"node_modules/stackframe"
:
{
"version"
:
"1.2.0"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/stackframe/-/stackframe-1.2.0.tgz"
,
"integrity"
:
"sha1-UkKUktY8YuuYmATBFVLj0i53kwM="
,
"license"
:
"MIT"
},
"node_modules/static-extend"
:
{
"node_modules/static-extend"
:
{
"version"
:
"0.1.2"
,
"version"
:
"0.1.2"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/static-extend/-/static-extend-0.1.2.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/static-extend/-/static-extend-0.1.2.tgz"
,
...
@@ -19830,6 +19846,14 @@
...
@@ -19830,6 +19846,14 @@
"js-cookie"
:
"^2.2.1"
"js-cookie"
:
"^2.2.1"
}
}
},
},
"node_modules/xbd-error-boundaries"
:
{
"version"
:
"0.2.9"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-error-boundaries/-/xbd-error-boundaries-0.2.9.tgz"
,
"integrity"
:
"sha512-M2BPH3nY+zldwmIkerGY0MzuLjXlD7Do2HL+PKAYZZW8cVyvdvFLAtGu5RKUWvaVOWIODvjEEPUk/Y13umLyGw=="
,
"dependencies"
:
{
"error-stack-parser"
:
"^2.0.6"
}
},
"node_modules/xbd-system-react"
:
{
"node_modules/xbd-system-react"
:
{
"version"
:
"0.0.1"
,
"version"
:
"0.0.1"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-system-react/-/xbd-system-react-0.0.1.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-system-react/-/xbd-system-react-0.0.1.tgz"
,
...
@@ -25143,6 +25167,14 @@
...
@@ -25143,6 +25167,14 @@
"is-arrayish"
:
"^0.2.1"
"is-arrayish"
:
"^0.2.1"
}
}
},
},
"error-stack-parser"
:
{
"version"
:
"2.0.6"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/error-stack-parser/-/error-stack-parser-2.0.6.tgz"
,
"integrity"
:
"sha1-WpmnB716TFinl5AtSNgoA+3mqtg="
,
"requires"
:
{
"stackframe"
:
"^1.1.1"
}
},
"es-abstract"
:
{
"es-abstract"
:
{
"version"
:
"1.17.6"
,
"version"
:
"1.17.6"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/es-abstract/-/es-abstract-1.17.6.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/es-abstract/-/es-abstract-1.17.6.tgz"
,
...
@@ -33593,6 +33625,11 @@
...
@@ -33593,6 +33625,11 @@
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/stack-utils/-/stack-utils-1.0.2.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/stack-utils/-/stack-utils-1.0.2.tgz"
,
"integrity"
:
"sha1-M+ujiXeIVYvr/C2wWdwVjsNs67g="
"integrity"
:
"sha1-M+ujiXeIVYvr/C2wWdwVjsNs67g="
},
},
"stackframe"
:
{
"version"
:
"1.2.0"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/stackframe/-/stackframe-1.2.0.tgz"
,
"integrity"
:
"sha1-UkKUktY8YuuYmATBFVLj0i53kwM="
},
"static-extend"
:
{
"static-extend"
:
{
"version"
:
"0.1.2"
,
"version"
:
"0.1.2"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/static-extend/-/static-extend-0.1.2.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/static-extend/-/static-extend-0.1.2.tgz"
,
...
@@ -36407,6 +36444,14 @@
...
@@ -36407,6 +36444,14 @@
"js-cookie"
:
"^2.2.1"
"js-cookie"
:
"^2.2.1"
}
}
},
},
"xbd-error-boundaries"
:
{
"version"
:
"0.2.9"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-error-boundaries/-/xbd-error-boundaries-0.2.9.tgz"
,
"integrity"
:
"sha512-M2BPH3nY+zldwmIkerGY0MzuLjXlD7Do2HL+PKAYZZW8cVyvdvFLAtGu5RKUWvaVOWIODvjEEPUk/Y13umLyGw=="
,
"requires"
:
{
"error-stack-parser"
:
"^2.0.6"
}
},
"xbd-system-react"
:
{
"xbd-system-react"
:
{
"version"
:
"0.0.1"
,
"version"
:
"0.0.1"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-system-react/-/xbd-system-react-0.0.1.tgz"
,
"resolved"
:
"http://47.107.176.206:8089/repository/xbdnpm/xbd-system-react/-/xbd-system-react-0.0.1.tgz"
,
package.json
View file @
49f614d
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
"react-router-dom"
:
"^5.2.0"
,
"react-router-dom"
:
"^5.2.0"
,
"react-scripts"
:
"3.4.1"
,
"react-scripts"
:
"3.4.1"
,
"xbd-cookie"
:
"^0.5.11"
,
"xbd-cookie"
:
"^0.5.11"
,
"xbd-error-boundaries"
:
"^0.2.9"
,
"xbd-system-react"
:
"0.0.1"
"xbd-system-react"
:
"0.0.1"
},
},
"scripts"
:
{
"scripts"
:
{
...
...
src/App.js
View file @
49f614d
import
React
from
'react'
import
React
,
{
useEffect
,
useState
}
from
'react'
import
RouterView
from
'./router'
import
RouterView
from
'./router'
import
{
Provider
}
from
'react-redux'
import
ErrorBoundaries
from
'xbd-error-boundaries'
import
{
ConfigProvider
}
from
'antd'
import
zhCN
from
'antd/lib/locale/zh_CN'
import
zhCN
from
'antd/lib/locale/zh_CN'
import
moment
from
'moment'
import
moment
from
'moment'
import
'moment/locale/zh-cn'
import
store
from
'./store'
import
store
from
'./store'
import
http
from
'./libs/fetch'
import
{
APP
}
from
'./config'
import
{
Provider
}
from
'react-redux'
import
{
ConfigProvider
,
Modal
,
notification
}
from
'antd'
import
{
getbaseConfig
}
from
'@/api/config'
import
'moment/locale/zh-cn'
moment
.
locale
(
'zh'
)
moment
.
locale
(
'zh'
)
function
App
()
{
function
App
()
{
return
(
const
[
appCode
,
setAppCode
]
=
useState
(
''
)
<
Provider
store
=
{
store
}
>
<
ConfigProvider
locale
=
{
zhCN
}
>
useEffect
(()
=>
{
<
RouterView
><
/RouterView
>
// 成功回调
<
/ConfigProvider
>
const
onSucess
=
(
res
)
=>
{
<
/Provider
>
store
.
dispatch
.
baseConfig
.
setState
(
res
)
)
http
.
setHeader
(
'operationChannel'
,
res
.
operationChannel
)
setAppCode
(
res
.
app_code
)
window
.
localStorage
.
setItem
(
'baseConfig'
,
JSON
.
stringify
(
res
))
document
.
title
=
res
.
platformName
let
link
=
document
.
createElement
(
'link'
)
link
.
type
=
'image/x-icon'
link
.
rel
=
'shortcut icon'
link
.
href
=
res
.
logoIcon
document
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
link
)
}
// 失败回调
const
onError
=
(
res
)
=>
{
if
(
res
===
undefined
)
{
Modal
.
error
({
title
:
'启动错误'
,
content
:
'获取关键数据失败,请联系客服'
})
}
else
{
console
.
error
(
res
)
const
CacheConfig
=
window
.
localStorage
.
getItem
(
'baseConfig'
)
if
(
!
CacheConfig
)
onError
()
else
{
notification
.
open
({
message
:
'获取最新系统配置失败'
,
description
:
'网络情况较差!加载最新系统核心配置失败,可能部分系统功能不能正确启用。请刷新页面或联系客服'
,
duration
:
0
})
onSucess
(
JSON
.
parse
(
CacheConfig
))
}
}
}
getbaseConfig
()
.
then
(
res
=>
!
res
.
id
===
undefined
?
onError
()
:
onSucess
(
res
))
.
catch
(
onError
)
},
[])
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
return
(
<
Provider
store
=
{
store
}
>
<
ConfigProvider
locale
=
{
zhCN
}
>
<
RouterView
><
/RouterView
>
<
/ConfigProvider
>
<
/Provider
>
)
}
else
{
return
(
<
ErrorBoundaries
app_code
=
{
appCode
}
url
=
{
`
${
APP
.
GET_PALTFORM_CONFIG_URL
}
api/log`
}
>
<
Provider
store
=
{
store
}
>
<
ConfigProvider
locale
=
{
zhCN
}
>
<
RouterView
><
/RouterView
>
<
/ConfigProvider
>
<
/Provider
>
<
/ErrorBoundaries
>
)
}
}
}
export
default
App
export
default
App
src/store/modules/baseConfig/index.js
View file @
49f614d
import
{
getbaseConfig
}
from
'@/api/config'
import
{
Modal
}
from
'antd'
export
default
{
export
default
{
state
:
{},
state
:
{},
reducers
:
{
reducers
:
{
setState
(
_
,
data
)
{
setState
(
_
,
data
)
{
return
data
||
{}
return
data
||
{}
}
}
},
effects
:
{
init
()
{
return
getbaseConfig
()
.
then
(
res
=>
{
window
.
document
.
title
=
res
.
platformName
this
.
setState
(
res
)
return
res
})
.
catch
(()
=>
{
Modal
.
error
(
'加载平台信息失败,请刷新重试'
)
})
}
}
}
}
}
\ No newline at end of file
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