- 将原有的静态样式注入改为动态JavaScript生成 - 添加了对玻璃态效果选择器的动态处理支持 - 添加了对卡片项目选择器的动态处理支持 - 实现了多选择器的自动分割和格式化功能 - 提升了样式的灵活性和可维护性 - 减少了HTML模板中的重复代码块
This commit is contained in:
+46
-29
@@ -4,34 +4,51 @@
|
||||
window.I18n.translations[I18n.locale].js.browser_update =
|
||||
'The Horizon theme does not support your browser. Please update your browser, or <a href="?safe_mode=no_themes">switch to safe mode</a>.';
|
||||
}
|
||||
|
||||
// 处理动态样式
|
||||
(() => {
|
||||
const glassSelectors = "{{settings.extra_glass_morphism_selectors}}".trim();
|
||||
const cardSelectors = "{{settings.extra_card_item_selectors}}".trim();
|
||||
|
||||
let styles = '';
|
||||
|
||||
if (glassSelectors) {
|
||||
const selectors = glassSelectors.split('\n').filter(s => s.trim()).map(s => s.trim()).join(', ');
|
||||
styles += `
|
||||
${selectors} {
|
||||
background-color: #ffffffa8 !important;
|
||||
border-radius: var(--d-border-radius);
|
||||
backdrop-filter: blur(32px);
|
||||
box-shadow: #00000077 0 0 19px 0;
|
||||
padding: 24px;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (cardSelectors) {
|
||||
const selectors = cardSelectors.split('\n').filter(s => s.trim()).map(s => s.trim()).join(', ');
|
||||
styles += `
|
||||
${selectors} {
|
||||
background: var(--d-chat-input-bg-color);
|
||||
border-radius: var(--d-border-radius);
|
||||
box-shadow: #00000024 0 0 7px 2px;
|
||||
margin: 10px 0;
|
||||
position: relative;
|
||||
padding: 16px 12px;
|
||||
overflow: hidden;
|
||||
transition: background-color 0.2s ease-in-out;
|
||||
}
|
||||
${selectors}:hover {
|
||||
background-color: var(--accent-text-color);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
if (styles) {
|
||||
const styleEl = document.createElement('style');
|
||||
styleEl.textContent = styles;
|
||||
document.head.appendChild(styleEl);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
{{#if settings.extra_glass_morphism_selectors}}
|
||||
<style>
|
||||
{{settings.extra_glass_morphism_selectors}} {
|
||||
background-color: #ffffffa8 !important;
|
||||
border-radius: var(--d-border-radius);
|
||||
backdrop-filter: blur(32px);
|
||||
box-shadow: #00000077 0 0 19px 0;
|
||||
padding: 24px;
|
||||
}
|
||||
</style>
|
||||
{{/if}}
|
||||
|
||||
{{#if settings.extra_card_item_selectors}}
|
||||
<style>
|
||||
{{settings.extra_card_item_selectors}} {
|
||||
background: var(--d-chat-input-bg-color);
|
||||
border-radius: var(--d-border-radius);
|
||||
box-shadow: #00000024 0 0 7px 2px;
|
||||
margin: 10px 0;
|
||||
position: relative;
|
||||
padding: 16px 12px;
|
||||
overflow: hidden;
|
||||
transition: background-color 0.2s ease-in-out;
|
||||
}
|
||||
{{settings.extra_card_item_selectors}}:hover {
|
||||
background-color: var(--accent-text-color);
|
||||
}
|
||||
</style>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user