mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 06:35:13 +08:00
🏅 Sync 2026-04-19 00:24:08
This commit is contained in:
1 parent
e08c81d7fc
commit
746d64b361
30 files changed
+1982
-1250
No files matched your search
@@ -1,431 +0,0 @@
|
||||
/**
|
||||
* OpenWrt 23/24 å…¼å®¹æ€§æ ·å¼�è¡¥ä¸?
|
||||
*
|
||||
* 这个文件包å�«é’ˆå¯¹ OpenWrt 23.x å’?24.x çš„æ ·å¼�ä¿®å¤?
|
||||
* 新版 LuCI 使用了一些新�CSS 类�和结�
|
||||
*/
|
||||
|
||||
/* ============================================
|
||||
1. 新版 LuCI 视图容器兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版 LuCI 使用 #view 作为主�内容容器 */
|
||||
#view {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#view > * {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* 兼容新版 LuCI �.cbi-map 结构 */
|
||||
.cbi-map {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
2. 新版表å�•å…ƒç´ æ ·å¼�
|
||||
============================================ */
|
||||
|
||||
/* 新版 LuCI çš?input æ ·å¼�兼容 */
|
||||
.cbi-input-text,
|
||||
.cbi-input-password,
|
||||
.cbi-input-select {
|
||||
color: var(--inputtext_color);
|
||||
padding: 5px 10px;
|
||||
font-size: 0.92rem;
|
||||
border: var(--input_border);
|
||||
background-color: var(--inputbg_color);
|
||||
border-radius: 8px;
|
||||
height: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
max-width: 550px;
|
||||
}
|
||||
|
||||
/* 新版 checkbox å’?radio æ ·å¼� */
|
||||
.cbi-input-checkbox,
|
||||
.cbi-input-radio {
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
margin-right: 0.5rem;
|
||||
vertical-align: middle;
|
||||
accent-color: var(--active_color);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
3. æ–°ç‰ˆæŒ‰é’®æ ·å¼�兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版 LuCI 按钮类� */
|
||||
.btn.cbi-button,
|
||||
button.cbi-button {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
text-transform: uppercase;
|
||||
color: #fff;
|
||||
background-color: #337ab7;
|
||||
transition: all 0.2s ease-in-out;
|
||||
display: inline-block;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
min-width: 80px;
|
||||
padding: 0 8px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* 新版 primary/positive 按钮 */
|
||||
.cbi-button-positive,
|
||||
.cbi-button-action {
|
||||
color: var(--bttext_color) !important;
|
||||
background-color: var(--active_color) !important;
|
||||
}
|
||||
|
||||
.cbi-button-positive:hover,
|
||||
.cbi-button-action:hover {
|
||||
background-color: #4a8a80 !important;
|
||||
}
|
||||
|
||||
/* 新版 negative 按钮 */
|
||||
.cbi-button-negative {
|
||||
color: #fff !important;
|
||||
background-color: #d9534f !important;
|
||||
}
|
||||
|
||||
.cbi-button-negative:hover {
|
||||
background-color: #c9302c !important;
|
||||
}
|
||||
|
||||
/* 新版 neutral 按钮 */
|
||||
.cbi-button-neutral {
|
||||
color: #fff !important;
|
||||
background-color: #617486 !important;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
4. æ–°ç‰ˆè¡¨æ ¼æ ·å¼�兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版 LuCI è¡¨æ ¼ç»“æž„ */
|
||||
.table.cbi-section-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table.cbi-section-table .tr {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
.table.cbi-section-table .th,
|
||||
.table.cbi-section-table .td {
|
||||
display: table-cell;
|
||||
padding: 12px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* æ–°ç‰ˆè¡¨æ ¼æ ‡é¢˜è¡?*/
|
||||
.tr.cbi-section-table-titles {
|
||||
background-color: var(--inputbg_color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
5. 新版下拉��兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版 cbi-dropdown æ ·å¼� */
|
||||
.cbi-dropdown {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
min-height: 2.8rem;
|
||||
border: var(--input_border);
|
||||
background-color: var(--inputbg_color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.cbi-dropdown > ul {
|
||||
display: flex;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
width: 100%;
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.cbi-dropdown > ul > li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.cbi-dropdown[open] > ul.dropdown {
|
||||
position: absolute;
|
||||
z-index: 1100;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: var(--sectionbg_color);
|
||||
border: var(--input_border);
|
||||
border-radius: 0 0 8px 8px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.cbi-dropdown[open] > ul.dropdown > li {
|
||||
padding: 0.5em 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cbi-dropdown[open] > ul.dropdown > li:hover {
|
||||
background-color: var(--active_color);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
6. æ–°ç‰ˆæ ‡ç¾é¡µæ ·å¼�å…¼å®?
|
||||
============================================ */
|
||||
|
||||
/* 新版 LuCI æ ‡ç¾é¡?*/
|
||||
.cbi-tabmenu {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
border-bottom: var(--tabmenu_bottom);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.cbi-tabmenu > li {
|
||||
display: inline-block;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.cbi-tabmenu > li > a {
|
||||
display: block;
|
||||
padding: 0.5rem 1rem;
|
||||
text-decoration: none;
|
||||
color: var(--text_color);
|
||||
border-bottom: 2px solid transparent;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.cbi-tabmenu > li.cbi-tab > a,
|
||||
.cbi-tabmenu > li > a:hover {
|
||||
color: var(--active_color);
|
||||
border-bottom-color: var(--active_color);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
7. 新版模æ€�æ¡†æ ·å¼�兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版 modal æ ·å¼� */
|
||||
.modal {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
min-height: 32px;
|
||||
margin: 5em auto;
|
||||
padding: 1em;
|
||||
border-radius: 8px;
|
||||
background: var(--model_background);
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.modal > * {
|
||||
flex-basis: 100%;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.modal > h4 {
|
||||
color: var(--text_color);
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.modal > .btn,
|
||||
.modal > .cbi-button {
|
||||
flex-basis: auto;
|
||||
margin: 0.25em;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
8. 新版进度æ�¡æ ·å¼�å…¼å®?
|
||||
============================================ */
|
||||
|
||||
/* 新版进度�*/
|
||||
.cbi-progressbar {
|
||||
position: relative;
|
||||
min-width: 11rem;
|
||||
height: 1.5rem;
|
||||
background-color: var(--progressbar_color);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cbi-progressbar > div {
|
||||
height: 100%;
|
||||
background: var(--progressbar);
|
||||
transition: width 0.25s ease-in;
|
||||
}
|
||||
|
||||
.cbi-progressbar::after {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
content: attr(title);
|
||||
text-align: center;
|
||||
line-height: 1.5rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--progressbartxt_color);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
9. 新版状�指示器兼容
|
||||
============================================ */
|
||||
|
||||
/* 新版状�徽�*/
|
||||
.ifacebadge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.2rem;
|
||||
padding: 0.3rem 0.6rem;
|
||||
background-color: var(--active_color);
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.ifacebadge > img,
|
||||
.ifacebadge > em {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* åŒºåŸŸå¾½ç« */
|
||||
.zonebadge {
|
||||
display: inline-block;
|
||||
padding: 0.2rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
10. 新版�应�布局兼容
|
||||
============================================ */
|
||||
|
||||
@media screen and (max-width: 992px) {
|
||||
/* 新版移动端��*/
|
||||
.main-left {
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.main-left.active,
|
||||
.main-left[style*="width: 17rem"],
|
||||
.main-left:not([style*="width: 0"]) {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
11. 新版 LuCI 特定页�修�
|
||||
============================================ */
|
||||
|
||||
/* 系统概览页� */
|
||||
[data-page="admin-status-overview"] .cbi-section {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* 网络接�页� */
|
||||
[data-page="admin-network-network"] .ifacebox {
|
||||
margin: 0.5rem;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* æ— çº¿é¡µé�¢ */
|
||||
[data-page="admin-network-wireless"] .cbi-section-table {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
/* 软件包页�*/
|
||||
[data-page="admin-system-opkg"] .controls {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
[data-page="admin-system-opkg"] .controls input[type="text"] {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
12. 深色模�增强
|
||||
============================================ */
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
/* 新版深色模å¼�下的代ç �å�?*/
|
||||
code, pre {
|
||||
background-color: #2d2d2d;
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
/* 新版深色模å¼�ä¸‹çš„è¡¨æ ¼ */
|
||||
.table.cbi-section-table .tr:nth-child(even) {
|
||||
background-color: rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
/* 新版深色模�下的输入�*/
|
||||
.cbi-input-text:focus,
|
||||
.cbi-input-password:focus,
|
||||
.cbi-input-select:focus {
|
||||
border-color: var(--active_color);
|
||||
box-shadow: 0 0 6px var(--active_color);
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
13. 打å�°æ ·å¼�
|
||||
============================================ */
|
||||
|
||||
@media print {
|
||||
.main-left,
|
||||
.navbar,
|
||||
header,
|
||||
.showSide,
|
||||
.darkMask {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.main-right {
|
||||
width: 100% !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
14. æ— éšœç¢�访问增å¼?
|
||||
============================================ */
|
||||
|
||||
/* 焦点���*/
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--active_color);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* �少动画 (用户�好) */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -1,28 +1,404 @@
|
||||
(function ($) {
|
||||
function applySafeAreaFix() {
|
||||
var url = self.location.href;
|
||||
|
||||
// 修复某些插件导致在https下env(safe-area-inset-bottom)为0的情况
|
||||
var url = self.location.href;
|
||||
if ((/(iPhone|iPad|iPod|iOS|Mac|Macintosh)/i.test(navigator.userAgent)) && url.indexOf("openclash") != -1 ) {
|
||||
var oMeta = document.createElement('meta');
|
||||
oMeta.content = 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover';
|
||||
oMeta.name = 'viewport';
|
||||
document.getElementsByTagName('head')[0].appendChild(oMeta);
|
||||
// 修复某些插件导致在 https 下 env(safe-area-inset-bottom) 为 0 的情况
|
||||
if ((/(iPhone|iPad|iPod|iOS|Mac|Macintosh)/i.test(navigator.userAgent)) && url.indexOf("openclash") !== -1) {
|
||||
var oMeta = document.createElement('meta');
|
||||
oMeta.content = 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover';
|
||||
oMeta.name = 'viewport';
|
||||
document.getElementsByTagName('head')[0].appendChild(oMeta);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置indicators图标,(放在menu script执行之前passwall某些代码错误中断导致失败)
|
||||
document.getElementById("indicators").addEventListener('DOMSubtreeModified', function () {
|
||||
var child = document.getElementById("indicators");
|
||||
if (child.firstElementChild.getAttribute("data-indicator") != "uci-changes") {
|
||||
child.firstElementChild.textContent = eval("'\ue6b9'")
|
||||
}
|
||||
}, false);
|
||||
function setHeaderShadow() {
|
||||
if (window.innerWidth <= 992) {
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)");
|
||||
} else {
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)");
|
||||
}
|
||||
}
|
||||
|
||||
// 监听窗口大小,动态设置header box阴影长度
|
||||
$(window).resize( function () {
|
||||
if (window.innerWidth <= 992) {
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
||||
} else {
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
}
|
||||
function syncIndicators() {
|
||||
var indicatorRoot = document.getElementById("indicators");
|
||||
|
||||
if (!indicatorRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(indicatorRoot.querySelectorAll('[data-indicator]'), function (indicator) {
|
||||
var id = indicator.getAttribute('data-indicator');
|
||||
var label = (indicator.textContent || '').trim();
|
||||
|
||||
if (!label) {
|
||||
label = indicator.getAttribute('aria-label') || indicator.getAttribute('title') || '';
|
||||
}
|
||||
|
||||
if (id === 'poll-status') {
|
||||
indicator.setAttribute('title', label);
|
||||
indicator.setAttribute('aria-label', label);
|
||||
} else if (id === 'uci-changes') {
|
||||
var match = label.match(/(\d+)\s*$/);
|
||||
|
||||
indicator.setAttribute('title', label);
|
||||
indicator.setAttribute('aria-label', label);
|
||||
indicator.setAttribute('data-count', match ? match[1] : '');
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
}
|
||||
|
||||
function initIndicators() {
|
||||
var indicatorRoot = document.getElementById("indicators");
|
||||
|
||||
if (!indicatorRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
syncIndicators();
|
||||
|
||||
new MutationObserver(syncIndicators).observe(indicatorRoot, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['data-style']
|
||||
});
|
||||
}
|
||||
|
||||
function syncOverviewPortStatus() {
|
||||
var view = document.getElementById('view');
|
||||
var portGroups = new Map();
|
||||
var mediaPath = (L.env && L.env.media) ? L.env.media : '/luci-static/design';
|
||||
var iconMap = {
|
||||
'alias': 'ethernet',
|
||||
'alias_disabled': 'ethernet_disabled',
|
||||
'bridge': 'bridge',
|
||||
'bridge_disabled': 'bridge_disabled',
|
||||
'ethernet': 'ethernet',
|
||||
'ethernet_disabled': 'ethernet_disabled',
|
||||
'switch': 'switch',
|
||||
'switch_disabled': 'switch_disabled',
|
||||
'tunnel': 'tunnel',
|
||||
'tunnel_disabled': 'tunnel_disabled',
|
||||
'vlan': 'vlan',
|
||||
'vlan_disabled': 'vlan_disabled',
|
||||
'wifi': 'wifi',
|
||||
'wifi_disabled': 'wifi_disabled',
|
||||
'signal-none': 'signal-none',
|
||||
'signal-0': 'signal-0',
|
||||
'signal-0-25': 'signal-0-25',
|
||||
'signal-25-50': 'signal-25-50',
|
||||
'signal-50-75': 'signal-50-75',
|
||||
'signal-75-100': 'signal-75-100',
|
||||
'signal-000-000': 'signal-0',
|
||||
'signal-000-025': 'signal-0-25',
|
||||
'signal-025-050': 'signal-25-50',
|
||||
'signal-050-075': 'signal-50-75',
|
||||
'signal-075-100': 'signal-75-100',
|
||||
'port_up': 'port_up',
|
||||
'port_down': 'port_down'
|
||||
};
|
||||
|
||||
if (!view || document.body.getAttribute('data-page') !== 'admin-status-overview') {
|
||||
return;
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(view.querySelectorAll('img[src*="/luci-static/resources/icons/"]'), function (img) {
|
||||
var src = img.getAttribute('src') || '';
|
||||
var match = src.match(/\/icons\/([^/?#]+)\.(?:png|svg)(?:[?#].*)?$/);
|
||||
var key = match ? match[1] : '';
|
||||
var mapped = iconMap[key];
|
||||
var badge = img.closest('.ifacebadge');
|
||||
|
||||
if (!mapped || !badge) {
|
||||
return;
|
||||
}
|
||||
|
||||
var size = key.indexOf('port_') === 0 ? '18px' :
|
||||
key.indexOf('signal-') === 0 ? '16px' : '20px';
|
||||
|
||||
img.setAttribute('src', mediaPath + '/images/' + mapped + '.png');
|
||||
img.style.setProperty('background-image', 'none', 'important');
|
||||
img.style.setProperty('visibility', 'visible', 'important');
|
||||
img.style.setProperty('opacity', '1', 'important');
|
||||
img.style.setProperty('display', 'inline-block', 'important');
|
||||
img.style.setProperty('width', size, 'important');
|
||||
img.style.setProperty('height', size, 'important');
|
||||
img.style.setProperty('min-width', size, 'important');
|
||||
img.style.setProperty('padding', '0', 'important');
|
||||
img.style.setProperty('margin', '0 .25rem 0 0', 'important');
|
||||
img.style.setProperty('vertical-align', 'middle', 'important');
|
||||
img.style.setProperty('object-fit', 'contain', 'important');
|
||||
});
|
||||
|
||||
Array.prototype.forEach.call(view.querySelectorAll('.cbi-section > div'), function (grid) {
|
||||
var isPortGrid = grid &&
|
||||
grid.style &&
|
||||
grid.style.display === 'grid' &&
|
||||
grid.style.gridTemplateColumns.indexOf('minmax(70px, 1fr)') !== -1 &&
|
||||
grid.querySelector('img[src*="/luci-static/resources/icons/port_"]');
|
||||
|
||||
if (!isPortGrid) {
|
||||
return;
|
||||
}
|
||||
|
||||
grid.classList.add('port-status-grid');
|
||||
|
||||
Array.prototype.forEach.call(grid.querySelectorAll('.ifacebox'), function (card) {
|
||||
card.classList.add('port-status-card');
|
||||
});
|
||||
});
|
||||
|
||||
Array.prototype.forEach.call(view.querySelectorAll('img[src*="/luci-static/resources/icons/port_"]'), function (img) {
|
||||
var card = img.closest('.ifacebox');
|
||||
var slot = card ? card.closest('.port-status-slot') : null;
|
||||
var parent = card ? (slot ? slot.parentElement : card.parentElement) : null;
|
||||
var iconType = (img.getAttribute('src') || '').indexOf('port_down.png') !== -1 ? 'down' : 'up';
|
||||
var badge = img.closest('.ifacebadge');
|
||||
|
||||
if (badge) {
|
||||
img.setAttribute('src', mediaPath + '/images/port_' + iconType + '.png');
|
||||
}
|
||||
|
||||
if (!card || !parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
img.setAttribute('src', mediaPath + '/images/port_' + iconType + '.png');
|
||||
img.style.setProperty('display', 'block', 'important');
|
||||
img.style.setProperty('width', '24px', 'important');
|
||||
img.style.setProperty('height', '24px', 'important');
|
||||
img.style.setProperty('padding', '0', 'important');
|
||||
img.style.setProperty('margin', '0.05rem auto', 'important');
|
||||
|
||||
if (img.nextElementSibling && img.nextElementSibling.tagName === 'BR') {
|
||||
img.nextElementSibling.style.setProperty('display', 'none', 'important');
|
||||
}
|
||||
|
||||
if (!portGroups.has(parent)) {
|
||||
portGroups.set(parent, []);
|
||||
}
|
||||
|
||||
if (portGroups.get(parent).indexOf(card) === -1) {
|
||||
portGroups.get(parent).push(card);
|
||||
}
|
||||
});
|
||||
|
||||
portGroups.forEach(function (cards, parent) {
|
||||
var width = window.innerWidth || document.documentElement.clientWidth || 1280;
|
||||
var columns;
|
||||
|
||||
cards.forEach(function (card) {
|
||||
var body = card.querySelector('.ifacebox-body');
|
||||
var slot = card.parentElement;
|
||||
|
||||
if (!slot || !slot.classList.contains('port-status-slot')) {
|
||||
slot = document.createElement('div');
|
||||
slot.className = 'port-status-slot';
|
||||
parent.insertBefore(slot, card);
|
||||
slot.appendChild(card);
|
||||
}
|
||||
|
||||
card.classList.add('port-status-card');
|
||||
|
||||
slot.style.setProperty('display', 'flex', 'important');
|
||||
slot.style.setProperty('justify-content', 'center', 'important');
|
||||
slot.style.setProperty('align-items', 'stretch', 'important');
|
||||
slot.style.setProperty('min-width', '0', 'important');
|
||||
slot.style.setProperty('padding', '0.15rem 0.65rem 0.75rem', 'important');
|
||||
|
||||
card.style.setProperty('margin', '0', 'important');
|
||||
card.style.setProperty('min-width', '76px', 'important');
|
||||
card.style.setProperty('max-width', '108px', 'important');
|
||||
card.style.setProperty('width', 'fit-content', 'important');
|
||||
card.style.setProperty('text-align', 'center', 'important');
|
||||
|
||||
if (body) {
|
||||
body.style.setProperty('text-align', 'center', 'important');
|
||||
body.style.setProperty('align-items', 'center', 'important');
|
||||
body.style.setProperty('justify-content', 'center', 'important');
|
||||
}
|
||||
});
|
||||
|
||||
if (width <= 480) {
|
||||
columns = 1;
|
||||
} else if (width <= 768) {
|
||||
columns = Math.min(cards.length, 2);
|
||||
} else if (cards.length <= 4) {
|
||||
columns = cards.length;
|
||||
} else if (cards.length <= 6) {
|
||||
columns = 3;
|
||||
} else {
|
||||
columns = 4;
|
||||
}
|
||||
|
||||
parent.style.setProperty('display', 'grid', 'important');
|
||||
parent.style.setProperty('grid-template-columns', 'repeat(' + columns + ', minmax(0, 1fr))', 'important');
|
||||
parent.style.setProperty('align-items', 'stretch', 'important');
|
||||
parent.style.setProperty('justify-items', 'stretch', 'important');
|
||||
parent.style.setProperty('width', '100%', 'important');
|
||||
parent.style.setProperty('max-width', '100%', 'important');
|
||||
parent.style.setProperty('padding', '0.2rem 0.6rem 0.35rem', 'important');
|
||||
parent.style.setProperty('margin', '0 auto 1rem', 'important');
|
||||
parent.style.setProperty('row-gap', '0.2rem', 'important');
|
||||
parent.style.setProperty('column-gap', '0', 'important');
|
||||
});
|
||||
}
|
||||
|
||||
function initOverviewPortStatus() {
|
||||
var view = document.getElementById('view');
|
||||
|
||||
if (!view || document.body.getAttribute('data-page') !== 'admin-status-overview') {
|
||||
return;
|
||||
}
|
||||
|
||||
syncOverviewPortStatus();
|
||||
|
||||
new MutationObserver(syncOverviewPortStatus).observe(view, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
function syncNetworkInterfaceIcons() {
|
||||
var view = document.getElementById('view');
|
||||
var mediaPath = (L.env && L.env.media) ? L.env.media : '/luci-static/design';
|
||||
var iconMap = {
|
||||
'alias': 'ethernet',
|
||||
'alias_disabled': 'ethernet_disabled',
|
||||
'bridge': 'bridge',
|
||||
'bridge_disabled': 'bridge_disabled',
|
||||
'ethernet': 'ethernet',
|
||||
'ethernet_disabled': 'ethernet_disabled',
|
||||
'switch': 'switch',
|
||||
'switch_disabled': 'switch_disabled',
|
||||
'tunnel': 'tunnel',
|
||||
'tunnel_disabled': 'tunnel_disabled',
|
||||
'vlan': 'vlan',
|
||||
'vlan_disabled': 'vlan_disabled',
|
||||
'wifi': 'wifi',
|
||||
'wifi_disabled': 'wifi_disabled'
|
||||
};
|
||||
|
||||
if (!view || document.body.getAttribute('data-page') !== 'admin-network-network') {
|
||||
return;
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(view.querySelectorAll('img[src*="/luci-static/resources/icons/"]'), function (img) {
|
||||
var src = img.getAttribute('src') || '';
|
||||
var match = src.match(/\/icons\/([^/?#]+)\.(?:png|svg)(?:[?#].*)?$/);
|
||||
var key = match ? match[1] : '';
|
||||
var mapped = iconMap[key];
|
||||
|
||||
if (!mapped) {
|
||||
return;
|
||||
}
|
||||
|
||||
img.setAttribute('src', mediaPath + '/images/' + mapped + '.png');
|
||||
img.classList.add('theme-network-icon');
|
||||
img.style.setProperty('background-image', 'none', 'important');
|
||||
img.style.setProperty('object-fit', 'contain', 'important');
|
||||
});
|
||||
}
|
||||
|
||||
function initNetworkInterfaceIcons() {
|
||||
var view = document.getElementById('view');
|
||||
|
||||
if (!view || document.body.getAttribute('data-page') !== 'admin-network-network') {
|
||||
return;
|
||||
}
|
||||
|
||||
syncNetworkInterfaceIcons();
|
||||
|
||||
new MutationObserver(syncNetworkInterfaceIcons).observe(view, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
function syncWirelessIcons() {
|
||||
var mediaPath = (L.env && L.env.media) ? L.env.media : '/luci-static/design';
|
||||
var iconMap = {
|
||||
'wifi': 'wifi_big',
|
||||
'wifi_disabled': 'wifi_big_disabled',
|
||||
'signal-none': 'signal-none',
|
||||
'signal-0': 'signal-0',
|
||||
'signal-0-25': 'signal-0-25',
|
||||
'signal-25-50': 'signal-25-50',
|
||||
'signal-50-75': 'signal-50-75',
|
||||
'signal-75-100': 'signal-75-100',
|
||||
'signal-000-000': 'signal-0',
|
||||
'signal-000-025': 'signal-0-25',
|
||||
'signal-025-050': 'signal-25-50',
|
||||
'signal-050-075': 'signal-50-75',
|
||||
'signal-075-100': 'signal-75-100'
|
||||
};
|
||||
|
||||
if (document.body.getAttribute('data-page') !== 'admin-network-wireless') {
|
||||
return;
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(document.querySelectorAll('img[src*="/luci-static/resources/icons/"]'), function (img) {
|
||||
var src = img.getAttribute('src') || '';
|
||||
var match = src.match(/\/icons\/([^/?#]+)\.(?:png|svg)(?:[?#].*)?$/);
|
||||
var key = match ? match[1] : '';
|
||||
var inAssocList = !!img.closest('#wifi_assoclist_table');
|
||||
var mapped = iconMap[key];
|
||||
var badge = img.closest('.ifacebadge') || img.closest('.center');
|
||||
var isDeviceIcon = (key === 'wifi' || key === 'wifi_disabled');
|
||||
var size = isDeviceIcon ? '64px' : '18px';
|
||||
|
||||
if (!mapped || !badge) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inAssocList && isDeviceIcon) {
|
||||
mapped = key;
|
||||
size = '16px';
|
||||
}
|
||||
|
||||
img.setAttribute('src', mediaPath + '/images/' + mapped + '.png');
|
||||
img.classList.add('theme-wireless-icon');
|
||||
img.style.setProperty('background-image', 'none', 'important');
|
||||
img.style.setProperty('visibility', 'visible', 'important');
|
||||
img.style.setProperty('opacity', '1', 'important');
|
||||
img.style.setProperty('display', 'inline-block', 'important');
|
||||
img.style.setProperty('width', size, 'important');
|
||||
img.style.setProperty('height', size, 'important');
|
||||
img.style.setProperty('min-width', size, 'important');
|
||||
img.style.setProperty('padding', '0', 'important');
|
||||
img.style.setProperty('margin', (inAssocList && isDeviceIcon) ? '0 .2rem 0 0' : (isDeviceIcon ? '0 .3rem 0 0' : '0 .25rem 0 0'), 'important');
|
||||
img.style.setProperty('vertical-align', 'middle', 'important');
|
||||
img.style.setProperty('object-fit', 'contain', 'important');
|
||||
});
|
||||
}
|
||||
|
||||
function initWirelessIcons() {
|
||||
if (document.body.getAttribute('data-page') !== 'admin-network-wireless') {
|
||||
return;
|
||||
}
|
||||
|
||||
syncWirelessIcons();
|
||||
|
||||
new MutationObserver(syncWirelessIcons).observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
applySafeAreaFix();
|
||||
initIndicators();
|
||||
initOverviewPortStatus();
|
||||
initNetworkInterfaceIcons();
|
||||
initWirelessIcons();
|
||||
setHeaderShadow();
|
||||
$(window).on('resize', setHeaderShadow);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -1,17 +1,73 @@
|
||||
'use strict';
|
||||
'require baseclass';
|
||||
'require request';
|
||||
'require ui';
|
||||
|
||||
// 兼容新旧版本 LuCI
|
||||
var LuciCompat = {
|
||||
isNewVersion: function() {
|
||||
return L.env.luci_version && parseFloat(L.env.luci_version.split('.')[0]) >= 23;
|
||||
}
|
||||
};
|
||||
|
||||
return baseclass.extend({
|
||||
__init__: function() {
|
||||
ui.menu.load().then(L.bind(this.render, this));
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
|
||||
if (params.get('menu') === 'flush') {
|
||||
ui.menu.flushCache();
|
||||
params.delete('menu');
|
||||
window.history.replaceState(null, '', window.location.pathname +
|
||||
(params.toString() ? '?' + params.toString() : '') +
|
||||
window.location.hash);
|
||||
}
|
||||
|
||||
this.syncConditionalMenuCache()
|
||||
.then(L.bind(function(reloading) {
|
||||
if (reloading)
|
||||
return;
|
||||
|
||||
return ui.menu.load().then(L.bind(this.render, this));
|
||||
}, this));
|
||||
},
|
||||
|
||||
reloadPageWithMenuFlush: function() {
|
||||
var url = new URL(window.location.href);
|
||||
|
||||
url.searchParams.set('menu', 'flush');
|
||||
window.location.replace(url.toString());
|
||||
},
|
||||
|
||||
getConditionalMenuStamp: function() {
|
||||
var googleFuMode = !!document.querySelector('.navbar a[href*="/admin/services/openclash"]');
|
||||
|
||||
return Promise.resolve(JSON.stringify({
|
||||
google_fu_mode: googleFuMode
|
||||
}));
|
||||
},
|
||||
|
||||
flushBackendMenuCache: function() {
|
||||
ui.menu.flushCache();
|
||||
|
||||
return L.resolveDefault(request.get(L.url('admin/services/theme_menu_flush')), null).then(function() {
|
||||
ui.menu.flushCache();
|
||||
}).then(function() {
|
||||
ui.menu.flushCache();
|
||||
});
|
||||
},
|
||||
|
||||
syncConditionalMenuCache: function() {
|
||||
var storageKey = 'design.menu.condition-stamp';
|
||||
|
||||
if (!document.body.classList.contains('logged-in'))
|
||||
return Promise.resolve();
|
||||
|
||||
return this.getConditionalMenuStamp().then(L.bind(function(stamp) {
|
||||
var previousStamp = window.localStorage.getItem(storageKey);
|
||||
|
||||
if (previousStamp === stamp)
|
||||
return false;
|
||||
|
||||
window.localStorage.setItem(storageKey, stamp);
|
||||
|
||||
return this.flushBackendMenuCache().then(L.bind(function() {
|
||||
this.reloadPageWithMenuFlush();
|
||||
return true;
|
||||
}, this));
|
||||
}, this));
|
||||
},
|
||||
|
||||
render: function(tree) {
|
||||
@@ -243,4 +299,3 @@ return baseclass.extend({
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user