feat: restrict table height to prevent scrolling and add drag-and-drop sorting

This commit is contained in:
jocayn
2026-06-13 19:17:15 +08:00
parent 807b765e2c
commit 1d23bf1773
+44 -3
View File
@@ -6,6 +6,7 @@
<title>CatMata Sub2Proxy 控制面板</title> <title>CatMata Sub2Proxy 控制面板</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<script src="https://unpkg.com/lucide@latest"></script> <script src="https://unpkg.com/lucide@latest"></script>
<script src="https://unpkg.com/sortablejs@1.15.2/Sortable.min.js"></script>
<style> <style>
:root { :root {
--bg-main: #0b0f19; --bg-main: #0b0f19;
@@ -330,11 +331,24 @@
/* Proxy Nodes view */ /* Proxy Nodes view */
.table-container { .table-container {
max-height: 480px; max-height: 380px;
overflow-y: auto; overflow-y: auto;
overflow-x: auto; overflow-x: auto;
} }
/* Sortable Dragging Styling */
.sortable-ghost {
background: rgba(139, 92, 246, 0.1) !important;
border-left: 2px solid var(--accent-purple) !important;
opacity: 0.85;
}
.drag-handle {
cursor: grab;
}
.drag-handle:active {
cursor: grabbing;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@@ -756,6 +770,7 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th style="width: 50px; text-align: center;">排序</th>
<th>解析名 (Tag)</th> <th>解析名 (Tag)</th>
<th>代理名</th> <th>代理名</th>
<th>协议 (Type)</th> <th>协议 (Type)</th>
@@ -766,7 +781,7 @@
</thead> </thead>
<tbody id="proxies-list"> <tbody id="proxies-list">
<tr> <tr>
<td colspan="6" style="text-align: center; color: var(--text-secondary); padding: 3rem;"> <td colspan="7" style="text-align: center; color: var(--text-secondary); padding: 3rem;">
请先点击右上角 “一键拉取” 按钮解析节点 请先点击右上角 “一键拉取” 按钮解析节点
</td> </td>
</tr> </tr>
@@ -938,6 +953,29 @@
updateLatestUrls(); updateLatestUrls();
loadSubscriptions(); loadSubscriptions();
loadDnsTemplates(); loadDnsTemplates();
// Initialize Sortable on proxies list
const el = document.getElementById('proxies-list');
new Sortable(el, {
handle: '.drag-handle',
animation: 150,
ghostClass: 'sortable-ghost',
onEnd: function (evt) {
const oldIndex = evt.oldIndex;
const newIndex = evt.newIndex;
if (oldIndex === newIndex) return;
if (proxies.length === 0) return;
// Update memory proxies array order
const movedItem = proxies.splice(oldIndex, 1)[0];
proxies.splice(newIndex, 0, movedItem);
// Rerender table to update button dataset index
renderProxiesTable();
log(`调整代理节点顺序:从位置 ${oldIndex + 1} 移动到 ${newIndex + 1}`);
}
});
}); });
async function loadAppConfig() { async function loadAppConfig() {
@@ -1209,7 +1247,7 @@
if (proxies.length === 0) { if (proxies.length === 0) {
list.innerHTML = ` list.innerHTML = `
<tr> <tr>
<td colspan="6" style="text-align: center; color: var(--text-secondary); padding: 3rem;"> <td colspan="7" style="text-align: center; color: var(--text-secondary); padding: 3rem;">
未提取到任何代理节点 未提取到任何代理节点
</td> </td>
</tr> </tr>
@@ -1225,6 +1263,9 @@
const server = node.server || ''; const server = node.server || '';
const port = node.port || node.server_port || ''; const port = node.port || node.server_port || '';
tr.innerHTML = ` tr.innerHTML = `
<td class="drag-handle" style="text-align: center; color: var(--text-secondary);">
<i data-lucide="grip-vertical" style="width: 16px; height: 16px;"></i>
</td>
<td style="font-weight: 500;" title="${escapeHtml(parsedName)}">${escapeHtml(parsedName)}</td> <td style="font-weight: 500;" title="${escapeHtml(parsedName)}">${escapeHtml(parsedName)}</td>
<td title="${escapeHtml(proxyName)}">${escapeHtml(proxyName)}</td> <td title="${escapeHtml(proxyName)}">${escapeHtml(proxyName)}</td>
<td><span class="node-proto proto-${escapeHtml(nodeType.toLowerCase())}">${escapeHtml(nodeType)}</span></td> <td><span class="node-proto proto-${escapeHtml(nodeType.toLowerCase())}">${escapeHtml(nodeType)}</span></td>