Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
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
ReactWeb5
CivWeb
Commits
ef0aa0e8
Commit
ef0aa0e8
authored
Feb 01, 2021
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化菜单加载速度
parent
0e8f6915
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
11 deletions
+45
-11
proxy.js
config/proxy.js
+12
-0
app.js
src/app.js
+6
-6
micro.js
src/micro.js
+3
-1
index.js
src/pages/user/login/index.js
+5
-0
routes.js
src/utils/routes.js
+3
-2
utils.js
src/utils/utils.js
+16
-2
No files found.
config/proxy.js
View file @
ef0aa0e8
...
...
@@ -50,6 +50,7 @@ module.exports = {
},
},
'/Publish'
:
{
// target: 'http://192.168.10.150:8777',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
...
...
@@ -65,6 +66,17 @@ module.exports = {
'/Publish'
:
'/Publish'
,
},
},
'/CityTemp'
:
{
// target: 'http://192.168.10.150:8777',
target
:
'https://panda-water.cn'
,
changeOrigin
:
true
,
headers
:
{
'Access-Control-Allow-Origin'
:
'*'
,
},
pathRewrite
:
{
'/CityTemp'
:
'/CityTemp'
,
},
},
},
prod
:
{
'/CityInterface'
:
{
...
...
src/app.js
View file @
ef0aa0e8
...
...
@@ -25,7 +25,7 @@ import './vm';
import
{
actionCreators
}
from
'./containers/App/store'
;
import
{
initMicroApps
}
from
'./micro'
;
import
history
from
'./utils/history'
;
import
{
isString
}
from
'./utils/utils'
;
import
{
isString
,
getToken
}
from
'./utils/utils'
;
import
i18n
from
'./utils/share'
;
import
{
appService
}
from
'./api'
;
import
Login
from
'./pages/user/login/login'
;
...
...
@@ -68,7 +68,7 @@ const initGlobalConfig = () => {
// eslint-disable-next-line no-undef
let
config
=
createStoreage
.
get
(
'globalConfig'
)
||
{};
store
.
dispatch
(
actionCreators
.
updateComplexConfig
({}));
if
(
!
Cookies
.
get
(
'token'
)
||
config
.
token
==
null
)
{
if
(
!
getToken
(
)
||
config
.
token
==
null
)
{
// eslint-disable-next-line no-undef
createStoreage
.
remove
(
namespace
);
config
=
{};
...
...
@@ -82,7 +82,7 @@ const initGlobalConfig = () => {
if
(
!
createStoreage
.
get
(
'globalConfig'
))
{
window
.
createStoreage
=
new
Storeage
(
namespace
);
}
if
(
!
Cookies
.
get
(
'token'
))
{
if
(
!
getToken
(
))
{
localStorage
.
removeItem
(
'loginSite'
);
}
...
...
@@ -119,12 +119,12 @@ const initGlobalConfig = () => {
),
);
// eslint-disable-next-line no-new
if
(
Cookies
.
get
(
'token'
))
{
if
(
getToken
(
))
{
// eslint-disable-next-line no-new
new
Login
(
{
global
:
Object
.
assign
({},
data
,
{
token
:
Cookies
.
get
(
'token'
),
token
:
getToken
(
),
}),
// eslint-disable-next-line no-shadow
updateConfig
:
data
=>
...
...
@@ -132,7 +132,7 @@ const initGlobalConfig = () => {
},
()
=>
{
(
async
()
=>
{
(
await
(
Cookies
.
get
(
'token'
)
&&
(
await
(
getToken
(
)
&&
window
.
globalConfig
&&
window
.
globalConfig
.
token
))
&&
initMicroApps
(
loader
,
store
);
})();
...
...
src/micro.js
View file @
ef0aa0e8
...
...
@@ -29,6 +29,7 @@ const MICRO_STATUS = {
};
export
const
initMicroApps
=
(
loader
,
store
)
=>
{
console
.
log
(
window
.
globalConfig
);
const
entrys
=
process
.
env
.
NODE_ENV
!==
'production'
?
micorConfig
.
dev
:
micorConfig
.
prod
;
...
...
@@ -38,7 +39,8 @@ export const initMicroApps = (loader, store) => {
item
.
props
=
{
emitter
:
window
.
share
.
event
,
baseRoot
:
item
.
name
,
// eslint-disable-next-line no-undef
// eslint-
// disable-next-line no-undef
globalConfig
:
createStoreage
.
get
(
'globalConfig'
),
XMLHttpRequest
:
window
.
XMLHttpRequest
,
};
...
...
src/pages/user/login/index.js
View file @
ef0aa0e8
...
...
@@ -405,9 +405,11 @@ const Login = forwardRef((props, _ref) => {
:
null
);
setSubmitting
(
true
);
props
.
updateCurrentIndex
&&
props
.
updateCurrentIndex
(
-
1
);
action
&&
action
.
events
.
on
(
'loginSuccess'
,
event
=>
{
setSubmitting
(
false
);
props
.
updateCurrentIndex
&&
props
.
updateCurrentIndex
(
0
);
props
.
history
.
push
(
`/?client=
${
props
.
global
.
client
}
`
);
window
.
share
.
event
.
emit
(
'triggerMicro'
,
props
.
global
);
});
...
...
@@ -652,6 +654,9 @@ const mapDispatchToProps = dispatch => ({
updateLoginMode
(
mode
)
{
dispatch
(
actionCreators
.
changeLoginMode
(
mode
));
},
updateCurrentIndex
(
index
)
{
dispatch
(
actionCreators
.
updateCurrentIndex
(
index
));
},
});
export
default
connect
(
mapStateToProps
,
...
...
src/utils/routes.js
View file @
ef0aa0e8
...
...
@@ -45,7 +45,8 @@ const generRotes = (widgets, parent, level = 0) => {
return
}
(
widgets
).
forEach
((
item
,
index
)
=>
{
if
(
item
.
hasOwnProperty
(
'widgets'
)
&&
item
.
widgets
!==
null
)
{
if
(
item
.
hasOwnProperty
(
'widgets'
)
&&
item
.
widgets
!==
null
&&
Array
.
isArray
(
item
.
widgets
)
&&
item
.
widgets
.
length
>
0
)
{
const
_level_
=
level
+
1
;
const
path
=
`/civweb/
${
guid
(
'web_console'
)}
`
;
const
subKey
=
guid
(
'panda'
);
...
...
@@ -96,7 +97,7 @@ const generRotes = (widgets, parent, level = 0) => {
alias
:
item
.
product
||
DEFAULT_APPLICATION
,
extData
:
{
...
item
,
icon
:
(
item
&&
item
.
icon
.
replace
(
/
\s
*/g
,
''
))
||
''
,
icon
:
(
item
&&
item
.
icon
&&
item
.
icon
!==
null
&&
item
.
icon
.
replace
(
/
\s
*/g
,
''
))
||
''
,
},
parent
,
};
...
...
src/utils/utils.js
View file @
ef0aa0e8
import
pathRegexp
from
'path-to-regexp'
;
import
{
parse
}
from
'querystring'
;
import
Cookies
from
'js-cookie'
;
import
isProd
from
'./env'
;
import
pkg
from
'../../package.json'
;
const
{
toString
}
=
Object
.
prototype
;
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
...
...
@@ -158,5 +159,18 @@ export const asyncAction = action => {
wait
.
then
(()
=>
setTimeout
(()
=>
callback
()));
};
};
export
const
combineURLs
=
(
baseURL
,
relativeURL
)
=>
{
return
relativeURL
?
baseURL
.
replace
(
/
\/
+$/
,
''
)
+
'/'
+
relativeURL
.
replace
(
/^
\/
+/
,
''
):
baseURL
;
}
export
function
getAssetsURL
(
relativeURL
)
{
//CityTemp 后端约定的本地文件夹路径
if
(
!
relativeURL
)
return
;
return
combineURLs
(
window
.
location
.
origin
,
relativeURL
);
}
export
function
getToken
()
{
return
Cookies
.
get
(
'token'
);
};
export
function
setToken
(
token
)
{
Cookies
.
set
(
token
)
}
export
const
closeTabAction
=
(
history
,
returnUrl
,
callback
)
=>
{};
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