Files
Melo/src/renderer-lyric/index.html
T

42 lines
1.6 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>桌面歌词-洛雪音乐助手</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()
document.documentElement.classList.add(/os=(\w+)/.exec(window.location.search)[1])
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>