Update: (步骤备份)更改主题色通知方式
This commit is contained in:
@@ -299,16 +299,6 @@ layui.define(['jquery', 'tools', 'element', 'yaml', 'form', 'tabPage', 'menu', '
|
|||||||
const variableKey = "--global-primary-color";
|
const variableKey = "--global-primary-color";
|
||||||
const variableVal = localStorage.getItem("theme-color-color");
|
const variableVal = localStorage.getItem("theme-color-color");
|
||||||
document.documentElement.style.setProperty(variableKey, variableVal);
|
document.documentElement.style.setProperty(variableKey, variableVal);
|
||||||
|
|
||||||
/* 遍历所有 iframe 更改主题色 */
|
|
||||||
const iframes = document.querySelectorAll('iframe');
|
|
||||||
iframes.forEach(function(iframe) {
|
|
||||||
try {
|
|
||||||
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
|
||||||
// 设置 iframe 中的主题色
|
|
||||||
iframeDocument.documentElement.style.setProperty(variableKey, variableVal);
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
|
// 自动变换主题色
|
||||||
const variableKey = "--global-primary-color";
|
const variableKey = "--global-primary-color";
|
||||||
const variableVal = localStorage.getItem("theme-color-color");
|
const variableVal = localStorage.getItem("theme-color-color");
|
||||||
document.documentElement.style.setProperty(variableKey, variableVal);
|
document.documentElement.style.setProperty(variableKey, variableVal);
|
||||||
|
|||||||
@@ -92,6 +92,24 @@
|
|||||||
// yml | json | api
|
// yml | json | api
|
||||||
admin.setConfigurationPath("{{ url_for('system.rights.configs') }}");
|
admin.setConfigurationPath("{{ url_for('system.rights.configs') }}");
|
||||||
|
|
||||||
|
// 主题色自动通知子页面
|
||||||
|
admin._changeTheme = admin.changeTheme;
|
||||||
|
admin.changeTheme = function() {
|
||||||
|
admin._changeTheme(); // 调用原方法
|
||||||
|
|
||||||
|
/* 遍历所有 iframe 更改主题色 */
|
||||||
|
const variableKey = "--global-primary-color";
|
||||||
|
const variableVal = localStorage.getItem("theme-color-color");
|
||||||
|
const iframes = document.querySelectorAll('iframe');
|
||||||
|
iframes.forEach(function (iframe) {
|
||||||
|
try {
|
||||||
|
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
||||||
|
// 设置 iframe 中的主题色
|
||||||
|
iframeDocument.documentElement.style.setProperty(variableKey, variableVal);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
// 渲染
|
// 渲染
|
||||||
admin.render();
|
admin.render();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user