mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-05-22 23:49:48 +02:00
Add files via upload
This commit is contained in:
+59
-95
@@ -3272,175 +3272,156 @@ header {
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.skills-list-with-pagination {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 90px; /* 为固定分页栏留出空间 */
|
||||
min-height: 0;
|
||||
/* 为分页组件预留空间,确保视觉连接自然 */
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.pagination-fixed {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 10;
|
||||
background: var(--bg-primary);
|
||||
border-top: 1px solid var(--border-color);
|
||||
box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
|
||||
margin-top: 0;
|
||||
padding: 0;
|
||||
/* 确保分页组件宽度与内容区域一致,不包括滚动条 */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
/* 确保分页组件不延伸到滚动条区域 */
|
||||
overflow: hidden;
|
||||
/* 当列表有滚动条时,分页组件应该与内容区域对齐 */
|
||||
position: relative;
|
||||
/* 添加四个角的圆角,与上方卡片保持一致 */
|
||||
border-radius: 8px;
|
||||
padding: 16px 24px;
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination {
|
||||
margin-top: 0;
|
||||
border-top: 1px solid var(--border-color);
|
||||
padding: 16px 20px;
|
||||
background: var(--bg-primary);
|
||||
border-top: none;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border-radius: 12px;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
/* 确保分页内容与列表内容对齐 */
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
/* 柔和的顶部边框,与列表自然分离 */
|
||||
border-top-color: rgba(233, 236, 239, 0.6);
|
||||
/* 添加四个角的圆角,与上方卡片保持一致 */
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* 左侧:信息显示和每页数量选择器 - 更自然的设计 */
|
||||
/* 左侧:信息显示 */
|
||||
.pagination-fixed .pagination-info {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
flex-wrap: wrap;
|
||||
/* 去掉背景色和边框,更自然 */
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info span {
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info .pagination-page-size {
|
||||
/* 中间:每页数量选择器 */
|
||||
.pagination-fixed .pagination-page-size {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info .pagination-page-size select {
|
||||
padding: 6px 10px;
|
||||
border-radius: 6px;
|
||||
.pagination-fixed .pagination-page-size label {
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-page-size select {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--bg-primary);
|
||||
border-radius: 8px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
min-width: 70px;
|
||||
font-weight: 500;
|
||||
/* 更柔和的边框 */
|
||||
border-color: rgba(233, 236, 239, 0.8);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info .pagination-page-size select:focus {
|
||||
.pagination-fixed .pagination-page-size select:hover {
|
||||
border-color: var(--accent-color);
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-page-size select:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent-color);
|
||||
box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info .pagination-page-size select:hover {
|
||||
border-color: var(--accent-color);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
/* 右侧:分页按钮组 - 更统一的设计 */
|
||||
/* 右侧:分页按钮组 */
|
||||
.pagination-fixed .pagination-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls .btn-secondary {
|
||||
padding: 7px 14px;
|
||||
padding: 8px 16px;
|
||||
font-size: 0.875rem;
|
||||
min-width: auto;
|
||||
transition: all 0.2s ease;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
/* 更柔和的边框 */
|
||||
border-color: rgba(233, 236, 239, 0.8);
|
||||
min-width: auto;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls .btn-secondary:hover:not(:disabled) {
|
||||
background: var(--bg-tertiary);
|
||||
border-color: var(--accent-color);
|
||||
color: var(--accent-color);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 102, 255, 0.1);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls .btn-secondary:active:not(:disabled) {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 1px 2px rgba(0, 102, 255, 0.08);
|
||||
box-shadow: 0 2px 4px rgba(0, 102, 255, 0.15);
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls .btn-secondary:disabled {
|
||||
opacity: 0.4;
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: var(--bg-secondary);
|
||||
border-color: var(--border-color);
|
||||
color: var(--text-muted);
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-page {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 500;
|
||||
padding: 0 12px;
|
||||
white-space: nowrap;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/* 响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.pagination-fixed {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination {
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-info {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-page-size {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.pagination-fixed .pagination-controls .btn-secondary {
|
||||
@@ -3448,6 +3429,10 @@ header {
|
||||
min-width: 60px;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.skills-list-with-pagination {
|
||||
padding-bottom: 140px; /* 移动端需要更多空间 */
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-info {
|
||||
@@ -3952,27 +3937,6 @@ header {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
accent-color: var(--accent-color);
|
||||
margin: 0;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* 确保复选框单元格垂直居中 */
|
||||
.monitor-table td:first-child,
|
||||
.monitor-table th:first-child {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 统一表头复选框大小 */
|
||||
#monitor-select-all {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
cursor: pointer;
|
||||
accent-color: var(--accent-color);
|
||||
margin: 0;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* 移除第一列的特殊样式,让表格更灵活 */
|
||||
|
||||
+24
-82
@@ -165,76 +165,45 @@ function renderSkillsPagination() {
|
||||
}
|
||||
|
||||
// 计算显示范围
|
||||
const start = total === 0 ? 0 : (currentPage - 1) * pageSize + 1;
|
||||
const end = total === 0 ? 0 : Math.min(currentPage * pageSize, total);
|
||||
const start = (currentPage - 1) * pageSize + 1;
|
||||
const end = Math.min(currentPage * pageSize, total);
|
||||
|
||||
let paginationHTML = '<div class="pagination">';
|
||||
|
||||
// 左侧:显示范围信息和每页数量选择器(参考MCP样式)
|
||||
// 左侧:显示范围信息
|
||||
paginationHTML += `
|
||||
<div class="pagination-info">
|
||||
<span>显示 ${start}-${end} / 共 ${total} 条</span>
|
||||
<label class="pagination-page-size">
|
||||
每页显示
|
||||
<select id="skills-page-size-pagination" onchange="changeSkillsPageSize()">
|
||||
<option value="10" ${pageSize === 10 ? 'selected' : ''}>10</option>
|
||||
<option value="20" ${pageSize === 20 ? 'selected' : ''}>20</option>
|
||||
<option value="50" ${pageSize === 50 ? 'selected' : ''}>50</option>
|
||||
<option value="100" ${pageSize === 100 ? 'selected' : ''}>100</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 中间:每页数量选择器
|
||||
paginationHTML += `
|
||||
<div class="pagination-page-size">
|
||||
<label for="skills-page-size-pagination">每页:</label>
|
||||
<select id="skills-page-size-pagination" onchange="changeSkillsPageSize()">
|
||||
<option value="10" ${pageSize === 10 ? 'selected' : ''}>10</option>
|
||||
<option value="20" ${pageSize === 20 ? 'selected' : ''}>20</option>
|
||||
<option value="50" ${pageSize === 50 ? 'selected' : ''}>50</option>
|
||||
<option value="100" ${pageSize === 100 ? 'selected' : ''}>100</option>
|
||||
</select>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 右侧:分页按钮(参考MCP样式:首页、上一页、第X/Y页、下一页、末页)
|
||||
paginationHTML += `
|
||||
<div class="pagination-controls">
|
||||
<button class="btn-secondary" onclick="loadSkills(1, ${pageSize})" ${currentPage === 1 || total === 0 ? 'disabled' : ''}>首页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(${currentPage - 1}, ${pageSize})" ${currentPage === 1 || total === 0 ? 'disabled' : ''}>上一页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(1, ${pageSize})" ${currentPage === 1 ? 'disabled' : ''}>首页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(${currentPage - 1}, ${pageSize})" ${currentPage === 1 ? 'disabled' : ''}>上一页</button>
|
||||
<span class="pagination-page">第 ${currentPage} / ${totalPages || 1} 页</span>
|
||||
<button class="btn-secondary" onclick="loadSkills(${currentPage + 1}, ${pageSize})" ${currentPage >= totalPages || total === 0 ? 'disabled' : ''}>下一页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(${totalPages || 1}, ${pageSize})" ${currentPage >= totalPages || total === 0 ? 'disabled' : ''}>末页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(${currentPage + 1}, ${pageSize})" ${currentPage >= totalPages ? 'disabled' : ''}>下一页</button>
|
||||
<button class="btn-secondary" onclick="loadSkills(${totalPages || 1}, ${pageSize})" ${currentPage >= totalPages ? 'disabled' : ''}>末页</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
paginationHTML += '</div>';
|
||||
|
||||
paginationContainer.innerHTML = paginationHTML;
|
||||
|
||||
// 确保分页组件与列表内容区域对齐(不包括滚动条)
|
||||
function alignPaginationWidth() {
|
||||
const skillsList = document.getElementById('skills-list');
|
||||
if (skillsList && paginationContainer) {
|
||||
// 获取列表的实际内容宽度(不包括滚动条)
|
||||
const listClientWidth = skillsList.clientWidth; // 可视区域宽度(不包括滚动条)
|
||||
const listScrollHeight = skillsList.scrollHeight; // 内容总高度
|
||||
const listClientHeight = skillsList.clientHeight; // 可视区域高度
|
||||
const hasScrollbar = listScrollHeight > listClientHeight;
|
||||
|
||||
// 如果列表有垂直滚动条,分页组件应该与列表内容区域对齐(clientWidth)
|
||||
// 如果没有滚动条,使用100%宽度
|
||||
if (hasScrollbar) {
|
||||
// 分页组件应该与列表内容区域对齐,不包括滚动条
|
||||
paginationContainer.style.width = `${listClientWidth}px`;
|
||||
} else {
|
||||
// 如果没有滚动条,使用100%宽度
|
||||
paginationContainer.style.width = '100%';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 立即执行一次
|
||||
alignPaginationWidth();
|
||||
|
||||
// 监听窗口大小变化和列表内容变化
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
alignPaginationWidth();
|
||||
});
|
||||
|
||||
const skillsList = document.getElementById('skills-list');
|
||||
if (skillsList) {
|
||||
resizeObserver.observe(skillsList);
|
||||
}
|
||||
}
|
||||
|
||||
// 改变每页显示数量
|
||||
@@ -492,27 +461,7 @@ async function saveSkill() {
|
||||
|
||||
// 删除skill
|
||||
async function deleteSkill(skillName) {
|
||||
// 先检查是否有角色绑定了该skill
|
||||
let boundRoles = [];
|
||||
try {
|
||||
const checkResponse = await apiFetch(`/api/skills/${encodeURIComponent(skillName)}/bound-roles`);
|
||||
if (checkResponse.ok) {
|
||||
const checkData = await checkResponse.json();
|
||||
boundRoles = checkData.bound_roles || [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('检查skill绑定失败:', error);
|
||||
// 如果检查失败,继续执行删除流程
|
||||
}
|
||||
|
||||
// 构建确认消息
|
||||
let confirmMessage = `确定要删除skill "${skillName}" 吗?此操作不可恢复。`;
|
||||
if (boundRoles.length > 0) {
|
||||
const rolesList = boundRoles.join('、');
|
||||
confirmMessage = `确定要删除skill "${skillName}" 吗?\n\n⚠️ 该skill当前已被以下 ${boundRoles.length} 个角色绑定:\n${rolesList}\n\n删除后,系统将自动从这些角色中移除该skill的绑定。\n\n此操作不可恢复,是否继续?`;
|
||||
}
|
||||
|
||||
if (!confirm(confirmMessage)) {
|
||||
if (!confirm(`确定要删除skill "${skillName}" 吗?此操作不可恢复。`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -526,14 +475,7 @@ async function deleteSkill(skillName) {
|
||||
throw new Error(error.error || '删除skill失败');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
let successMessage = 'skill已删除';
|
||||
if (data.affected_roles && data.affected_roles.length > 0) {
|
||||
const rolesList = data.affected_roles.join('、');
|
||||
successMessage = `skill已删除,已自动从 ${data.affected_roles.length} 个角色中移除绑定:${rolesList}`;
|
||||
}
|
||||
showNotification(successMessage, 'success');
|
||||
|
||||
showNotification('skill已删除', 'success');
|
||||
// 如果当前页没有数据了,回到上一页
|
||||
const currentPage = skillsPagination.currentPage;
|
||||
const totalAfterDelete = skillsPagination.total - 1;
|
||||
@@ -644,7 +586,7 @@ function renderSkillsMonitor() {
|
||||
<table class="monitor-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: left !important;">Skill名称</th>
|
||||
<th style="text-align: left;">Skill名称</th>
|
||||
<th style="text-align: center;">总调用</th>
|
||||
<th style="text-align: center;">成功</th>
|
||||
<th style="text-align: center;">失败</th>
|
||||
@@ -662,7 +604,7 @@ function renderSkillsMonitor() {
|
||||
|
||||
return `
|
||||
<tr>
|
||||
<td style="text-align: left !important;"><strong>${escapeHtml(stat.skill_name || '')}</strong></td>
|
||||
<td><strong>${escapeHtml(stat.skill_name || '')}</strong></td>
|
||||
<td style="text-align: center;">${totalCalls}</td>
|
||||
<td style="text-align: center; color: #28a745; font-weight: 500;">${successCalls}</td>
|
||||
<td style="text-align: center; color: #dc3545; font-weight: 500;">${failedCalls}</td>
|
||||
|
||||
Reference in New Issue
Block a user