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
bfebd780
Commit
bfebd780
authored
Jul 08, 2022
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 站点切换支持改变主题
parent
82fa49ff
Pipeline
#54946
passed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
40 deletions
+42
-40
login.js
src/pages/user/login/login.js
+16
-1
render.js
src/render.js
+26
-39
No files found.
src/pages/user/login/login.js
View file @
bfebd780
...
...
@@ -376,7 +376,22 @@ class Login {
self
.
globalConfig
.
shortcutIcon
=
mainConf
.
shortcutIcon
;
if
(
mainConf
&&
mainConf
.
hasOwnProperty
(
'topMenu'
))
self
.
globalConfig
.
topMenu
=
mainConf
.
topMenu
;
if
(
mainConf
&&
mainConf
.
navTheme
)
self
.
globalConfig
.
navTheme
=
mainConf
.
navTheme
;
// 云平台统一navTheme
if
(
mainConf
&&
mainConf
.
navTheme
&&
self
.
globalConfig
.
CloudStyle
!==
'否'
)
self
.
globalConfig
.
navTheme
=
mainConf
.
navTheme
;
// 云平台统一navTheme
// 云平台切换站点 应用站点自己主题配置
if
(
config
.
CloudStyle
===
'否'
)
{
self
.
globalConfig
.
variableTheme
=
{
primaryColor
:
config
.
primaryColor
,
navTheme
:
config
.
navTheme
,
headerPrimaryColor
:
config
.
headerPrimaryColor
,
}
}
else
{
self
.
globalConfig
.
variableTheme
=
{
primaryColor
:
mainConf
.
primaryColor
,
navTheme
:
mainConf
.
navTheme
,
headerPrimaryColor
:
mainConf
.
headerPrimaryColor
,
}
}
// if (mainConf.productType)
// self.globalConfig.productType = mainConf.productType;
self
.
updateConfig
&&
self
.
updateConfig
(
self
.
globalConfig
);
...
...
src/render.js
View file @
bfebd780
...
...
@@ -230,46 +230,33 @@ export const AppInitState = () => {
)
return
false
return
true
}
/**
* @param {Object} theme
* primaryColor:
* navTheme: "dark" or "light"
* headerPrimaryColor:
*/
window
.
share
&&
window
.
share
.
event
&&
window
.
share
.
event
.
on
(
'update:theme'
,
function
(
theme
)
{
if
(
!
theme
||
!
hasThemeChanged
(
window
.
globalConfig
.
variableTheme
,
theme
))
return
;
const
preVariableTheme
=
window
.
globalConfig
.
variableTheme
??
{};
const
{
primaryColor
:
prePrimaryColor
,
navTheme
:
preNavTheme
,
headerPrimaryColor
:
preHeaderPrimaryColor
,
}
=
preVariableTheme
;
const
{
primaryColor
,
navTheme
,
headerPrimaryColor
}
=
theme
;
if
(
primaryColor
&&
primaryColor
!==
prePrimaryColor
)
{
ConfigProvider
.
config
({
prefixCls
:
customPrefixCls
,
theme
:
{
primaryColor
,
}
});
}
if
(
navTheme
&&
navTheme
!==
preNavTheme
)
{
// do nothing
}
if
(
headerPrimaryColor
&&
headerPrimaryColor
!==
preHeaderPrimaryColor
)
{
registerTheme
(
customPrefixCls
,
{
'header-bg-color'
:
headerPrimaryColor
,
});
store
.
subscribe
((
function
()
{
let
preVariableTheme
=
store
.
getState
().
toJS
().
global
?.
globalConfig
?.
variableTheme
;
return
function
()
{
// if (!preVariableTheme)
const
variableTheme
=
store
.
getState
().
toJS
().
global
?.
globalConfig
?.
variableTheme
;
if
(
!
hasThemeChanged
(
preVariableTheme
,
variableTheme
))
return
false
const
{
primaryColor
:
prePrimaryColor
,
navTheme
:
preNavTheme
,
headerPrimaryColor
:
preHeaderPrimaryColor
,
}
=
(
preVariableTheme
||
{});
const
{
primaryColor
,
headerPrimaryColor
}
=
variableTheme
;
if
(
primaryColor
&&
primaryColor
!==
prePrimaryColor
)
{
ConfigProvider
.
config
({
prefixCls
:
customPrefixCls
,
theme
:
{
primaryColor
,
}
});
}
if
(
headerPrimaryColor
&&
headerPrimaryColor
!==
preHeaderPrimaryColor
)
{
registerTheme
(
customPrefixCls
,
{
'header-bg-color'
:
headerPrimaryColor
,
});
}
}
// updage global config
const
variableTheme
=
Object
.
assign
({},
preVariableTheme
,
theme
);
store
.
dispatch
(
actionCreators
.
getConfig
(
Object
.
assign
({},
window
.
globalConfig
,
{
variableTheme
:
variableTheme
,
})));
})
})())
};
initLocale
();
...
...
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