update 2023-03-18 19:56:03

This commit is contained in:
github-actions[bot]
2023-03-18 19:56:03 +08:00
parent 4ac457e454
commit 6292620f01
9 changed files with 349 additions and 50 deletions

View File

@ -161,7 +161,7 @@
<%-= css %>
</style>
<% end -%>
<script src="<%=resource%>/xhr.js?<%= ver.luciversion %>"></script>
<script src="<%=media%>/js/xhr.js?v=<%= ver.luciversion %>"></script>
<style title="text/css" id="global-scroll">
::-webkit-scrollbar {
width: 4px
@ -180,16 +180,16 @@
>
<header>
<script>
<% if mode == 'normal' then %>
let color_scheme = window.matchMedia('(prefers-color-scheme: dark)');
document.body.setAttribute('data-theme', color_scheme.matches? 'dark' : 'light');
window.matchMedia && color_scheme.addEventListener('change', (event) => {
document.body.setAttribute('data-theme', event.matches? 'dark' : 'light');
})
<script>
function setTheme() {
let color_scheme = window.matchMedia('(prefers-color-scheme: dark)');
document.body.setAttribute('data-theme', color_scheme.matches && 'dark');
}
setTheme();
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setTheme);
</script>
<% end -%>
</script>
<% if navbar == 'display' then %>
<style>
@ -235,34 +235,12 @@
end
%>
<% if ucichanges > 0 then %>
<a class="label notice" style="margin-right: 30px;" href="<%=url(category, 'uci/changes')%>?redir=<%=http.urlencode(http.formvalue('redir') or table.concat(disp.context.request, "/"))%>"><%=translate('Unsaved Changes')%>: <%=ucichanges%></a>
<a id="notice_status" class="label notice" href="<%=url(category, 'uci/changes')%>?redir=<%=http.urlencode(http.formvalue('redir') or table.concat(disp.context.request, "/"))%>"><%=translate('Unsaved Changes')%>: <%=ucichanges%></a>
<% end %>
<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
<span class="label success" id="xhr_poll_status_on"><span id="refresh_on" class="mobile-hide"></span></span>
<span class="label" id="xhr_poll_status_off" style="display:none"><span id="refresh_off" class="mobile-hide"></span></span>
</span>
<script>
const pollStatus = document.querySelector('#xhr_poll_status');
const notice = document.querySelector('.notice');
function updateMarginRight() {
const style = notice.style; // 缓存样式对象
if (pollStatus.style.display === '') {
style.setProperty('margin-right', '30px', 'important');
} else if (pollStatus.style.display === 'none') {
style.setProperty('margin-right', '0', 'important');
}
}
const observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
updateMarginRight();
}
}
});
const config = { attributes: true, attributeFilter: ['style'] };
observer.observe(pollStatus, config);
updateMarginRight();
</script>
<% end %>
</div>
</div>