PageSourceSearch

https://linuxmirrors.cn/assets/js/modules/tdesign-theme.js

js linuxmirrors.cn collected 2026-10-07 02:15:37 UTC 1,020 bytes, 32 lines download raw bytes

1// 更新 TDesign 主题
2function updateTDesignGlobalTheme() {
3    const scheme = document.querySelector('[data-md-color-scheme]')?.getAttribute('data-md-color-scheme')
4    const isDarkMode = scheme === 'slate' || scheme === 'dark'
5    if (isDarkMode) {
6        document.documentElement.setAttribute('theme-mode', 'dark')
7    } else {
8        document.documentElement.removeAttribute('theme-mode')
9    }
10}
11
12// 主题监听器
13function setupThemeObserver() {
14    // 监听主题变化
15    const observer = new MutationObserver(() => {
16        updateTDesignGlobalTheme()
17    })
18    const element = document.querySelector('[data-md-color-scheme]')
19    if (element) {
20        observer.observe(element, {
21            attributes: true,
22            attributeFilter: ['data-md-color-scheme'],
23        })
24    } else {
25        // 如果元素不存在,等待页面加载完成后重试
26        setTimeout(setupThemeObserver, 1000)
27    }
28}
29
30document.addEventListener('DOMContentLoaded', function () {
31    setupThemeObserver()
32})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.