|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
|
<meta name="theme-color" content="#1890ff" />
|
|
|
|
|
<title>{% if title %}{{ title | safe }}{% else %}{% endif %}</title>
|
|
|
|
|
{% if meta %}{{ meta | safe }}{% endif %}
|
|
|
|
|
<link
|
|
|
|
@ -23,6 +24,13 @@
|
|
|
|
|
<script src="https://b.alicdn.com/s/polyfill.min.js?features=default,es2015,Intl"></script>
|
|
|
|
|
<link id="darkThemeLink" rel="stylesheet" href="/dark.css" />
|
|
|
|
|
<script>
|
|
|
|
|
/* 设置 meta theme-color 的值,默认会设置一个 #1890ff */
|
|
|
|
|
function setColor(isDarken) {
|
|
|
|
|
try {
|
|
|
|
|
const theme = document.getElementsByTagName('meta')['theme-color'];
|
|
|
|
|
theme.setAttribute('content', isDarken ? 'rgba(0,0,0,0.65)' : '#1890ff');
|
|
|
|
|
} catch (error) {}
|
|
|
|
|
}
|
|
|
|
|
/* -------------------------- 主题相关 -------------------------- */
|
|
|
|
|
(function () {
|
|
|
|
|
/* 获取查询参数对象 */
|
|
|
|
@ -58,7 +66,7 @@
|
|
|
|
|
);
|
|
|
|
|
// load后卸载
|
|
|
|
|
window.addEventListener('load', () => darkThemeLinkEl.remove(), { once: true });
|
|
|
|
|
|
|
|
|
|
setColor(true);
|
|
|
|
|
// 清除dark.css中的全部transition 待解析完后恢复
|
|
|
|
|
var styleElement = document.createElement('style');
|
|
|
|
|
styleElement.type = 'text/css';
|
|
|
|
@ -71,6 +79,7 @@
|
|
|
|
|
// 设置系统主题
|
|
|
|
|
document.documentElement.style.colorScheme = 'dark';
|
|
|
|
|
} else {
|
|
|
|
|
setColor(false);
|
|
|
|
|
document.documentElement.style.colorScheme = 'light';
|
|
|
|
|
darkThemeLinkEl.remove();
|
|
|
|
|
}
|
|
|
|
|