43 lines
1.7 KiB
HTML
43 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" style="background-color: transparent;">
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Lyric - LX Music</title>
|
|
</head>
|
|
<body id="body" style="background-color: transparent;">
|
|
<div id="root"></div>
|
|
<script>
|
|
const formatLang = (lang = 'en') => {
|
|
if (lang === 'zh-cn') return 'zh-Hans'
|
|
if (lang === 'zh-tw') return 'zh-Hant'
|
|
return lang.split('-')[0]
|
|
}
|
|
window.setLang = (lang = navigator.language.toLocaleLowerCase()) => {
|
|
document.documentElement.setAttribute('lang', formatLang(lang))
|
|
}
|
|
window.setLang()
|
|
window.os = /os=(\w+)/.exec(window.location.search)[1]
|
|
document.documentElement.classList.add(window.os)
|
|
window.dom_style_theme = document.createElement('style')
|
|
window.dom_style_lyric = document.createElement('style')
|
|
|
|
window.setTheme = colors => {
|
|
window.dom_style_theme.innerText = `:root {${(Object.entries(colors)).map(([key, value]) => `${key}:${value};`).join('')}}`
|
|
}
|
|
window.setLyricColor = colors => {
|
|
console.log(colors)
|
|
window.dom_style_lyric.innerText = `:root {${(Object.entries(colors)).map(([key, value]) => `${key}:${value};`).join('')}}`
|
|
}
|
|
document.body.appendChild(window.dom_style_lyric)
|
|
|
|
const applyThemeColor = (theme) => {
|
|
theme = JSON.parse(decodeURIComponent(theme))
|
|
window.setTheme(theme.colors)
|
|
document.body.appendChild(window.dom_style_theme)
|
|
}
|
|
if (/theme=(.+)(#|$)/.test(window.location.search)) applyThemeColor(RegExp.$1)
|
|
</script>
|
|
</body>
|
|
</html>
|