Skip to content

Bug: 主题自动变化是不是只有mode auto才生效比较合适呢 #5916

@Child-qjj

Description

@Child-qjj

Version

Vben Admin V5

Describe the bug?

设置了单一主题也会被系统主题影响,是不是加个判断,仅在mode为auto时自动切换

// 监听系统主题偏好设置变化
window
.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', ({ matches: isDark }) => {
this.updatePreferences({
theme: { mode: isDark ? 'dark' : 'light' },
});
});

Reproduction

设置theme: light,手动切换电脑系统主题为暗色,系统变更为暗色
期望:mode !== 'auto' 页面不受系统主题影响

System Info

System:
    OS: macOS 13.5.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 110.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
    pnpm: 9.12.2 - ~/.nvm/versions/node/v20.16.0/bin/pnpm
    Watchman: 2024.11.18.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 135.0.7049.85
    Safari: 16.6

Relevant log output

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions