MCPcopy Create free account
hub / github.com/Xu22Web/tech-study-js / initThemeColor

Function initThemeColor

tech-study.js:232–256  ·  view source on GitHub ↗

* @description 初始化主题色

()

Source from the content-addressed store, hash-verified

230 * @description 初始化主题色
231 */
232function initThemeColor() {
233 try {
234 // 监听主题变化
235 watch(themeColor, () => {
236 // 设置主题
237 document.documentElement.style.setProperty('--themeColor', themeColor.value);
238 });
239 // 主题色
240 const themeColorTemp = GM_getValue('themeColor');
241 if (themeColorTemp) {
242 themeColor.value = themeColorTemp;
243 }
244 // 监听值变化
245 GM_addValueChangeListener('themeColor', (key, oldVal, newVal, remote) => {
246 if (remote) {
247 // 主题色
248 const themeColorTemp = newVal;
249 if (themeColorTemp) {
250 themeColor.value = themeColorTemp;
251 }
252 }
253 });
254 }
255 catch (error) { }
256}
257/**
258 * @description 渲染提示
259 */

Callers 1

tech-study.jsFile · 0.70

Calls 1

watchFunction · 0.70

Tested by

no test coverage detected