1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| import useSnackbar from "../Tools/useSnackbar.js"
window.hueColors = new Map()
window.nowHue
export default () => { const ap = window.fixedap if (ap) { const playList = ap.list const playIndex = playList.index const nowStyle = playList.audios[playIndex].theme try { changeStyle(nowStyle) } catch { new Promise((resolve)=> { setTimeout(() => { useSnackbar("因不可抗力因素没得到封面颜色w(゚Д゚)w,但至少不影响你收听啦.....((/- -)/") resolve() }, 3000) }) } } }
const hslToStr = (hsl) => { return `hsl(${hsl[0] * 360},${hsl[1] * 100}%,${hsl[2] * 100}%)` }
const changeStyle = (hsl) => { const htmlEl = document.documentElement const mode = htmlEl.dataset.theme
const hue = hsl[0]
const hueKey = Math.round(hue * 100) / 100
let keyName if (hsl[1] < 0.05) { keyName = "gray" } else { keyName = hueKey }
let darkChange = mode === "dark"
if (darkChange) { htmlEl.style.setProperty("--music-border-color", "hsl(0, 0%, 20%)") htmlEl.style.setProperty("--music-console-border-color", "hsl(0, 0%, 40%)")
keyName = mode + keyName } else { htmlEl.style.setProperty("--music-border-color", "hsl(0, 0%, 93%)") htmlEl.style.setProperty("--music-console-border-color", "hsl(0, 0%, 91%)") }
if (window.nowHue === keyName) { return } else { let colors = window.hueColors.get(keyName) if (!colors) { if (darkChange) { if (keyName === "gray" || keyName === "darkgray") { colors = { bgColor: hslToStr([0, 0, 0.1]), bgColorChoose: hslToStr([0, 0, 0.2]), scrollBarBgColor: hslToStr([0, 0, 0.4]), scrollBarBgColorHover: hslToStr([0, 0, 0.5]), musicListCurColor: hslToStr([0, 0, 0.6]), musicWordsColor: hslToStr([0, 0, 1]), musicWordsColorLighter: hslToStr([0, 0, 0.8]), musicWordsColorLightest: hslToStr([0, 0, 0.7]), musicIconColorHover: hslToStr([0, 0, 1]), musicPlayerBar: hslToStr([0, 0, 0.75]), musicPlayerBarLoad: hslToStr([0, 0, 0.9]), musicPlayerBarPlayed: hslToStr([0, 0, 0.1]) }
} else { colors = { bgColor: hslToStr([hueKey, 0.3, 0.1]), bgColorChoose: hslToStr([hueKey, 0.5, 0.2]), scrollBarBgColor: hslToStr([hueKey, 0.25, 0.4]), scrollBarBgColorHover: hslToStr([hueKey, 0.4, 0.5]), musicListCurColor: hslToStr([hueKey, 0.9, 0.6]), musicWordsColor: hslToStr([hueKey, 0, 1]), musicWordsColorLighter: hslToStr([hueKey, 0.05, 0.8]), musicWordsColorLightest: hslToStr([hueKey, 0.05, 0.7]), musicIconColorHover: hslToStr([hueKey, 0.01, 1]), musicPlayerBar: hslToStr([hueKey, 0.05, 0.75]), musicPlayerBarLoad: hslToStr([hueKey, 0.05, 0.9]), musicPlayerBarPlayed: hslToStr([hueKey, 1, 0.44]) } } } else { if (keyName === "gray") { colors = { bgColor: hslToStr([0, 0, 0.99]), bgColorChoose: hslToStr([0, 0, 0.95]), scrollBarBgColor: hslToStr([0, 0, 0.9]), scrollBarBgColorHover: hslToStr([0, 0, 0.8]), musicListCurColor: hslToStr([0, 0, 0.6]), musicWordsColor: hslToStr([0, 0., 0.29]), musicWordsColorLighter: hslToStr([0, 0, 0.4]), musicWordsColorLightest: hslToStr([0, 0, 0.6]), musicIconColorHover: hslToStr([0, 0, 0.2]), musicPlayerBar: hslToStr([0, 0, 0.8]), musicPlayerBarLoad: hslToStr([0, 0, 0.67]), musicPlayerBarPlayed: hslToStr([0, 0, 0.44]) }
} else { colors = { bgColor: hslToStr([hueKey, 1, 0.99]), bgColorChoose: hslToStr([hueKey, 0.5, 0.95]), scrollBarBgColor: hslToStr([hueKey, 0.4, 0.9]), scrollBarBgColorHover: hslToStr([hueKey, 0.25, 0.8]), musicListCurColor: hslToStr([hueKey, 0.9, 0.6]), musicWordsColor: hslToStr([hueKey, 0.03, 0.29]), musicWordsColorLighter: hslToStr([0, 0, 0.4]), musicWordsColorLightest: hslToStr([0, 0, 0.6]), musicIconColorHover: hslToStr([hueKey, 0.01, 0.2]), musicPlayerBar: hslToStr([0, 0, 0.8]), musicPlayerBarLoad: hslToStr([0, 0, 0.67]), musicPlayerBarPlayed: hslToStr([hueKey, 0.64, 0.44]) } } } window.hueColors.set(keyName, colors) }
htmlEl.style.setProperty("--bg-color", colors.bgColor) htmlEl.style.setProperty("--bg-color-choose", colors.bgColorChoose) htmlEl.style.setProperty("--scroll-bar-bg-color", colors.scrollBarBgColor) htmlEl.style.setProperty("--scroll-bar-bg-color-hover", colors.scrollBarBgColorHover) htmlEl.style.setProperty("--music-list-cur-color", colors.musicListCurColor) htmlEl.style.setProperty("--music-words-color", colors.musicWordsColor) htmlEl.style.setProperty("--music-words-color-lighter", colors.musicWordsColorLighter) htmlEl.style.setProperty("--music-words-color-lightest", colors.musicWordsColorLightest) htmlEl.style.setProperty("--music-icon-color-hover", colors.musicIconColorHover) htmlEl.style.setProperty("--music-player-bar", colors.musicPlayerBar) htmlEl.style.setProperty("--music-player-bar-load", colors.musicPlayerBarLoad) htmlEl.style.setProperty("--music-player-bar-played", colors.musicPlayerBarPlayed)
const apDOM = window.fixedap.container const dot = apDOM.querySelector(".aplayer-thumb") const bar = apDOM.querySelector(".aplayer-played") const vol = apDOM.querySelector(".aplayer-volume") dot.style.backgroundColor = colors.musicPlayerBarPlayed bar.style.backgroundColor = colors.musicPlayerBarPlayed vol.style.backgroundColor = colors.musicPlayerBarPlayed
window.nowHue = keyName } }
|