Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f46ec309
authored
Apr 12, 2025
by
Netfan
Committed by
GitHub
Apr 12, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: theme mode follow the system only `auto` (#5923)
* 修复主题在未设置为auto时,仍然会跟随系统主题变化的问题。
1 parent
9bd5a190
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
packages/@core/preferences/src/preferences.ts
packages/effects/plugins/src/vxe-table/init.ts
packages/@core/preferences/src/preferences.ts
View file @
f46ec30
...
...
@@ -198,9 +198,16 @@ class PreferenceManager {
window
.
matchMedia
(
'(prefers-color-scheme: dark)'
)
.
addEventListener
(
'change'
,
({
matches
:
isDark
})
=>
{
this
.
updatePreferences
({
theme
:
{
mode
:
isDark
?
'dark'
:
'light'
},
});
// 如果偏好设置中主题模式为auto,则跟随系统更新
if
(
this
.
state
.
theme
.
mode
===
'auto'
)
{
this
.
updatePreferences
({
theme
:
{
mode
:
isDark
?
'dark'
:
'light'
},
});
// 恢复为auto模式
this
.
updatePreferences
({
theme
:
{
mode
:
'auto'
},
});
}
});
}
...
...
packages/effects/plugins/src/vxe-table/init.ts
View file @
f46ec30
...
...
@@ -106,7 +106,7 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
initVxeTable
();
useTableForm
=
useVbenForm
;
const
preference
=
usePreferences
();
const
{
isDark
,
locale
}
=
usePreferences
();
const
localMap
=
{
'zh-CN'
:
zhCN
,
...
...
@@ -114,11 +114,11 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
};
watch
(
[()
=>
preference
.
theme
.
value
,
()
=>
preference
.
locale
.
value
],
([
theme
,
local
e
])
=>
{
VxeUI
.
setTheme
(
theme
===
'dark'
?
'dark'
:
'light'
);
VxeUI
.
setI18n
(
locale
,
localMap
[
local
e
]);
VxeUI
.
setLanguage
(
locale
);
[()
=>
isDark
.
value
,
()
=>
locale
.
value
],
([
isDarkValue
,
localeValu
e
])
=>
{
VxeUI
.
setTheme
(
isDarkValue
?
'dark'
:
'light'
);
VxeUI
.
setI18n
(
locale
Value
,
localMap
[
localeValu
e
]);
VxeUI
.
setLanguage
(
locale
Value
);
},
{
immediate
:
true
,
...
...
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