mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-11-17 04:17:45 +00:00
8029 lines
No EOL
356 KiB
HTML
8029 lines
No EOL
356 KiB
HTML
<!--20260913-->
|
||
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>日志分析工具</title>
|
||
<style>
|
||
/* 基础样式 */
|
||
html,
|
||
body {
|
||
background: #f8f9fa;
|
||
color: #333;
|
||
height: 100%;
|
||
margin: 0;
|
||
padding: 0;
|
||
font-family: Arial, sans-serif;
|
||
}
|
||
|
||
#container {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
/* 拖放区域样式 */
|
||
#dropZone {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: 3px dashed #ccc;
|
||
margin: 10px;
|
||
transition: background-color 0.3s;
|
||
overflow: auto;
|
||
}
|
||
|
||
#dropZone.dragover {
|
||
background-color: #f0f0f0;
|
||
border-color: #666;
|
||
}
|
||
|
||
#dropZone.empty {
|
||
font-size: 24px;
|
||
color: #666;
|
||
}
|
||
|
||
#dropZone.has-content {
|
||
padding: 20px;
|
||
align-items: flex-start;
|
||
}
|
||
|
||
/* 表格样式 */
|
||
table {
|
||
border-collapse: collapse;
|
||
width: 100%;
|
||
margin: 10px 0;
|
||
}
|
||
|
||
th,
|
||
td {
|
||
border: 1px solid #ddd;
|
||
padding: 8px;
|
||
text-align: left;
|
||
}
|
||
|
||
th {
|
||
background-color: #888;
|
||
position: sticky;
|
||
top: -20px;
|
||
z-index: 1;
|
||
}
|
||
|
||
tr:nth-child(odd) {
|
||
background-color: #eaeaea;
|
||
}
|
||
|
||
tr:nth-child(even) {
|
||
background-color: #f9f9f9;
|
||
}
|
||
|
||
/* 颜色样式 */
|
||
.red {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.dispatch-alert {
|
||
color: orange;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.pause-alert {
|
||
color: rgb(255, 0, 255);
|
||
font-weight: bold;
|
||
}
|
||
|
||
.abnormal-alert {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.purple-alert {
|
||
color: #8c8cff;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.strategy-error {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.element-missing {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.nahida-missing {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.file-missing {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.auto-potion {
|
||
color: #32CD32;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.combat-script-error {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.task-name-red {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.duration-red {
|
||
color: red;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.picks-bold {
|
||
font-weight: bold;
|
||
}
|
||
|
||
/* 折叠组样式 */
|
||
.group-header {
|
||
cursor: pointer;
|
||
display: flex;
|
||
align-items: flex-start;
|
||
padding: 10px;
|
||
background-color: #e7e7e7;
|
||
border-radius: 4px;
|
||
margin: 5px 0;
|
||
position: sticky;
|
||
top: -20px;
|
||
z-index: 20;
|
||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.group-header:hover {
|
||
background-color: #bdbebf;
|
||
}
|
||
|
||
.group-header h2 {
|
||
margin: 0;
|
||
padding: 10px 0;
|
||
font-size: 18px;
|
||
}
|
||
|
||
.arrow {
|
||
display: inline-block;
|
||
margin-right: 10px;
|
||
margin-top: 12.5px;
|
||
transition: transform 0.2s;
|
||
transform: rotate(0deg);
|
||
}
|
||
|
||
.arrow.collapsed {
|
||
transform: rotate(90deg);
|
||
}
|
||
|
||
.group-container {
|
||
margin-left: 20px;
|
||
border-left: 2px solid #dee2e6;
|
||
padding-left: 10px;
|
||
margin-bottom: 0;
|
||
position: relative;
|
||
}
|
||
|
||
.collapsible {
|
||
display: block;
|
||
}
|
||
|
||
.collapsible.collapsed {
|
||
display: none;
|
||
}
|
||
|
||
/* 表头固定样式 */
|
||
.sticky-header {
|
||
position: sticky;
|
||
top: 40px;
|
||
z-index: 3;
|
||
}
|
||
|
||
/* 队伍角色样式 */
|
||
.team-roles-row {
|
||
background-color: #888 !important;
|
||
border-bottom: 1px solid #ddd;
|
||
position: sticky;
|
||
top: 20px;
|
||
z-index: 4;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.team-roles-content {
|
||
font-family: monospace;
|
||
color: #333;
|
||
font-weight: bolder;
|
||
}
|
||
|
||
.team-role-line {
|
||
line-height: 1.4;
|
||
}
|
||
|
||
/* 单元格交互样式 */
|
||
.coords-cell {
|
||
position: relative;
|
||
cursor: default;
|
||
}
|
||
|
||
.coords-cell.has-coords {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.coords-cell.pinned::after {
|
||
content: "📌";
|
||
margin-left: 5px;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.has-battle-events {
|
||
cursor: pointer;
|
||
position: relative;
|
||
}
|
||
|
||
.has-battle-events.pinned::after {
|
||
content: "📌";
|
||
margin-left: 5px;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.no-events {
|
||
cursor: default !important;
|
||
}
|
||
|
||
/* 行高亮样式 */
|
||
tr.highlighted {
|
||
background-color: #e6f7ff !important;
|
||
}
|
||
|
||
/* 旧版格式特殊样式 */
|
||
.legacy-format .group-header {
|
||
position: sticky;
|
||
top: -20px;
|
||
z-index: 20;
|
||
background-color: #e7e7e7;
|
||
margin: 5px 0;
|
||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.legacy-format .sticky-header {
|
||
position: sticky;
|
||
top: 40px;
|
||
z-index: 3;
|
||
}
|
||
|
||
.legacy-format .team-roles-row {
|
||
position: sticky;
|
||
top: 20px;
|
||
z-index: 4;
|
||
}
|
||
|
||
.legacy-format .main-row-name {
|
||
background-color: #f0f0f0;
|
||
}
|
||
|
||
.legacy-format .sub-row {
|
||
background-color: #f9f9f9;
|
||
}
|
||
|
||
.legacy-format .ignore-sort {
|
||
background-color: #e0e0e0;
|
||
}
|
||
|
||
.ignore-sort {
|
||
font-weight: normal;
|
||
}
|
||
|
||
/* 弹窗样式 */
|
||
.coord-popup,
|
||
.battle-popup {
|
||
display: none;
|
||
position: fixed;
|
||
background-color: #f9f9f9;
|
||
border: 1px solid #ccc;
|
||
border-radius: 5px;
|
||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
|
||
z-index: 10000;
|
||
max-width: 250px;
|
||
font-size: 14px;
|
||
cursor: default;
|
||
user-select: text;
|
||
}
|
||
|
||
.coord-popup.visible,
|
||
.battle-popup.visible {
|
||
display: block;
|
||
}
|
||
|
||
.coord-popup-header,
|
||
.battle-popup-header {
|
||
background-color: #eee;
|
||
padding: 8px 12px;
|
||
border-bottom: 1px solid #ccc;
|
||
cursor: move;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
}
|
||
|
||
.coord-popup-title,
|
||
.battle-popup-title {
|
||
font-weight: bold;
|
||
}
|
||
|
||
.close-btn {
|
||
cursor: pointer;
|
||
font-size: 18px;
|
||
color: #999;
|
||
padding: 0 5px;
|
||
}
|
||
|
||
.close-btn:hover {
|
||
color: #000;
|
||
}
|
||
|
||
.coord-popup-content,
|
||
.battle-popup-content {
|
||
padding: 10px;
|
||
max-height: 300px;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.coord-popup .coord-item,
|
||
.battle-popup .battle-item {
|
||
margin: 5px 0;
|
||
padding: 3px 0;
|
||
border-bottom: 1px dashed #ddd;
|
||
}
|
||
|
||
.coord-popup .coord-item:last-child,
|
||
.battle-popup .battle-item:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
/* 移动设备上传区域 */
|
||
#fileUploadContainer {
|
||
display: none;
|
||
flex-direction: column;
|
||
gap: 15px;
|
||
padding: 15px;
|
||
border: 2px dashed #ccc;
|
||
border-radius: 8px;
|
||
background-color: #f9f9f9;
|
||
margin: 10px;
|
||
align-items: center;
|
||
}
|
||
|
||
#fileUploadBtn {
|
||
padding: 12px 24px;
|
||
background-color: #4CAF50;
|
||
color: white;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 16px;
|
||
transition: background-color 0.3s;
|
||
width: 100%;
|
||
max-width: 300px;
|
||
}
|
||
|
||
#fileUploadBtn:hover {
|
||
background-color: #45a049;
|
||
}
|
||
|
||
#fileInput {
|
||
display: none;
|
||
}
|
||
|
||
/* 移动设备控制按钮 */
|
||
#mobileControls {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
margin: 8px 0px;
|
||
gap: 8px;
|
||
width: 100%;
|
||
}
|
||
|
||
.control-btn {
|
||
padding: 8px 12px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 4px;
|
||
background-color: #f0f0f0;
|
||
cursor: pointer;
|
||
font-size: 14px;
|
||
transition: all 0.3s;
|
||
flex: 1;
|
||
min-width: 80px;
|
||
text-align: center;
|
||
}
|
||
|
||
.control-btn.active {
|
||
background-color: #4CAF50;
|
||
color: white;
|
||
border-color: #4CAF50;
|
||
font-weight: bold;
|
||
}
|
||
|
||
.control-btn:nth-child(1).active {
|
||
background-color: #ff9800;
|
||
border-color: #ff9800;
|
||
}
|
||
|
||
.control-btn:nth-child(2).active {
|
||
background-color: #2196F3;
|
||
border-color: #2196F3;
|
||
}
|
||
|
||
.control-btn:nth-child(3).active {
|
||
background-color: #2196F3;
|
||
border-color: #2196F3;
|
||
}
|
||
|
||
.control-btn:nth-child(4).active {
|
||
background-color: #2196F3;
|
||
border-color: #2196F3;
|
||
}
|
||
|
||
.control-btn:nth-child(5).active {
|
||
background-color: #9C27B0;
|
||
border-color: #9C27B0;
|
||
}
|
||
|
||
.control-btn:nth-child(6).active {
|
||
background-color: #f44336;
|
||
border-color: #f44336;
|
||
}
|
||
|
||
.control-btn:nth-child(7).active {
|
||
background-color: #FF9800;
|
||
border-color: #FF9800;
|
||
}
|
||
|
||
.control-btn:nth-child(8).active {
|
||
background-color: #4CAF50;
|
||
border-color: #4CAF50;
|
||
color: white;
|
||
}
|
||
|
||
.control-btn:nth-child(9).active {
|
||
background-color: #1976D2;
|
||
border-color: #1976D2;
|
||
}
|
||
|
||
/* 快速导航菜单 */
|
||
.quick-nav {
|
||
position: fixed;
|
||
top: 60px;
|
||
right: 10px;
|
||
background: rgba(255, 255, 255, 0.95);
|
||
border: 1px solid #ccc;
|
||
border-radius: 8px;
|
||
padding: 10px;
|
||
overflow-y: auto;
|
||
z-index: 1000;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||
display: none;
|
||
flex-direction: column;
|
||
min-width: 250px;
|
||
max-width: 300px;
|
||
max-height: 70vh;
|
||
}
|
||
|
||
.quick-nav.visible {
|
||
display: flex;
|
||
}
|
||
|
||
.quick-nav-header {
|
||
font-weight: bold;
|
||
margin-bottom: 8px;
|
||
padding-bottom: 5px;
|
||
border-bottom: 1px solid #ddd;
|
||
text-align: center;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.quick-nav-item {
|
||
padding: 6px 8px;
|
||
margin: 2px 0;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 12px;
|
||
transition: background-color 0.2s;
|
||
word-break: break-word;
|
||
}
|
||
|
||
.quick-nav-item:hover {
|
||
background-color: #e0e0e0;
|
||
}
|
||
|
||
.quick-nav-item.active {
|
||
background-color: #4CAF50;
|
||
color: white;
|
||
}
|
||
|
||
.quick-nav-search {
|
||
width: 100%;
|
||
padding: 6px;
|
||
margin-bottom: 8px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 4px;
|
||
font-size: 12px;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.quick-nav-toggle {
|
||
position: fixed;
|
||
top: 10px;
|
||
right: 10px;
|
||
background: rgba(255, 255, 255, 0.95);
|
||
border: 1px solid #ccc;
|
||
border-radius: 4px;
|
||
padding: 8px 12px;
|
||
cursor: pointer;
|
||
z-index: 1001;
|
||
font-size: 14px;
|
||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||
transition: all 0.3s;
|
||
display: none;
|
||
}
|
||
|
||
.quick-nav-toggle:hover {
|
||
background: rgba(255, 255, 255, 1);
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||
}
|
||
|
||
#quickNavTotalTime {
|
||
font-size: 12px;
|
||
color: #333;
|
||
padding: 6px 8px;
|
||
text-align: center;
|
||
border-bottom: 1px solid #ddd;
|
||
background-color: #f5f5f5;
|
||
flex-shrink: 0;
|
||
/* 防止被壓縮 */
|
||
}
|
||
|
||
#quickNavTotalTimeValue {
|
||
font-weight: bold;
|
||
color: #333;
|
||
}
|
||
|
||
/* 暗色主題下的樣式 */
|
||
body.dark-theme #quickNavTotalTime {
|
||
background-color: #333;
|
||
color: #ffffff;
|
||
border-bottom-color: #555;
|
||
}
|
||
|
||
body.dark-theme #quickNavTotalTimeValue {
|
||
color: #ffffff;
|
||
}
|
||
|
||
/* 状态指示器 */
|
||
.mode-indicator {
|
||
position: fixed;
|
||
top: 10px;
|
||
left: 10px;
|
||
background-color: rgba(76, 175, 80, 0.8);
|
||
color: white;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
font-size: 14px;
|
||
z-index: 10000;
|
||
display: none;
|
||
}
|
||
|
||
.filter-indicator {
|
||
position: fixed;
|
||
top: 10px;
|
||
left: 10px;
|
||
background-color: rgba(255, 165, 0, 0.9);
|
||
color: white;
|
||
padding: 8px 12px;
|
||
border-radius: 4px;
|
||
font-size: 14px;
|
||
z-index: 10000;
|
||
display: none;
|
||
max-width: 300px;
|
||
word-wrap: break-word;
|
||
}
|
||
|
||
.filter-indicator.visible {
|
||
display: block;
|
||
}
|
||
|
||
.filter-indicator .filter-keywords {
|
||
font-weight: bold;
|
||
color: #ffeb3b;
|
||
}
|
||
|
||
.time-toggle-indicator,
|
||
.stats-toggle-indicator {
|
||
position: fixed;
|
||
bottom: 10px;
|
||
right: 10px;
|
||
background-color: rgba(0, 0, 0, 0.7);
|
||
color: white;
|
||
padding: 5px 10px;
|
||
border-radius: 5px;
|
||
font-size: 12px;
|
||
z-index: 1000;
|
||
opacity: 0;
|
||
transition: opacity 0.5s;
|
||
}
|
||
|
||
.time-toggle-indicator.visible,
|
||
.stats-toggle-indicator.visible {
|
||
opacity: 1;
|
||
}
|
||
|
||
.help-indicator {
|
||
position: fixed;
|
||
bottom: 20px;
|
||
right: 20px;
|
||
padding: 10px 15px;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
z-index: 1000;
|
||
opacity: 0;
|
||
transition: opacity 0.5s;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||
background-color: #000;
|
||
color: #fff;
|
||
pointer-events: none;
|
||
/* 隐藏后不接受鼠标事件 */
|
||
user-select: none;
|
||
/* 禁止选择文本 */
|
||
}
|
||
|
||
.help-indicator.visible {
|
||
opacity: 1;
|
||
}
|
||
|
||
/* 弹窗和自定义提示 */
|
||
.custom-alert {
|
||
position: fixed;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
background-color: white;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
||
z-index: 10000;
|
||
min-width: 300px;
|
||
text-align: center;
|
||
display: none;
|
||
}
|
||
|
||
.custom-alert h3 {
|
||
margin-top: 0;
|
||
color: #333;
|
||
}
|
||
|
||
.custom-alert-buttons {
|
||
display: flex;
|
||
justify-content: center;
|
||
gap: 10px;
|
||
margin-top: 20px;
|
||
}
|
||
|
||
.custom-alert-btn {
|
||
padding: 8px 16px;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.custom-alert-confirm {
|
||
background-color: #4CAF50;
|
||
color: white;
|
||
}
|
||
|
||
.custom-alert-cancel {
|
||
background-color: #f44336;
|
||
color: white;
|
||
}
|
||
|
||
.overlay {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
background-color: rgba(0, 0, 0, 0.5);
|
||
z-index: 9999;
|
||
display: none;
|
||
}
|
||
|
||
/* 显示/隐藏状态类 */
|
||
.time-columns-hidden .column-start-time,
|
||
.time-columns-hidden .column-end-time {
|
||
display: none;
|
||
}
|
||
|
||
.stats-columns-hidden .column-revive,
|
||
.stats-columns-hidden .column-retry,
|
||
.stats-columns-hidden .column-retry-detail,
|
||
.stats-columns-hidden .column-too-far-skip,
|
||
.stats-columns-hidden .column-timeout,
|
||
.stats-columns-hidden .column-teleport {
|
||
display: none;
|
||
}
|
||
|
||
.picks-columns-hidden .column-picks {
|
||
display: none;
|
||
}
|
||
|
||
.static-mode .mode-indicator {
|
||
display: block;
|
||
}
|
||
|
||
.static-mode .coord-popup,
|
||
.static-mode .battle-popup {
|
||
display: block !important;
|
||
position: static !important;
|
||
margin: 10px 0;
|
||
box-shadow: none;
|
||
max-width: 100%;
|
||
max-height: none;
|
||
}
|
||
|
||
.static-mode .coord-popup-header,
|
||
.static-mode .battle-popup-header {
|
||
cursor: default;
|
||
background-color: #e0e0e0;
|
||
}
|
||
|
||
.static-mode .close-btn {
|
||
display: none;
|
||
}
|
||
|
||
.static-mode .coords-cell,
|
||
.static-mode .has-battle-events {
|
||
cursor: default;
|
||
}
|
||
|
||
.static-mode .coords-cell.pinned::after,
|
||
.static-mode .has-battle-events.pinned::after {
|
||
content: "";
|
||
}
|
||
|
||
/* 暗色主题 */
|
||
body.dark-theme {
|
||
background-color: #121212;
|
||
color: #ffffff;
|
||
}
|
||
|
||
body.dark-theme #dropZone {
|
||
border-color: #666;
|
||
background-color: #1e1e1e;
|
||
}
|
||
|
||
body.dark-theme table {
|
||
border-color: #444;
|
||
}
|
||
|
||
body.dark-theme th,
|
||
body.dark-theme td {
|
||
border-color: #444;
|
||
}
|
||
|
||
body.dark-theme th {
|
||
background-color: #888;
|
||
}
|
||
|
||
body.dark-theme tr:nth-child(odd) {
|
||
background-color: #2a2a2a;
|
||
}
|
||
|
||
body.dark-theme tr:nth-child(even) {
|
||
background-color: #1e1e1e;
|
||
}
|
||
|
||
body.dark-theme .group-header {
|
||
background-color: #333;
|
||
color: #ffffff;
|
||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
||
}
|
||
|
||
body.dark-theme .group-header:hover {
|
||
background-color: #444;
|
||
}
|
||
|
||
body.dark-theme .red {
|
||
color: #ff6666;
|
||
}
|
||
|
||
body.dark-theme .coord-popup {
|
||
background-color: #333;
|
||
border: 1px solid #666;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .coord-popup-header {
|
||
background-color: #444;
|
||
border-bottom: 1px solid #555;
|
||
}
|
||
|
||
body.dark-theme .close-btn {
|
||
color: #ccc;
|
||
}
|
||
|
||
body.dark-theme .close-btn:hover {
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .coord-popup .coord-item {
|
||
border-bottom: 1px dashed #555;
|
||
}
|
||
|
||
body.dark-theme .battle-popup {
|
||
background-color: #333;
|
||
border: 1px solid #666;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .battle-popup-header {
|
||
background-color: #444;
|
||
border-bottom: 1px solid #555;
|
||
}
|
||
|
||
body.dark-theme .battle-popup .battle-item {
|
||
border-bottom: 1px dashed #555;
|
||
}
|
||
|
||
body.dark-theme #fileUploadContainer {
|
||
background-color: #2a2a2a;
|
||
border-color: #555;
|
||
}
|
||
|
||
body.dark-theme .control-btn {
|
||
background-color: #333;
|
||
color: #fff;
|
||
border-color: #555;
|
||
}
|
||
|
||
body.dark-theme .quick-nav {
|
||
background: rgba(50, 50, 50, 0.95);
|
||
border-color: #666;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .quick-nav-header {
|
||
border-bottom-color: #666;
|
||
}
|
||
|
||
body.dark-theme .quick-nav-item:hover {
|
||
background-color: #555;
|
||
}
|
||
|
||
body.dark-theme .quick-nav-search {
|
||
background-color: #333;
|
||
border-color: #666;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .quick-nav-toggle {
|
||
background: rgba(50, 50, 50, 0.95);
|
||
border-color: #666;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .quick-nav-toggle:hover {
|
||
background: rgba(50, 50, 50, 1);
|
||
}
|
||
|
||
body.dark-theme .filter-indicator {
|
||
background-color: rgba(255, 140, 0, 0.9);
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .filter-indicator .filter-keywords {
|
||
color: #fff59d;
|
||
}
|
||
|
||
body.dark-theme .mode-indicator {
|
||
background-color: rgba(56, 142, 60, 0.8);
|
||
}
|
||
|
||
body.dark-theme .custom-alert {
|
||
background-color: #333;
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .custom-alert h3 {
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .legacy-format .group-header {
|
||
background-color: #333;
|
||
}
|
||
|
||
body.dark-theme .legacy-format .main-row-name {
|
||
background-color: #2a2a2a;
|
||
}
|
||
|
||
body.dark-theme .legacy-format .sub-row {
|
||
background-color: #1e1e1e;
|
||
}
|
||
|
||
body.dark-theme .legacy-format .ignore-sort {
|
||
background-color: #333;
|
||
}
|
||
|
||
body.dark-theme .team-roles-row {
|
||
background-color: #888 !important;
|
||
}
|
||
|
||
body.dark-theme .team-roles-content {
|
||
color: #ffffff;
|
||
}
|
||
|
||
body.dark-theme .team-role-line {
|
||
color: #ffffff;
|
||
}
|
||
|
||
body.dark-theme tr.highlighted {
|
||
background-color: #3a3a3a !important;
|
||
}
|
||
|
||
body.dark-theme .help-indicator {
|
||
background-color: #fff;
|
||
color: #000;
|
||
}
|
||
|
||
/* 移动设备响应式 */
|
||
@media (max-width: 0px),
|
||
(pointer: coarse) {
|
||
body {
|
||
text-size-adjust: none;
|
||
-webkit-text-size-adjust: none;
|
||
}
|
||
|
||
.task-name-red,
|
||
.main-row-name,
|
||
.group-header h2 {
|
||
font-size: 16px;
|
||
line-height: 1.4;
|
||
text-size-adjust: none;
|
||
-webkit-text-size-adjust: none;
|
||
}
|
||
|
||
table {
|
||
font-size: 14px;
|
||
}
|
||
|
||
th,
|
||
td {
|
||
padding: 6px 4px;
|
||
}
|
||
|
||
#mobileControls {
|
||
flex-wrap: wrap;
|
||
max-height: 88px;
|
||
overflow: hidden;
|
||
gap: 4px;
|
||
}
|
||
|
||
.control-btn {
|
||
flex: 0 0 calc(19.5% - 6px);
|
||
min-width: calc(19.5% - 6px);
|
||
font-size: 12px;
|
||
padding: 6px 8px;
|
||
margin: 2px;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.quick-nav {
|
||
top: 50px;
|
||
right: 5px;
|
||
left: auto;
|
||
max-width: calc(100vw - 20px);
|
||
}
|
||
|
||
.quick-nav-toggle {
|
||
top: 5px;
|
||
right: 5px;
|
||
padding: 6px 10px;
|
||
font-size: 12px;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 400px) {
|
||
#mobileControls {
|
||
max-height: 80px;
|
||
gap: 2px;
|
||
}
|
||
|
||
.control-btn {
|
||
flex: 0 0 calc(19.5% - 4px);
|
||
min-width: calc(19.5% - 4px);
|
||
font-size: 11px;
|
||
padding: 4px 6px;
|
||
}
|
||
}
|
||
|
||
/* 显示控制类 */
|
||
#fileUploadContainer.visible {
|
||
display: flex;
|
||
}
|
||
|
||
#fileUploadContainer.hidden {
|
||
display: none !important;
|
||
}
|
||
|
||
.filter-indicator.visible {
|
||
display: block;
|
||
}
|
||
|
||
.time-toggle-indicator.visible {
|
||
opacity: 1;
|
||
}
|
||
|
||
.stats-toggle-indicator.visible {
|
||
opacity: 1;
|
||
}
|
||
|
||
.help-indicator.visible {
|
||
opacity: 1;
|
||
}
|
||
|
||
.quick-nav-toggle {
|
||
display: none;
|
||
}
|
||
|
||
.static-mode .mode-indicator {
|
||
display: block;
|
||
}
|
||
|
||
/* 特殊布局调整 */
|
||
.filter-indicator.visible~.mode-indicator.static-mode {
|
||
left: calc(var(--filter-indicator-width) + 20px);
|
||
}
|
||
|
||
body.static-mode .team-role-line,
|
||
body.filter-mode .team-role-line {
|
||
text-align: center;
|
||
}
|
||
|
||
.team-role-line {
|
||
text-align: left;
|
||
}
|
||
|
||
/* 快速导航内部布局 */
|
||
#quickNavItems {
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
padding: 5px 0;
|
||
}
|
||
|
||
.quick-nav-header,
|
||
.quick-nav-search {
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* 确保两个输入框之间有适当间距 */
|
||
#quickNavExclude {
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
/* 確保在新版和舊版格式下排序按鈕樣式一致 */
|
||
.sort-btn {
|
||
position: absolute;
|
||
right: 5px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
font-size: 10px;
|
||
padding: 2px 5px;
|
||
cursor: pointer;
|
||
border-radius: 3px;
|
||
min-width: 20%;
|
||
text-align: center;
|
||
}
|
||
|
||
/* 針對新版格式的排序按鈕 */
|
||
table:not(.legacy-format) .sort-btn {
|
||
position: absolute;
|
||
right: 5px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
font-size: 10px;
|
||
padding: 2px 5px;
|
||
cursor: pointer;
|
||
border-radius: 3px;
|
||
color: #333;
|
||
min-width: 20%;
|
||
text-align: center;
|
||
background-color: rgba(0, 0, 0, 0);
|
||
border: 1px solid rgba(0, 0, 0, 0);
|
||
font-family: inherit;
|
||
}
|
||
|
||
/* 針對舊版格式的排序按鈕 */
|
||
.legacy-format .sort-btn {
|
||
position: absolute;
|
||
right: 5px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
font-size: 10px;
|
||
padding: 2px 5px;
|
||
cursor: pointer;
|
||
border-radius: 3px;
|
||
color: #333;
|
||
min-width: 20%;
|
||
text-align: center;
|
||
background-color: rgba(0, 0, 0, 0);
|
||
border: 1px solid rgba(0, 0, 0, 0);
|
||
font-family: inherit;
|
||
}
|
||
|
||
/* 暗色主題下的排序按鈕樣式 */
|
||
body.dark-theme .sort-btn {
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme table:not(.legacy-format) .sort-btn {
|
||
color: #fff;
|
||
}
|
||
|
||
body.dark-theme .legacy-format .sort-btn {
|
||
color: #fff;
|
||
}
|
||
|
||
/* 任务数量显示样式 */
|
||
.task-count {
|
||
float: right;
|
||
font-size: 12px;
|
||
font-weight: normal;
|
||
}
|
||
|
||
/* 时间筛选模式样式 */
|
||
.time-filter-mode .filter-indicator {
|
||
background-color: #1976D2;
|
||
}
|
||
|
||
.time-filter-mode .filter-keywords {
|
||
font-weight: bold;
|
||
color: #ffeb3b;
|
||
}
|
||
|
||
/* 暗色主题适配 */
|
||
.dark-theme.time-filter-mode .filter-indicator {
|
||
background-color: #1976D2;
|
||
}
|
||
|
||
.dark-theme.time-filter-mode .filter-keywords {
|
||
color: #ffeb3b;
|
||
;
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body>
|
||
<!-- 篩選狀態提示 -->
|
||
<div class="filter-indicator" id="filterIndicator">
|
||
<span>正在篩選: </span>
|
||
<span class="filter-keywords" id="filterKeywords"></span>
|
||
<br><small>按 H 鍵退出篩選</small>
|
||
</div>
|
||
<div class="mode-indicator">静态模式 <br><small>请 另存新档 或 截圖 分享页面</small></div>
|
||
|
||
<div id="container">
|
||
<div id="dropZone" class="empty">将日志文件拖放到此处</div>
|
||
<!-- 上传区域 -->
|
||
<div id="fileUploadContainer">
|
||
<!-- 上层:选择文件按钮 -->
|
||
<div>
|
||
<input type="file" id="fileInput" accept=".log,.txt" multiple>
|
||
<button id="fileUploadBtn">选择日志文件</button>
|
||
</div>
|
||
|
||
<!-- 下层:功能按钮 -->
|
||
<div id="mobileControls">
|
||
<button class="control-btn" data-key="192">切换颜色</button>
|
||
<button class="control-btn" data-key="84">时间列</button>
|
||
<button class="control-btn" data-key="89">统计列</button>
|
||
<button class="control-btn" data-key="73">拾取物列</button>
|
||
<!-- <button class="control-btn" data-key="79">拾取效率</button> -->
|
||
<button class="control-btn" data-key="80">导出模式</button>
|
||
<button class="control-btn" data-key="74">异常任务</button>
|
||
<button class="control-btn" data-key="72">任務篩選</button>
|
||
<button class="control-btn" data-key="77">统计拾取物</button>
|
||
<button class="control-btn" data-key="100">时间筛选模式</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 自定义提示框 -->
|
||
<div class="overlay" id="alertOverlay"></div>
|
||
<div class="custom-alert" id="customAlert">
|
||
<h3 id="alertTitle">确认操作</h3>
|
||
<p id="alertMessage">您确定要执行此操作吗?</p>
|
||
<div class="custom-alert-buttons">
|
||
<button class="custom-alert-btn custom-alert-confirm" id="alertConfirm">确定</button>
|
||
<button class="custom-alert-btn custom-alert-cancel" id="alertCancel">取消</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 时间列显示状态指示器 -->
|
||
<div class="time-toggle-indicator" id="timeToggleIndicator"></div>
|
||
<!-- 统计列显示状态指示器 -->
|
||
<div class="stats-toggle-indicator" id="statsToggleIndicator"></div>
|
||
<!-- 表格格式显示状态指示器 -->
|
||
<div class="stats-toggle-indicator" id="formatToggleIndicator"></div>
|
||
<!-- 在HTML中添加拾取物列显示状态指示器 -->
|
||
<div class="stats-toggle-indicator" id="picksToggleIndicator"></div>
|
||
<!-- 在HTML中添加零统计任务显示状态指示器 -->
|
||
<div class="stats-toggle-indicator" id="zeroStatsToggleIndicator"></div>
|
||
<!-- 帮助提示指示器 -->
|
||
<div class="help-indicator" id="helpIndicator">按 0 或 F1 键查看说明</div>
|
||
|
||
<!-- 快速导航切换按钮 -->
|
||
<div class="quick-nav-toggle" id="quickNavToggle" style="display: none;">📋 导航</div>
|
||
|
||
<!-- 快速导航菜单 -->
|
||
<div class="quick-nav" id="quickNav">
|
||
<div class="quick-nav-header">配置组导航</div>
|
||
<input type="text" class="quick-nav-search" id="quickNavSearch" placeholder="搜索配置组...">
|
||
<!-- 排除输入框 -->
|
||
<input type="text" class="quick-nav-search" id="quickNavExclude" placeholder="排除配置组...">
|
||
<!-- 总时长显示 -->
|
||
<div id="quickNavTotalTime"
|
||
style="padding: 5px 8px; font-size: 12px; color: #666; border-bottom: 1px solid #ddd; text-align: center;">
|
||
总时长: <span id="quickNavTotalTimeValue">0</span>
|
||
</div>
|
||
<div id="quickNavItems"></div>
|
||
</div>
|
||
|
||
<script>
|
||
// 全局变量
|
||
let lastValidTime = null;
|
||
let timeColumnsVisible = true; // 跟踪时间列的显示状态
|
||
let statsColumnsVisible = true; // 跟踪统计列的显示状态
|
||
let useLegacyFormat = false; // 跟踪表格格式状态
|
||
let picksColumnsVisible = true; // 跟踪拾取物列的显示状态
|
||
let hasLogData = false; // 跟踪是否有日志数据
|
||
let hideZeroStatsTasks = false; // 跟踪是否隐藏所有统计为0的任务
|
||
let isStaticMode = false;
|
||
// 添加上传区域显示状态变量
|
||
let uploadContainerVisible = false; // 电脑设备上上传区域的显示状态
|
||
|
||
let controlButtons = {}; // 存储按钮状态
|
||
let isFilterMode = false; // 跟踪篩選模式狀態
|
||
let currentFilterKeywords = []; // 當前篩選關鍵字
|
||
let currentExcludeGroupKeywords = []; // 當前排除的配置組關鍵字
|
||
|
||
let isAdjustingTableHeader = false;
|
||
let lastAdjustmentTime = 0;
|
||
const ADJUSTMENT_THROTTLE = 100; // 100ms节流
|
||
let currentExcludeText = ''; // 保存当前的排除文本
|
||
|
||
let currentPickEfficiencyItem = null; // 当前计算的拾取物
|
||
let isPickEfficiencyMode = false; // 是否处于拾取效率模式
|
||
|
||
let picksSortByCount = true; // true: 按数量排序, false: 按拾取顺序
|
||
let currentSortState = 0; // 0:读取顺序, 1:时间排序, 2:耗时升序, 3:耗时降序
|
||
|
||
let isTimeFilterMode = false; // 时间筛选模式
|
||
let timeFilterStart = null; // 筛选开始时间
|
||
let timeFilterEnd = null; // 筛选结束时间
|
||
|
||
// 特殊事件关键字(用于 J 键隐藏零统计时保留)
|
||
const SPECIAL_EVENT_KEYWORDS = ['自动吃药', '使用复活料理', '使用回血料理', '终点坐标异常,不记录',"资源缺失,请重新安装BGI"];
|
||
|
||
// 黑名單关键字
|
||
const BLACKLIST_KEYWORDS = [
|
||
// 'HTML 配置面板',
|
||
];
|
||
let blacklistDetected;
|
||
|
||
|
||
// 自定义确认对话框
|
||
function showCustomConfirm(title, message) {
|
||
return new Promise((resolve) => {
|
||
const alert = document.getElementById('customAlert');
|
||
const overlay = document.getElementById('alertOverlay');
|
||
const titleEl = document.getElementById('alertTitle');
|
||
const messageEl = document.getElementById('alertMessage');
|
||
const confirmBtn = document.getElementById('alertConfirm');
|
||
const cancelBtn = document.getElementById('alertCancel');
|
||
|
||
// 设置标题和消息
|
||
titleEl.textContent = title;
|
||
messageEl.textContent = message;
|
||
|
||
// 显示对话框
|
||
alert.style.display = 'block';
|
||
overlay.style.display = 'block';
|
||
|
||
// 键盘事件处理函数
|
||
const handleKeyPress = (e) => {
|
||
if (e.key === 'Enter') {
|
||
onConfirm();
|
||
} else if (e.key === 'Escape') {
|
||
onCancel();
|
||
}
|
||
};
|
||
|
||
// 处理确认按钮点击
|
||
const onConfirm = () => {
|
||
cleanup();
|
||
resolve(true);
|
||
};
|
||
|
||
// 处理取消按钮点击
|
||
const onCancel = () => {
|
||
cleanup();
|
||
resolve(false);
|
||
};
|
||
|
||
// 清理事件监听器
|
||
const cleanup = () => {
|
||
confirmBtn.removeEventListener('click', onConfirm);
|
||
cancelBtn.removeEventListener('click', onCancel);
|
||
overlay.removeEventListener('click', onCancel);
|
||
document.removeEventListener('keydown', handleKeyPress);
|
||
alert.style.display = 'none';
|
||
overlay.style.display = 'none';
|
||
};
|
||
|
||
// 添加事件监听器
|
||
confirmBtn.addEventListener('click', onConfirm);
|
||
cancelBtn.addEventListener('click', onCancel);
|
||
overlay.addEventListener('click', onCancel);
|
||
document.addEventListener('keydown', handleKeyPress);
|
||
});
|
||
}
|
||
|
||
// 导出为静态HTML
|
||
function exportAsStaticHTML() {
|
||
// 打开所有弹窗并将其内容内联显示
|
||
document.querySelectorAll('.coord-popup, .battle-popup').forEach(popup => {
|
||
popup.style.display = 'block';
|
||
popup.style.position = 'static';
|
||
popup.style.boxShadow = 'none';
|
||
popup.style.margin = '10px 0';
|
||
popup.style.maxWidth = '100%';
|
||
popup.style.maxHeight = 'none';
|
||
|
||
// 移除关闭按钮
|
||
const closeBtn = popup.querySelector('.close-btn');
|
||
if (closeBtn) closeBtn.style.display = 'none';
|
||
});
|
||
|
||
// 禁用所有交互元素
|
||
document.querySelectorAll('.coords-cell, .has-battle-events').forEach(cell => {
|
||
cell.style.cursor = 'default';
|
||
});
|
||
|
||
// 添加静态模式类
|
||
document.body.classList.add('static-mode');
|
||
const modeIndicator = document.querySelector('.mode-indicator');
|
||
if (modeIndicator) {
|
||
modeIndicator.classList.add('static-mode');
|
||
}
|
||
isStaticMode = true;
|
||
|
||
// 添加static-mode类到body
|
||
document.body.classList.add('static-mode');
|
||
|
||
// 显示提示信息
|
||
updateButtonState(80);
|
||
// alert("页面已转换为静态模式,请使用浏览器的\"另存新档\"功能(Ctrl+S)保存网页。");
|
||
}
|
||
|
||
// 恢复交互模式
|
||
function restoreInteractiveMode() {
|
||
// 隐藏所有弹窗
|
||
document.querySelectorAll('.coord-popup, .battle-popup').forEach(popup => {
|
||
popup.style.display = '';
|
||
popup.style.position = '';
|
||
popup.style.boxShadow = '';
|
||
popup.style.margin = '';
|
||
popup.style.maxWidth = '';
|
||
popup.style.maxHeight = '';
|
||
|
||
// 恢复关闭按钮
|
||
const closeBtn = popup.querySelector('.close-btn');
|
||
if (closeBtn) closeBtn.style.display = '';
|
||
});
|
||
|
||
// 恢复交互元素
|
||
document.querySelectorAll('.coords-cell.has-coords, .has-battle-events').forEach(cell => {
|
||
cell.style.cursor = 'pointer';
|
||
});
|
||
|
||
// 移除静态模式类
|
||
document.body.classList.remove('static-mode');
|
||
const modeIndicator = document.querySelector('.mode-indicator');
|
||
if (modeIndicator) {
|
||
modeIndicator.classList.remove('static-mode');
|
||
}
|
||
isStaticMode = false;
|
||
|
||
// 移除static-mode类
|
||
document.body.classList.remove('static-mode');
|
||
|
||
// 重新初始化弹窗
|
||
if (window.setupCoordPopups) {
|
||
setupCoordPopups();
|
||
}
|
||
}
|
||
|
||
// 处理P键按下事件
|
||
function handlePKey() {
|
||
if (isStaticMode) {
|
||
// 静态模式下直接恢复交互模式
|
||
restoreInteractiveMode();
|
||
} else {
|
||
// 交互模式下询问用户是否导出
|
||
showCustomConfirm(
|
||
"导出静态报告",
|
||
`是否显示卡死点并转换为静态模式以便导出文件?转换为静态模式后,请使用浏览器的\"另存新档\"功能(Ctrl+S)分享网页。或截图分享当前页面。`
|
||
|
||
).then(confirmed => {
|
||
if (confirmed) {
|
||
exportAsStaticHTML();
|
||
// 注意:exportAsStaticHTML()内部已经添加了static-mode类
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
// 在文件解析前重置时间戳追踪
|
||
function resetTimeTracker() {
|
||
lastValidTime = null;
|
||
}
|
||
const parsingContext = {
|
||
activeGroups: new Map(),
|
||
activeTasks: new Map(),
|
||
allGroups: []
|
||
};
|
||
|
||
// 取得URL参数(大小寫兼容)
|
||
function getValue(varname) {
|
||
const url = window.location.href;
|
||
const urlObj = new URL(url);
|
||
const params = new URLSearchParams(urlObj.search);
|
||
|
||
// 1. 首先嘗試原始大小寫
|
||
let value = params.get(varname);
|
||
if (value !== null) {
|
||
return value;
|
||
}
|
||
|
||
// 2. 如果沒有找到,嘗試小寫
|
||
const paramNames = Array.from(params.keys());
|
||
const matchedName = paramNames.find(name =>
|
||
name.toLowerCase() === varname.toLowerCase()
|
||
);
|
||
|
||
// 返回匹配的參數值,如果找不到則返回空字符串
|
||
return matchedName ? params.get(matchedName) : "";
|
||
}
|
||
|
||
// 页面加载时显示帮助提示
|
||
window.onload = function () {
|
||
// 首先读取URL参数
|
||
const themeParam = getValue("C");
|
||
const boxParam = getValue("LBox");
|
||
|
||
// 1. 设置主题(参数优先级最高)
|
||
if (themeParam === "1") {
|
||
document.body.classList.add('dark-theme');
|
||
} else if (themeParam === "0") {
|
||
document.body.classList.remove('dark-theme');
|
||
} else {
|
||
// 如果没有主题参数,使用原来的时间判断逻辑
|
||
const now = new Date();
|
||
const currentHour = now.getHours();
|
||
const minutes = now.getMinutes();
|
||
if ((currentHour < 6) || (currentHour === 6 && minutes <= 30)) {
|
||
document.body.classList.add('dark-theme');
|
||
}
|
||
}
|
||
|
||
// 显示帮助提示
|
||
const helpIndicator = document.getElementById('helpIndicator');
|
||
helpIndicator.classList.add('visible');
|
||
|
||
// 5秒后隐藏帮助提示
|
||
setTimeout(() => {
|
||
helpIndicator.classList.remove('visible');
|
||
}, 5000);
|
||
|
||
// 设置文件上传按钮事件
|
||
document.getElementById('fileUploadBtn').addEventListener('click', function () {
|
||
document.getElementById('fileInput').click();
|
||
});
|
||
|
||
// 处理文件选择事件
|
||
document.getElementById('fileInput').addEventListener('change', handleFileSelect);
|
||
|
||
// 检测是否为移动设备
|
||
const isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||
const hasTouchScreen = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
||
|
||
// 优先使用 URL 参数 LBox 控制显示状态
|
||
if (boxParam === "true") {
|
||
// 强制显示上传区域
|
||
document.getElementById('fileUploadContainer').classList.add('visible');
|
||
uploadContainerVisible = true;
|
||
} else if (boxParam === "false") {
|
||
// 强制隐藏上传区域
|
||
document.getElementById('fileUploadContainer').classList.remove('visible');
|
||
uploadContainerVisible = false;
|
||
} else {
|
||
// 未指定 LBox 参数时,按移动设备检测决定
|
||
if (isMobileDevice || hasTouchScreen) {
|
||
document.body.classList.add('mobile-device');
|
||
document.getElementById('fileUploadContainer').classList.add('visible');
|
||
uploadContainerVisible = true;
|
||
} else {
|
||
document.getElementById('fileUploadContainer').classList.remove('visible');
|
||
uploadContainerVisible = false;
|
||
}
|
||
}
|
||
|
||
// 初始化功能按钮状态
|
||
initControlButtons();
|
||
|
||
// 设置功能按钮点击事件
|
||
document.querySelectorAll('.control-btn').forEach(btn => {
|
||
btn.addEventListener('click', function () {
|
||
const keyCode = parseInt(this.dataset.key);
|
||
handleControlButtonClick(keyCode);
|
||
});
|
||
});
|
||
|
||
// 确保初始状态没有这些类名
|
||
document.body.classList.remove('static-mode', 'filter-mode');
|
||
hideQuickNavToggle(); // 确保快速导航初始状态是隐藏的
|
||
};
|
||
|
||
// 初始化功能按钮状态
|
||
function initControlButtons() {
|
||
// 设置初始状态
|
||
controlButtons = {
|
||
192: document.body.classList.contains('dark-theme'), // 主题切换
|
||
84: timeColumnsVisible, // 时间列
|
||
89: statsColumnsVisible, // 统计列
|
||
73: picksColumnsVisible, // 拾取物列
|
||
// 79: isPickEfficiencyMode, // 拾取效率模式
|
||
80: isStaticMode, // 导出模式
|
||
74: hideZeroStatsTasks, // 异常任务
|
||
72: isFilterMode, // 任務篩選
|
||
77: false, // 统计拾取物
|
||
100: isTimeFilterMode // 时间筛选模式
|
||
};
|
||
|
||
// 更新按钮显示状态
|
||
updateControlButtons();
|
||
}
|
||
|
||
// 处理功能按钮点击
|
||
function handleControlButtonClick(keyCode) {
|
||
// 对于统计按钮,直接调用函数
|
||
if (keyCode === 77) {
|
||
countPickups();
|
||
return;
|
||
}
|
||
|
||
// 模拟键盘事件
|
||
const event = new KeyboardEvent('keydown', {
|
||
keyCode: keyCode,
|
||
which: keyCode
|
||
});
|
||
|
||
// 触发对应的快捷键功能
|
||
document.dispatchEvent(event);
|
||
|
||
// 更新按钮状态
|
||
updateButtonState(keyCode);
|
||
}
|
||
|
||
// 更新单个按钮状态
|
||
function updateButtonState(keyCode) {
|
||
let isActive = false;
|
||
|
||
switch (keyCode) {
|
||
case 192: // 切换颜色
|
||
isActive = document.body.classList.contains('dark-theme');
|
||
break;
|
||
case 84: // 时间列
|
||
isActive = timeColumnsVisible;
|
||
break;
|
||
case 89: // 统计列
|
||
isActive = statsColumnsVisible;
|
||
break;
|
||
case 73: // 拾取物列
|
||
isActive = picksColumnsVisible;
|
||
break;
|
||
// case 79: // O 键 - 拾取效率
|
||
// isActive = isPickEfficiencyMode;
|
||
// break;
|
||
case 80: // 导出模式
|
||
isActive = isStaticMode;
|
||
break;
|
||
case 74: // 异常任务
|
||
isActive = hideZeroStatsTasks;
|
||
break;
|
||
case 72: // 任務篩選
|
||
isActive = isFilterMode;
|
||
break;
|
||
// case 85: // 表格格式切换
|
||
// isActive = useLegacyFormat;
|
||
// break;
|
||
case 77: // 统计拾取物- 始终为false,只是占位符
|
||
isActive = false;
|
||
break;
|
||
case 100: // 数字键盘4 - 时间筛选
|
||
isActive = isTimeFilterMode;
|
||
break;
|
||
}
|
||
|
||
// 更新按钮状态
|
||
controlButtons[keyCode] = isActive;
|
||
const button = document.querySelector(`.control-btn[data-key="${keyCode}"]`);
|
||
|
||
if (button) {
|
||
if (isActive) {
|
||
button.classList.add('active');
|
||
} else {
|
||
button.classList.remove('active');
|
||
}
|
||
}
|
||
}
|
||
|
||
// 更新所有功能按钮状态
|
||
function updateControlButtons() {
|
||
for (const keyCode in controlButtons) {
|
||
updateButtonState(parseInt(keyCode));
|
||
}
|
||
}
|
||
|
||
// 任務篩選功能
|
||
function toggleTaskFilter() {
|
||
if (isFilterMode) {
|
||
// 退出篩選模式
|
||
exitFilterMode();
|
||
} else {
|
||
// 進入篩選模式
|
||
enterFilterMode();
|
||
}
|
||
|
||
}
|
||
|
||
// 進入篩選模式
|
||
function enterFilterMode() {
|
||
const input = prompt("请输入筛选条件\n格式:包含关键字(多个用逗号分隔) /- 排除配置组关键字(多个用逗号分隔)\n例如:蒙德,璃月/-钓鱼,采集\n只排除:/-钓鱼,采集\n只包含:蒙德,璃月");
|
||
|
||
if (input === null) {
|
||
return; // 用戶取消
|
||
}
|
||
|
||
const trimmedInput = input.trim();
|
||
if (trimmedInput === '') {
|
||
alert("请至少输入一个筛选条件!");
|
||
return;
|
||
}
|
||
|
||
// 分割包含和排除部分
|
||
let includePart = '';
|
||
let excludePart = '';
|
||
const separatorIndex = trimmedInput.indexOf('/-');
|
||
if (separatorIndex === -1) {
|
||
// 没有分隔符,全部作为包含关键字
|
||
includePart = trimmedInput;
|
||
} else {
|
||
includePart = trimmedInput.substring(0, separatorIndex).trim();
|
||
excludePart = trimmedInput.substring(separatorIndex + 2).trim(); // 跳过 "/-"
|
||
}
|
||
|
||
// 解析包含关键字
|
||
const includeKeywords = includePart
|
||
? includePart.split(',').map(keyword => keyword.trim()).filter(keyword => keyword.length > 0)
|
||
: [];
|
||
|
||
// 解析排除关键字
|
||
const excludeKeywords = excludePart
|
||
? excludePart.split(',').map(keyword => keyword.trim()).filter(keyword => keyword.length > 0)
|
||
: [];
|
||
|
||
// 如果兩部分都為空,不進入篩選模式
|
||
if (includeKeywords.length === 0 && excludeKeywords.length === 0) {
|
||
alert("请至少输入一个筛选条件!");
|
||
return;
|
||
}
|
||
|
||
currentFilterKeywords = includeKeywords;
|
||
currentExcludeGroupKeywords = excludeKeywords;
|
||
isFilterMode = true;
|
||
|
||
// 添加filter-mode类到body
|
||
document.body.classList.add('filter-mode');
|
||
|
||
//应用筛选
|
||
applyTaskFilter();
|
||
|
||
// 如果零统计隐藏已启用,额外应用零统计筛选
|
||
if (hideZeroStatsTasks) {
|
||
toggleZeroStatsTasksInFilterMode();
|
||
}
|
||
// 更新任務數量
|
||
updateTaskCounts();
|
||
// 顯示篩選提示
|
||
showFilterIndicator();
|
||
// 更新按鈕狀態
|
||
updateButtonState(72);
|
||
}
|
||
|
||
// 退出筛选模式的函数,确保正确处理零统计状态
|
||
function exitFilterMode() {
|
||
isFilterMode = false;
|
||
currentFilterKeywords = [];
|
||
currentExcludeGroupKeywords = [];
|
||
|
||
// 移除筛选,显示所有任务和总计行
|
||
removeTaskFilter();
|
||
|
||
// 移除filter-mode类
|
||
document.body.classList.remove('filter-mode');
|
||
|
||
// 重新应用零统计任务隐藏(如果启用)
|
||
if (hideZeroStatsTasks) {
|
||
toggleZeroStatsTasksNormal(); // 使用非筛选模式版本
|
||
}
|
||
|
||
// 如果处于拾取效率模式,重新应用拾取效率计算
|
||
if (isPickEfficiencyMode) {
|
||
// 重新应用拾取效率模式,这会隐藏拾取物汇总行
|
||
applyPickEfficiency();
|
||
} else {
|
||
// 不在拾取效率模式下,确保拾取物汇总行正确显示
|
||
const tables = document.querySelectorAll('table');
|
||
tables.forEach(table => {
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
// 只有在非拾取效率模式下才显示汇总行
|
||
row.style.display = '';
|
||
});
|
||
});
|
||
}
|
||
|
||
// 隐藏筛选提示
|
||
hideFilterIndicator();
|
||
|
||
// 更新按钮状态
|
||
updateButtonState(72);
|
||
}
|
||
|
||
// 在筛选模式下隐藏所有拾取物
|
||
function applyTaskFilter() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
const groupHeader = container.querySelector('.group-header h2');
|
||
const groupName = groupHeader ? groupHeader.textContent : '';
|
||
const pureGroupName = extractGroupName(groupName); // 提取纯配置组名
|
||
|
||
let groupHasVisibleTask = false;
|
||
|
||
// 确保队伍角色行显示
|
||
const teamRolesRow = table.querySelector('.team-roles-row');
|
||
if (teamRolesRow) teamRolesRow.style.display = '';
|
||
|
||
// 隐藏所有拾取物行
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => row.style.display = 'none');
|
||
|
||
// 檢查排除關鍵字
|
||
const groupExcluded = currentExcludeGroupKeywords.length > 0 &&
|
||
currentExcludeGroupKeywords.some(keyword => pureGroupName.toLowerCase().includes(keyword.toLowerCase()));
|
||
|
||
if (groupExcluded) {
|
||
container.style.display = 'none';
|
||
return; // 跳過此組
|
||
}
|
||
|
||
// 檢查包含關鍵字(配置組名)
|
||
const groupMatchesInclude = currentFilterKeywords.length === 0 ||
|
||
currentFilterKeywords.some(keyword => pureGroupName.toLowerCase().includes(keyword.toLowerCase()));
|
||
|
||
// 如果配置组名匹配,显示整个配置组的所有任务
|
||
if (groupMatchesInclude) {
|
||
// 配置組名匹配,顯示所有任務行
|
||
const rows = table.querySelectorAll('tr');
|
||
rows.forEach(row => {
|
||
if (!row.querySelector('th') && !row.classList.contains('team-roles-row') && !row.classList.contains('summary-row')) {
|
||
row.style.display = '';
|
||
}
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
// 配置組名不匹配,按任務名稱篩選
|
||
if (!useLegacyFormat) {
|
||
const rows = table.querySelectorAll('tr');
|
||
rows.forEach(row => {
|
||
// 跳过表头行、队伍角色行和已经隐藏的summary-row
|
||
if (row.querySelector('th') || row.classList.contains('team-roles-row') || row.classList.contains('summary-row')) return;
|
||
|
||
// 获取任务名称
|
||
const taskNameCell = row.querySelector('td:first-child');
|
||
if (taskNameCell) {
|
||
const taskName = taskNameCell.textContent.toLowerCase();
|
||
|
||
// 检查任务名称是否包含任一关键字
|
||
const matchesInclude = currentFilterKeywords.some(keyword =>
|
||
taskName.includes(keyword.toLowerCase())
|
||
);
|
||
|
||
// 检查统计列是否非零
|
||
let matchesStats = true;
|
||
if (hideZeroStatsTasks) {
|
||
const reviveCell = row.querySelector('.column-revive');
|
||
const retryCell = row.querySelector('.column-retry');
|
||
const retryDetailCell = row.querySelector('.column-retry-detail');
|
||
const tooFarSkipCell = row.querySelector('.column-too-far-skip');
|
||
const timeoutCell = row.querySelector('.column-timeout');
|
||
const teleportCell = row.querySelector('.column-teleport');
|
||
|
||
if (reviveCell && retryCell && retryDetailCell && tooFarSkipCell && timeoutCell && teleportCell) {
|
||
const isAllZero =
|
||
(reviveCell.textContent.trim() === '' || reviveCell.textContent.trim() === '0') &&
|
||
(retryCell.textContent.trim() === '' || retryCell.textContent.trim() === '0') &&
|
||
(retryDetailCell.textContent.trim() === '' || retryDetailCell.textContent.trim() === '0') &&
|
||
(tooFarSkipCell.textContent.trim() === '' || tooFarSkipCell.textContent.trim() === '0') &&
|
||
(timeoutCell.textContent.trim() === '' || timeoutCell.textContent.trim() === '0') &&
|
||
(teleportCell.textContent.trim() === '' || teleportCell.textContent.trim() === '0');
|
||
|
||
// 如果全零,检查特殊事件
|
||
let hasSpecialEvent = false;
|
||
if (isAllZero) {
|
||
let picksText = '';
|
||
// 新版格式:拾取物列在当前行
|
||
const picksCell = row.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
if (SPECIAL_EVENT_KEYWORDS.some(keyword => picksText.includes(keyword))) {
|
||
hasSpecialEvent = true;
|
||
}
|
||
}
|
||
// 最终:全零且无特殊事件 -> matchesStats = false;否则 true
|
||
matchesStats = !(isAllZero && !hasSpecialEvent);
|
||
}
|
||
}
|
||
|
||
if (matchesInclude && matchesStats) {
|
||
row.style.display = '';
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
row.style.display = 'none';
|
||
}
|
||
}
|
||
});
|
||
}
|
||
// 旧版格式
|
||
else {
|
||
const taskNameRows = table.querySelectorAll('tr .main-row-name');
|
||
|
||
taskNameRows.forEach(taskNameCell => {
|
||
const row = taskNameCell.closest('tr');
|
||
const taskId = row.getAttribute('data-task-id');
|
||
|
||
if (taskId) {
|
||
const taskName = taskNameCell.textContent.toLowerCase();
|
||
|
||
// 检查任务名称是否包含任一关键字
|
||
const matchesInclude = currentFilterKeywords.some(keyword =>
|
||
taskName.includes(keyword.toLowerCase())
|
||
);
|
||
|
||
// 检查统计列是否非零
|
||
let matchesStats = true;
|
||
if (hideZeroStatsTasks) {
|
||
const reviveCell = row.querySelector('.column-revive');
|
||
const retryCell = row.querySelector('.column-retry');
|
||
const retryDetailCell = row.querySelector('.column-retry-detail');
|
||
const tooFarSkipCell = row.querySelector('.column-too-far-skip');
|
||
const timeoutCell = row.querySelector('.column-timeout');
|
||
const teleportCell = row.querySelector('.column-teleport');
|
||
|
||
if (reviveCell && retryCell && retryDetailCell && tooFarSkipCell && timeoutCell && teleportCell) {
|
||
const isAllZero =
|
||
(reviveCell.textContent.trim() === '' || reviveCell.textContent.trim() === '0') &&
|
||
(retryCell.textContent.trim() === '' || retryCell.textContent.trim() === '0') &&
|
||
(retryDetailCell.textContent.trim() === '' || retryDetailCell.textContent.trim() === '0') &&
|
||
(tooFarSkipCell.textContent.trim() === '' || tooFarSkipCell.textContent.trim() === '0') &&
|
||
(timeoutCell.textContent.trim() === '' || timeoutCell.textContent.trim() === '0') &&
|
||
(teleportCell.textContent.trim() === '' || teleportCell.textContent.trim() === '0');
|
||
|
||
// 如果全零,检查特殊事件
|
||
let hasSpecialEvent = false;
|
||
if (isAllZero) {
|
||
let picksText = '';
|
||
// 旧版格式:拾取物在子行
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const subRow = table.querySelector(`tr[data-task-id="${taskId}"].sub-row`);
|
||
if (subRow) {
|
||
const picksCell = subRow.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
}
|
||
}
|
||
if (SPECIAL_EVENT_KEYWORDS.some(keyword => picksText.includes(keyword))) {
|
||
hasSpecialEvent = true;
|
||
}
|
||
}
|
||
// 最终:全零且无特殊事件 -> matchesStats = false;否则 true
|
||
matchesStats = !(isAllZero && !hasSpecialEvent);
|
||
}
|
||
}
|
||
|
||
if (matchesInclude && matchesStats) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
if (!r.classList.contains('summary-row')) r.style.display = '';
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => r.style.display = 'none');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
// 如果配置组没有可见任务,隐藏整个配置组(包括队伍角色行)
|
||
container.style.display = groupHasVisibleTask ? '' : 'none';
|
||
});
|
||
|
||
// 筛选后调整表头位置
|
||
setTimeout(() => {
|
||
adjustTableHeaderPosition();
|
||
updateTaskCounts(); // 更新任务数量显示
|
||
refreshQuickNav();
|
||
}, 50);
|
||
}
|
||
|
||
function removeTaskFilter() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
|
||
// 确保队伍角色行显示
|
||
const teamRolesRow = table.querySelector('.team-roles-row');
|
||
if (teamRolesRow) {
|
||
teamRolesRow.style.display = '';
|
||
}
|
||
|
||
// 显示所有行,但根据模式状态处理拾取物行
|
||
const rows = table.querySelectorAll('tr');
|
||
rows.forEach(row => {
|
||
if (!row.querySelector('th')) {
|
||
if (row.classList.contains('summary-row')) {
|
||
// 在拾取效率模式下隐藏拾取物汇总行
|
||
if (isPickEfficiencyMode) {
|
||
row.style.display = 'none';
|
||
} else {
|
||
row.style.display = hideZeroStatsTasks ? 'none' : '';
|
||
}
|
||
} else {
|
||
row.style.display = '';
|
||
}
|
||
}
|
||
});
|
||
|
||
// 显示配置组
|
||
container.style.display = '';
|
||
});
|
||
|
||
// 重新调整表头位置
|
||
setTimeout(() => {
|
||
adjustTableHeaderPosition();
|
||
updateTaskCounts(); // 更新任务数量显示
|
||
refreshQuickNav();
|
||
}, 50);
|
||
}
|
||
|
||
// 顯示篩選提示
|
||
function showFilterIndicator() {
|
||
const indicator = document.getElementById('filterIndicator');
|
||
const keywordsElement = document.getElementById('filterKeywords');
|
||
|
||
let displayText = '';
|
||
if (currentFilterKeywords.length > 0) {
|
||
displayText += '包含: ' + currentFilterKeywords.join(', ');
|
||
}
|
||
if (currentExcludeGroupKeywords.length > 0) {
|
||
if (displayText) displayText += ' | ';
|
||
displayText += '排除組: ' + currentExcludeGroupKeywords.join(', ');
|
||
}
|
||
keywordsElement.textContent = displayText;
|
||
indicator.classList.add('visible');
|
||
|
||
// 动态计算筛选提示宽度并设置CSS变量
|
||
const filterWidth = indicator.offsetWidth;
|
||
document.documentElement.style.setProperty('--filter-indicator-width', filterWidth + 'px');
|
||
}
|
||
|
||
// 隱藏篩選提示
|
||
function hideFilterIndicator() {
|
||
const indicator = document.getElementById('filterIndicator');
|
||
indicator.classList.remove('visible');
|
||
|
||
// 移除CSS变量
|
||
document.documentElement.style.removeProperty('--filter-indicator-width');
|
||
}
|
||
|
||
// 拖放事件处理
|
||
const dropZone = document.getElementById('dropZone');
|
||
|
||
dropZone.addEventListener('dragover', (e) => {
|
||
e.preventDefault();
|
||
dropZone.classList.add('dragover');
|
||
});
|
||
|
||
dropZone.addEventListener('dragleave', () => {
|
||
dropZone.classList.remove('dragover');
|
||
});
|
||
|
||
// 處理拖放事件
|
||
dropZone.addEventListener('drop', async e => {
|
||
e.preventDefault();
|
||
dropZone.style.backgroundColor = '';
|
||
|
||
const success = await processFiles(e.dataTransfer.files);
|
||
if (!success) {
|
||
alert('请拖入BetterGI日志文件(文件名以better-genshin-impact开头)');
|
||
}
|
||
});
|
||
|
||
// 處理文件選擇事件
|
||
async function handleFileSelect(e) {
|
||
const success = await processFiles(e.target.files);
|
||
if (!success) {
|
||
alert('请选择BetterGI日志文件(文件名以better-genshin-impact开头)');
|
||
}
|
||
}
|
||
|
||
//處理文件列表的通用函數
|
||
async function processFiles(fileList) {
|
||
const files = Array.from(fileList)
|
||
.filter(f => f.name.startsWith('better-genshin-impact'))
|
||
.sort((a, b) => parseDateFromFileName(a.name) - parseDateFromFileName(b.name));
|
||
|
||
if (files.length === 0) {
|
||
return false;
|
||
}
|
||
|
||
parsingContext.activeGroups.clear();
|
||
parsingContext.activeTasks.clear();
|
||
parsingContext.allGroups = [];
|
||
|
||
try {
|
||
resetTimeTracker();
|
||
dropZone.innerHTML = '<div class="loading">解析中...</div>';
|
||
dropZone.className = 'has-content';
|
||
|
||
for (const file of files) {
|
||
const content = await file.text();
|
||
parseLog(content, parseDateFromFileName(file.name));
|
||
}
|
||
|
||
const result = finalizeParsing();
|
||
dropZone.innerHTML = generateHTML(result);
|
||
setupCoordPopups();
|
||
|
||
// 折叠功能事件处理
|
||
document.querySelectorAll('.group-header').forEach((el, i) => {
|
||
el.onclick = (e) => {
|
||
const arrow = el.querySelector('.arrow');
|
||
const content = document.getElementById(`group-${i}`);
|
||
const container = el.closest('.group-container');
|
||
|
||
// 获取配置组标题和内容的位置信息
|
||
const headerRect = el.getBoundingClientRect();
|
||
const containerRect = container.getBoundingClientRect();
|
||
|
||
// 判断标题是否在可视区域顶部(考虑固定定位)
|
||
const isStickyAtTop = headerRect.top <= 15 && headerRect.top >= -10;
|
||
|
||
if (isStickyAtTop) {
|
||
// 计算需要滚动到的位置
|
||
// 让配置组标题滚动到距离顶部30px的位置
|
||
const targetPosition = container.offsetTop - 40;
|
||
const currentPosition = dropZone.scrollTop;
|
||
const scrollDistance = Math.abs(targetPosition - currentPosition);
|
||
|
||
// 计算滚动时间:根据距离,但不小于300ms,不大于2000ms,然后加上500ms的额外时间
|
||
const scrollDuration = Math.min(2000, Math.max(200, scrollDistance)) + 50;
|
||
|
||
// 使用平滑滚动
|
||
dropZone.scrollTo({
|
||
top: targetPosition,
|
||
behavior: 'smooth'
|
||
});
|
||
|
||
// 在滚动完成后再折叠,使用计算出的时间
|
||
setTimeout(() => {
|
||
toggleCollapseState(el, content, arrow);
|
||
}, scrollDuration);
|
||
|
||
} else {
|
||
// 已经在顶部,直接折叠
|
||
toggleCollapseState(el, content, arrow);
|
||
}
|
||
};
|
||
});
|
||
|
||
// 应用初始时间列显示状态
|
||
updateTimeColumnsVisibility();
|
||
// 应用初始统计列显示状态
|
||
updateStatsColumnsVisibility();
|
||
// 应用初始表格格式
|
||
updateTableFormat();
|
||
// 设置行高亮效果
|
||
setupRowHighlight();
|
||
|
||
// 使用防抖版本調整表頭
|
||
setTimeout(() => {
|
||
debouncedAdjustTableHeader();
|
||
}, 150);
|
||
|
||
// 第二次讀檔時保留各功能状态
|
||
if (hasLogData) {
|
||
refreshHTML();
|
||
}
|
||
// 标记已有日志数据
|
||
hasLogData = true;
|
||
showQuickNavToggle();
|
||
return true;
|
||
} catch (e) {
|
||
dropZone.innerHTML = `<div class="error">解析失败:${e.message}</div>`;
|
||
hideQuickNavToggle();
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function setupSortButtons() {
|
||
// 时间排序按钮
|
||
document.querySelectorAll('.sort-btn').forEach(btn => {
|
||
// 移除旧的事件监听器
|
||
const newBtn = btn.cloneNode(true);
|
||
btn.parentNode.replaceChild(newBtn, btn);
|
||
|
||
newBtn.addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
|
||
const table = this.closest('table');
|
||
const isLegacy = table.closest('.legacy-format') !== null;
|
||
const tbody = table.querySelector('tbody');
|
||
|
||
if (!tbody) return;
|
||
|
||
// 切换排序状态
|
||
// 如果当前是耗时排序,切换到时间排序
|
||
// 否则在读取顺序和时间排序之间切换
|
||
if (currentSortState === 2 || currentSortState === 3) {
|
||
currentSortState = 1; // 切换到时间排序
|
||
} else {
|
||
currentSortState = currentSortState === 0 ? 1 : 0; // 在0和1之间切换
|
||
}
|
||
|
||
// 应用排序
|
||
applySorting(tbody, isLegacy);
|
||
|
||
// 更新按钮状态
|
||
updateSortButtons();
|
||
});
|
||
});
|
||
|
||
function applySorting(tbody, isLegacy) {
|
||
if (isLegacy) {
|
||
sortLegacyTableByAll(tbody);
|
||
} else {
|
||
sortNormalTableByAll(tbody);
|
||
}
|
||
}
|
||
|
||
function sortNormalTableByAll(tbody) {
|
||
const rows = Array.from(tbody.querySelectorAll('tr[data-original-index]'));
|
||
if (rows.length <= 1) return;
|
||
|
||
rows.sort((a, b) => {
|
||
if (currentSortState === 0) {
|
||
// 读取顺序
|
||
const indexA = parseInt(a.getAttribute('data-original-index') || 0);
|
||
const indexB = parseInt(b.getAttribute('data-original-index') || 0);
|
||
return indexA - indexB;
|
||
} else if (currentSortState === 1) {
|
||
// 时间排序:最近的在前
|
||
const timeA = parseInt(a.getAttribute('data-start-timestamp') || 0);
|
||
const timeB = parseInt(b.getAttribute('data-start-timestamp') || 0);
|
||
return timeB - timeA;
|
||
} else {
|
||
// 获取耗时秒数
|
||
const durationA = parseDurationToSeconds(a.querySelector('td:nth-child(4)').textContent);
|
||
const durationB = parseDurationToSeconds(b.querySelector('td:nth-child(4)').textContent);
|
||
|
||
if (currentSortState === 2) {
|
||
// 耗时升序(小到大)
|
||
return durationA - durationB;
|
||
} else {
|
||
// 耗时降序(大到小)
|
||
return durationB - durationA;
|
||
}
|
||
}
|
||
});
|
||
|
||
// 重新插入
|
||
const fragment = document.createDocumentFragment();
|
||
rows.forEach(row => fragment.appendChild(row));
|
||
|
||
// 保存並重新組裝
|
||
const headerRow = tbody.querySelector('.team-roles-row');
|
||
const summaryRow = tbody.querySelector('.summary-row');
|
||
|
||
while (tbody.firstChild) tbody.removeChild(tbody.firstChild);
|
||
if (headerRow) tbody.appendChild(headerRow);
|
||
tbody.appendChild(fragment);
|
||
if (summaryRow) tbody.appendChild(summaryRow);
|
||
}
|
||
|
||
function sortLegacyTableByAll(tbody) {
|
||
console.log('sortLegacyTableByAll called');
|
||
|
||
if (!tbody) return;
|
||
|
||
// 获取所有任务ID
|
||
const taskMap = new Map();
|
||
const taskRows = tbody.querySelectorAll('tr[data-task-id]');
|
||
|
||
// 收集每个任务的所有行
|
||
taskRows.forEach(row => {
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
if (!taskMap.has(taskId)) {
|
||
taskMap.set(taskId, []);
|
||
}
|
||
taskMap.get(taskId).push(row);
|
||
}
|
||
});
|
||
|
||
// 获取主行用于排序
|
||
const mainRows = Array.from(tbody.querySelectorAll('.main-row-name'))
|
||
.map(cell => {
|
||
const tr = cell.closest('tr');
|
||
return tr && tr.hasAttribute('data-task-id') ? tr : null;
|
||
})
|
||
.filter(tr => tr !== null);
|
||
|
||
if (mainRows.length <= 1) return;
|
||
|
||
// 排序主行
|
||
mainRows.sort((a, b) => {
|
||
if (currentSortState === 0) {
|
||
const indexA = parseInt(a.getAttribute('data-original-index') || 0);
|
||
const indexB = parseInt(b.getAttribute('data-original-index') || 0);
|
||
return indexA - indexB;
|
||
} else if (currentSortState === 1) {
|
||
const timeA = parseInt(a.getAttribute('data-start-timestamp') || 0);
|
||
const timeB = parseInt(b.getAttribute('data-start-timestamp') || 0);
|
||
return timeB - timeA;
|
||
} else {
|
||
// 获取耗时秒数
|
||
const durationA = parseDurationToSeconds(a.querySelector('td:nth-child(4)').textContent);
|
||
const durationB = parseDurationToSeconds(b.querySelector('td:nth-child(4)').textContent);
|
||
|
||
if (currentSortState === 2) {
|
||
return durationA - durationB;
|
||
} else {
|
||
return durationB - durationA;
|
||
}
|
||
}
|
||
});
|
||
|
||
// 创建文档片段
|
||
const fragment = document.createDocumentFragment();
|
||
|
||
// 获取并保存非任务行
|
||
const headerRow = tbody.querySelector('.team-roles-row');
|
||
const summaryRow = tbody.querySelector('.summary-row');
|
||
|
||
// 清空tbody
|
||
while (tbody.firstChild) {
|
||
tbody.removeChild(tbody.firstChild);
|
||
}
|
||
|
||
// 添加表头行
|
||
if (headerRow) {
|
||
tbody.appendChild(headerRow);
|
||
}
|
||
|
||
// 按排序后的顺序添加任务行
|
||
mainRows.forEach(mainRow => {
|
||
const taskId = mainRow.getAttribute('data-task-id');
|
||
if (taskId && taskMap.has(taskId)) {
|
||
const rows = taskMap.get(taskId);
|
||
rows.forEach(row => {
|
||
fragment.appendChild(row);
|
||
});
|
||
}
|
||
});
|
||
|
||
// 添加排序后的任务行
|
||
tbody.appendChild(fragment);
|
||
|
||
// 添加汇总行
|
||
if (summaryRow) {
|
||
tbody.appendChild(summaryRow);
|
||
}
|
||
}
|
||
|
||
// 耗时排序按钮
|
||
document.querySelectorAll('.duration-sort-btn').forEach(btn => {
|
||
const newBtn = btn.cloneNode(true);
|
||
btn.parentNode.replaceChild(newBtn, btn);
|
||
|
||
newBtn.addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
|
||
const table = this.closest('table');
|
||
const isLegacy = table.closest('.legacy-format') !== null;
|
||
const tbody = table.querySelector('tbody');
|
||
|
||
if (!tbody) return;
|
||
|
||
// 切换排序状态
|
||
// 如果当前是时间排序或读取顺序,切换到耗时升序
|
||
// 否则在耗时升序和耗时降序之间切换
|
||
if (currentSortState === 0 || currentSortState === 1) {
|
||
currentSortState = 2; // 切换到耗时升序
|
||
} else if (currentSortState === 2) {
|
||
currentSortState = 3; // 切换到耗时降序
|
||
} else {
|
||
currentSortState = 2; // 从耗时降序回到耗时升序
|
||
}
|
||
|
||
// 应用排序
|
||
applySorting(tbody, isLegacy);
|
||
|
||
// 更新按钮状态
|
||
updateSortButtons();
|
||
});
|
||
});
|
||
}
|
||
|
||
function updateSortButtons() {
|
||
// 更新时间排序按钮
|
||
document.querySelectorAll('.sort-btn').forEach(btn => {
|
||
if (currentSortState === 0) {
|
||
btn.textContent = '↓';
|
||
btn.title = '读取顺序';
|
||
} else if (currentSortState === 1) {
|
||
btn.textContent = '↑';
|
||
btn.title = '时间排序(最近的在前)';
|
||
} else {
|
||
btn.textContent = '↕';
|
||
btn.title = '点击切换排序';
|
||
}
|
||
});
|
||
|
||
// 更新耗时排序按钮
|
||
document.querySelectorAll('.duration-sort-btn').forEach(btn => {
|
||
if (currentSortState === 2) {
|
||
btn.textContent = '↑';
|
||
btn.title = '耗时升序(小到大)';
|
||
} else if (currentSortState === 3) {
|
||
btn.textContent = '↓';
|
||
btn.title = '耗时降序(大到小)';
|
||
} else {
|
||
btn.textContent = '↕';
|
||
btn.title = '点击切换排序';
|
||
}
|
||
});
|
||
}
|
||
|
||
// 坐标弹窗事件处理函数
|
||
function setupCoordPopups() {
|
||
const coordsCells = document.querySelectorAll('.coords-cell');
|
||
const battleCells = document.querySelectorAll('.has-battle-events');
|
||
let popupPositions = new WeakMap(); // 存储每个弹窗的位置状态
|
||
let pinnedPopup = null;
|
||
let isDragging = false;
|
||
let dragOffsetX, dragOffsetY;
|
||
let dragElement = null;
|
||
const allPopups = []; // 存储所有弹窗元素
|
||
|
||
// 添加双击重置功能
|
||
let lastClickTime = 0;
|
||
let clickTimeout = null;
|
||
|
||
setupSortButtons();
|
||
|
||
// 定位弹窗函数
|
||
const positionPopup = (popup, cell) => {
|
||
// 如果已有位置记录,使用记录的位置
|
||
if (popupPositions.has(popup)) {
|
||
const pos = popupPositions.get(popup);
|
||
popup.style.left = pos.x + 'px';
|
||
popup.style.top = pos.y + 'px';
|
||
return;
|
||
}
|
||
|
||
// 否则定位在单元格中间
|
||
const cellRect = cell.getBoundingClientRect();
|
||
const popupRect = popup.getBoundingClientRect();
|
||
|
||
// 计算位置 - 单元格中间
|
||
let left = cellRect.left + (cellRect.width - popupRect.width) / 2;
|
||
let top = cellRect.top + (cellRect.height - popupRect.height) / 2;
|
||
|
||
// 确保不会超出视口
|
||
if (left < 5) left = 5;
|
||
if (top < 5) top = 5;
|
||
if (left + popupRect.width > window.innerWidth) {
|
||
left = window.innerWidth - popupRect.width - 5;
|
||
}
|
||
if (top + popupRect.height > window.innerHeight) {
|
||
top = window.innerHeight - popupRect.height - 5;
|
||
}
|
||
|
||
popup.style.left = left + 'px';
|
||
popup.style.top = top + 'px';
|
||
|
||
// 存储初始位置
|
||
popupPositions.set(popup, { x: left, y: top });
|
||
};
|
||
|
||
// 处理坐标弹窗单元格
|
||
coordsCells.forEach(cell => {
|
||
const popup = cell.querySelector('.coord-popup');
|
||
if (!popup) return;
|
||
|
||
// 双击事件处理
|
||
cell.addEventListener('dblclick', (e) => {
|
||
e.stopPropagation();
|
||
|
||
// 重置弹窗位置
|
||
if (popup) {
|
||
// 清除位置记录,强制重新定位到中间
|
||
popupPositions.delete(popup);
|
||
positionPopup(popup, cell);
|
||
|
||
// 确保弹窗可见
|
||
popup.classList.add('visible');
|
||
}
|
||
});
|
||
|
||
// 只在有坐标数据时才添加点击事件
|
||
if (cell.classList.contains('has-coords')) {
|
||
// 点击单元格固定/取消固定弹窗
|
||
cell.addEventListener('click', (e) => {
|
||
// 阻止事件冒泡,避免触发弹窗的点击事件
|
||
e.stopPropagation();
|
||
|
||
// 忽略标题栏和关闭按钮的点击
|
||
if (e.target.closest('.coord-popup-header')) return;
|
||
|
||
if (popup.classList.contains('pinned')) {
|
||
// 取消固定
|
||
popup.classList.remove('pinned');
|
||
cell.classList.remove('pinned');
|
||
pinnedPopup = null;
|
||
|
||
// 如果鼠标不在单元格上,隐藏弹窗
|
||
if (!cell.matches(':hover')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
} else {
|
||
// 固定弹窗
|
||
pinPopup(popup, cell);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 固定弹窗函数
|
||
const pinPopup = (popup, cell) => {
|
||
popup.classList.add('pinned');
|
||
cell.classList.add('pinned');
|
||
pinnedPopup = popup;
|
||
|
||
// 确保弹窗可见
|
||
popup.classList.add('visible');
|
||
|
||
// 存储当前位置
|
||
popupPositions.set(popup, {
|
||
x: parseInt(popup.style.left),
|
||
y: parseInt(popup.style.top)
|
||
});
|
||
};
|
||
|
||
// 鼠标悬停显示弹窗(只在有坐标数据时)
|
||
if (cell.classList.contains('has-coords')) {
|
||
cell.addEventListener('mouseenter', (e) => {
|
||
// 如果已有其他弹窗固定,不做处理
|
||
if (pinnedPopup && pinnedPopup !== popup) return;
|
||
|
||
positionPopup(popup, cell);
|
||
popup.classList.add('visible');
|
||
});
|
||
|
||
cell.addEventListener('mouseleave', (e) => {
|
||
// 检查鼠标是否移动到弹窗上
|
||
if (popup.contains(e.relatedTarget)) return;
|
||
|
||
// 如果弹窗未固定,隐藏它
|
||
if (!popup.classList.contains('pinned')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
});
|
||
}
|
||
|
||
// 弹窗鼠标进入/离开处理
|
||
popup.addEventListener('mouseenter', () => {
|
||
// 防止单元格mouseleave事件触发
|
||
popup._hovering = true;
|
||
});
|
||
|
||
popup.addEventListener('mouseleave', () => {
|
||
popup._hovering = false;
|
||
|
||
// 如果弹窗未固定且鼠标不在单元格上,隐藏弹窗
|
||
if (!popup.classList.contains('pinned') && !cell.matches(':hover')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
});
|
||
|
||
// 在创建弹窗后添加到 allPopups
|
||
if (popup) {
|
||
allPopups.push(popup);
|
||
}
|
||
|
||
// 点击关闭按钮
|
||
const closeBtn = popup.querySelector('.close-btn');
|
||
closeBtn.addEventListener('click', (e) => {
|
||
e.stopPropagation();
|
||
popup.classList.remove('visible', 'pinned');
|
||
cell.classList.remove('pinned');
|
||
pinnedPopup = null;
|
||
|
||
// 清除位置记录
|
||
popupPositions.delete(popup);
|
||
});
|
||
|
||
// 标题栏拖拽功能 - 移动时自动固定
|
||
const header = popup.querySelector('.coord-popup-header');
|
||
header.addEventListener('mousedown', (e) => {
|
||
if (e.target === closeBtn) return;
|
||
|
||
isDragging = true;
|
||
dragElement = popup;
|
||
const rect = popup.getBoundingClientRect();
|
||
dragOffsetX = e.clientX - rect.left;
|
||
dragOffsetY = e.clientY - rect.top;
|
||
|
||
// 移动时自动固定弹窗
|
||
if (!popup.classList.contains('pinned')) {
|
||
pinPopup(popup, cell);
|
||
}
|
||
|
||
e.preventDefault();
|
||
});
|
||
|
||
// 阻止内容区域的点击事件冒泡
|
||
popup.addEventListener('click', (e) => {
|
||
e.stopPropagation();
|
||
});
|
||
|
||
});
|
||
|
||
// 处理战斗事件弹窗单元格
|
||
battleCells.forEach(cell => {
|
||
const popups = cell.querySelectorAll('.battle-popup');
|
||
if (!popups || popups.length === 0) return;
|
||
|
||
popups.forEach(popup => {
|
||
// 双击事件处理
|
||
cell.addEventListener('dblclick', (e) => {
|
||
e.stopPropagation();
|
||
|
||
// 重置弹窗位置
|
||
if (popup) {
|
||
// 清除位置记录,强制重新定位到中间
|
||
popupPositions.delete(popup);
|
||
positionPopup(popup, cell);
|
||
|
||
// 确保弹窗可见
|
||
popup.classList.add('visible');
|
||
}
|
||
});
|
||
|
||
// 点击单元格固定/取消固定弹窗
|
||
cell.addEventListener('click', (e) => {
|
||
e.stopPropagation();
|
||
if (e.target.closest('.battle-popup-header')) return;
|
||
|
||
if (popup.classList.contains('pinned')) {
|
||
popup.classList.remove('pinned');
|
||
cell.classList.remove('pinned');
|
||
pinnedPopup = null;
|
||
if (!cell.matches(':hover')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
} else {
|
||
pinPopup(popup, cell);
|
||
}
|
||
});
|
||
|
||
// 固定弹窗函数
|
||
const pinPopup = (popup, cell) => {
|
||
popup.classList.add('pinned');
|
||
cell.classList.add('pinned');
|
||
pinnedPopup = popup;
|
||
popup.classList.add('visible');
|
||
positionPopup(popup, cell);
|
||
popupPositions.set(popup, {
|
||
x: parseInt(popup.style.left),
|
||
y: parseInt(popup.style.top)
|
||
});
|
||
};
|
||
|
||
// 鼠标悬停显示弹窗
|
||
cell.addEventListener('mouseenter', (e) => {
|
||
if (pinnedPopup && pinnedPopup !== popup) return;
|
||
positionPopup(popup, cell);
|
||
popup.classList.add('visible');
|
||
});
|
||
|
||
cell.addEventListener('mouseleave', (e) => {
|
||
if (popup.contains(e.relatedTarget)) return;
|
||
if (!popup.classList.contains('pinned')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
});
|
||
|
||
// 弹窗鼠标进入/离开处理
|
||
popup.addEventListener('mouseenter', () => {
|
||
popup._hovering = true;
|
||
});
|
||
|
||
popup.addEventListener('mouseleave', () => {
|
||
popup._hovering = false;
|
||
if (!popup.classList.contains('pinned') && !cell.matches(':hover')) {
|
||
popup.classList.remove('visible');
|
||
}
|
||
});
|
||
|
||
// 添加到全局弹窗列表
|
||
allPopups.push(popup);
|
||
|
||
// 点击关闭按钮
|
||
const closeBtn = popup.querySelector('.close-btn');
|
||
closeBtn.addEventListener('click', (e) => {
|
||
e.stopPropagation();
|
||
popup.classList.remove('visible', 'pinned');
|
||
cell.classList.remove('pinned');
|
||
pinnedPopup = null;
|
||
popupPositions.delete(popup);
|
||
});
|
||
|
||
// 标题栏拖拽功能
|
||
const header = popup.querySelector('.battle-popup-header');
|
||
header.addEventListener('mousedown', (e) => {
|
||
if (e.target === closeBtn) return;
|
||
isDragging = true;
|
||
dragElement = popup;
|
||
const rect = popup.getBoundingClientRect();
|
||
dragOffsetX = e.clientX - rect.left;
|
||
dragOffsetY = e.clientY - rect.top;
|
||
if (!popup.classList.contains('pinned')) {
|
||
pinPopup(popup, cell);
|
||
}
|
||
e.preventDefault();
|
||
});
|
||
|
||
// 阻止内容区域的点击事件冒泡
|
||
popup.addEventListener('click', (e) => {
|
||
e.stopPropagation();
|
||
});
|
||
});
|
||
});
|
||
|
||
// 全局鼠标事件处理拖拽
|
||
document.addEventListener('mousemove', (e) => {
|
||
if (!isDragging || !dragElement) return;
|
||
|
||
dragElement.style.left = (e.clientX - dragOffsetX) + 'px';
|
||
dragElement.style.top = (e.clientY - dragOffsetY) + 'px';
|
||
|
||
// 更新位置记录
|
||
popupPositions.set(dragElement, {
|
||
x: parseInt(dragElement.style.left),
|
||
y: parseInt(dragElement.style.top)
|
||
});
|
||
});
|
||
|
||
document.addEventListener('mouseup', () => {
|
||
if (isDragging && dragElement) {
|
||
// 更新位置记录
|
||
popupPositions.set(dragElement, {
|
||
x: parseInt(dragElement.style.left),
|
||
y: parseInt(dragElement.style.top)
|
||
});
|
||
}
|
||
isDragging = false;
|
||
dragElement = null;
|
||
});
|
||
|
||
// 添加重置函数
|
||
function resetCoordPopups() {
|
||
// 关闭所有可见弹窗
|
||
allPopups.forEach(popup => {
|
||
popup.classList.remove('visible', 'pinned');
|
||
|
||
// 移除单元格的固定状态
|
||
const cell = popup.closest('.coords-cell, .has-battle-events');
|
||
if (cell) {
|
||
cell.classList.remove('pinned');
|
||
}
|
||
});
|
||
|
||
// 清除位置记录
|
||
popupPositions = new WeakMap();
|
||
pinnedPopup = null;
|
||
|
||
// 重新定位所有弹窗到单元格中间
|
||
coordsCells.forEach(cell => {
|
||
const popup = cell.querySelector('.coord-popup');
|
||
if (popup) { positionPopup(popup, cell); }
|
||
});
|
||
battleCells.forEach(cell => {
|
||
const popups = cell.querySelectorAll('.battle-popup');
|
||
popups.forEach(popup => positionPopup(popup, cell));
|
||
});
|
||
}
|
||
|
||
// 暴露重置函数到全局
|
||
window.resetCoordPopups = resetCoordPopups;
|
||
|
||
// 窗口大小变化时重新定位
|
||
window.addEventListener('resize', () => {
|
||
document.querySelectorAll('.coord-popup.visible, .battle-popup.visible').forEach(popup => {
|
||
// 如果弹窗有位置记录,调整位置确保在视口内
|
||
if (popupPositions.has(popup)) {
|
||
const pos = popupPositions.get(popup);
|
||
const popupRect = popup.getBoundingClientRect();
|
||
|
||
// 检查位置是否在视口内
|
||
let newLeft = pos.x;
|
||
let newTop = pos.y;
|
||
|
||
if (newLeft + popupRect.width > window.innerWidth) {
|
||
newLeft = window.innerWidth - popupRect.width - 5;
|
||
}
|
||
if (newTop + popupRect.height > window.innerHeight) {
|
||
newTop = window.innerHeight - popupRect.height - 5;
|
||
}
|
||
if (newLeft < 5) newLeft = 5;
|
||
if (newTop < 5) newTop = 5;
|
||
|
||
// 更新位置
|
||
popup.style.left = newLeft + 'px';
|
||
popup.style.top = newTop + 'px';
|
||
|
||
// 更新位置记录
|
||
popupPositions.set(popup, { x: newLeft, y: newTop });
|
||
} else {
|
||
// 如果没有位置记录,重新定位到单元格中间
|
||
const cell = popup.closest('.coords-cell, .has-battle-events');
|
||
if (cell) {
|
||
positionPopup(popup, cell);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
// // 添加拾取效率按钮事件处理
|
||
// const efficiencyButtons = document.querySelectorAll('.pick-efficiency-btn');
|
||
// efficiencyButtons.forEach(btn => {
|
||
// btn.addEventListener('click', function (e) {
|
||
// e.stopPropagation();
|
||
// togglePickEfficiencyMode();
|
||
// });
|
||
// });
|
||
|
||
// 窗口大小变化时使用防抖
|
||
window.addEventListener('resize', debouncedAdjustTableHeader);
|
||
}
|
||
|
||
// 从文件名解析日期
|
||
function parseDateFromFileName(fileName) {
|
||
const match = fileName.match(/(\d{4})(\d{2})(\d{2})/);
|
||
if (match) {
|
||
return new Date(
|
||
parseInt(match[1]),
|
||
parseInt(match[2]) - 1,
|
||
parseInt(match[3])
|
||
);
|
||
}
|
||
return new Date(0); // 无效日期置前
|
||
}
|
||
|
||
// 在文件解析成功后显示导航按钮
|
||
function showQuickNavToggle() {
|
||
const quickNavToggle = document.getElementById('quickNavToggle');
|
||
if (quickNavToggle && hasLogData) {
|
||
quickNavToggle.style.display = 'block'; // 改为block显示
|
||
}
|
||
}
|
||
|
||
// 在文件解析失败或没有数据时隐藏导航按钮
|
||
function hideQuickNavToggle() {
|
||
const quickNavToggle = document.getElementById('quickNavToggle');
|
||
if (quickNavToggle) {
|
||
quickNavToggle.style.display = 'none'; // 确保隐藏
|
||
}
|
||
|
||
// 同时隐藏快速导航菜单
|
||
const quickNav = document.getElementById('quickNav');
|
||
if (quickNav) {
|
||
quickNav.classList.remove('visible');
|
||
}
|
||
}
|
||
|
||
// 日志解析逻辑
|
||
function parseLog(content, fileDate) {
|
||
const lines = content.split('\n');
|
||
let prevLine = "";
|
||
let lastCoordForRevive = null; // 用于血量恢复完成的坐标跟踪
|
||
let lastCoordForStuck = null; // 用于疑似卡死的坐标跟踪
|
||
let battleCount = 0; // 自动战斗计数器
|
||
|
||
// 精细加权系统
|
||
const WEIGHTS = {
|
||
SURVIVAL_AFTER_SKILL: 20, // 生存位技能后的切换 +20
|
||
NORMAL_SWITCH: 1, // 一般成功切换角色 +1
|
||
COLLECTION_SWITCH: -100, // 采集相关切换 -100(确保排除)
|
||
MOVEMENT_CONTEXT: 5 // 移动上下文权重 +8
|
||
};
|
||
|
||
// 任务级别的角色统计
|
||
let survivalWeights = new Map(); // 生存位权重
|
||
let walkWeights = new Map(); // 行走位权重
|
||
let dashWeights = new Map(); // 赶路位权重
|
||
let lastSwitchedRole = null; // 记录最近切换的角色
|
||
let pendingSurvivalAction = false; // 标记有生存位动作待处理
|
||
let nahidaCollect = false; // 纳西妲采集标记
|
||
let kazuhaCollect = false; // 枫原万叶采集标记
|
||
|
||
let currentGroup = null;
|
||
let currentTask = null;
|
||
|
||
blacklistDetected = false;
|
||
|
||
lines.forEach(line => {
|
||
if (!blacklistDetected) {
|
||
for (const keyword of BLACKLIST_KEYWORDS) {
|
||
if (line.includes(keyword)) {
|
||
blacklistDetected = true;
|
||
break;
|
||
}
|
||
}
|
||
// 在每行开始时更新当前组和任务
|
||
currentGroup = Array.from(parsingContext.activeGroups.values()).pop() || null;
|
||
if (currentGroup) {
|
||
currentTask = currentGroup.tasks.length > 0 ? currentGroup.tasks[currentGroup.tasks.length - 1] : null;
|
||
} else {
|
||
currentTask = null;
|
||
}
|
||
|
||
// 检测采集动作
|
||
if (line.includes('执行 "纳西妲" 长按E转圈拾取')) {
|
||
nahidaCollect = true;
|
||
} else if (line.includes('使用枫原万叶长E拾取掉落物') || line.includes('使用 枫原万叶-长E 拾取掉落物') || line.includes('使用 琴-长E 拾取掉落物')) {
|
||
// 配置0.52 战后琴拾取 聚材料命令 關鍵字更改來排除採集動作
|
||
kazuhaCollect = true;
|
||
}
|
||
|
||
// 检测生存位技能指令
|
||
if (line.includes('切换盾、回血角色,使用元素战技')) {
|
||
pendingSurvivalAction = true;
|
||
}
|
||
|
||
// 检测赶路位指令
|
||
// if (line.includes('自动赶路:"') && line.includes('赶路')) {
|
||
// const dashMatch = line.match(/自动赶路:"(.+?)" 赶路/);
|
||
// 检测赶路位指令(同时适配有无双引号,以及 “赶路” 或 “接近”)
|
||
if (line.includes('自动赶路:') && (line.includes('赶路') || line.includes('接近'))) {
|
||
// 正则解析:匹配“自动赶路:”后面,且在“赶路”或“接近”之前的角色名字(支持可选的双引号)
|
||
const dashMatch = line.match(/自动赶路:"?(.+?)"?(赶路|接近).*/);
|
||
if (dashMatch && currentGroup && currentTask) {
|
||
// 直接剔除所有的双引号
|
||
const dashRoleName = dashMatch[1].replace(/"/g, '').trim();
|
||
|
||
// 记录最近的赶路角色,用于排除行走位权重
|
||
currentTask.recentDashRole = dashRoleName;
|
||
// // 从行走位权重中移除该角色的权重,确保它不会被选为行走位
|
||
// walkWeights.delete(dashRoleName);
|
||
|
||
// 给赶路位较高的权重(比行走位高,比生存位技能低)
|
||
let dashWeightToAdd = 15; // 赶路位权重值
|
||
|
||
// 更新赶路位权重
|
||
const currentDashWeight = dashWeights.get(dashRoleName) || 0;
|
||
dashWeights.set(dashRoleName, currentDashWeight + dashWeightToAdd);
|
||
}
|
||
}
|
||
|
||
// 检测成功切换角色
|
||
if (line.includes('成功切换角色:"')) {
|
||
const roleMatch = line.match(/成功切换角色:"(.+?)"/);
|
||
if (roleMatch && currentGroup && currentTask) {
|
||
const roleName = roleMatch[1];
|
||
lastSwitchedRole = roleName; // 更新最近切换的角色
|
||
|
||
let survivalWeightToAdd = 0;
|
||
let walkWeightToAdd = 0;
|
||
|
||
// 检查最近是否有赶路操作
|
||
const hasRecentDash = currentTask.recentDashRole === roleName;
|
||
|
||
// 采集相关的切换 - 给负权重确保排除
|
||
if (nahidaCollect || kazuhaCollect) {
|
||
}
|
||
// 如果是赶路位角色的切换,不给行走位权重
|
||
else if (hasRecentDash) {
|
||
// 赶路位切换不计入行走位权重
|
||
}
|
||
// 生存位技能后的切换 - 高权重
|
||
else if (pendingSurvivalAction) {
|
||
survivalWeightToAdd = WEIGHTS.SURVIVAL_AFTER_SKILL;
|
||
walkWeightToAdd = WEIGHTS.NORMAL_SWITCH; // 同时也计入行走位
|
||
pendingSurvivalAction = false;
|
||
}
|
||
// 一般切换 - 正常权重
|
||
else {
|
||
walkWeightToAdd = WEIGHTS.NORMAL_SWITCH * 10;
|
||
}
|
||
|
||
// 移动上下文权重判断
|
||
if (prevLine.includes('到达路径点附近') ||
|
||
prevLine.includes('执行 "简易策略脚本"') ||
|
||
prevLine.includes('粗略接近途经点') ||
|
||
prevLine.includes('精确接近目标点')) {
|
||
walkWeightToAdd += WEIGHTS.MOVEMENT_CONTEXT;
|
||
}
|
||
|
||
// 交互或拾取后的切换权重 +8
|
||
if (prevLine.includes('交互或拾取:"')) {
|
||
walkWeightToAdd += 8;
|
||
}
|
||
|
||
// 更新权重
|
||
if (survivalWeightToAdd !== 0) {
|
||
const currentSurvivalWeight = survivalWeights.get(roleName) || 0;
|
||
survivalWeights.set(roleName, currentSurvivalWeight + survivalWeightToAdd);
|
||
}
|
||
|
||
if (walkWeightToAdd !== 0) {
|
||
const currentWalkWeight = walkWeights.get(roleName) || 0;
|
||
walkWeights.set(roleName, currentWalkWeight + walkWeightToAdd);
|
||
}
|
||
|
||
// 重置采集标记
|
||
nahidaCollect = false;
|
||
kazuhaCollect = false;
|
||
}
|
||
}
|
||
|
||
function finalizeGroup(group, endTime) {
|
||
if (!group.endTime) {
|
||
group.endTime = endTime;
|
||
}
|
||
// 检查是否有有效任务(可复用 hasTaskActualContent 逻辑)
|
||
let hasValidTasks = false;
|
||
group.tasks.forEach(task => {
|
||
if (hasTaskActualContent(task)) hasValidTasks = true;
|
||
});
|
||
if (!hasValidTasks) {
|
||
group.skipped = true;
|
||
return; // 跳过的组不处理角色信息
|
||
}
|
||
// 汇总配置组角色信息(原代码中“配置组结束”部分的处理)
|
||
const groupSurvivalRoles = new Map();
|
||
const groupWalkRoles = new Map();
|
||
const groupDashRoles = new Map();
|
||
group.tasks.forEach(task => {
|
||
if (task.survivalRoles && task.survivalRoles.length > 0) {
|
||
const main = task.survivalRoles[0];
|
||
groupSurvivalRoles.set(main, (groupSurvivalRoles.get(main) || 0) + 1);
|
||
}
|
||
if (task.walkRoles && task.walkRoles.length > 0) {
|
||
const main = task.walkRoles[0];
|
||
groupWalkRoles.set(main, (groupWalkRoles.get(main) || 0) + 1);
|
||
}
|
||
if (task.dashRoles && task.dashRoles.length > 0) {
|
||
const main = task.dashRoles[0];
|
||
groupDashRoles.set(main, (groupDashRoles.get(main) || 0) + 1);
|
||
}
|
||
});
|
||
const sortedSurvival = Array.from(groupSurvivalRoles.entries()).sort((a, b) => b[1] - a[1]);
|
||
group.survivalRoles = sortedSurvival.length > 0 ? [sortedSurvival[0][0]] : [];
|
||
const sortedWalk = Array.from(groupWalkRoles.entries()).sort((a, b) => b[1] - a[1]);
|
||
group.walkRoles = sortedWalk.length > 0 ? [sortedWalk[0][0]] : [];
|
||
const sortedDash = Array.from(groupDashRoles.entries()).sort((a, b) => b[1] - a[1]);
|
||
group.dashRoles = sortedDash.length > 0 ? [sortedDash[0][0]] : [];
|
||
}
|
||
|
||
// 解析配置组
|
||
let match = line.match(/配置组 "(.+?)" 加载完成/);
|
||
if (match) {
|
||
const groupName = match[1];
|
||
// 强制结束当前活跃的配置组(无论名称是否相同)
|
||
const activeGroupsList = Array.from(parsingContext.activeGroups.values());
|
||
if (activeGroupsList.length > 0) {
|
||
// 通常只有一个活跃组,取最后一个(即当前正在运行的组)
|
||
const currentActiveGroup = activeGroupsList[activeGroupsList.length - 1];
|
||
finalizeGroup(currentActiveGroup, parseTime(prevLine, fileDate));
|
||
parsingContext.allGroups.push(currentActiveGroup);
|
||
parsingContext.activeGroups.delete(currentActiveGroup.name);
|
||
}
|
||
|
||
// 创建新配置组
|
||
let group = {
|
||
name: groupName,
|
||
startTime: parseTime(prevLine, fileDate),
|
||
endTime: null,
|
||
tasks: [],
|
||
picks: new Map(),
|
||
lastActive: null,
|
||
teamRoles: new Set(),
|
||
survivalRoles: [],
|
||
walkRoles: [],
|
||
dashRoles: [],
|
||
hasRotationTargeting: false,
|
||
hasBeamPickup: false,
|
||
};
|
||
group.lastActive = parseTime(prevLine, fileDate);
|
||
parsingContext.activeGroups.set(groupName, group);
|
||
|
||
// 重置各种计数器
|
||
battleCount = 0;
|
||
lastCoordForRevive = null;
|
||
lastCoordForStuck = null;
|
||
survivalWeights.clear();
|
||
walkWeights.clear();
|
||
lastSwitchedRole = null;
|
||
pendingSurvivalAction = false;
|
||
nahidaCollect = false;
|
||
kazuhaCollect = false;
|
||
|
||
currentGroup = group;
|
||
}
|
||
|
||
// 配置组结束
|
||
match = line.match(/配置组 "(.+?)" 执行结束/);
|
||
if (match) {
|
||
const group = parsingContext.activeGroups.get(match[1]);
|
||
if (group) {
|
||
finalizeGroup(group, parseTime(prevLine, fileDate));
|
||
parsingContext.allGroups.push(group);
|
||
parsingContext.activeGroups.delete(match[1]);
|
||
|
||
// 重置全局角色计数
|
||
survivalWeights.clear();
|
||
walkWeights.clear();
|
||
lastSwitchedRole = null;
|
||
pendingSurvivalAction = false;
|
||
nahidaCollect = false;
|
||
kazuhaCollect = false;
|
||
|
||
currentGroup = Array.from(parsingContext.activeGroups.values()).pop() || null;
|
||
}
|
||
}
|
||
|
||
// 解析任务
|
||
if (currentGroup) {
|
||
// 识别到的队伍角色
|
||
if (line.includes('识别到的队伍角色:"')) {
|
||
const match = line.match(/识别到的队伍角色:"(.+?)"/);
|
||
if (match && currentGroup) {
|
||
const teamRoleStr = match[1];
|
||
currentGroup.teamRoles.add(teamRoleStr);
|
||
}
|
||
}
|
||
|
||
// 檢測旋轉索敵
|
||
if (line.includes('敌人位置: (') && line.includes('血量高度:')) {
|
||
currentGroup.hasRotationTargeting = true;
|
||
}
|
||
|
||
// 检测战后光柱拾取
|
||
if (line.includes('超时或视野内没有可拾取物品,结束扫描')) {
|
||
if (currentGroup) {
|
||
currentGroup.hasBeamPickup = true;
|
||
}
|
||
}
|
||
|
||
// 检测自动战斗开始
|
||
if (line.includes('执行 "自动战斗"')) {
|
||
battleCount++;
|
||
}
|
||
|
||
// match = line.match(/→ 开始执行地图追踪任务: "(.+?)"/);
|
||
// match = line.match(/→ 开始执行路径追踪任务: "(.+?)"/)
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"/);
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|assets\/(.+?\.json)/);
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|assets\/(.+?\.json)|当前钓鱼点: (.+)/);
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|assets\/(.+?\.json)|当前钓鱼点: (.+)|→ 开始执行JS脚本: "(.+?)"/);
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|开始购买NPC: "(.+?)"|当前钓鱼点: (.+)|→ 开始执行JS脚本: "(.+?)"/);
|
||
// match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|开始购买NPC: "(.+?)"|assets\/(.+?\.json)|当前钓鱼点: (.+)|→ 开始执行JS脚本: "(.+?)"|→ 开始执行键鼠脚本: "(.+?)"/);
|
||
match = line.match(/→ 开始执行(?:地图|路径)追踪任务: "(.+?)"|assets\/(.+?\.json)|→ 开始执行JS脚本: "(.+?)"|→ 开始执行键鼠脚本: "(.+?)"/);
|
||
if (match) {
|
||
// const taskName = match[1] || match[2] || match[3] || match[4];
|
||
const taskName = match[1] || match[2] || match[3] || match[4];
|
||
const task = {
|
||
name: taskName,
|
||
startTime: parseTime(prevLine, fileDate),
|
||
endTime: null,
|
||
faults: {
|
||
revive: 0,
|
||
teleport: 0,
|
||
retry: 0,
|
||
retryDetail: 0,
|
||
too_far_skip: 0,
|
||
timeout: 0
|
||
},
|
||
picks: new Map(),
|
||
reviveEvents: [], // 复活事件
|
||
timeoutEvents: [], // 超时事件
|
||
maxBattleCount: 0, // 记录最大战斗次数
|
||
specialAlerts: new Map(), // 用于计数特殊事件
|
||
survivalRoles: [], // 生存位角色
|
||
walkRoles: [], // 行走位角色
|
||
dashRoles: [], // 赶路位角色
|
||
recentDashRole: null, // 最近的赶路角色,用于排除行走位权重
|
||
skipped: false // 跳过标记
|
||
};
|
||
currentGroup.tasks.push(task);
|
||
parsingContext.activeTasks.set(task.name, task);
|
||
battleCount = 0;
|
||
|
||
// 重置任务级别的角色统计
|
||
survivalWeights.clear();
|
||
walkWeights.clear();
|
||
lastSwitchedRole = null;
|
||
pendingSurvivalAction = false;
|
||
nahidaCollect = false;
|
||
kazuhaCollect = false;
|
||
|
||
// 更新当前任务
|
||
currentTask = task;
|
||
}
|
||
|
||
// 任務結束
|
||
match = line.match(/→ 脚本执行结束: "(.+?)"/);
|
||
if (match) {
|
||
const task = parsingContext.activeTasks.get(match[1]);
|
||
if (task) {
|
||
task.endTime = parseTime(prevLine, fileDate);
|
||
|
||
// 任务结束时,如果还有待处理的生存位动作,使用最近切换的角色
|
||
if (pendingSurvivalAction && lastSwitchedRole && !nahidaCollect && !kazuhaCollect) {
|
||
const currentWeight = survivalWeights.get(lastSwitchedRole) || 0;
|
||
survivalWeights.set(lastSwitchedRole, currentWeight + 3); // 中等权重
|
||
pendingSurvivalAction = false;
|
||
}
|
||
|
||
// 确定生存位:取权重最高的角色(只考虑正权重)
|
||
let finalSurvivalRole = null;
|
||
if (survivalWeights.size > 0) {
|
||
const sortedSurvival = Array.from(survivalWeights.entries())
|
||
.filter(([role, weight]) => weight > 0) // 只考虑正权重
|
||
.sort((a, b) => b[1] - a[1]);
|
||
if (sortedSurvival.length > 0) {
|
||
finalSurvivalRole = sortedSurvival[0][0];
|
||
}
|
||
}
|
||
|
||
// 确定行走位:取权重最高的角色(只考虑正权重)
|
||
let finalWalkRole = null;
|
||
if (walkWeights.size > 0) {
|
||
const sortedWalk = Array.from(walkWeights.entries())
|
||
.filter(([role, weight]) => weight > 0) // 只考虑正权重
|
||
.sort((a, b) => b[1] - a[1]);
|
||
if (sortedWalk.length > 0) {
|
||
finalWalkRole = sortedWalk[0][0];
|
||
}
|
||
}
|
||
|
||
// 确定赶路位:取权重最高的角色(只考虑正权重)
|
||
let finalDashRole = null;
|
||
if (dashWeights.size > 0) {
|
||
const sortedDash = Array.from(dashWeights.entries())
|
||
.filter(([role, weight]) => weight > 0)
|
||
.sort((a, b) => b[1] - a[1]);
|
||
if (sortedDash.length > 0) {
|
||
finalDashRole = sortedDash[0][0];
|
||
}
|
||
}
|
||
|
||
// 保存到任务
|
||
task.survivalRoles = finalSurvivalRole ? [finalSurvivalRole] : [];
|
||
task.walkRoles = finalWalkRole ? [finalWalkRole] : [];
|
||
task.dashRoles = finalDashRole ? [finalDashRole] : [];
|
||
|
||
// 调试输出
|
||
// console.log(`任务 ${task.name} 生存位权重:`, Array.from(survivalWeights.entries()));
|
||
// console.log(`任务 ${task.name} 行走位权重:`, Array.from(walkWeights.entries()));
|
||
// console.log(`任务 ${task.name} 最终结果:`, {
|
||
// survival: task.survivalRoles,
|
||
// walk: task.walkRoles
|
||
// });
|
||
|
||
parsingContext.activeTasks.delete(task.name);
|
||
|
||
// 重置角色计数
|
||
survivalWeights.clear();
|
||
walkWeights.clear();
|
||
dashWeights.clear();
|
||
lastSwitchedRole = null;
|
||
pendingSurvivalAction = false;
|
||
nahidaCollect = false;
|
||
kazuhaCollect = false;
|
||
|
||
// 重置赶路角色标记
|
||
if (currentTask) {
|
||
currentTask.recentDashRole = null;
|
||
}
|
||
|
||
// 更新当前任务
|
||
currentTask = currentGroup.tasks.length > 0 ? currentGroup.tasks[currentGroup.tasks.length - 1] : null;
|
||
}
|
||
}
|
||
|
||
// 统计信息
|
||
if (currentTask) {
|
||
// 检测任务跳过信息
|
||
if (line.includes("任务已到禁止执行时段,将跳过")) {
|
||
currentTask.skipped = true;
|
||
// 记录跳过信息到特殊事件
|
||
// const message = line.trim();
|
||
// const type = 'abnormal-alert';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
}
|
||
|
||
// 更新最大战斗次数
|
||
if (battleCount > currentTask.maxBattleCount) {
|
||
currentTask.maxBattleCount = battleCount;
|
||
}
|
||
|
||
// 捕获坐标信息(无论是否在卡死前)
|
||
// const coordMatch = line.match(/粗略接近途经点,位置\("(-?\d+(?:\.\d+)?)","(-?\d+(?:\.\d+)?)"\)/);
|
||
const coordMatch = line.match(/(?:粗略接近途经点|精确接近目标点),位置\("(-?\d+(?:\.\d+)?)","(-?\d+(?:\.\d+)?)"\)/);
|
||
if (coordMatch) {
|
||
// 同时更新两个坐标跟踪器
|
||
lastCoordForRevive = { x: coordMatch[1], y: coordMatch[2] };
|
||
lastCoordForStuck = { x: coordMatch[1], y: coordMatch[2] };
|
||
}
|
||
|
||
// if (line.includes("前往七天神像复活")) currentTask.faults.revive++;
|
||
|
||
// 复活事件
|
||
if (line.includes("血量恢复完成。")) {
|
||
currentTask.faults.revive++;
|
||
// 记录复活事件对应的战斗序号和坐标
|
||
currentTask.reviveEvents.push({
|
||
battleCount: battleCount,
|
||
coord: lastCoordForRevive ? { x: lastCoordForRevive.x, y: lastCoordForRevive.y } : null
|
||
});
|
||
// 重置复活坐标跟踪器
|
||
lastCoordForRevive = null;
|
||
}
|
||
|
||
if (line.includes("当前角色血量过低")) currentTask.faults.revive = currentTask.faults.revive - 0.9;
|
||
if (line.match(/传送失败,重试 (\d+) 次/)) {
|
||
currentTask.faults.teleport = parseInt(RegExp.$1);
|
||
} else if (line.includes("多次尝试未移动到目标传送点,传送失败") || line.includes("目标传送点未移动到可点击区域,传送失败") || line.includes("等待传送点交互面板超时 重试")) {
|
||
// 没有具体重试次数,每次+1
|
||
currentTask.faults.teleport++;
|
||
}
|
||
// if (line.includes("重试一次路线")) currentTask.faults.retry++;
|
||
// if (line.includes("记录恢复点位,地图追踪将到达上次点位之前将跳过走路之外的操作")) currentTask.faults.retry++;
|
||
if (line.includes("记录恢复点位,地图追踪将到达上次点位之前将跳过走路之外的操作")) {
|
||
// if (line.includes("此路线出现3次卡死,重试一次路线或放弃此路线!")) {
|
||
currentTask.faults.retry++;
|
||
// 当重试次数超过2时,添加异常消息
|
||
if (currentTask && currentTask.faults.retry > 2) {
|
||
const message = '路线多次卡死,放弃此路线!';
|
||
const type = 'abnormal-alert';
|
||
if (!currentTask.specialAlerts.has(message)) {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
if (line.includes("疑似卡死,尝试脱离...") || line.includes("疑似卡死,尝试随机脱离...") || line.includes("尝试朝向上一个节点")) {
|
||
currentTask.faults.retryDetail++;
|
||
if (line.includes("尝试朝向上一个节点")) {
|
||
currentTask.faults.retryDetail = currentTask.faults.retryDetail - 0.9;
|
||
}
|
||
// 使用最近捕获的坐标
|
||
if (lastCoordForStuck) {
|
||
if (!currentTask.faults.coords) {
|
||
currentTask.faults.coords = [];
|
||
}
|
||
currentTask.faults.coords.push(lastCoordForStuck);
|
||
// 重置卡死坐标跟踪器
|
||
lastCoordForStuck = null;
|
||
}
|
||
}
|
||
// if (line.includes("距离过远,跳过路径点")) currentTask.faults.too_far_skip++;
|
||
// 0.56.后不傳回极大的坐标
|
||
if (
|
||
(line.includes("距离过远") && /\(\d+\.?\d*,\d+\.?\d*\)->\(\d+\.?\d*,\d+\.?\d*\)=\d+\.?\d*,跳过路径点/) ||
|
||
line.includes("未识别到当前位置")
|
||
) {
|
||
currentTask.faults.too_far_skip++;
|
||
}
|
||
|
||
if (line.includes(",重试多次后仍然失败,放弃此路径点!")) {
|
||
const message = '路径识别失败,放弃部份路径';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 战斗超时事件
|
||
// if (line.includes("战斗超时")) {
|
||
if (line.includes("战斗超时结束") || line.includes("旋转次数达到上限,战斗结束")) {
|
||
currentTask.faults.timeout++;
|
||
// 记录超时事件对应的战斗序号
|
||
currentTask.timeoutEvents.push(battleCount);
|
||
}
|
||
|
||
// 特殊事件的处理逻辑,使用计数而不是重复添加
|
||
// 0. 识别到的队伍角色:".*"
|
||
// test. 測試用例子
|
||
// if (line.includes('识别到的队伍角色:"')) {
|
||
// const match = line.match(/识别到的队伍角色:"(.+?)"/);
|
||
// if (match) {
|
||
// const message = `队伍角色:"${match[1]}"`;
|
||
// const type = 'auto-potion';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
// }
|
||
// if (line.includes('成功切换角色:"')) {
|
||
// const match = line.match(/成功切换角色:"(.+?)"/);
|
||
// if (match) {
|
||
// const message = `成功切换角色:"${match[1]}"`;
|
||
// const type = 'auto-potion';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
// }
|
||
// if (line.includes('切换盾、回血角色,使用元素战技')) {
|
||
// const message = `生存位技能`;
|
||
// const type = 'auto-potion';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
|
||
// 1. 开始自动领取派遣任务!
|
||
if (line.includes("开始自动领取派遣任务!")) {
|
||
const message = '领取派遣任务';
|
||
const type = 'dispatch-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 2. 自动吃药
|
||
if (line.includes('检测到红血且不在CD,自动吃药') || line.includes('自动吃药:"发现红血" 使用小道具')) {
|
||
const message = '自动吃药';
|
||
const type = 'auto-potion';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 3. 快捷键触发暂停,等待解除
|
||
if (line.includes("快捷键触发暂停,等待解除")) {
|
||
const message = '快捷键暂停';
|
||
const type = 'pause-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 4. 文件找不到
|
||
if (line.includes('"Could not find file') || line.includes('"Could not find a part of the path')) {
|
||
const message = '路径文件丢失';
|
||
const type = 'file-missing';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 5. 战斗策略错误
|
||
if (line.includes('执行地图追踪时候发生错误: "战斗策略脚本中出现未知的方法:')) {
|
||
const match = line.match(/执行地图追踪时候发生错误: "战斗策略脚本中出现未知的方法:(.+?)"/);
|
||
if (match) {
|
||
const message = `地图追踪战斗策略错误:"${match[1]}"`;
|
||
const type = 'strategy-error';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 5.1 战斗策略错误-角色名称校验失败(地图追踪策略脚本错误)
|
||
if (line.includes('执行地图追踪时候发生错误: "角色名称校验失败:')) {
|
||
const match = line.match(/执行地图追踪时候发生错误: "角色名称校验失败:(.+?)"/);
|
||
if (match) {
|
||
const message = `地图追踪策略脚本错误:"${match[1]}"`;
|
||
const type = 'strategy-error';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 5.5 策略脚本action_params内容为空
|
||
if (
|
||
line.includes('策略脚本action_params内容为空')) {
|
||
const message = '路徑中策略脚本内容为空';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 6. 战斗脚本设置错误
|
||
if (
|
||
// line.includes('执行脚本时发生异常: "未匹配到任何战斗脚本"')
|
||
// || line.includes('执行地图追踪时候发生错误: "未匹配到任何战斗脚本"')
|
||
line.includes('未匹配到任何战斗脚本')
|
||
|| line.includes('执行地图追踪时候发生错误: "战斗策略文件不存在"')) {
|
||
const message = '未匹配到任何战斗脚本';
|
||
const type = 'combat-script-error';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 7. 缺少元素采集角色
|
||
if (line.includes('此路径存在 "') && line.includes('元素采集 动作,')) {
|
||
const match = line.match(/此路径存在 "(.+?)"元素采集 动作,/);
|
||
if (match) {
|
||
const message = `队伍缺少 ${match[1]} 元素采集角色`;
|
||
const type = 'element-missing';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 7.5 切人失败,无法进行"X"元素采集
|
||
if (line.includes('切人失败,无法进行"') && line.includes('元素采集')) {
|
||
const match = line.match(/切人失败,无法进行"(.+?)"元素采集/);
|
||
if (match) {
|
||
const message = `切人失败,无法进行 ${match[1]} 元素采集`;
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 8. 缺少纳西妲
|
||
if (line.includes('此路径存在纳西妲收集动作,队伍中没有纳西妲角色,无法执行此路径!')) {
|
||
const message = '队伍缺少纳西妲';
|
||
const type = 'nahida-missing';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 9. 切换队伍失败
|
||
if (line.includes('切换队伍失败,无法执行此路径!请检查配置组中的地图追踪配置!')) {
|
||
const message = '切换队伍失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 10. 当前获取焦点的窗口不是原神,尝试恢复窗口
|
||
if (line.includes("当前获取焦点的窗口不是原神,尝试恢复窗口") || (line.includes("当前获取焦点的窗口为: ") && line.includes(",不是原神,尝试恢复窗口"))) {
|
||
const message = '窗口焦点异常,尝试恢复';
|
||
const type = 'pause-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
//10.1
|
||
if (line.includes("当前获取焦点的窗口不是原神,暂停") || (line.includes("当前获取焦点的窗口为: ") && line.includes(",不是原神,暂停"))) {
|
||
const message = '窗口焦点异常,暂停';
|
||
const type = 'pause-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
//10.2
|
||
if (line.includes("多次尝试未恢复,尝试最小化后激活窗口!")) {
|
||
const message = '窗口焦点异常,最小化重试';
|
||
const type = 'pause-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 11. 队伍角色识别失败
|
||
if (line.includes("队伍角色识别失败")) {
|
||
const message = '队伍角色识别失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 12. 打开大地图失败,请检查按键绑定中「打开地图」按键设置是否和原神游戏中一致!
|
||
if (line.includes("打开大地图失败,重试 3 次") || line.includes("打开大地图失败,请检查按键绑定中「打开地图」按键设置是否和原神游戏中一致!")) {
|
||
const message = '打开地图失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 13. 选项列表不存在传送点 重试
|
||
if (line.includes("选项列表不存在传送点 重试") ||
|
||
line.includes("传送点未激活或不存在 重试") ||
|
||
line.match(/选项列表不存在传送点/) ||
|
||
line.match(/执行脚本时发生异常: "点击传送点后未出现交互面板,可能是传送点未激活"/) ||
|
||
line.match(/执行地图追踪时候发生错误: "点击传送点后未出现交互面板,可能是传送点未激活"/)) {
|
||
currentTask.faults.teleport++;
|
||
const message = '传送点不存在或未激活';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 13.5 执行地图追踪时候发生错误: "传送失败"
|
||
if (line.includes("执行地图追踪时候发生错误: \"传送失败\"") ||
|
||
line.includes("执行脚本时发生异常: \"传送失败\"") ||
|
||
line.includes("执行脚本时发生异常: \"单次传送超过") ||
|
||
line.includes("执行地图追踪时候发生错误: \"单次传送超过")) {
|
||
const message = '传送失败,跳过路径';
|
||
const type = 'abnormal-alert';
|
||
currentTask.faults.teleport++;
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 13.6 传送等待超时,换台电脑吧
|
||
if (line.includes("传送等待超时,换台电脑吧")) {
|
||
const message = '传送等待超时';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
|
||
// 14. 选项列表不存在传送点 重试
|
||
if (line.includes("识别大地图位置失败")) {
|
||
const message = '识别大地图位置失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 15. 切换区域失败:".*"
|
||
if (line.includes('切换区域失败:"')) {
|
||
const match = line.match(/切换区域失败:"(.+?)"/);
|
||
if (match) {
|
||
const message = `切换区域失败:"${match[1]}"`;
|
||
const type = 'pause-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 16. 执行地图追踪时候发生错误: "未能返回主界面"
|
||
if (line.includes('执行地图追踪时候发生错误: "未能返回主界面"')) {
|
||
const message = '未能返回主界面';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 16.5. 检测到其他界面
|
||
if (line.includes('检测到其他界面')) {
|
||
const message = '检测到其他界面,关闭其他界面';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 17. 调度器任务出现未预期的异常,自动重启bgi
|
||
if (line.includes('调度器任务出现未预期的异常,自动重启bgi')) {
|
||
const message = '自动重启bgi';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 18. 任务启动失败:当前存在正在运行中的独立任务,请不要重复执行任务!
|
||
if (line.includes('任务启动失败:当前存在正在运行中的独立任务,请不要重复执行任务!')) {
|
||
const message = '任务启动失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 19. 简易策略脚本要求的角色不存在!队伍中需要存在下面角色中的一个或多个:".*"
|
||
if (line.includes('简易策略脚本要求的角色不存在!队伍中需要存在下面角色中的一个或多个:"')) {
|
||
const match = line.match(/简易策略脚本要求的角色不存在!队伍中需要存在下面角色中的一个或多个:"(.+?)"/);
|
||
if (match) {
|
||
const message = `缺少脚本指定角色:"${match[1]}"`;
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 20. 队伍切换失败
|
||
if (line.startsWith('队伍切换失败')) {
|
||
const message = '队伍切换失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 21.没有找到四叶印
|
||
if (line.startsWith('没有找到四叶印')) {
|
||
const message = '没有找到四叶印';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 22.未识别到具体路径,取上次点位
|
||
// if (line.startsWith('未识别到具体路径,取上次点位')) {
|
||
// const message = '地圖识别錯誤,取上次点位';
|
||
// const type = 'pause-alert';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
|
||
// 23.未识别到具体路径,打开地图计算中心点
|
||
// if (line.startsWith('未识别到具体路径,打开地图计算中心点')) {
|
||
// const message = '地圖识别錯誤,打开地图计算中心点';
|
||
// const type = 'pause-alert';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
|
||
// 24.鋤地一條龍1.10.0(强制黑芙)
|
||
if (line.startsWith('上条路线识别到白芙,开始强制切换黑芙')) {
|
||
const message = '强制切换黑芙';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 25.鋤地一條龍(检测到冻结,尝试挣脱)
|
||
if (line.startsWith('检测到冻结,尝试挣脱')) {
|
||
const message = '冻结挣脱';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 26.鋤地一條龍(检测到烹饪界面,尝试脱离)
|
||
if (line.startsWith('检测到烹饪界面,尝试脱离')) {
|
||
const message = '脱离烹饪界面';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 27.鋤地一條龍(坐标获取异常,不记录运行数据)
|
||
if (
|
||
line.includes('坐标获取异常,不记录运行数据') || // 鋤地2.0.2前日志
|
||
line.includes('路线未正常完成、坐标获取异常或不处于主界面,不记录运行数据') || // 鋤地2.0.3日志
|
||
line.includes('距离异常,不记录数据') || // 采集cd管理
|
||
(line.includes('出现异常') && line.includes('不记录cd')) ||
|
||
line.includes('坐标获取失败,不更新记录') || // CD-Aware-AutoGather2.0前日志
|
||
line.includes('出发点与终点过于接近,不记录运行数据') ||
|
||
line.includes('位置几乎未变化,不更新刷新时间') ||
|
||
line.includes('路线运行失败:') // 采集cd管理3.1.0/鋤地2.12.0 起 莫醬版BGI路線失敗
|
||
) {
|
||
const message = '终点坐标异常,不记录';
|
||
const type = 'abnormal-alert';
|
||
// currentTask.faults.too_far_skip++;
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 28.調時(设置时间到 HH 点 MM 分)
|
||
// if (line.includes("设置时间到") && line.includes("点") && line.includes("分")) {
|
||
// const match = line.match(/设置时间到 (\d+) 点 (\d+) 分/);
|
||
// if (match) {
|
||
// const hour = match[1];
|
||
// const minute = match[2];
|
||
// const message = `调时至${hour}时${minute}分`;
|
||
// const type = 'purple-alert';
|
||
// if (currentTask.specialAlerts.has(message)) {
|
||
// const existing = currentTask.specialAlerts.get(message);
|
||
// existing.count++;
|
||
// } else {
|
||
// currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
// 29. 采集cd管理(进行食材加工)
|
||
if (line.match(/正在前往.*进行食材加工/)) {
|
||
const message = '进行食材加工';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 30. 战斗过程检测到游泳,前往七天神像重试
|
||
if (line.includes('游泳检测:尝试回到战斗地点')) {
|
||
const message = '战斗时游泳,回战斗地点';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 31. 战斗过程检测到游泳,前往七天神像重试
|
||
if (line.includes('战斗过程检测到游泳,前往七天神像重试')) {
|
||
const message = '战斗时游泳,回七天神像';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 32. 游戏窗口分辨率错误
|
||
if (line.includes('游戏窗口分辨率小于 1920x1080 !无法使用地图追踪功能!') || line.includes('执行脚本时发生异常: "游戏窗口分辨率不是 16:9"')) {
|
||
const message = '游戏窗口分辨率错误';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 33.鋤地一條龍2.8.0(使用复活料理 & 使用回血料理)
|
||
if (line.match(/交互或拾取:"使用(复活|回血)料理"/)) {
|
||
const match = line.match(/交互或拾取:"使用(复活|回血)料理"/);
|
||
if (match) {
|
||
const foodType = match[1]; // 获取捕获组中的 '复活' 或 '回血'
|
||
const message = `使用${foodType}料理`;
|
||
const type = 'auto-potion';
|
||
|
||
// 优化 Map 的更新逻辑
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
if (existing) {
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 34.切换角色卡住,执行脱困
|
||
if (line.includes('切换角色卡住,执行脱困')) {
|
||
const message = '切换角色卡住,执行脱困';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 35.处于限制时间内
|
||
if (line.includes('处于限制时间内')) {
|
||
const message = '处于限制时间内';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 35.5 接近限制时间,等待X分钟
|
||
const waitMatch = line.match(/接近限制时间,等待 (\d+) 分钟/);
|
||
if (waitMatch) {
|
||
const waitMin = waitMatch[1];
|
||
const message = `接近限制时间,等待 ${waitMin} 分钟`;
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 36.进入钓鱼模式失败
|
||
if (line.includes('进入钓鱼模式失败')) {
|
||
const message = '进入钓鱼模式失败';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 37. 检测到复苏按钮,点击 or 复苏完成
|
||
if (line.includes('检测到复苏按钮,点击') || line.includes('复苏完成')) {
|
||
const message = '全队死亡,复苏';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 38.已达到总运行限时(采集CD管理3.1.0)
|
||
if (line.includes('已达到总运行限时 ')) {
|
||
const message = '已达到总运行限时,结束脚本';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 39.检测路线文件格式错误(鋤地一條龍2.13.0)
|
||
const routeErrorMatch = line.match(/(读取或解析路线文件失败|路线文件结构无效|路线文件标签格式无效),跳过 (.+?):/);
|
||
if (routeErrorMatch) {
|
||
const path = routeErrorMatch[2]; // 提取路径
|
||
const message = `路线文件格式有誤:${path}`;
|
||
const type = 'abnormal-alert';
|
||
if (currentTask) {
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// 40.视角转动超时
|
||
if (line.includes('视角转动到目标角度超时,停止转动')) {
|
||
const message = '视角转动超时';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 41.执行脚本时发生异常: "Index was outside the bounds of the array."
|
||
if (line.includes('执行脚本时发生异常: "Index was outside the bounds of the array."') ||
|
||
line.includes('执行地图追踪时候发生错误: "Index was outside the bounds of the array."')) {
|
||
const message = '资源缺失,请重新安装BGI';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 42.执行地图追踪时候发生错误: "不存在的角色编号"
|
||
if (line.includes('执行地图追踪时候发生错误: "不存在的角色编号"')) {
|
||
const message = '切换角色参数设定错误';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 43.加入黑名单(鋤地一條龍)
|
||
if (line.includes('加入黑名单:')) {
|
||
const match = line.match(/加入黑名单:(.+)/);
|
||
if (match) {
|
||
const itemName = match[1].trim();
|
||
const message = `加入黑名单:"${itemName}" `;
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
}
|
||
|
||
// LCB版
|
||
// 900. 网络恢复中...
|
||
if (line.includes('网络恢复中...')) {
|
||
const message = '网络恢复中...';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 995. 执行超时,放弃此次追踪
|
||
if (line.includes("执行超时,放弃此次追踪")) {
|
||
const message = '路径点执行超时,放弃整条路径';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 996. 进入剧情,自动点击剧情直到结束
|
||
if (line.includes('进入剧情')) {
|
||
const message = '进入剧情';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 997. 检测到空月祝福界面,自动点击
|
||
if (line.includes('检测到空月祝福界面,自动点击')) {
|
||
const message = '领取空月祝福';
|
||
const type = 'purple-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 998. 用户取消,终止运行
|
||
// if (line.includes('用户取消,终止运行') || line.includes('取消自动任务') || line.includes('检测到您配置的停止快捷键"')) {
|
||
if (line.includes('用户取消,终止运行') || line.includes('检测到您配置的停止快捷键"')) {
|
||
const message = '用户终止运行';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 999. 此追踪脚本未正常走完!
|
||
if (line.includes('此追踪脚本未正常走完!')) {
|
||
const message = '脚本未正常走完';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
// 1000. 游戏窗口大小发生变化
|
||
if (line.includes('游戏窗口大小发生变化')) {
|
||
const message = '游戏窗口大小发生变化';
|
||
const type = 'abnormal-alert';
|
||
if (currentTask.specialAlerts.has(message)) {
|
||
const existing = currentTask.specialAlerts.get(message);
|
||
existing.count++;
|
||
} else {
|
||
currentTask.specialAlerts.set(message, { type: type, count: 1 });
|
||
}
|
||
}
|
||
|
||
const pickPatterns = [
|
||
/交互或拾取:"(.+?)"/, // 原有模式
|
||
/尝试钓取 "(.+?)"/, // 釣魚模式
|
||
/拉扯结束/ // 釣魚結束標記
|
||
];
|
||
|
||
let pickMatchResult = null;
|
||
let pickItemName = null;
|
||
|
||
// 使用配置的模式進行匹配
|
||
for (const pattern of pickPatterns) {
|
||
const match = line.match(pattern);
|
||
if (match) {
|
||
pickMatchResult = match;
|
||
|
||
// 提取拾取物名稱
|
||
// 如果有捕獲組(.*),使用捕獲組內容作為拾取物
|
||
// 如果沒有捕獲組,使用整個匹配字符串作為拾取物
|
||
if (match.length > 1 && match[1]) {
|
||
pickItemName = match[1];
|
||
} else {
|
||
pickItemName = match[0];
|
||
}
|
||
|
||
break; // 匹配到一個模式就停止
|
||
}
|
||
}
|
||
if (pickItemName) {
|
||
currentTask.picks.set(pickItemName, (currentTask.picks.get(pickItemName) || 0) + 1);
|
||
currentGroup.picks.set(pickItemName, (currentGroup.picks.get(pickItemName) || 0) + 1);
|
||
|
||
// 記錄拾取順序
|
||
if (!currentTask.pickSequence) {
|
||
currentTask.pickSequence = [];
|
||
}
|
||
currentTask.pickSequence.push(pickItemName);
|
||
}
|
||
}
|
||
}
|
||
prevLine = line;
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
// 清理任务名称:提取纯文件名(不含路径和扩展名)
|
||
function getFileNameWithoutExtension(fullPath) {
|
||
// 先提取文件名(不含路径)
|
||
const fileName = fullPath.split('\\').pop(); // 按反斜杠分割取最后一部分
|
||
|
||
// 再去掉扩展名
|
||
// const nameWithoutExt = fileName.replace(/\.\w+$/, '');
|
||
// 只移除特定的扩展名,如 .json
|
||
const nameWithoutExt = fileName.replace(/\.(json|txt|xml|jpg|png)$/i, '');
|
||
|
||
return nameWithoutExt;
|
||
}
|
||
|
||
// 检查任务是否有实际执行内容
|
||
function hasTaskActualContent(task) {
|
||
// 如果有任何统计信息不为0,说明有实际执行
|
||
if (task.faults.revive > 0 ||
|
||
task.faults.teleport > 0 ||
|
||
task.faults.retry > 0 ||
|
||
task.faults.retryDetail > 0 ||
|
||
task.faults.too_far_skip > 0 ||
|
||
task.faults.timeout > 0) {
|
||
return true;
|
||
}
|
||
|
||
// 如果有拾取物,说明有实际执行
|
||
if (task.picks && task.picks.size > 0) {
|
||
return true;
|
||
}
|
||
|
||
// 如果有特殊事件(除了跳过相关的),说明有实际执行
|
||
if (task.specialAlerts && task.specialAlerts.size > 0) {
|
||
for (let [message, alertInfo] of task.specialAlerts) {
|
||
// 排除跳过相关的消息
|
||
if (!message.includes('跳过') && !message.includes('禁止执行时段')) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 如果任务持续时间超过很短的时间(比如10秒),说明可能有实际执行
|
||
if (task.startTime && task.endTime) {
|
||
const duration = (task.endTime.getTime() - task.startTime.getTime()) / 1000;
|
||
if (duration > -1) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
// 在 finalizeParsing 函数中过滤掉跳过的配置组
|
||
function finalizeParsing() {
|
||
// 处理未完成任务
|
||
parsingContext.activeTasks.forEach(task => {
|
||
task.endTime = task.startTime;
|
||
});
|
||
|
||
// 处理未完成配置组
|
||
parsingContext.activeGroups.forEach(group => {
|
||
group.endTime = group.tasks.length > 0
|
||
? group.tasks[group.tasks.length - 1].startTime
|
||
: group.startTime;
|
||
|
||
// 检查配置组是否只有跳过的任务
|
||
let hasValidTasks = false;
|
||
group.tasks.forEach(task => {
|
||
if (hasTaskActualContent(task)) {
|
||
hasValidTasks = true;
|
||
}
|
||
});
|
||
|
||
if (!hasValidTasks) {
|
||
group.skipped = true;
|
||
}
|
||
|
||
parsingContext.allGroups.push(group);
|
||
});
|
||
|
||
// 过滤掉跳过的配置组
|
||
parsingContext.allGroups = parsingContext.allGroups.filter(group => !group.skipped);
|
||
|
||
return parsingContext.allGroups.sort((a, b) =>
|
||
(b.endTime || b.startTime) - (a.endTime || a.startTime)
|
||
);
|
||
}
|
||
|
||
function formatDuration(seconds) {
|
||
if (seconds < 0) return "时间异常"; // 处理负值情况
|
||
|
||
const days = Math.floor(seconds / 86400);
|
||
seconds %= 86400;
|
||
const hours = Math.floor(seconds / 3600);
|
||
seconds %= 3600;
|
||
const minutes = Math.floor(seconds / 60);
|
||
const sec = seconds % 60;
|
||
|
||
let result = [];
|
||
if (days > 0) result.push(`${days}天`);
|
||
if (hours > 0) result.push(`${hours}小时`);
|
||
if (minutes > 0) result.push(`${minutes}分钟`);
|
||
if (sec > 0 || result.length === 0) {
|
||
result.push(sec % 1 === 0 ? `${sec}秒` : `${sec.toFixed(2)}秒`);
|
||
}
|
||
|
||
return result.join('') || "0秒";
|
||
}
|
||
|
||
// 耗时计算函数
|
||
function calculateDuration(start, end) {
|
||
if (!start || !end) return '进行中';
|
||
const diff = (end.getTime() - start.getTime()) / 1000;
|
||
return formatDuration(diff);
|
||
}
|
||
|
||
// 配置组耗时计算
|
||
function calculateGroupDuration(group) {
|
||
if (!group.startTime || !group.endTime) return '进行中';
|
||
const diff = (group.endTime.getTime() - group.startTime.getTime()) / 1000;
|
||
return formatDuration(diff);
|
||
}
|
||
|
||
// 新的耗时计算函数
|
||
function formatDuration(totalSeconds) {
|
||
if (totalSeconds <= 0) return "0秒";
|
||
|
||
const hours = Math.floor(totalSeconds / 3600);
|
||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||
const seconds = totalSeconds % 60;
|
||
|
||
let result = "";
|
||
|
||
if (hours > 0) {
|
||
result += `${hours}小时`;
|
||
}
|
||
|
||
if (minutes > 0 || hours > 0) {
|
||
result += `${minutes}分钟`;
|
||
}
|
||
|
||
if (seconds > 0 || (hours === 0 && minutes === 0)) {
|
||
if (seconds % 1 === 0) {
|
||
result += `${Math.floor(seconds)}秒`;
|
||
} else {
|
||
result += `${seconds.toFixed(2)}秒`;
|
||
}
|
||
}
|
||
|
||
return result || "0秒";
|
||
}
|
||
|
||
// 时间解析辅助函数
|
||
function parseTime(line, fileDate) {
|
||
const timeMatch = line?.match(/\[(\d{2}):(\d{2}):(\d{2})\.\d+\]/);
|
||
if (!timeMatch) return null;
|
||
|
||
// 创建基础时间对象
|
||
const baseDate = new Date(fileDate);
|
||
const hours = parseInt(timeMatch[1]);
|
||
const minutes = parseInt(timeMatch[2]);
|
||
const seconds = parseInt(timeMatch[3]);
|
||
|
||
// 智能日期推算
|
||
const currentTime = new Date(baseDate);
|
||
currentTime.setHours(hours, minutes, seconds);
|
||
|
||
// 处理跨日情况
|
||
if (lastValidTime && currentTime < lastValidTime) {
|
||
// 如果时间回退超过4小时,视为次日(兼容凌晨4点刷新机制)
|
||
if ((lastValidTime - currentTime) > 4 * 60 * 60 * 1000) {
|
||
currentTime.setDate(currentTime.getDate() + 1);
|
||
}
|
||
}
|
||
|
||
lastValidTime = currentTime;
|
||
return currentTime;
|
||
}
|
||
|
||
// 重写全屏功能 - 使用更可靠的方法
|
||
function toggleFullScreen() {
|
||
const doc = window.document;
|
||
const docEl = doc.documentElement;
|
||
|
||
// 检查当前全屏状态
|
||
const isFullScreen =
|
||
doc.fullscreenElement ||
|
||
doc.webkitFullscreenElement ||
|
||
doc.mozFullScreenElement ||
|
||
doc.msFullscreenElement;
|
||
|
||
// 切换全屏状态
|
||
if (!isFullScreen) {
|
||
// 进入全屏
|
||
if (docEl.requestFullscreen) {
|
||
docEl.requestFullscreen();
|
||
} else if (docEl.mozRequestFullScreen) { // Firefox
|
||
docEl.mozRequestFullScreen();
|
||
} else if (docEl.webkitRequestFullscreen) { // Chrome, Safari and Opera
|
||
docEl.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
|
||
} else if (docEl.msRequestFullscreen) { // IE/Edge
|
||
docEl.msRequestFullscreen();
|
||
}
|
||
} else {
|
||
// 退出全屏
|
||
if (doc.exitFullscreen) {
|
||
document.exitFullscreen();
|
||
} else if (document.mozCancelFullScreen) { // Firefox
|
||
document.mozCancelFullScreen();
|
||
} else if (document.webkitExitFullscreen) { // Chrome, Safari and Opera
|
||
document.webkitExitFullscreen();
|
||
} else if (document.msExitFullscreen) { // IE/Edge
|
||
document.msExitFullscreen();
|
||
}
|
||
}
|
||
}
|
||
|
||
// HTML生成逻辑
|
||
function generateHTML(groups) {
|
||
if (blacklistDetected) {
|
||
// return `<div style="text-align:center;padding:50px;font-size:24px;color:red;">
|
||
// ⚠️ 检测到黑名单,已阻止生成表格。⚠️
|
||
// </div>`;
|
||
return ``;
|
||
}
|
||
if (useLegacyFormat) {
|
||
return generateLegacyFormatHTML(groups);
|
||
} else {
|
||
return generateNewFormatHTML(groups);
|
||
}
|
||
}
|
||
|
||
// 旧版格式HTML生成
|
||
function generateNewFormatHTML(groups) {
|
||
let html = '<div style="width: 100%;">';
|
||
|
||
groups.forEach((group, index) => {
|
||
html += `
|
||
<div class="group-container">
|
||
<div class="group-header" data-group-index="${index}">
|
||
<span class="arrow collapsed">▶</span>
|
||
<div class="header-content">
|
||
<h2>配置組:${group.name} (${formatDateTime(group.startTime)} - ${group.endTime ? `${formatDateTime(group.endTime)}) <span style="font-size:14px;color:#666;margin-left:10px;">耗时${calculateGroupDuration(group)}</span>` : '进行中)'}</h2>
|
||
</div>
|
||
</div>
|
||
<div class="collapsible" id="group-${index}">
|
||
<table>
|
||
<thead>`;
|
||
|
||
// 添加隊伍角色行到thead
|
||
if (group.teamRoles && group.teamRoles.size > 0) {
|
||
html += `
|
||
<tr class="team-roles-row">
|
||
<td colspan="${useLegacyFormat ? 10 : 11}">
|
||
<div class="team-roles-content">
|
||
${Array.from(group.teamRoles).map(roleStr => {
|
||
let displayText = `队伍角色: ${roleStr}`;
|
||
|
||
// 添加角色類型標注
|
||
const roleNotes = [];
|
||
|
||
// 檢查行走位 - 改为模糊匹配
|
||
if (group.walkRoles && group.walkRoles.length > 0) {
|
||
const walkRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundWalkRoles = group.walkRoles.filter(walkRole =>
|
||
walkRoleNames.some(roleName =>
|
||
roleName.includes(walkRole) || walkRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundWalkRoles.length > 0) {
|
||
roleNotes.push(`行走位:${foundWalkRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 檢查生存位 - 改为模糊匹配
|
||
if (group.survivalRoles && group.survivalRoles.length > 0) {
|
||
const survivalRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundSurvivalRoles = group.survivalRoles.filter(survivalRole =>
|
||
survivalRoleNames.some(roleName =>
|
||
roleName.includes(survivalRole) || survivalRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundSurvivalRoles.length > 0) {
|
||
roleNotes.push(`生存位:${foundSurvivalRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 檢查赶路位 - 改为模糊匹配
|
||
if (group.dashRoles && group.dashRoles.length > 0) {
|
||
const dashRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundDashRoles = group.dashRoles.filter(dashRole =>
|
||
dashRoleNames.some(roleName =>
|
||
roleName.includes(dashRole) || dashRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundDashRoles.length > 0) {
|
||
roleNotes.push(`赶路位:${foundDashRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 如果有標注,添加到顯示文本
|
||
if (roleNotes.length > 0) {
|
||
displayText += ` (${roleNotes.join(' ')})`;
|
||
}
|
||
|
||
// 旋轉索敵
|
||
if (group.hasRotationTargeting) {
|
||
displayText += ` (旋转索敌)`;
|
||
}
|
||
|
||
// 光柱拾取
|
||
if (group.hasBeamPickup) {
|
||
displayText += ` (光柱拾取)`;
|
||
}
|
||
|
||
return `<div class="team-role-line">${displayText}</div>`;
|
||
}).join('')}
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
html += `
|
||
<tr class="sticky-header">
|
||
<th data-sort-type="string">
|
||
任务名称
|
||
<span class="task-count">${group.tasks.length}个</span>
|
||
</th>
|
||
<th class="column-start-time">
|
||
开始时间
|
||
<btn class="sort-btn" style="font-size:15px;padding:1px 4px;margin-left:3px;cursor:pointer;"
|
||
title="点击切换排序(默认:读取顺序)">↓</btn>
|
||
</th>
|
||
<th class="column-end-time">结束时间</th>
|
||
<th data-sort-type="number">
|
||
耗时
|
||
<btn class="duration-sort-btn" style="font-size:15px;padding:1px 4px;margin-left:3px;cursor:pointer;"
|
||
title="点击切换排序">↕</btn>
|
||
</th>
|
||
<th class="column-revive">复活次数</th>
|
||
<th class="column-retry">重试次数</th>
|
||
<th class="column-retry-detail">疑似卡死</th>
|
||
<th class="column-too-far-skip">过远跳过</th>
|
||
<th class="column-timeout">战斗超时</th>
|
||
<th class="column-teleport">传送失败</th>
|
||
<th class="column-picks">
|
||
拾取物
|
||
<!--<button class="pick-efficiency-btn" style="margin-left:5px;padding:2px 6px;font-size:12px;cursor:pointer;" title="计算拾取效率">⚡</button>-->
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>`;
|
||
|
||
group.tasks.forEach((task, taskIndex) => {
|
||
|
||
const hasCoords = task.faults.coords && task.faults.coords.length > 0;
|
||
|
||
// 生成复活事件弹窗
|
||
let revivePopupHTML = '';
|
||
let hasReviveEvents = false;
|
||
if (task.reviveEvents && task.reviveEvents.length > 0) {
|
||
hasReviveEvents = true;
|
||
revivePopupHTML = '<div class="battle-popup">';
|
||
revivePopupHTML += '<div class="battle-popup-header">';
|
||
revivePopupHTML += '<div class="battle-popup-title">复活事件详细</div>';
|
||
revivePopupHTML += '<span class="close-btn">×</span>';
|
||
revivePopupHTML += '</div>';
|
||
revivePopupHTML += '<div class="battle-popup-content">';
|
||
|
||
// 按battleCount分组
|
||
const eventsByBattleCount = {};
|
||
task.reviveEvents.forEach(event => {
|
||
if (!eventsByBattleCount[event.battleCount]) {
|
||
eventsByBattleCount[event.battleCount] = [];
|
||
}
|
||
eventsByBattleCount[event.battleCount].push(event);
|
||
});
|
||
|
||
// 处理战斗前的复活事件(battleCount为0)
|
||
if (eventsByBattleCount[0] && eventsByBattleCount[0].length > 0) {
|
||
eventsByBattleCount[0].forEach(event => {
|
||
const coordText = event.coord ? `(X=${event.coord.x}, Y=${event.coord.y})` : '';
|
||
revivePopupHTML += `<div class="battle-item">${coordText}</div>`;
|
||
});
|
||
}
|
||
|
||
// 生成完整的战斗序列(从1到最大战斗次数)
|
||
for (let i = 1; i <= task.maxBattleCount; i++) {
|
||
const events = eventsByBattleCount[i] || [];
|
||
|
||
if (events.length > 0) {
|
||
// 有复活事件,显示坐标
|
||
const coords = events.map(e => e.coord ? `(X=${e.coord.x}, Y=${e.coord.y})` : '').filter(text => text);
|
||
const coordText = coords.length > 0 ? ':' + coords.join('、') : '';
|
||
revivePopupHTML += `<div class="battle-item">${i}${coordText}</div>`;
|
||
} else {
|
||
// 无复活事件,只显示序号
|
||
revivePopupHTML += `<div class="battle-item">${i}</div>`;
|
||
}
|
||
}
|
||
|
||
revivePopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 生成坐标弹窗HTML
|
||
let coordPopupHTML = '';
|
||
if (hasCoords) {
|
||
coordPopupHTML = '<div class="coord-popup">';
|
||
coordPopupHTML += '<div class="coord-popup-header">';
|
||
coordPopupHTML += '<div class="coord-popup-title">卡死点坐标</div>';
|
||
coordPopupHTML += '<span class="close-btn">×</span>';
|
||
coordPopupHTML += '</div>';
|
||
coordPopupHTML += '<div class="coord-popup-content">';
|
||
|
||
task.faults.coords.forEach((coord, idx) => {
|
||
coordPopupHTML += `<div class="coord-item">`;
|
||
coordPopupHTML += `<strong>#${idx + 1}</strong><br>`;
|
||
coordPopupHTML += `X: ${coord.x}<br>Y: ${coord.y}`;
|
||
coordPopupHTML += '</div>';
|
||
});
|
||
|
||
coordPopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 生成超时事件弹窗
|
||
let timeoutPopupHTML = '';
|
||
let hasTimeoutEvents = false;
|
||
if (task.timeoutEvents && task.timeoutEvents.length > 0) {
|
||
hasTimeoutEvents = true;
|
||
timeoutPopupHTML = '<div class="battle-popup">';
|
||
timeoutPopupHTML += '<div class="battle-popup-header">';
|
||
timeoutPopupHTML += '<div class="battle-popup-title">超时事件详细</div>';
|
||
timeoutPopupHTML += '<span class="close-btn">×</span>';
|
||
timeoutPopupHTML += '</div>';
|
||
timeoutPopupHTML += '<div class="battle-popup-content">';
|
||
|
||
// 生成完整的战斗序列(从1到最大战斗次数)
|
||
for (let i = 1; i <= task.maxBattleCount; i++) {
|
||
const hasEvent = task.timeoutEvents.includes(i);
|
||
timeoutPopupHTML += `<div class="battle-item">${i}${hasEvent ? '(X)' : ''}</div>`;
|
||
}
|
||
|
||
timeoutPopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 设置单元格类 - 只在有事件时添加可点击类
|
||
const reviveCellClass = hasReviveEvents ? 'has-battle-events' : 'no-events';
|
||
const timeoutCellClass = hasTimeoutEvents ? 'has-battle-events' : 'no-events';
|
||
|
||
// 判断是否需要将任务名和耗时标红
|
||
const shouldHighlight =
|
||
task.faults.retry > 0 &&
|
||
task.faults.retryDetail === 0 &&
|
||
task.faults.revive === 0;
|
||
|
||
// 格式化revive值:整数显示整数,小数显示两位小数
|
||
let reviveDisplay = '';
|
||
if (task.faults.revive !== 0) {
|
||
if (Number.isInteger(task.faults.revive)) {
|
||
reviveDisplay = task.faults.revive;
|
||
} else {
|
||
// 确保小数部分有两位
|
||
reviveDisplay = task.faults.revive.toFixed(2);
|
||
}
|
||
}
|
||
|
||
// 格式化retry值:整数显示整数,小数显示两位小数
|
||
let retryDetail = '';
|
||
if (task.faults.retryDetail !== 0) {
|
||
if (Number.isInteger(task.faults.retryDetail)) {
|
||
retryDetail = task.faults.retryDetail;
|
||
} else {
|
||
// 确保小数部分有两位
|
||
retryDetail = task.faults.retryDetail.toFixed(2);
|
||
}
|
||
}
|
||
|
||
// 计算任务耗时
|
||
const duration = calculateDuration(task.startTime, task.endTime);
|
||
|
||
// 单元格类 - 如果有坐标数据添加 has-coords 类
|
||
const cellClass = hasCoords ? 'coords-cell has-coords' : 'coords-cell';
|
||
|
||
// 生成拾取物显示文本
|
||
let picksText = formatPicks(task.picks, task.pickSequence, true);
|
||
|
||
// 按顺序添加提示文本
|
||
const alerts = [];
|
||
|
||
// 特殊事件
|
||
if (task.specialAlerts && task.specialAlerts.size > 0) {
|
||
for (let [message, alertInfo] of task.specialAlerts) {
|
||
const displayMessage = alertInfo.count > 1 ? `${message} (${alertInfo.count})` : message;
|
||
alerts.push(`<span class="${alertInfo.type}">${displayMessage}</span>`);
|
||
}
|
||
}
|
||
|
||
// 如果有提示,添加到拾取物文本
|
||
if (alerts.length > 0) {
|
||
if (picksText === '无') {
|
||
picksText = "无<br>" + alerts.join('<br>');
|
||
} else {
|
||
picksText += '<br>' + alerts.join('<br>');
|
||
}
|
||
}
|
||
|
||
html += `
|
||
<tr data-original-index="${taskIndex}" data-start-timestamp="${task.startTime ? task.startTime.getTime() : 0}"">
|
||
<td class="${shouldHighlight ? 'task-name-red' : ''}">${getFileNameWithoutExtension(task.name)}</td>
|
||
<td class="column-start-time">${formatDateTime(task.startTime)}</td>
|
||
<td class="column-end-time">${task.endTime ? formatDateTime(task.endTime) : '进行中'}</td>
|
||
<td class="${shouldHighlight ? 'duration-red' : ''}">${duration}</td>
|
||
<td class="column-revive ${reviveCellClass} ${task.faults.revive >= 2 ? 'red' : ''}">
|
||
${reviveDisplay}
|
||
${revivePopupHTML}
|
||
</td>
|
||
<td class="column-retry ${task.faults.retry >= 2 ? 'red' : ''}">${task.faults.retry == 0 ? '' : task.faults.retry}</td>
|
||
<td class="column-retry-detail ${cellClass} ${task.faults.retryDetail >= 2 ? '' : ''}">
|
||
${retryDetail}
|
||
${coordPopupHTML}
|
||
</td>
|
||
<td class="column-too-far-skip ${task.faults.too_far_skip >= 2 ? 'red' : 'red'}">${task.faults.too_far_skip == 0 ? '' : task.faults.too_far_skip}</td>
|
||
<td class="column-timeout ${timeoutCellClass} ${task.faults.timeout >= 1 ? 'red' : ''}">
|
||
${task.faults.timeout == 0 ? '' : task.faults.timeout}
|
||
${timeoutPopupHTML}
|
||
</td>
|
||
<td class="column-teleport ${task.faults.teleport >= 3 ? 'red' : ''}">${task.faults.teleport == 0 ? '' : task.faults.teleport}</td>
|
||
<td class="column-picks">${picksText}</td>
|
||
</tr>`;
|
||
});
|
||
|
||
html += `
|
||
<tr class="ignore-sort summary-row">
|
||
<td colspan="11" class="column-picks">
|
||
<span class="picks-bold">所有拾取物: </span>
|
||
${formatPicks(group.picks)}
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>`;
|
||
});
|
||
|
||
html += '</div>';
|
||
return html;
|
||
}
|
||
|
||
// 新版格式HTML生成
|
||
function generateLegacyFormatHTML(groups) {
|
||
let html = '<div class="legacy-format" style="width: 100%;">';
|
||
|
||
groups.forEach((group, index) => {
|
||
html += `
|
||
<div class="group-container">
|
||
<div class="group-header" data-group-index="${index}">
|
||
<span class="arrow collapsed">▶</span>
|
||
<div class="header-content">
|
||
<h2>配置組:${group.name} (${formatDateTime(group.startTime)} - ${group.endTime ? `${formatDateTime(group.endTime)}) <span style="font-size:14px;color:#666;margin-left:10px;">耗时${calculateGroupDuration(group)}</span>` : '进行中)'}</h2>
|
||
</div>
|
||
</div>
|
||
<div class="collapsible" id="group-${index}">
|
||
<div class="sticky-table">
|
||
<table>
|
||
<thead>`;
|
||
|
||
// 添加隊伍角色行到thead
|
||
if (group.teamRoles && group.teamRoles.size > 0) {
|
||
html += `
|
||
<tr class="team-roles-row">
|
||
<td colspan="${useLegacyFormat ? 10 : 11}">
|
||
<div class="team-roles-content">
|
||
${Array.from(group.teamRoles).map(roleStr => {
|
||
let displayText = `队伍角色: ${roleStr}`;
|
||
|
||
// 添加角色類型標注
|
||
const roleNotes = [];
|
||
|
||
// 檢查行走位 - 改为模糊匹配
|
||
if (group.walkRoles && group.walkRoles.length > 0) {
|
||
const walkRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundWalkRoles = group.walkRoles.filter(walkRole =>
|
||
walkRoleNames.some(roleName =>
|
||
roleName.includes(walkRole) || walkRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundWalkRoles.length > 0) {
|
||
roleNotes.push(`行走位:${foundWalkRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 檢查生存位 - 改为模糊匹配
|
||
if (group.survivalRoles && group.survivalRoles.length > 0) {
|
||
const survivalRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundSurvivalRoles = group.survivalRoles.filter(survivalRole =>
|
||
survivalRoleNames.some(roleName =>
|
||
roleName.includes(survivalRole) || survivalRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundSurvivalRoles.length > 0) {
|
||
roleNotes.push(`生存位:${foundSurvivalRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 檢查赶路位 - 改为模糊匹配
|
||
if (group.dashRoles && group.dashRoles.length > 0) {
|
||
const dashRoleNames = roleStr.split(',').map(r => r.trim());
|
||
const foundDashRoles = group.dashRoles.filter(dashRole =>
|
||
dashRoleNames.some(roleName =>
|
||
roleName.includes(dashRole) || dashRole.includes(roleName)
|
||
)
|
||
);
|
||
if (foundDashRoles.length > 0) {
|
||
roleNotes.push(`赶路位:${foundDashRoles.join(',')}`);
|
||
}
|
||
}
|
||
|
||
// 如果有標注,添加到顯示文本
|
||
if (roleNotes.length > 0) {
|
||
displayText += ` (${roleNotes.join(' ')})`;
|
||
}
|
||
|
||
// 旋轉索敵
|
||
if (group.hasRotationTargeting) {
|
||
displayText += ` (旋转索敌)`;
|
||
}
|
||
|
||
// 光柱拾取
|
||
if (group.hasBeamPickup) {
|
||
displayText += ` (光柱拾取)`;
|
||
}
|
||
|
||
return `<div class="team-role-line">${displayText}</div>`;
|
||
}).join('')}
|
||
</div>
|
||
</td>
|
||
</tr>`;
|
||
}
|
||
|
||
html += `
|
||
<tr class="sticky-header">
|
||
<th data-sort-type="string">
|
||
任务名称
|
||
<span class="task-count">${group.tasks.length}个</span>
|
||
</th>
|
||
<th class="column-start-time">
|
||
开始时间
|
||
<btn class="sort-btn" style="font-size:15px;padding:1px 4px;margin-left:3px;cursor:pointer;"
|
||
title="点击切换排序(默认:读取顺序)">↓</btn>
|
||
</th>
|
||
<th class="column-end-time" data-sort-type="date">结束时间</th>
|
||
<th data-sort-type="number">
|
||
耗时
|
||
<btn class="duration-sort-btn" style="font-size:15px;padding:1px 4px;margin-left:3px;cursor:pointer;"
|
||
title="点击切换排序">↕</btn>
|
||
</th>
|
||
<th class="column-revive" data-sort-type="number">复活次数</th>
|
||
<th class="column-retry" data-sort-type="number">重试次数</th>
|
||
<th class="column-retry-detail" data-sort-type="number">疑似卡死</th>
|
||
<th class="column-too-far-skip" data-sort-type="number">过远跳过</th>
|
||
<th class="column-timeout" data-sort-type="number">战斗超时</th>
|
||
<th class="column-teleport" data-sort-type="number">传送失败</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>`;
|
||
|
||
group.tasks.forEach((task, taskIndex) => {
|
||
const hasCoords = task.faults.coords && task.faults.coords.length > 0;
|
||
|
||
// 生成复活事件弹窗
|
||
let revivePopupHTML = '';
|
||
let hasReviveEvents = false;
|
||
if (task.reviveEvents && task.reviveEvents.length > 0) {
|
||
hasReviveEvents = true;
|
||
revivePopupHTML = '<div class="battle-popup">';
|
||
revivePopupHTML += '<div class="battle-popup-header">';
|
||
revivePopupHTML += '<div class="battle-popup-title">复活事件详细</div>';
|
||
revivePopupHTML += '<span class="close-btn">×</span>';
|
||
revivePopupHTML += '</div>';
|
||
revivePopupHTML += '<div class="battle-popup-content">';
|
||
|
||
// 按battleCount分组
|
||
const eventsByBattleCount = {};
|
||
task.reviveEvents.forEach(event => {
|
||
if (!eventsByBattleCount[event.battleCount]) {
|
||
eventsByBattleCount[event.battleCount] = [];
|
||
}
|
||
eventsByBattleCount[event.battleCount].push(event);
|
||
});
|
||
|
||
// 处理战斗前的复活事件(battleCount为0)
|
||
if (eventsByBattleCount[0] && eventsByBattleCount[0].length > 0) {
|
||
eventsByBattleCount[0].forEach(event => {
|
||
const coordText = event.coord ? `(X=${event.coord.x}, Y=${event.coord.y})` : '';
|
||
revivePopupHTML += `<div class="battle-item">${coordText}</div>`;
|
||
});
|
||
}
|
||
|
||
// 生成完整的战斗序列(从1到最大战斗次数)
|
||
for (let i = 1; i <= task.maxBattleCount; i++) {
|
||
const events = eventsByBattleCount[i] || [];
|
||
|
||
if (events.length > 0) {
|
||
// 有复活事件,显示坐标
|
||
const coords = events.map(e => e.coord ? `(X=${e.coord.x}, Y=${e.coord.y})` : '').filter(text => text);
|
||
const coordText = coords.length > 0 ? ':' + coords.join('、') : '';
|
||
revivePopupHTML += `<div class="battle-item">${i}${coordText}</div>`;
|
||
} else {
|
||
// 无复活事件,只显示序号
|
||
revivePopupHTML += `<div class="battle-item">${i}</div>`;
|
||
}
|
||
}
|
||
|
||
revivePopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 生成坐标弹窗HTML
|
||
let coordPopupHTML = '';
|
||
if (hasCoords) {
|
||
coordPopupHTML = '<div class="coord-popup">';
|
||
coordPopupHTML += '<div class="coord-popup-header">';
|
||
coordPopupHTML += '<div class="coord-popup-title">卡死点坐标</div>';
|
||
coordPopupHTML += '<span class="close-btn">×</span>';
|
||
coordPopupHTML += '</div>';
|
||
coordPopupHTML += '<div class="coord-popup-content">';
|
||
|
||
task.faults.coords.forEach((coord, idx) => {
|
||
coordPopupHTML += `<div class="coord-item">`;
|
||
coordPopupHTML += `<strong>#${idx + 1}</strong><br>`;
|
||
coordPopupHTML += `X: ${coord.x}<br>Y: ${coord.y}`;
|
||
coordPopupHTML += '</div>';
|
||
});
|
||
|
||
coordPopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 生成超时事件弹窗
|
||
let timeoutPopupHTML = '';
|
||
let hasTimeoutEvents = false;
|
||
if (task.timeoutEvents && task.timeoutEvents.length > 0) {
|
||
hasTimeoutEvents = true;
|
||
timeoutPopupHTML = '<div class="battle-popup">';
|
||
timeoutPopupHTML += '<div class="battle-popup-header">';
|
||
timeoutPopupHTML += '<div class="battle-popup-title">超时事件详细</div>';
|
||
timeoutPopupHTML += '<span class="close-btn">×</span>';
|
||
timeoutPopupHTML += '</div>';
|
||
timeoutPopupHTML += '<div class="battle-popup-content">';
|
||
|
||
// 生成完整的战斗序列(从1到最大战斗次数)
|
||
for (let i = 1; i <= task.maxBattleCount; i++) {
|
||
const hasEvent = task.timeoutEvents.includes(i);
|
||
timeoutPopupHTML += `<div class="battle-item">${i}${hasEvent ? '(X)' : ''}</div>`;
|
||
}
|
||
|
||
timeoutPopupHTML += '</div></div>';
|
||
}
|
||
|
||
// 设置单元格类 - 只在有事件时添加可点击类
|
||
const reviveCellClass = hasReviveEvents ? 'has-battle-events' : 'no-events';
|
||
const timeoutCellClass = hasTimeoutEvents ? 'has-battle-events' : 'no-events';
|
||
const cellClass = hasCoords ? 'coords-cell has-coords' : 'coords-cell';
|
||
|
||
// 判断是否需要将任务名和耗时标红
|
||
const shouldHighlight =
|
||
task.faults.retry > 0 &&
|
||
task.faults.retryDetail === 0 &&
|
||
task.faults.revive === 0;
|
||
|
||
// 格式化revive值:整数显示整数,小数显示两位小数
|
||
let reviveDisplay = '';
|
||
if (task.faults.revive !== 0) {
|
||
if (Number.isInteger(task.faults.revive)) {
|
||
reviveDisplay = task.faults.revive;
|
||
} else {
|
||
// 确保小数部分有两位
|
||
reviveDisplay = task.faults.revive.toFixed(2);
|
||
}
|
||
}
|
||
|
||
// 格式化retry值:整数显示整数,小数显示两位小数
|
||
let retryDetail = '';
|
||
if (task.faults.retryDetail !== 0) {
|
||
if (Number.isInteger(task.faults.retryDetail)) {
|
||
retryDetail = task.faults.retryDetail;
|
||
} else {
|
||
// 确保小数部分有两位
|
||
retryDetail = task.faults.retryDetail.toFixed(2);
|
||
}
|
||
}
|
||
|
||
// 计算任务耗时
|
||
const duration = calculateDuration(task.startTime, task.endTime);
|
||
|
||
// 生成拾取物显示文本
|
||
let picksText = formatPicks(task.picks, task.pickSequence, true);
|
||
|
||
// 按顺序添加提示文本
|
||
const alerts = [];
|
||
|
||
// 特殊事件
|
||
if (task.specialAlerts && task.specialAlerts.size > 0) {
|
||
for (let [message, alertInfo] of task.specialAlerts) {
|
||
const displayMessage = alertInfo.count > 1 ? `${message} (${alertInfo.count})` : message;
|
||
alerts.push(`<span class="${alertInfo.type}">${displayMessage}</span>`);
|
||
}
|
||
}
|
||
|
||
// 如果有提示,添加到拾取物文本
|
||
if (alerts.length > 0) {
|
||
if (picksText === '无') {
|
||
picksText = "无<br>" + alerts.join('<br>');
|
||
} else {
|
||
picksText += '<br>' + alerts.join('<br>');
|
||
}
|
||
}
|
||
|
||
html += `
|
||
<tr data-task-id="group-${index}-task-${taskIndex}" data-original-index="${taskIndex}" data-start-timestamp="${task.startTime ? task.startTime.getTime() : 0}">
|
||
<td class="main-row-name ${shouldHighlight ? 'task-name-red' : ''}" rowspan="2">${getFileNameWithoutExtension(task.name)}</td>
|
||
<td class="column-start-time">${formatDateTime(task.startTime)}</td>
|
||
<td class="column-end-time">${task.endTime ? formatDateTime(task.endTime) : '进行中'}</td>
|
||
<td class="${shouldHighlight ? 'duration-red' : ''}">${duration}</td>
|
||
<td class="column-revive ${reviveCellClass} ${task.faults.revive >= 2 ? 'red' : ''}">
|
||
${reviveDisplay}
|
||
${revivePopupHTML}
|
||
</td>
|
||
<td class="column-retry ${task.faults.retry >= 2 ? 'red' : ''}">${task.faults.retry == 0 ? '' : task.faults.retry}</td>
|
||
<td class="column-retry-detail ${cellClass} ${task.faults.retryDetail >= 2 ? '' : ''}">
|
||
${retryDetail}
|
||
${coordPopupHTML}
|
||
</td>
|
||
<td class="column-too-far-skip ${task.faults.too_far_skip >= 2 ? 'red' : 'red'}">${task.faults.too_far_skip == 0 ? '' : task.faults.too_far_skip}</td>
|
||
<td class="column-timeout ${timeoutCellClass} ${task.faults.timeout >= 1 ? 'red' : ''}">
|
||
${task.faults.timeout == 0 ? '' : task.faults.timeout}
|
||
${timeoutPopupHTML}
|
||
</td>
|
||
<td class="column-teleport ${task.faults.teleport >= 3 ? 'red' : ''}">${task.faults.teleport == 0 ? '' : task.faults.teleport}</td>
|
||
</tr>
|
||
<tr class="sub-row" data-task-id="group-${index}-task-${taskIndex}">
|
||
<td colspan="9" class="column-picks"><span class="picks-bold">拾取物: </span>${picksText}</td>
|
||
</tr>`;
|
||
});
|
||
|
||
html += `
|
||
<tr class="ignore-sort summary-row">
|
||
<td colspan="10" class="column-picks">
|
||
<span class="picks-bold">所有拾取物: </span>${formatPicks(group.picks)}
|
||
</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
});
|
||
|
||
html += '</div>';
|
||
return html;
|
||
}
|
||
|
||
// 格式化日期时间
|
||
function formatDateTime(date) {
|
||
if (!date) return '未知时间';
|
||
return date.toLocaleString('zh-CN', {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit',
|
||
hour: '2-digit',
|
||
minute: '2-digit',
|
||
second: '2-digit'
|
||
});
|
||
}
|
||
|
||
// 折叠功能事件处理
|
||
document.querySelectorAll('.group-header').forEach((el, i) => {
|
||
el.onclick = (e) => {
|
||
const arrow = el.querySelector('.arrow');
|
||
const content = document.getElementById(`group-${i}`);
|
||
const container = el.closest('.group-container');
|
||
|
||
// 获取配置组标题和内容的位置信息
|
||
const headerRect = el.getBoundingClientRect();
|
||
const containerRect = container.getBoundingClientRect();
|
||
|
||
// 判断标题是否在可视区域顶部(考虑固定定位)
|
||
const isStickyAtTop = headerRect.top <= 15 && headerRect.top >= -10;
|
||
|
||
if (isStickyAtTop) {
|
||
// 计算需要滚动到的位置
|
||
// 让配置组标题滚动到距离顶部30px的位置
|
||
const targetPosition = container.offsetTop - 40;
|
||
const currentPosition = dropZone.scrollTop;
|
||
const scrollDistance = Math.abs(targetPosition - currentPosition);
|
||
|
||
// 计算滚动时间:根据距离,但不小于300ms,不大于2000ms,然后加上500ms的额外时间
|
||
const scrollDuration = Math.min(2000, Math.max(200, scrollDistance)) + 50;
|
||
|
||
// 使用平滑滚动
|
||
dropZone.scrollTo({
|
||
top: targetPosition,
|
||
behavior: 'smooth'
|
||
});
|
||
|
||
// 在滚动完成后再折叠,使用计算出的时间
|
||
setTimeout(() => {
|
||
toggleCollapseState(el, content, arrow);
|
||
}, scrollDuration);
|
||
|
||
} else {
|
||
// 已经在顶部,直接折叠
|
||
toggleCollapseState(el, content, arrow);
|
||
}
|
||
};
|
||
});
|
||
|
||
// 提取折叠状态切换逻辑到单独函数
|
||
function toggleCollapseState(el, content, arrow) {
|
||
// 切换状态
|
||
el.classList.toggle('collapsed');
|
||
content.classList.toggle('collapsed');
|
||
arrow.classList.toggle('collapsed');
|
||
|
||
// 使用防抖版本 折叠/展开后重新计算表头位置
|
||
debouncedAdjustTableHeader();
|
||
}
|
||
|
||
// 格式化拾取物的函数,支持两种显示方式
|
||
function formatPicks(picks, pickSequence, excludeItems = false) {
|
||
if (!picks || picks.size === 0) return '无';
|
||
|
||
// 需要排除的物品列表
|
||
// const excludeList = ['小怪', '精英'];
|
||
const excludeList = [];
|
||
|
||
// 过滤函数
|
||
const shouldExclude = (item) => {
|
||
if (!excludeItems) return false;
|
||
return excludeList.some(excluded => item.includes(excluded)); // 包含匹配
|
||
// return excludeList.includes(item); // 完全相等
|
||
};
|
||
|
||
if (picksSortByCount) {
|
||
// 按数量从多到少排序(合并统计)
|
||
const entries = Array.from(picks.entries());
|
||
|
||
// 如果需要排除,过滤掉排除的物品
|
||
const filteredEntries = excludeItems
|
||
? entries.filter(([item, count]) => !shouldExclude(item))
|
||
: entries;
|
||
|
||
if (filteredEntries.length === 0) return '无';
|
||
|
||
return filteredEntries
|
||
.sort((a, b) => b[1] - a[1])
|
||
.map(([item, count]) => `${item} (${count})`)
|
||
.join(', ');
|
||
} else {
|
||
// 按拾取顺序显示(不合并,重复的单独显示)
|
||
if (!pickSequence || pickSequence.length === 0) return '无';
|
||
|
||
// 如果需要排除,过滤掉排除的物品
|
||
const filteredSequence = excludeItems
|
||
? pickSequence.filter(item => !shouldExclude(item))
|
||
: pickSequence;
|
||
|
||
if (filteredSequence.length === 0) return '无';
|
||
|
||
return filteredSequence.join(', ');
|
||
}
|
||
}
|
||
|
||
// 添加切换拾取物显示顺序的函数
|
||
function togglePicksSortOrder() {
|
||
picksSortByCount = !picksSortByCount;
|
||
|
||
// 刷新HTML以应用新的排序方式
|
||
refreshHTML();
|
||
|
||
// 显示状态提示
|
||
showPicksSortOrderIndicator();
|
||
}
|
||
|
||
// 添加显示拾取物排序状态提示的函数
|
||
function showPicksSortOrderIndicator() {
|
||
const indicator = document.getElementById('picksToggleIndicator');
|
||
indicator.textContent = `拾取物显示: ${picksSortByCount ? '按数量合并' : '按拾取顺序'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
// 更新时间列的显示状态
|
||
function updateTimeColumnsVisibility() {
|
||
if (timeColumnsVisible) {
|
||
document.body.classList.remove('time-columns-hidden');
|
||
} else {
|
||
document.body.classList.add('time-columns-hidden');
|
||
}
|
||
}
|
||
|
||
// 显示时间列状态提示
|
||
function showTimeToggleIndicator() {
|
||
const indicator = document.getElementById('timeToggleIndicator');
|
||
indicator.textContent = `时间列: ${timeColumnsVisible ? '显示' : '隐藏'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
// 更新统计列的显示状态
|
||
function updateStatsColumnsVisibility() {
|
||
if (statsColumnsVisible) {
|
||
document.body.classList.remove('stats-columns-hidden');
|
||
} else {
|
||
document.body.classList.add('stats-columns-hidden');
|
||
}
|
||
}
|
||
|
||
// 显示统计列状态提示
|
||
function showStatsToggleIndicator() {
|
||
const indicator = document.getElementById('statsToggleIndicator');
|
||
indicator.textContent = `统计列: ${statsColumnsVisible ? '显示' : '隐藏'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
// 添加拾取物列显示状态更新函数
|
||
function updatePicksColumnsVisibility() {
|
||
if (picksColumnsVisible) {
|
||
document.body.classList.remove('picks-columns-hidden');
|
||
} else {
|
||
document.body.classList.add('picks-columns-hidden');
|
||
}
|
||
}
|
||
|
||
// 添加拾取物列状态提示函数
|
||
function showPicksToggleIndicator() {
|
||
const indicator = document.getElementById('picksToggleIndicator');
|
||
indicator.textContent = `拾取物列: ${picksColumnsVisible ? '显示' : '隐藏'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
// 更新表格格式
|
||
function updateTableFormat() {
|
||
if (useLegacyFormat) {
|
||
document.body.classList.add('legacy-format');
|
||
} else {
|
||
document.body.classList.remove('legacy-format');
|
||
}
|
||
}
|
||
|
||
// 显示表格格式状态提示
|
||
function showFormatToggleIndicator() {
|
||
const indicator = document.getElementById('formatToggleIndicator');
|
||
indicator.textContent = `表格格式: ${useLegacyFormat ? '新版' : '旧版'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
function refreshHTML() {
|
||
const result = parsingContext.allGroups;
|
||
|
||
// 保存当前状态
|
||
const currentHideZeroStats = hideZeroStatsTasks;
|
||
const currentFilterMode = isFilterMode;
|
||
currentFilterKeywords = [...currentFilterKeywords];
|
||
currentExcludeGroupKeywords = [...currentExcludeGroupKeywords];
|
||
|
||
const currentPickEfficiencyMode = isPickEfficiencyMode; // 保存拾取效率模式状态
|
||
currentPickEfficiencyItem = currentPickEfficiencyItem; // 保存当前计算的物品
|
||
const currentPicksSortByCount = picksSortByCount; // 保存拾取物排序状态
|
||
|
||
const currenTimeFilterMode = isTimeFilterMode;// 保存时间筛选模式
|
||
const currentimeFilterStart = timeFilterStart;// 保存筛选开始时间
|
||
const currentimeFilterEnd = timeFilterEnd;// 保存筛选开始时间
|
||
|
||
dropZone.innerHTML = generateHTML(result);
|
||
setupCoordPopups();
|
||
|
||
// 折叠功能事件处理
|
||
document.querySelectorAll('.group-header').forEach((el, i) => {
|
||
el.onclick = (e) => {
|
||
const arrow = el.querySelector('.arrow');
|
||
const content = document.getElementById(`group-${i}`);
|
||
const container = el.closest('.group-container');
|
||
|
||
// 获取配置组标题和内容的位置信息
|
||
const headerRect = el.getBoundingClientRect();
|
||
const containerRect = container.getBoundingClientRect();
|
||
|
||
// 判断标题是否在可视区域顶部(考虑固定定位)
|
||
const isStickyAtTop = headerRect.top <= 15 && headerRect.top >= -10;
|
||
|
||
if (isStickyAtTop) {
|
||
// 计算需要滚动到的位置
|
||
// 让配置组标题滚动到距离顶部30px的位置
|
||
const targetPosition = container.offsetTop - 40;
|
||
const currentPosition = dropZone.scrollTop;
|
||
const scrollDistance = Math.abs(targetPosition - currentPosition);
|
||
|
||
// 计算滚动时间:根据距离,但不小于300ms,不大于2000ms,然后加上500ms的额外时间
|
||
const scrollDuration = Math.min(2000, Math.max(200, scrollDistance)) + 50;
|
||
|
||
// 使用平滑滚动
|
||
dropZone.scrollTo({
|
||
top: targetPosition,
|
||
behavior: 'smooth'
|
||
});
|
||
|
||
// 在滚动完成后再折叠,使用计算出的时间
|
||
setTimeout(() => {
|
||
toggleCollapseState(el, content, arrow);
|
||
}, scrollDuration);
|
||
|
||
} else {
|
||
// 已经在顶部,直接折叠
|
||
toggleCollapseState(el, content, arrow);
|
||
}
|
||
};
|
||
});
|
||
|
||
// 应用当前显示状态
|
||
updateTimeColumnsVisibility();
|
||
updateStatsColumnsVisibility();
|
||
updatePicksColumnsVisibility();
|
||
updateTableFormat();
|
||
|
||
// 设置行高亮效果
|
||
setupRowHighlight();
|
||
|
||
// 重置排序状态为读取顺序
|
||
currentSortState = 0;
|
||
|
||
// 动态调整表头位置 - 添加这行
|
||
setTimeout(() => {
|
||
adjustTableHeaderPosition();
|
||
setupSortButtons();
|
||
dropZone.scrollTop = 0;
|
||
updateTaskCounts(); // 重新计算任务数量
|
||
}, 200); // 延迟100ms确保DOM完全渲染
|
||
|
||
// 恢复状态
|
||
hideZeroStatsTasks = currentHideZeroStats;
|
||
isFilterMode = currentFilterMode;
|
||
currentFilterKeywords = currentFilterKeywords;
|
||
currentExcludeGroupKeywords = currentExcludeGroupKeywords;
|
||
|
||
isPickEfficiencyMode = currentPickEfficiencyMode;
|
||
currentPickEfficiencyItem = currentPickEfficiencyItem;
|
||
picksSortByCount = currentPicksSortByCount; // 恢复拾取物排序状态
|
||
if (currenTimeFilterMode) {
|
||
applyTimeFilter(currentimeFilterStart, currentimeFilterEnd);
|
||
}
|
||
|
||
// 应用筛选状态
|
||
if (isFilterMode) {
|
||
applyTaskFilter();
|
||
showFilterIndicator();
|
||
|
||
// 如果在筛选模式下且不在拾取效率模式,确保拾取物行隐藏
|
||
if (!isPickEfficiencyMode) {
|
||
const tables = document.querySelectorAll('table');
|
||
tables.forEach(table => {
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
row.style.display = 'none';
|
||
});
|
||
});
|
||
}
|
||
}
|
||
|
||
// 应用异常任务显示状态
|
||
if (hideZeroStatsTasks) {
|
||
setTimeout(() => {
|
||
if (!isFilterMode) {
|
||
toggleZeroStatsTasksNormal();
|
||
} else {
|
||
// 在筛选模式下应用零统计筛选
|
||
toggleZeroStatsTasksInFilterMode();
|
||
}
|
||
updateButtonState(74);
|
||
updateButtonState(72);
|
||
updateTaskCounts();// 更新任务数量显示
|
||
}, 150);
|
||
}
|
||
|
||
// 重新应用拾取效率模式
|
||
if (isPickEfficiencyMode && currentPickEfficiencyItem) {
|
||
setTimeout(() => {
|
||
// 在拾取效率模式下隐藏拾取物汇总行
|
||
const tables = document.querySelectorAll('table');
|
||
tables.forEach(table => {
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
row.style.display = 'none';
|
||
});
|
||
});
|
||
|
||
applyPickEfficiency();
|
||
// updateButtonState(79);
|
||
}, 150);
|
||
}
|
||
|
||
// 重新生成HTML后,根据当前模式设置body类名
|
||
if (isStaticMode) {
|
||
document.body.classList.add('static-mode');
|
||
} else {
|
||
document.body.classList.remove('static-mode');
|
||
}
|
||
|
||
if (isFilterMode) {
|
||
document.body.classList.add('filter-mode');
|
||
} else {
|
||
document.body.classList.remove('filter-mode');
|
||
}
|
||
|
||
// 更新快速导航
|
||
updateQuickNavItems();
|
||
}
|
||
|
||
function adjustTableHeaderPosition() {
|
||
const now = Date.now();
|
||
|
||
// 节流控制
|
||
if (isAdjustingTableHeader || (now - lastAdjustmentTime) < ADJUSTMENT_THROTTLE) {
|
||
return;
|
||
}
|
||
|
||
isAdjustingTableHeader = true;
|
||
lastAdjustmentTime = now;
|
||
|
||
// 使用requestAnimationFrame优化性能
|
||
requestAnimationFrame(() => {
|
||
|
||
try {
|
||
const tables = document.querySelectorAll('table');
|
||
const tablesLength = tables.length;
|
||
|
||
for (let i = 0; i < tablesLength; i++) {
|
||
const table = tables[i];
|
||
const thead = table.querySelector('thead');
|
||
if (!thead) continue;
|
||
|
||
// 缓存DOM查询结果
|
||
const groupContainer = table.closest('.group-container');
|
||
const groupHeader = groupContainer ? groupContainer.querySelector('.group-header') : null;
|
||
const groupHeaderHeight = groupHeader ? groupHeader.offsetHeight : 0;
|
||
|
||
const teamRolesRow = thead.querySelector('.team-roles-row');
|
||
const headerRow = thead.querySelector('.sticky-header');
|
||
|
||
// 批量处理样式变更
|
||
if (teamRolesRow) {
|
||
teamRolesRow.style.top = `${groupHeaderHeight - 20}px`;
|
||
}
|
||
|
||
if (teamRolesRow && headerRow) {
|
||
const teamRolesHeight = teamRolesRow.offsetHeight;
|
||
const headerTop = groupHeaderHeight + teamRolesHeight - 20;
|
||
|
||
headerRow.style.top = `${headerTop}px`;
|
||
|
||
// 批量处理th元素
|
||
const headerThs = headerRow.querySelectorAll('th');
|
||
for (let j = 0; j < headerThs.length; j++) {
|
||
headerThs[j].style.top = `${headerTop}px`;
|
||
}
|
||
} else if (headerRow) {
|
||
const headerTop = groupHeaderHeight - 20;
|
||
headerRow.style.top = `${headerTop}px`;
|
||
|
||
if (useLegacyFormat) {
|
||
const headerThs = headerRow.querySelectorAll('th');
|
||
for (let j = 0; j < headerThs.length; j++) {
|
||
headerThs[j].style.top = `${headerTop}px`;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} catch (error) {
|
||
console.warn('调整表头位置时出错:', error);
|
||
} finally {
|
||
isAdjustingTableHeader = false;
|
||
}
|
||
});
|
||
}
|
||
|
||
// 防抖函数
|
||
function debounce(func, wait) {
|
||
let timeout;
|
||
return function executedFunction(...args) {
|
||
const later = () => {
|
||
clearTimeout(timeout);
|
||
func(...args);
|
||
};
|
||
clearTimeout(timeout);
|
||
timeout = setTimeout(later, wait);
|
||
};
|
||
}
|
||
|
||
|
||
// 节流函数
|
||
function throttle(func, limit) {
|
||
let inThrottle;
|
||
return function (...args) {
|
||
if (!inThrottle) {
|
||
func.apply(this, args);
|
||
inThrottle = true;
|
||
setTimeout(() => inThrottle = false, limit);
|
||
}
|
||
};
|
||
}
|
||
|
||
// 创建优化后的事件处理器
|
||
const optimizedAdjustTableHeader = throttle(adjustTableHeaderPosition, 50);
|
||
const debouncedAdjustTableHeader = debounce(adjustTableHeaderPosition, 150);
|
||
|
||
// 事件监听器
|
||
function setupOptimizedEventListeners() {
|
||
// 滚动事件使用节流
|
||
window.addEventListener('scroll', optimizedAdjustTableHeader, { passive: true });
|
||
|
||
// 调整大小事件使用防抖
|
||
window.addEventListener('resize', debouncedAdjustTableHeader, { passive: true });
|
||
|
||
// 移除旧的事件监听器(如果有)
|
||
window.removeEventListener('scroll', adjustTableHeaderPosition);
|
||
window.removeEventListener('resize', adjustTableHeaderPosition);
|
||
}
|
||
|
||
// 在页面加载完成后设置优化的事件监听器
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', setupOptimizedEventListeners);
|
||
} else {
|
||
setupOptimizedEventListeners();
|
||
}
|
||
|
||
// 设置行高亮效果
|
||
function setupRowHighlight() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const rows = table.querySelectorAll('tr:not(.sticky-header):not(.team-roles-row)');
|
||
const rowsArray = Array.from(rows);
|
||
|
||
rowsArray.forEach(row => {
|
||
// 使用事件委托的变体,减少事件监听器数量
|
||
const handler = useLegacyFormat ? createLegacyRowHandler(table) : createStandardRowHandler();
|
||
|
||
row.addEventListener('mouseenter', handler.enter);
|
||
row.addEventListener('mouseleave', handler.leave);
|
||
});
|
||
});
|
||
}
|
||
|
||
function createStandardRowHandler() {
|
||
return {
|
||
enter: function (e) {
|
||
e.currentTarget.classList.add('highlighted');
|
||
},
|
||
leave: function (e) {
|
||
e.currentTarget.classList.remove('highlighted');
|
||
}
|
||
};
|
||
}
|
||
|
||
function createLegacyRowHandler(table) {
|
||
return {
|
||
enter: function (e) {
|
||
const taskId = e.currentTarget.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => r.classList.add('highlighted'));
|
||
}
|
||
},
|
||
leave: function (e) {
|
||
const taskId = e.currentTarget.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => r.classList.remove('highlighted'));
|
||
}
|
||
}
|
||
};
|
||
}
|
||
|
||
// 添加键盘快捷键来打开快速导航(例如 Ctrl+G)
|
||
document.addEventListener('keydown', function (e) {
|
||
// 如果正在搜索框中输入,不触发快捷键
|
||
const searchInput = document.getElementById('quickNavSearch');
|
||
if (searchInput && document.activeElement === searchInput) {
|
||
// 只允许ESC键在搜索框中工作
|
||
if (e.keyCode === 27) { // ESC
|
||
hideQuickNav();
|
||
e.preventDefault();
|
||
}
|
||
return; // 其他快捷键在搜索时不触发
|
||
}
|
||
|
||
// 打开快速导航
|
||
if (e.keyCode === 71) { // G 鍵
|
||
e.preventDefault();
|
||
if (hasLogData) {
|
||
toggleQuickNav();
|
||
}
|
||
}
|
||
});
|
||
|
||
// 監聽鍵盤按下
|
||
document.onkeydown = function (e) {
|
||
var keyNum = e; // // 使用事件对象而不是 window.event
|
||
|
||
if (keyNum.keyCode == 54) {
|
||
// 6 計算原神下次60體時間
|
||
// 呼叫視窗、要求現在體力
|
||
var ps = prompt("計算_原神_下次 60 體力\n輸入現在_原神_體力", "");
|
||
ps = ps.split(",")
|
||
// 判定是否數字
|
||
if (isFinite(ps[0])) {
|
||
// 是否有參數次數
|
||
if (isFinite(ps[1])) {
|
||
var endText = "下次_原神_60體力_時間大約為"
|
||
for (var i = 0; i < Number(ps[1]); i++) {
|
||
endText = endText + "___" + GCSRT(Number(ps[0]), 60 * (i + 1), 8);
|
||
}
|
||
// 輪出結果
|
||
alert(endText);
|
||
} else {
|
||
alert("下次_原神_60體力_時間大約為___" + GCSRT(Number(ps), 60, 8) + "___" + GCSRT(Number(ps), 120, 8) + "。。。。。。" + GCSRT(Number(ps), 200, 8));
|
||
}
|
||
|
||
} else {
|
||
alert("請輸入數字");
|
||
}
|
||
|
||
} else if (keyNum.keyCode == 55) {
|
||
// 7 計算原神下次40體時間
|
||
// 呼叫視窗、要求現在體力
|
||
var ps = prompt("計算_原神_下次 40 體力\n輸入現在_原神_體力", "");
|
||
ps = ps.split(",")
|
||
|
||
// 判定是否數字
|
||
if (isFinite(ps[0])) {
|
||
// 是否有參數次數
|
||
if (isFinite(ps[1])) {
|
||
var endText = "下次_原神_40體力_時間大約為"
|
||
for (var i = 0; i < Number(ps[1]); i++) {
|
||
endText = endText + "___" + GCSRT(Number(ps[0]), 40 * (i + 1), 8);
|
||
}
|
||
// 輪出結果
|
||
alert(endText);
|
||
} else {
|
||
alert("下次_原神_40體力_時間大約為___" + GCSRT(Number(ps), 40, 8) + "___" + GCSRT(Number(ps), 80, 8) + "。。。。。。" + GCSRT(Number(ps), 200, 8));
|
||
}
|
||
} else {
|
||
alert("請輸入數字");
|
||
}
|
||
} else if (keyNum.keyCode == 56) {
|
||
// 8 計算自訂體力時間
|
||
// 呼叫視窗、要求現在體力
|
||
var ps = prompt("輸入現在_要計算體力_的參數\r(現在體力,目標體力,體力cd)", "");
|
||
//分割為列陣
|
||
ps = ps.split(",")
|
||
// 判定是否數字
|
||
if (isFinite(ps[0]) || isFinite(ps[1]) || isFinite(ps[2])) {
|
||
alert("下次_目標體力_時間大約為___" + GCSRT(Number(ps[0]), Number(ps[1]), Number(ps[2])));
|
||
} else {
|
||
alert("請輸入數字");
|
||
}
|
||
} else if (keyNum.keyCode == 57) {
|
||
// 9 計算任務距離時間
|
||
handleDateComparison();
|
||
} else if (keyNum.keyCode == 96 || keyNum.keyCode == 48) {
|
||
// 左0or右0 幫助
|
||
var help_text = "";
|
||
help_text += "Better Genshin Impact 日志分析工具 - 简易说明\n";
|
||
help_text += "• 鼠标悬停统计数字查看详情\n\n";
|
||
|
||
help_text += "常用快捷键:\n";
|
||
help_text += "T 切换时间列显示/隐藏\n";
|
||
help_text += "Y 切换统计列显示/隐藏\n";
|
||
help_text += "U 切换表格格式(新旧版)\n";
|
||
help_text += "I 切换拾取物列显示/隐藏\n";
|
||
help_text += "Alt+I 切换拾取物显示顺序(数量/拾取顺序)\n";
|
||
help_text += "J 隐藏/显示所有统计为0的任务\n";
|
||
help_text += "P 进入/退出导出模式\n";
|
||
help_text += "~ 切换亮色/暗色主题\n";
|
||
help_text += "R 重置弹窗位置\n\n";
|
||
|
||
help_text += "实用计算功能:\n";
|
||
help_text += "7 计算原神下次40体力时间\n";
|
||
help_text += "9 计算时间距离现在多久\n";
|
||
help_text += "右2 计算日期+3天\n";
|
||
help_text += "右3 计算两个时间点间隔\n";
|
||
help_text += "右5 计算N天后的日期\n";
|
||
help_text += "右7 计算原神下次120体力时间\n";
|
||
help_text += "右8 计算HH.MM后的时间\n";
|
||
help_text += "右9 计算时间+46小时后\n\n";
|
||
help_text += "详细说明请复制下方网址查看:";
|
||
|
||
// 使用prompt并预设网址,方便用户复制
|
||
prompt(help_text, "https://github.com/this-Fish/this-fish.github.io/tree/main/Read_BetterGI_Log");
|
||
|
||
} else if (keyNum.keyCode == 98) {
|
||
// 計算BGI日志格式 +3天
|
||
addThreeDaysSimple();
|
||
} else if (keyNum.keyCode == 99) {
|
||
// 右3 計算運行時間
|
||
calculateTimeDifference();
|
||
} else if (keyNum.keyCode == 101) {
|
||
// 右5 計算+N天數
|
||
handleAddDays();
|
||
} else if (keyNum.keyCode == 103) {
|
||
// 右7 計算原神下次120體時間
|
||
// 呼叫視窗、要求現在體力
|
||
var ps = prompt("計算_原神_下次 120 體力\n輸入現在_原神_體力", "");
|
||
ps = ps.split(",")
|
||
|
||
// 判定是否數字
|
||
if (isFinite(ps[0])) {
|
||
// 是否有參數次數
|
||
if (isFinite(ps[1])) {
|
||
var endText = "下次_原神_120體力_時間大約為"
|
||
for (var i = 0; i < Number(ps[1]); i++) {
|
||
endText = endText + "___" + GCSRT(Number(ps[0]), 120 * (i + 1), 8);
|
||
}
|
||
// 輪出結果
|
||
alert(endText);
|
||
} else {
|
||
alert("下次_原神_120體力_時間大約為___" + GCSRT(Number(ps), 120, 8) + "。。。。。。" + GCSRT(Number(ps), 200, 8));
|
||
}
|
||
} else {
|
||
alert("請輸入數字");
|
||
}
|
||
} else if (keyNum.keyCode == 104) {
|
||
// 右8 計算任務HH.MM后時間
|
||
handleAddCustomTime();
|
||
} else if (keyNum.keyCode == 105) {
|
||
// 右9 計算任務46小時后時間
|
||
handleDateAddition();
|
||
} else if (keyNum.keyCode == 70 && keyNum.altKey) {
|
||
// alt + f
|
||
toggleFullScreen();
|
||
e.preventDefault(); // 阻止默认行为
|
||
return;
|
||
} else if (keyNum.keyCode == 192) {
|
||
document.body.classList.toggle('dark-theme'); // 切换暗色主题
|
||
|
||
// 更新帮助提示的样式
|
||
const helpIndicator = document.getElementById('helpIndicator');
|
||
if (document.body.classList.contains('dark-theme')) {
|
||
helpIndicator.style.backgroundColor = '#fff';
|
||
helpIndicator.style.color = '#000';
|
||
} else {
|
||
helpIndicator.style.backgroundColor = '#000';
|
||
helpIndicator.style.color = '#fff';
|
||
}
|
||
} else if (keyNum.keyCode == 87) {
|
||
// W 畫面向上移
|
||
dropZone.scrollBy(0, -150);
|
||
} else if (keyNum.keyCode == 83) {
|
||
// S 畫面向下移
|
||
dropZone.scrollBy(0, 150);
|
||
} else if (keyNum.keyCode == 110 || keyNum.keyCode == 190) {
|
||
// 左. 右. 同視窗開新頁面
|
||
window.open("index.html");
|
||
} else if (keyNum.keyCode === 82) {
|
||
// R键
|
||
if (window.resetCoordPopups) {
|
||
window.resetCoordPopups();
|
||
}
|
||
e.preventDefault(); // 阻止默认行为
|
||
} else if (keyNum.keyCode == 84) { // T键 - 切换时间列显示
|
||
timeColumnsVisible = !timeColumnsVisible;
|
||
updateTimeColumnsVisibility();
|
||
showTimeToggleIndicator();
|
||
e.preventDefault(); // 阻止默认行为
|
||
} else if (keyNum.keyCode == 89) { // Y键 - 切换统计列显示
|
||
statsColumnsVisible = !statsColumnsVisible;
|
||
updateStatsColumnsVisibility();
|
||
showStatsToggleIndicator();
|
||
e.preventDefault(); // 阻止默认行为
|
||
} else if (keyNum.keyCode == 85) { // U 键 - 切换表格格式
|
||
// 检查是否有日志数据
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
// 保存当前状态
|
||
const currentHideZeroStats = hideZeroStatsTasks;
|
||
const currentFilterMode = isFilterMode;
|
||
|
||
useLegacyFormat = !useLegacyFormat;
|
||
refreshHTML();
|
||
showFormatToggleIndicator();
|
||
|
||
// 恢复状态
|
||
hideZeroStatsTasks = currentHideZeroStats;
|
||
isFilterMode = currentFilterMode;
|
||
|
||
// 更新按钮状态
|
||
updateButtonState(74); // 异常任务按钮
|
||
updateButtonState(72); // 筛选模式按钮
|
||
|
||
e.preventDefault(); // 阻止默认行为
|
||
} else if (keyNum.keyCode == 72) { // H 鍵 - 任務篩選
|
||
// 檢查是否有日志數據
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
// 如果处于时间筛选模式,退出时间筛选
|
||
if (isTimeFilterMode) {
|
||
exitTimeFilterMode();
|
||
} else {
|
||
// 否则切换任务筛选
|
||
toggleTaskFilter();
|
||
}
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 73 && keyNum.altKey) { // Alt + I - 切换拾取物显示顺序
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
togglePicksSortOrder();
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 73) { // I键 - 切换拾取物列显示(仅旧版格式)
|
||
// if (!useLegacyFormat) {
|
||
picksColumnsVisible = !picksColumnsVisible;
|
||
updatePicksColumnsVisibility();
|
||
showPicksToggleIndicator();
|
||
e.preventDefault(); // 阻止默认行为
|
||
// }
|
||
} else if (keyNum.keyCode == 74) { // J 键 - 隐藏/显示所有统计为0的任务
|
||
toggleZeroStatsTasks();
|
||
e.preventDefault(); // 阻止默认行为
|
||
} else if (keyNum.keyCode === 80 || keyNum.key === 'p' || keyNum.key === 'P') {
|
||
// 阻止默认行为,避免可能冲突
|
||
e.preventDefault();
|
||
|
||
// 处理 P 键功能
|
||
handlePKey();
|
||
} else if (keyNum.keyCode == 76 && keyNum.altKey) { // Alt+L
|
||
// 如果在移动设备上,不允许隐藏
|
||
if (document.body.classList.contains('mobile-device')) {
|
||
// alert('在移动设备上上传区域始终保持显示');
|
||
return;
|
||
}
|
||
|
||
// 切换电脑设备上的显示状态
|
||
uploadContainerVisible = !uploadContainerVisible;
|
||
const uploadContainer = document.getElementById('fileUploadContainer');
|
||
|
||
if (uploadContainerVisible) {
|
||
uploadContainer.classList.add('visible');
|
||
} else {
|
||
uploadContainer.classList.remove('visible');
|
||
}
|
||
|
||
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 79) { // O 键 - 拾取效率计算
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
togglePickEfficiencyMode();
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 77) { // M 键 - 统计拾取物
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
countPickups();
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 112) { // F1 鍵 - 打開 README.md
|
||
window.open("https://github.com/this-Fish/this-fish.github.io/tree/main/Read_BetterGI_Log");
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 113) { // F2 鍵 - 快速上傳文件
|
||
// 防止在輸入框中觸發
|
||
const activeElement = document.activeElement;
|
||
const tagName = activeElement.tagName.toLowerCase();
|
||
if (tagName === 'input' || tagName === 'textarea') {
|
||
return; // 讓輸入框正常處理按鍵
|
||
}
|
||
|
||
// 直接觸發文件選擇對話框
|
||
document.getElementById('fileInput').click();
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 219) { // [ 鍵 - 自由编辑网页
|
||
// 防止在輸入框中觸發
|
||
"true" === document.body.getAttribute("contenteditable") ? (document.body.setAttribute("contenteditable", false), alert("关闭自由编辑网页!")) : (document.body.setAttribute("contenteditable", true), alert("启用自由编辑网页!"))
|
||
e.preventDefault();
|
||
} else if (keyNum.keyCode == 100) { // 右4
|
||
if (!hasLogData) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
// 如果已经处于时间筛选模式,按4键退出
|
||
if (isTimeFilterMode) {
|
||
exitTimeFilterMode();
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
if (isFilterMode) {
|
||
// 退出篩選模式
|
||
exitFilterMode();
|
||
return;
|
||
}
|
||
|
||
// 否则进入时间筛选模式
|
||
showTimeFilterPrompt();
|
||
e.preventDefault();
|
||
}
|
||
|
||
// 在每个快捷键处理完后,更新对应的按钮状态
|
||
if ([192, 84, 89, 73, 80, 74].includes(keyNum.keyCode)) {
|
||
// 稍等片刻再更新,确保状态变量已经改变
|
||
setTimeout(() => {
|
||
updateButtonState(e.keyCode);
|
||
}, 50);
|
||
}
|
||
}
|
||
|
||
// 时间筛选提示函数
|
||
function showTimeFilterPrompt() {
|
||
|
||
// 如果当前处于任务筛选模式,先退出
|
||
if (isFilterMode) {
|
||
exitFilterMode();
|
||
}
|
||
|
||
// 计算默认开始时间(当天04:00,如果当前时间在00:00-03:59,则减1天)
|
||
const now = new Date();
|
||
let startDate = new Date(now);
|
||
|
||
if (now.getHours() < 4) {
|
||
// 如果是00:00-03:59,使用前一天的04:00
|
||
startDate.setDate(startDate.getDate() - 1);
|
||
}
|
||
startDate.setHours(4, 0, 0, 0);
|
||
|
||
const endDate = new Date(now); // 结束时间默认当前时间
|
||
|
||
// 格式化日期为字符串
|
||
const formatDateForInput = (date) => {
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
const hours = String(date.getHours()).padStart(2, '0');
|
||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
||
};
|
||
|
||
// 计算当天0时0分0秒的格式化字符串
|
||
const todayStart = new Date(now);
|
||
todayStart.setHours(0, 0, 0, 0);
|
||
const defaultTodayStart = formatDateForInput(todayStart);
|
||
|
||
const defaultStartTime = formatDateForInput(startDate);
|
||
const defaultEndTime = formatDateForInput(endDate);
|
||
|
||
// 第一个提示框:开始时间
|
||
const startInput = prompt(
|
||
"请输入开始时间 (格式: YYYY/MM/DD HH:MM:SS)\n为空则使用当天0时0分0秒\n示例: 2026/01/13 12:05:25",
|
||
defaultStartTime
|
||
);
|
||
|
||
if (startInput === null) return; // 用户取消
|
||
|
||
// 第二个提示框:结束时间
|
||
const endInput = prompt(
|
||
"请输入结束时间 (格式: YYYY/MM/DD HH:MM:SS)\n为空则使用当前时间\n示例: 2026/01/13 18:30:07",
|
||
defaultEndTime
|
||
);
|
||
|
||
if (endInput === null) return; // 用户取消
|
||
|
||
// 解析时间字符串
|
||
const parseDateTime = (str) => {
|
||
// 如果输入为空,返回null,后续会特殊处理
|
||
if (!str || str.trim() === '') {
|
||
return null;
|
||
}
|
||
|
||
const parts = str.trim().split(/[/ :]/);
|
||
if (parts.length !== 6) {
|
||
throw new Error("时间格式错误,请使用 YYYY/MM/DD HH:MM:SS 格式");
|
||
}
|
||
|
||
const year = parseInt(parts[0], 10);
|
||
const month = parseInt(parts[1], 10) - 1; // 月份从0开始
|
||
const day = parseInt(parts[2], 10);
|
||
const hours = parseInt(parts[3], 10);
|
||
const minutes = parseInt(parts[4], 10);
|
||
const seconds = parseInt(parts[5], 10);
|
||
|
||
return new Date(year, month, day, hours, minutes, seconds);
|
||
};
|
||
|
||
try {
|
||
let startTime = parseDateTime(startInput);
|
||
let endTime = parseDateTime(endInput);
|
||
|
||
// 如果开始时间为空,使用当天0时0分0秒
|
||
if (startTime === null) {
|
||
startTime = new Date(now);
|
||
startTime.setHours(0, 0, 0, 0);
|
||
}
|
||
|
||
// 如果结束时间为空,使用当前时间
|
||
if (endTime === null) {
|
||
endTime = new Date(now);
|
||
}
|
||
|
||
if (startTime >= endTime) {
|
||
alert("开始时间必须早于结束时间");
|
||
return;
|
||
}
|
||
|
||
applyTimeFilter(startTime, endTime);
|
||
} catch (error) {
|
||
alert(`时间解析错误: ${error.message}`);
|
||
}
|
||
}
|
||
|
||
// 应用时间筛选
|
||
function applyTimeFilter(startTime, endTime) {
|
||
if (!startTime || !endTime) { return; }
|
||
// 保存筛选时间
|
||
timeFilterStart = startTime;
|
||
timeFilterEnd = endTime;
|
||
isTimeFilterMode = true;
|
||
|
||
// 添加时间筛选模式类
|
||
document.body.classList.add('time-filter-mode');
|
||
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
const groupHeader = container.querySelector('.group-header h2');
|
||
const groupName = groupHeader ? groupHeader.textContent : '';
|
||
|
||
// 确保队伍角色行显示
|
||
const teamRolesRow = table.querySelector('.team-roles-row');
|
||
if (teamRolesRow) {
|
||
teamRolesRow.style.display = '';
|
||
}
|
||
|
||
// 时间筛选模式下,不隐藏汇总行(除非拾取效率模式启用)
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
// 如果拾取效率模式启用,则隐藏汇总行,否则显示
|
||
if (isPickEfficiencyMode) {
|
||
row.style.display = 'none';
|
||
} else {
|
||
row.style.display = '';
|
||
}
|
||
});
|
||
|
||
let groupHasVisibleTask = false;
|
||
|
||
// 新版格式
|
||
if (!useLegacyFormat) {
|
||
const rows = table.querySelectorAll('tr[data-original-index]');
|
||
|
||
rows.forEach(row => {
|
||
// 跳过非任务行
|
||
if (row.querySelector('th') ||
|
||
row.classList.contains('team-roles-row') ||
|
||
row.classList.contains('summary-row')) {
|
||
return;
|
||
}
|
||
|
||
// 获取任务开始时间
|
||
const startTimeCell = row.querySelector('.column-start-time');
|
||
if (startTimeCell) {
|
||
const timeText = startTimeCell.textContent.trim();
|
||
|
||
const taskStartTime = parseTableTime(timeText);
|
||
|
||
// 判断任务是否在时间范围内
|
||
if (taskStartTime &&
|
||
taskStartTime >= timeFilterStart &&
|
||
taskStartTime <= timeFilterEnd) {
|
||
row.style.display = '';
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
row.style.display = 'none';
|
||
}
|
||
}
|
||
});
|
||
}
|
||
// 旧版格式
|
||
else {
|
||
const taskNameRows = table.querySelectorAll('tr .main-row-name');
|
||
|
||
taskNameRows.forEach(taskNameCell => {
|
||
const row = taskNameCell.closest('tr');
|
||
const taskId = row.getAttribute('data-task-id');
|
||
|
||
if (taskId) {
|
||
// 获取任务开始时间
|
||
const startTimeCell = row.querySelector('.column-start-time');
|
||
if (startTimeCell) {
|
||
const timeText = startTimeCell.textContent.trim();
|
||
const taskStartTime = parseTableTime(timeText);
|
||
|
||
if (taskStartTime &&
|
||
taskStartTime >= timeFilterStart &&
|
||
taskStartTime <= timeFilterEnd) {
|
||
// 显示相关行
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
if (!r.classList.contains('summary-row')) {
|
||
r.style.display = '';
|
||
}
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
// 隐藏相关行
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
r.style.display = 'none';
|
||
});
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
// 如果配置组没有可见任务,隐藏整个配置组
|
||
if (groupHasVisibleTask) {
|
||
container.style.display = '';
|
||
} else {
|
||
container.style.display = 'none';
|
||
}
|
||
});
|
||
|
||
// 显示筛选提示
|
||
showTimeFilterIndicator();
|
||
|
||
// 更新按钮状态
|
||
updateButtonState(100); // 虽然我们没有对应的按钮,但可以保留
|
||
|
||
// 更新任务计数
|
||
updateTaskCounts();
|
||
|
||
// 调整表头位置
|
||
setTimeout(() => {
|
||
adjustTableHeaderPosition();
|
||
refreshQuickNav();
|
||
}, 50);
|
||
}
|
||
|
||
// 解析表格中的时间字符串
|
||
function parseTableTime(timeStr) {
|
||
if (!timeStr || timeStr === '未知时间' || timeStr === '进行中') return null;
|
||
|
||
// 处理格式: 2025/05/23 07:19:45
|
||
const parts = timeStr.split(/[/ :]/);
|
||
if (parts.length !== 6) return null;
|
||
|
||
const year = parseInt(parts[0], 10);
|
||
const month = parseInt(parts[1], 10) - 1;
|
||
const day = parseInt(parts[2], 10);
|
||
const hours = parseInt(parts[3], 10);
|
||
const minutes = parseInt(parts[4], 10);
|
||
const seconds = parseInt(parts[5], 10);
|
||
|
||
return new Date(year, month, day, hours, minutes, seconds);
|
||
}
|
||
|
||
// 显示时间筛选提示
|
||
function showTimeFilterIndicator() {
|
||
const indicator = document.getElementById('filterIndicator');
|
||
const keywordsElement = document.getElementById('filterKeywords');
|
||
|
||
const formatDate = (date) => {
|
||
return date.toLocaleString('zh-CN', {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit',
|
||
hour: '2-digit',
|
||
minute: '2-digit',
|
||
second: '2-digit'
|
||
});
|
||
};
|
||
|
||
const startStr = formatDate(timeFilterStart);
|
||
const endStr = formatDate(timeFilterEnd);
|
||
|
||
keywordsElement.textContent = `${startStr} - ${endStr}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 动态计算筛选提示宽度
|
||
const filterWidth = indicator.offsetWidth;
|
||
document.documentElement.style.setProperty('--filter-indicator-width', filterWidth + 'px');
|
||
}
|
||
|
||
// 退出时间筛选模式
|
||
function exitTimeFilterMode() {
|
||
isTimeFilterMode = false;
|
||
timeFilterStart = null;
|
||
timeFilterEnd = null;
|
||
|
||
// 移除时间筛选模式类
|
||
document.body.classList.remove('time-filter-mode');
|
||
|
||
// 移除筛选,显示所有任务和总计行
|
||
removeTaskFilter();
|
||
|
||
// 隐藏筛选提示
|
||
hideFilterIndicator();
|
||
|
||
// 更新任务计数
|
||
setTimeout(() => {
|
||
updateTaskCounts();
|
||
adjustTableHeaderPosition();
|
||
refreshQuickNav();
|
||
}, 50);
|
||
|
||
updateButtonState(100);
|
||
// 显示退出提示
|
||
showTimeFilterExitIndicator();
|
||
}
|
||
|
||
// 显示时间筛选退出提示
|
||
function showTimeFilterExitIndicator() {
|
||
const indicator = document.getElementById('filterIndicator');
|
||
const keywordsElement = document.getElementById('filterKeywords');
|
||
|
||
keywordsElement.textContent = '时间筛选已退出';
|
||
indicator.classList.add('visible');
|
||
|
||
indicator.classList.remove('visible');
|
||
}
|
||
|
||
// 统计拾取物函数
|
||
function countPickups() {
|
||
if (!hasLogData) {
|
||
return;
|
||
}
|
||
|
||
// 获取用户输入,默认值为战狂,游医,教官,流放者
|
||
let input = prompt(
|
||
"请输入要统计的拾取物名称(多个用逗号分隔)\n例如:战狂,游医,教官,流放者\n\n匹配规则:包含关键字即计数",
|
||
"战狂,游医,教官,流放者"
|
||
);
|
||
|
||
if (input === null || input.trim() === '') {
|
||
return; // 用户取消或输入为空
|
||
}
|
||
|
||
// 统计鍵快捷標記
|
||
if (input == "/1") { input = "战狂,游医,教官,流放者" }
|
||
if (input == "/2") { input = "拉扯结束" }
|
||
if (input == "/3") { input = "小怪" }
|
||
if (input == "/4") { input = "使用回血料理,使用复活料理" }
|
||
if (input == "/5") { input = "源生嵌合体 并生嵌合胞 嵌合种" }
|
||
|
||
// 支持英文逗号、中文逗号、顿号、空格作为分隔符
|
||
const itemsToCount = input.split(/[,,、\s]+/)
|
||
.map(item => item.trim())
|
||
.filter(item => item.length > 0);
|
||
|
||
if (itemsToCount.length === 0) {
|
||
alert("请输入有效的拾取物名称!");
|
||
return;
|
||
}
|
||
|
||
// 统计总数
|
||
let totalCount = 0;
|
||
const itemCounts = {};
|
||
|
||
// 初始化每个物品的计数器
|
||
itemsToCount.forEach(item => {
|
||
itemCounts[item] = 0;
|
||
});
|
||
|
||
// 获取所有拾取物单元格(排除汇总行)
|
||
const pickCells = document.querySelectorAll('.column-picks');
|
||
|
||
pickCells.forEach(cell => {
|
||
// 检查单元格是否可见
|
||
const row = cell.closest('tr');
|
||
if (row && row.style.display === 'none') {
|
||
return; // 跳过隐藏的行
|
||
}
|
||
|
||
// 检查单元格是否在隐藏的配置组中
|
||
const container = cell.closest('.group-container');
|
||
if (container && container.style.display === 'none') {
|
||
return; // 跳过隐藏的配置组
|
||
}
|
||
|
||
// 检查是否是汇总行(所有拾取物行)
|
||
if (row.classList.contains('summary-row')) {
|
||
return; // 跳过汇总行
|
||
}
|
||
|
||
// 克隆单元格并移除特殊事件提示(如 <span class="abnormal-alert">用户终止运行 (7)</span>)
|
||
const cellClone = cell.cloneNode(true);
|
||
cellClone.querySelectorAll('.abnormal-alert, .auto-potion, .warning, .info').forEach(span => span.remove());
|
||
|
||
const text = cellClone.textContent.trim();
|
||
if (text === '无' || text === '') {
|
||
return; // 跳过无拾取物的单元格
|
||
}
|
||
|
||
// 解析拾取物文本 - 包含匹配
|
||
if (picksSortByCount) {
|
||
// 按数量合并模式:"物品A (2), 物品B (3)"
|
||
const regex = /([^(]+?)\s*\((\d+)\)/g;
|
||
let match;
|
||
while ((match = regex.exec(text)) !== null) {
|
||
const itemName = match[1].trim();
|
||
const count = parseInt(match[2]);
|
||
|
||
// 检查是否包含任一统计项(包含匹配)
|
||
itemsToCount.forEach(targetItem => {
|
||
if (itemName.includes(targetItem)) {
|
||
itemCounts[targetItem] += count;
|
||
totalCount += count;
|
||
}
|
||
});
|
||
}
|
||
} else {
|
||
// 按拾取顺序模式:"物品A, 物品B, 物品A"
|
||
const items = text.split(',').map(item => item.trim());
|
||
items.forEach(itemName => {
|
||
// 检查是否包含任一统计项(包含匹配)
|
||
itemsToCount.forEach(targetItem => {
|
||
if (itemName.includes(targetItem)) {
|
||
itemCounts[targetItem] += 1;
|
||
totalCount += 1;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
});
|
||
|
||
// 构建结果显示文本
|
||
let resultText = `总计: ${totalCount}个\n\n详细统计:\n`;
|
||
|
||
// 按数量从多到少排序
|
||
const sortedItems = Object.entries(itemCounts)
|
||
.sort((a, b) => b[1] - a[1])
|
||
.filter(([_, count]) => count > 0);
|
||
|
||
if (sortedItems.length > 0) {
|
||
sortedItems.forEach(([item, count]) => {
|
||
resultText += `${item}: ${count}个\n`;
|
||
});
|
||
} else {
|
||
resultText += "未找到包含指定关键字的拾取物";
|
||
}
|
||
|
||
// 显示结果
|
||
alert(resultText);
|
||
}
|
||
|
||
// 切换拾取效率模式
|
||
function togglePickEfficiencyMode() {
|
||
if (isPickEfficiencyMode) {
|
||
// 退出拾取效率模式
|
||
exitPickEfficiencyMode();
|
||
} else {
|
||
// 进入拾取效率模式
|
||
enterPickEfficiencyMode();
|
||
}
|
||
}
|
||
|
||
// 进入拾取效率模式
|
||
function enterPickEfficiencyMode() {
|
||
const input = prompt("请输入要计算效率的拾取物名称(多个关键字用逗号分隔,例如:甜甜花,薄荷)");
|
||
|
||
if (input === null) {
|
||
// 用户取消输入
|
||
return;
|
||
}
|
||
|
||
const itemNames = input.split(',')
|
||
.map(name => name.trim())
|
||
.filter(name => name.length > 0);
|
||
|
||
if (itemNames.length === 0) {
|
||
alert("请输入有效的拾取物名称!");
|
||
return;
|
||
}
|
||
|
||
currentPickEfficiencyItem = itemNames;
|
||
isPickEfficiencyMode = true;
|
||
|
||
// 应用拾取效率计算和排序
|
||
applyPickEfficiency();
|
||
|
||
// 更新按钮状态
|
||
// updateButtonState(79); // 假设使用 O 键(79)
|
||
}
|
||
|
||
// 退出拾取效率模式函数
|
||
function exitPickEfficiencyMode() {
|
||
isPickEfficiencyMode = false;
|
||
currentPickEfficiencyItem = null;
|
||
|
||
// 刷新页面恢复原始状态
|
||
refreshHTML();
|
||
|
||
// 如果在筛选模式下,确保拾取物行保持隐藏
|
||
if (isFilterMode) {
|
||
const tables = document.querySelectorAll('table');
|
||
tables.forEach(table => {
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
row.style.display = 'none';
|
||
});
|
||
});
|
||
}
|
||
|
||
// 隐藏状态提示
|
||
const indicator = document.getElementById('picksToggleIndicator');
|
||
indicator.classList.remove('visible');
|
||
|
||
// 更新按钮状态
|
||
// updateButtonState(79);
|
||
}
|
||
|
||
// 确保排除拾取物汇总行
|
||
function applyPickEfficiency() {
|
||
if (!currentPickEfficiencyItem) return;
|
||
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
|
||
// 隐藏拾取物汇总行
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => {
|
||
row.style.display = 'none';
|
||
});
|
||
|
||
// 选择所有任务行,排除表头、队伍角色行和汇总行
|
||
const rows = Array.from(table.querySelectorAll('tr:not(.sticky-header):not(.team-roles-row):not(.summary-row):not(.ignore-sort)'));
|
||
|
||
// 为每行计算拾取效率
|
||
const rowsWithEfficiency = rows.map(row => {
|
||
const durationCell = row.querySelector('td:nth-child(4)'); // 耗时列
|
||
const picksCell = row.querySelector('.column-picks'); // 拾取物列
|
||
|
||
let efficiency = Infinity; // 默认效率为无穷大(没有该拾取物)
|
||
let itemCount = 0;
|
||
let originalDurationHtml = durationCell ? durationCell.innerHTML : '';
|
||
|
||
if (durationCell && picksCell) {
|
||
const durationText = durationCell.textContent;
|
||
const picksText = picksCell.innerHTML;
|
||
|
||
// 解析耗时(转换为秒)
|
||
const durationInSeconds = parseDurationToSeconds(durationText);
|
||
|
||
// 查找指定拾取物的数量(支持多个关键词)
|
||
itemCount = findItemCount(picksText, currentPickEfficiencyItem);
|
||
|
||
// 计算效率:秒/个
|
||
if (itemCount > 0 && durationInSeconds > 0) {
|
||
efficiency = durationInSeconds / itemCount;
|
||
}
|
||
}
|
||
|
||
return {
|
||
row: row,
|
||
efficiency: efficiency,
|
||
itemCount: itemCount,
|
||
durationText: durationCell ? durationCell.textContent : '',
|
||
originalDurationHtml: originalDurationHtml
|
||
};
|
||
});
|
||
|
||
// 按效率排序(效率高的排在前面)
|
||
rowsWithEfficiency.sort((a, b) => {
|
||
// 有拾取物的排在前面
|
||
if (a.itemCount > 0 && b.itemCount === 0) return -1;
|
||
if (a.itemCount === 0 && b.itemCount > 0) return 1;
|
||
if (a.itemCount === 0 && b.itemCount === 0) return 0;
|
||
|
||
// 都有的按效率排序(效率高的排前面)
|
||
return a.efficiency - b.efficiency;
|
||
});
|
||
|
||
// 重新排列行
|
||
const tbody = table.querySelector('tbody');
|
||
|
||
// 先移除所有任务行(保留表头、队伍角色行和汇总行)
|
||
rows.forEach(row => {
|
||
row.remove();
|
||
});
|
||
|
||
// 添加排序后的行
|
||
rowsWithEfficiency.forEach(item => {
|
||
// 更新耗时显示
|
||
const durationCell = item.row.querySelector('td:nth-child(4)');
|
||
if (durationCell && item.itemCount > 0) {
|
||
const efficiencyText = formatEfficiencyText(item.efficiency, item.itemCount);
|
||
durationCell.innerHTML = `${item.durationText}<br><small style="color:#666;font-size:12px;">${efficiencyText}</small>`;
|
||
} else if (durationCell) {
|
||
// 恢复原始显示
|
||
durationCell.innerHTML = item.originalDurationHtml;
|
||
}
|
||
|
||
tbody.appendChild(item.row);
|
||
});
|
||
});
|
||
|
||
// 显示状态提示
|
||
showPickEfficiencyIndicator();
|
||
}
|
||
|
||
// 解析耗时字符串为秒数
|
||
function parseDurationToSeconds(durationText) {
|
||
if (!durationText || durationText === '进行中') return 0;
|
||
|
||
let totalSeconds = 0;
|
||
|
||
// 匹配天、小时、分钟、秒
|
||
const dayMatch = durationText.match(/(\d+)天/);
|
||
const hourMatch = durationText.match(/(\d+)小时/);
|
||
const minuteMatch = durationText.match(/(\d+)分钟/);
|
||
const secondMatch = durationText.match(/(\d+(?:\.\d+)?)秒/);
|
||
|
||
if (dayMatch) totalSeconds += parseInt(dayMatch[1]) * 24 * 60 * 60;
|
||
if (hourMatch) totalSeconds += parseInt(hourMatch[1]) * 60 * 60;
|
||
if (minuteMatch) totalSeconds += parseInt(minuteMatch[1]) * 60;
|
||
if (secondMatch) totalSeconds += parseFloat(secondMatch[1]);
|
||
|
||
return totalSeconds;
|
||
}
|
||
|
||
// 支持包含关键字的匹配
|
||
function findItemCount(picksHtml, itemNames) {
|
||
// 将HTML转换为文本进行搜索
|
||
const tempDiv = document.createElement('div');
|
||
tempDiv.innerHTML = picksHtml;
|
||
const picksText = tempDiv.textContent || tempDiv.innerText || '';
|
||
|
||
// 如果拾取物文本包含"无",直接返回0
|
||
if (picksText.includes('无')) return 0;
|
||
|
||
let totalCount = 0;
|
||
|
||
// 檢查是否為按拾取顺序模式(文本中沒有括號和數字)
|
||
const isSequenceMode = !picksHtml.includes('(') && picksText.includes(',');
|
||
|
||
if (isSequenceMode) {
|
||
// 按拾取顺序模式:直接統計關鍵字出現次數
|
||
const items = picksText.split(',').map(item => item.trim());
|
||
|
||
items.forEach(item => {
|
||
// 檢查物品名稱是否包含任一關鍵字
|
||
const matchesAnyKeyword = itemNames.some(keyword =>
|
||
item.toLowerCase().includes(keyword.toLowerCase())
|
||
);
|
||
|
||
if (matchesAnyKeyword) {
|
||
totalCount += 1; // 每個匹配的物品計為1
|
||
}
|
||
});
|
||
} else {
|
||
// 按數量合併模式:使用原有的邏輯
|
||
// 分割拾取物(按逗号分割)
|
||
const pickItems = picksText.split(',');
|
||
|
||
pickItems.forEach(item => {
|
||
const trimmedItem = item.trim();
|
||
|
||
// 检查物品名称是否包含任一关键字
|
||
const matchesAnyKeyword = itemNames.some(keyword =>
|
||
trimmedItem.toLowerCase().includes(keyword.toLowerCase())
|
||
);
|
||
|
||
if (matchesAnyKeyword) {
|
||
// 提取数量 - 匹配括号中的数字
|
||
const countMatch = trimmedItem.match(/\((\d+)\)/);
|
||
if (countMatch) {
|
||
totalCount += parseInt(countMatch[1]);
|
||
} else {
|
||
// 如果沒有括號,默認計為1
|
||
totalCount += 1;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
return totalCount;
|
||
}
|
||
|
||
// 转义正则表达式特殊字符
|
||
function escapeRegExp(string) {
|
||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||
}
|
||
|
||
// 格式化效率文本
|
||
function formatEfficiencyText(efficiency, itemCount) {
|
||
if (efficiency === Infinity) return '';
|
||
|
||
const secondsPerItem = Math.round(efficiency * 10) / 10; // 保留一位小数
|
||
return `${secondsPerItem}秒/1个`;
|
||
}
|
||
|
||
// 显示拾取效率状态提示
|
||
function showPickEfficiencyIndicator() {
|
||
const indicator = document.getElementById('picksToggleIndicator');
|
||
const keywordsText = Array.isArray(currentPickEfficiencyItem)
|
||
? currentPickEfficiencyItem.join(', ')
|
||
: currentPickEfficiencyItem;
|
||
|
||
indicator.textContent = `拾取效率: ${keywordsText} (按O退出)`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 不自动隐藏,直到用户退出模式
|
||
}
|
||
|
||
function showZeroStatsToggleIndicator() {
|
||
const indicator = document.getElementById('zeroStatsToggleIndicator');
|
||
indicator.textContent = `零统计任务: ${hideZeroStatsTasks ? '隐藏' : '显示'}`;
|
||
indicator.classList.add('visible');
|
||
|
||
// 2秒后隐藏提示
|
||
setTimeout(() => {
|
||
indicator.classList.remove('visible');
|
||
}, 2000);
|
||
}
|
||
|
||
// 零统计筛选的逻辑
|
||
function toggleZeroStatsTasks() {
|
||
hideZeroStatsTasks = !hideZeroStatsTasks;
|
||
|
||
// 如果在筛选模式下,需要重新应用筛选
|
||
if (isFilterMode || isTimeFilterMode) {
|
||
// 先应用筛选模式
|
||
if (isTimeFilterMode) {
|
||
applyTimeFilter(timeFilterStart, timeFilterEnd)
|
||
} else {
|
||
applyTaskFilter();
|
||
}
|
||
// 然后应用零统计筛选 - 使用筛选模式版本
|
||
if (hideZeroStatsTasks) {
|
||
toggleZeroStatsTasksInFilterMode();
|
||
} else {
|
||
// 退出零统计筛选时,重新应用筛选但不隐藏零统计任务
|
||
if (isTimeFilterMode) {
|
||
applyTimeFilter(timeFilterStart, timeFilterEnd)
|
||
} else {
|
||
applyTaskFilter();
|
||
}
|
||
}
|
||
} else {
|
||
// 非筛选模式下正常执行
|
||
toggleZeroStatsTasksNormal();
|
||
}
|
||
|
||
showZeroStatsToggleIndicator();
|
||
// 更新按钮状态
|
||
updateButtonState(74);
|
||
|
||
// 切换后刷新导航
|
||
setTimeout(() => {
|
||
updateTaskCounts();
|
||
refreshQuickNav();
|
||
}, 50);
|
||
}
|
||
|
||
// 辅助函数: 检查行是否全零统计
|
||
function isRowAllZeroStats(row) {
|
||
const reviveCell = row.querySelector('.column-revive');
|
||
const retryCell = row.querySelector('.column-retry');
|
||
const retryDetailCell = row.querySelector('.column-retry-detail');
|
||
const tooFarSkipCell = row.querySelector('.column-too-far-skip');
|
||
const timeoutCell = row.querySelector('.column-timeout');
|
||
const teleportCell = row.querySelector('.column-teleport');
|
||
|
||
if (reviveCell && retryCell && retryDetailCell && tooFarSkipCell && timeoutCell && teleportCell) {
|
||
// 1. 检查统计列是否全零
|
||
const isAllZero =
|
||
(reviveCell.textContent.trim() === '' || reviveCell.textContent.trim() === '0') &&
|
||
(retryCell.textContent.trim() === '' || retryCell.textContent.trim() === '0') &&
|
||
(retryDetailCell.textContent.trim() === '' || retryDetailCell.textContent.trim() === '0') &&
|
||
(tooFarSkipCell.textContent.trim() === '' || tooFarSkipCell.textContent.trim() === '0') &&
|
||
(timeoutCell.textContent.trim() === '' || timeoutCell.textContent.trim() === '0') &&
|
||
(teleportCell.textContent.trim() === '' || teleportCell.textContent.trim() === '0');
|
||
|
||
// 如果不是全零,直接返回 false(非全零,不隐藏)
|
||
if (!isAllZero) return false;
|
||
|
||
// 2. 全零时,检查是否有特殊事件
|
||
let picksText = '';
|
||
const table = row.closest('table');
|
||
if (table) {
|
||
if (!useLegacyFormat) {
|
||
// 新版:拾取物列在当前行
|
||
const picksCell = row.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
} else {
|
||
// 旧版:拾取物在子行
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const subRow = table.querySelector(`tr[data-task-id="${taskId}"].sub-row`);
|
||
if (subRow) {
|
||
const picksCell = subRow.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// 如果包含任一特殊关键字,返回 false(不隐藏)
|
||
if (SPECIAL_EVENT_KEYWORDS.some(keyword => picksText.includes(keyword))) {
|
||
return false;
|
||
}
|
||
return true; // 全零且无特殊事件,应隐藏
|
||
}
|
||
return false; // 统计单元格不完整,默认不隐藏
|
||
}
|
||
|
||
// 辅助函数: 检查任务是否在时间范围内
|
||
function isTaskInTimeRange(row) {
|
||
const startTimeCell = row.querySelector('.column-start-time');
|
||
if (startTimeCell) {
|
||
const timeText = startTimeCell.textContent.trim();
|
||
const taskStartTime = parseTableTime(timeText);
|
||
|
||
return taskStartTime &&
|
||
taskStartTime >= timeFilterStart &&
|
||
taskStartTime <= timeFilterEnd;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// 筛选模式下的零统计筛选函数
|
||
function toggleZeroStatsTasksInFilterMode() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
|
||
// 如果配置组已被 H 键排除(display: none),则跳过整个表格
|
||
if (container.style.display === 'none') {
|
||
return;
|
||
}
|
||
|
||
const groupHeader = container.querySelector('.group-header h2');
|
||
const groupName = groupHeader ? groupHeader.textContent : '';
|
||
|
||
// 确保队伍角色行始终显示
|
||
const teamRolesRow = table.querySelector('.team-roles-row');
|
||
if (teamRolesRow) teamRolesRow.style.display = '';
|
||
|
||
// 确保拾取物行保持隐藏
|
||
const summaryRows = table.querySelectorAll('.summary-row');
|
||
summaryRows.forEach(row => row.style.display = 'none');
|
||
|
||
let groupHasVisibleTask = false;
|
||
|
||
// 判断当前是哪种筛选模式
|
||
if (isTimeFilterMode) {
|
||
// 时间筛选模式 - 检查任务时间是否在范围内,并且统计非零(如果需要)
|
||
if (!useLegacyFormat) {
|
||
const rows = table.querySelectorAll('tr[data-original-index]');
|
||
rows.forEach(row => {
|
||
// 跳过非任务行
|
||
if (row.querySelector('th') ||
|
||
row.classList.contains('team-roles-row') ||
|
||
row.classList.contains('summary-row')) {
|
||
return;
|
||
}
|
||
|
||
// 判断任务是否在时间范围内
|
||
const isInTimeRange = isTaskInTimeRange(row);
|
||
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (isInTimeRange && matchesStats) {
|
||
row.style.display = '';
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
row.style.display = 'none';
|
||
}
|
||
});
|
||
} else {
|
||
// 旧版格式
|
||
const taskNameRows = table.querySelectorAll('tr .main-row-name');
|
||
taskNameRows.forEach(taskNameCell => {
|
||
const row = taskNameCell.closest('tr');
|
||
const taskId = row.getAttribute('data-task-id');
|
||
|
||
if (taskId) {
|
||
// 判断任务是否在时间范围内
|
||
const isInTimeRange = isTaskInTimeRange(row);
|
||
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (isInTimeRange && matchesStats) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
if (!r.classList.contains('summary-row')) {
|
||
r.style.display = '';
|
||
}
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
r.style.display = 'none';
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
} else {
|
||
// 普通任务筛选模式(H键筛选)
|
||
|
||
// 如果没有包含关键字,则直接认为所有未排除的组都匹配
|
||
const noIncludeKeywords = currentFilterKeywords.length === 0;
|
||
|
||
// 检查配置组名是否匹配关键字(仅在有关键字时进行)
|
||
const groupMatchesKeyword = !noIncludeKeywords && currentFilterKeywords.some(keyword =>
|
||
groupName.toLowerCase().includes(keyword.toLowerCase())
|
||
);
|
||
|
||
if (noIncludeKeywords || groupMatchesKeyword) {
|
||
// 没有包含关键字 或 配置组名匹配:显示组内所有任务,并应用零统计
|
||
if (!useLegacyFormat) {
|
||
const rows = table.querySelectorAll('tr');
|
||
rows.forEach(row => {
|
||
// 跳过表头行、队伍角色行和summary-row
|
||
if (row.querySelector('th') || row.classList.contains('team-roles-row') || row.classList.contains('summary-row')) {
|
||
if (row.classList.contains('summary-row')) {
|
||
row.style.display = 'none';
|
||
} else {
|
||
row.style.display = '';
|
||
}
|
||
return;
|
||
}
|
||
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (matchesStats) {
|
||
row.style.display = '';
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
row.style.display = 'none';
|
||
}
|
||
});
|
||
} else {
|
||
// 旧版格式
|
||
const taskNameRows = table.querySelectorAll('tr .main-row-name');
|
||
taskNameRows.forEach(taskNameCell => {
|
||
const row = taskNameCell.closest('tr');
|
||
const taskId = row.getAttribute('data-task-id');
|
||
|
||
if (taskId) {
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (matchesStats) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
if (!r.classList.contains('summary-row')) {
|
||
r.style.display = '';
|
||
}
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => r.style.display = 'none');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
} else {
|
||
// 配置组名不匹配,检查任务名是否匹配关键字
|
||
if (!useLegacyFormat) {
|
||
const rows = table.querySelectorAll('tr');
|
||
rows.forEach(row => {
|
||
// 跳过表头行、队伍角色行和summary-row
|
||
if (row.querySelector('th') || row.classList.contains('team-roles-row') || row.classList.contains('summary-row')) {
|
||
// 在普通筛选模式下,如果配置组名不匹配,summary-row也保持隐藏
|
||
if (row.classList.contains('summary-row')) {
|
||
row.style.display = 'none';
|
||
} else {
|
||
row.style.display = '';
|
||
}
|
||
return;
|
||
}
|
||
|
||
// 获取任务名称
|
||
const taskNameCell = row.querySelector('td:first-child');
|
||
if (taskNameCell) {
|
||
const taskName = taskNameCell.textContent.toLowerCase();
|
||
|
||
// 检查任务名称是否包含任一关键字
|
||
const matchesKeyword = currentFilterKeywords.some(keyword =>
|
||
taskName.includes(keyword.toLowerCase())
|
||
);
|
||
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (matchesKeyword && matchesStats) {
|
||
row.style.display = '';
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
row.style.display = 'none';
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
// 旧版格式
|
||
const taskNameRows = table.querySelectorAll('tr .main-row-name');
|
||
taskNameRows.forEach(taskNameCell => {
|
||
const row = taskNameCell.closest('tr');
|
||
const taskId = row.getAttribute('data-task-id');
|
||
|
||
if (taskId) {
|
||
const taskName = taskNameCell.textContent.toLowerCase();
|
||
|
||
// 检查任务名称是否包含任一关键字
|
||
const matchesKeyword = currentFilterKeywords.some(keyword =>
|
||
taskName.includes(keyword.toLowerCase())
|
||
);
|
||
|
||
// 检查统计列是否非零
|
||
const matchesStats = hideZeroStatsTasks ? !isRowAllZeroStats(row) : true;
|
||
|
||
if (matchesKeyword && matchesStats) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
if (!r.classList.contains('summary-row')) {
|
||
r.style.display = '';
|
||
}
|
||
});
|
||
groupHasVisibleTask = true;
|
||
} else {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
r.style.display = 'none';
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|
||
// 如果配置组没有可见任务且处于隐藏模式,隐藏整个配置组
|
||
if (hideZeroStatsTasks && !groupHasVisibleTask) {
|
||
container.style.display = 'none';
|
||
} else {
|
||
container.style.display = '';
|
||
}
|
||
});
|
||
}
|
||
|
||
// 非筛选模式下的零统计筛选
|
||
function toggleZeroStatsTasksNormal() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
// 先显示所有配置组
|
||
document.querySelectorAll('.group-container').forEach(container => {
|
||
container.style.display = '';
|
||
});
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
let hasVisibleTask = false;
|
||
|
||
const rows = table.querySelectorAll('tr');
|
||
|
||
rows.forEach(row => {
|
||
// 跳过表头行
|
||
if (row.querySelector('th')) {
|
||
row.style.display = '';
|
||
return;
|
||
}
|
||
|
||
// 检查是否为汇总行
|
||
if (row.classList.contains('summary-row')) {
|
||
row.style.display = hideZeroStatsTasks ? 'none' : '';
|
||
return;
|
||
}
|
||
|
||
// 获取统计单元格
|
||
const reviveCell = row.querySelector('.column-revive');
|
||
const retryCell = row.querySelector('.column-retry');
|
||
const retryDetailCell = row.querySelector('.column-retry-detail');
|
||
const tooFarSkipCell = row.querySelector('.column-too-far-skip');
|
||
const timeoutCell = row.querySelector('.column-timeout');
|
||
const teleportCell = row.querySelector('.column-teleport');
|
||
|
||
if (reviveCell && retryCell && retryDetailCell && tooFarSkipCell && timeoutCell && teleportCell) {
|
||
// 1. 计算统计列是否全零
|
||
const isAllZero =
|
||
(reviveCell.textContent.trim() === '' || reviveCell.textContent.trim() === '0') &&
|
||
(retryCell.textContent.trim() === '' || retryCell.textContent.trim() === '0') &&
|
||
(retryDetailCell.textContent.trim() === '' || retryDetailCell.textContent.trim() === '0') &&
|
||
(tooFarSkipCell.textContent.trim() === '' || tooFarSkipCell.textContent.trim() === '0') &&
|
||
(timeoutCell.textContent.trim() === '' || timeoutCell.textContent.trim() === '0') &&
|
||
(teleportCell.textContent.trim() === '' || teleportCell.textContent.trim() === '0');
|
||
|
||
// 2. 如果全零,检查是否有特殊事件
|
||
let hasSpecialEvent = false;
|
||
if (isAllZero) {
|
||
let picksText = '';
|
||
if (!useLegacyFormat) {
|
||
// 新版:拾取物列在当前行
|
||
const picksCell = row.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
} else {
|
||
// 旧版:拾取物在子行(通过 data-task-id 关联)
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const subRow = table.querySelector(`tr[data-task-id="${taskId}"].sub-row`);
|
||
if (subRow) {
|
||
const picksCell = subRow.querySelector('.column-picks');
|
||
if (picksCell) picksText = picksCell.textContent.trim();
|
||
}
|
||
}
|
||
}
|
||
// 检查是否包含任一特殊关键字(全局变量)
|
||
if (SPECIAL_EVENT_KEYWORDS.some(keyword => picksText.includes(keyword))) {
|
||
hasSpecialEvent = true;
|
||
}
|
||
}
|
||
|
||
// 3. 最终判定:全零且无特殊事件时才可能隐藏
|
||
const shouldHide = isAllZero && !hasSpecialEvent;
|
||
if (shouldHide) {
|
||
// 如果启用隐藏零统计,则隐藏;否则显示
|
||
row.style.display = hideZeroStatsTasks ? 'none' : '';
|
||
// 旧版格式:关联行(子行)同步处理
|
||
if (useLegacyFormat) {
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
r.style.display = hideZeroStatsTasks ? 'none' : '';
|
||
});
|
||
}
|
||
}
|
||
} else {
|
||
// 非全零 或 有特殊事件 → 始终显示
|
||
hasVisibleTask = true;
|
||
row.style.display = '';
|
||
if (useLegacyFormat) {
|
||
const taskId = row.getAttribute('data-task-id');
|
||
if (taskId) {
|
||
const relatedRows = table.querySelectorAll(`tr[data-task-id="${taskId}"]`);
|
||
relatedRows.forEach(r => {
|
||
r.style.display = '';
|
||
});
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// 如果配置组没有可见任务且处于隐藏模式,隐藏整个配置组
|
||
if (hideZeroStatsTasks && !hasVisibleTask) {
|
||
container.style.display = 'none';
|
||
}
|
||
});
|
||
}
|
||
|
||
// 添加更新任务数量的逻辑
|
||
function updateTaskCounts() {
|
||
const tables = document.querySelectorAll('table');
|
||
|
||
tables.forEach(table => {
|
||
const container = table.closest('.group-container');
|
||
const visibleTasks = container.querySelectorAll('tr[data-original-index]:not([style*="display: none"])').length;
|
||
const taskCountElement = table.querySelector('.task-count');
|
||
|
||
if (taskCountElement) {
|
||
taskCountElement.textContent = `${visibleTasks}个`;
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 計算體力恢復完成的時間
|
||
* calculateStaminaRecoveryTime
|
||
* GCSRT(現在體力,原40or尘30,原8or尘6)
|
||
* @param {number} currentStamina 當前體力值
|
||
* @param {number} targetStamina 需要達到的目標體力值
|
||
* @param {number} minutesPerPoint 每恢復1點體力需要的分鐘數
|
||
* @returns {object} 包含恢復完成的時間(Date 對象)和格式化時間字符串的對象
|
||
*/
|
||
function GCSRT(currentStamina, targetStamina, minutesPerPoint) {
|
||
// 參數校驗
|
||
if (typeof currentStamina !== 'number' ||
|
||
typeof targetStamina !== 'number' ||
|
||
typeof minutesPerPoint !== 'number') {
|
||
throw new Error('所有參數必須是數字類型');
|
||
}
|
||
|
||
// 如現時體力超過目標,減過現時體力、計算下次目標體力
|
||
if (currentStamina >= targetStamina) {
|
||
currentStamina = currentStamina - targetStamina;
|
||
targetStamina = targetStamina + targetStamina;
|
||
}
|
||
|
||
// 計算體力差
|
||
const staminaDifference = targetStamina - currentStamina;
|
||
|
||
// 計算總需要分鐘數
|
||
const totalMinutes = staminaDifference * minutesPerPoint;
|
||
|
||
// 計算恢復完成的時間
|
||
const now = new Date(); // 當前時間
|
||
const recoveryTime = new Date(now.getTime() + totalMinutes * 60000); // 加上總分鐘數
|
||
|
||
// 格式化時間輸出
|
||
const formattedTime = recoveryTime.toLocaleString(); // 根據本地時間格式顯示
|
||
|
||
return ` ${recoveryTime.getHours()} : ${recoveryTime.getMinutes()}`;
|
||
}
|
||
|
||
// 計算時間差
|
||
function handleDateComparison() {
|
||
// 获取用户输入
|
||
const input = prompt("請輸入日期時間(格式:YYYY/MM/DD HH:mm:ss)");
|
||
|
||
// 验证输入是否为空
|
||
if (input === null || input.trim() === "") {
|
||
// alert("輸入已取消或為空!");
|
||
console.log("輸入已取消或為空!");
|
||
return;
|
||
}
|
||
|
||
// 验证格式正则表达式
|
||
const formatRegex = /^\d{4}[-\/]\d{2}[-\/]\d{2} \d{2}:\d{2}:\d{2}$/;
|
||
if (!formatRegex.test(input)) {
|
||
alert("格式錯誤!請嚴格按照示例格式輸入");
|
||
return;
|
||
}
|
||
|
||
// 解析日期
|
||
const parseDate = (str) => {
|
||
const [datePart, timePart] = str.split(" ");
|
||
const [year, month, day] = datePart.split(/[-\/]/).map(Number); // 使用正則分割符
|
||
const [hours, minutes, seconds] = timePart.split(":").map(Number);
|
||
return new Date(year, month - 1, day, hours, minutes, seconds);
|
||
};
|
||
|
||
try {
|
||
const targetDate = parseDate(input);
|
||
const now = new Date();
|
||
|
||
// 检查日期有效性
|
||
if (isNaN(targetDate.getTime())) {
|
||
throw new Error("無效的日期時間");
|
||
}
|
||
|
||
// 计算时间差(毫秒)
|
||
const diff = targetDate - now;
|
||
|
||
// 格式化时间差
|
||
const formatDuration = (ms) => {
|
||
const seconds = Math.floor(Math.abs(ms) / 1000);
|
||
const days = Math.floor(seconds / 86400);
|
||
const hours = Math.floor((seconds % 86400) / 3600);
|
||
const minutes = Math.floor((seconds % 3600) / 60);
|
||
const sec = seconds % 60;
|
||
return `${days}天 ${hours}小時 ${minutes}分鐘 ${sec}秒`;
|
||
};
|
||
|
||
if (diff < 0) {
|
||
alert(`距離 ${input} 已經過去了:\n${formatDuration(diff)}`);
|
||
} else {
|
||
alert(`距離 ${input} 還有:\n${formatDuration(diff)}`);
|
||
}
|
||
} catch (e) {
|
||
alert(`錯誤:${e.message}`);
|
||
}
|
||
}
|
||
|
||
// BGI格式日期+3天
|
||
function addThreeDaysSimple() {
|
||
// 获取用户输入
|
||
const input = prompt("請輸入日期(格式:指定日期格式)\n例如:2025/05/22 或 2025-05-22");
|
||
|
||
// 验证输入是否为空
|
||
if (input === null || input.trim() === "") {
|
||
alert("輸入已取消或為空!");
|
||
return;
|
||
}
|
||
|
||
// 更灵活的格式正则表达式(支持 / 和 - 分隔符)
|
||
const formatRegex = /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/;
|
||
const formatRegex2 = /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/;
|
||
if (!formatRegex.test(input) && !formatRegex2.test(input)) {
|
||
alert("格式錯誤!請使用 YYYY/MM/DD 或 YYYY-MM-DD 格式輸入");
|
||
return;
|
||
}
|
||
|
||
// 解析日期(支持 / 和 - 分隔符)
|
||
const parseDate = (str) => {
|
||
const separator = str.includes('/') ? '/' : '-';
|
||
const parts = str.split(separator);
|
||
const year = parseInt(parts[0], 10);
|
||
const month = parseInt(parts[1], 10) - 1; // 月份从0开始
|
||
const day = parseInt(parts[2], 10);
|
||
return new Date(year, month, day);
|
||
};
|
||
|
||
try {
|
||
const inputDate = parseDate(input);
|
||
|
||
// 检查日期有效性
|
||
if (isNaN(inputDate.getTime())) {
|
||
throw new Error("無效的日期");
|
||
}
|
||
|
||
// 添加3天
|
||
const resultDate = new Date(inputDate);
|
||
resultDate.setDate(resultDate.getDate() + 3);
|
||
|
||
// 格式化日期函数(仅显示年月日)
|
||
const formatDate = (date) => {
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
return `${year}/${month}/${day}`;
|
||
};
|
||
|
||
// 显示结果
|
||
alert(
|
||
`原始日期:${formatDate(inputDate)}\n` +
|
||
`加3天後日期:${formatDate(resultDate)}`
|
||
);
|
||
|
||
} catch (e) {
|
||
alert(`錯誤:${e.message}`);
|
||
}
|
||
}
|
||
|
||
// 計算運行時間
|
||
function calculateTimeDifference() {
|
||
// 輸入格式驗證正則
|
||
const timeFormatRegex = /^\d{4}[-\/]\d{2}[-\/]\d{2} \d{2}:\d{2}:\d{2}$/;
|
||
|
||
// 獲取第一個時間
|
||
const time1Str = prompt("請輸入第一個時間(格式:YYYY/MM/DD HH:mm:ss)\n範例:2025/05/22 10:52:05");
|
||
if (!time1Str || !timeFormatRegex.test(time1Str)) {
|
||
alert("輸入取消或格式錯誤!");
|
||
return;
|
||
}
|
||
|
||
// 獲取第二個時間
|
||
const time2Str = prompt("請輸入第二個時間(格式:YYYY/MM/DD HH:mm:ss)");
|
||
if (!time2Str || !timeFormatRegex.test(time2Str)) {
|
||
alert("輸入取消或格式錯誤!");
|
||
return;
|
||
}
|
||
|
||
// 解析時間函數
|
||
const parseTime = (str) => {
|
||
const [datePart, timePart] = str.split(' ');
|
||
const [year, month, day] = datePart.split(/[-\/]/).map(Number); // 使用正則分割符
|
||
const [hours, minutes, seconds] = timePart.split(':').map(Number);
|
||
return new Date(year, month - 1, day, hours, minutes, seconds);
|
||
};
|
||
|
||
try {
|
||
// 解析日期對象
|
||
const date1 = parseTime(time1Str);
|
||
const date2 = parseTime(time2Str);
|
||
|
||
// 驗證日期有效性
|
||
if (isNaN(date1.getTime()) || isNaN(date2.getTime())) {
|
||
throw new Error("包含無效日期時間");
|
||
}
|
||
|
||
// 計算時間差(毫秒)
|
||
const diffMs = date2 - date1;
|
||
|
||
// 時間差格式化
|
||
const formatDuration = (ms) => {
|
||
const absMs = Math.abs(ms);
|
||
const seconds = Math.floor(absMs / 1000);
|
||
const days = Math.floor(seconds / 86400);
|
||
const hours = Math.floor((seconds % 86400) / 3600);
|
||
const minutes = Math.floor((seconds % 3600) / 60);
|
||
const secs = seconds % 60;
|
||
return `${days}天 ${hours}小時 ${minutes}分鐘 ${secs}秒`;
|
||
};
|
||
|
||
// 判斷先後關係
|
||
let orderText = '';
|
||
if (diffMs > 0) {
|
||
orderText = `${time2Str} 晚於 ${time1Str}`;
|
||
} else if (diffMs < 0) {
|
||
orderText = `${time2Str} 早於 ${time1Str}`;
|
||
} else {
|
||
orderText = "兩個時間完全相同";
|
||
}
|
||
|
||
// 顯示結果
|
||
alert(
|
||
`時間差計算結果:\n\n` +
|
||
`${orderText}\n` +
|
||
`相差:${formatDuration(diffMs)}`
|
||
);
|
||
|
||
} catch (e) {
|
||
alert(`錯誤:${e.message}`);
|
||
}
|
||
}
|
||
|
||
// 計算+N天數
|
||
function handleAddDays() {
|
||
// 獲取用戶輸入
|
||
const input = prompt("請輸入要添加的天數");
|
||
|
||
// 驗證輸入是否為空
|
||
if (input === null || input.trim() === "") {
|
||
alert("輸入已取消或為空!");
|
||
return;
|
||
}
|
||
|
||
// 轉換為數字
|
||
const days = parseFloat(input);
|
||
if (isNaN(days)) {
|
||
alert("無效的數字!請輸入有效的天數");
|
||
return;
|
||
}
|
||
|
||
// 計算新日期
|
||
const currentDate = new Date();
|
||
const newDate = new Date(currentDate.getTime() + days * 86400000);
|
||
|
||
// 格式化日期函數
|
||
const formatDate = (date) => {
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
return `${year}/${month}/${day}`;
|
||
};
|
||
|
||
// 顯示結果
|
||
alert(
|
||
`當前時間:${formatDate(currentDate)}\n` +
|
||
`加上 ${days} 天後的時間:${formatDate(newDate)}`
|
||
);
|
||
}
|
||
|
||
// 計算任務HH.MM后時間
|
||
function handleAddCustomTime() {
|
||
// 獲取用戶輸入
|
||
const input = prompt("請輸入要添加的時間(格式:hh.mm,例如 02.30)");
|
||
|
||
// 驗證輸入是否為空
|
||
if (input === null || input.trim() === "") {
|
||
alert("輸入已取消或為空!");
|
||
return;
|
||
}
|
||
|
||
// 驗證格式正則表達式
|
||
const timeFormatRegex = /^-?\d{1,2}\.\d{1,2}$/;
|
||
if (!timeFormatRegex.test(input)) {
|
||
alert("格式錯誤!請使用 hh.mm 格式輸入(例如 03.15 或 2.5)");
|
||
return;
|
||
}
|
||
|
||
// 解析時間
|
||
const [hoursStr, minutesStr] = input.split('.');
|
||
const hours = parseInt(hoursStr, 10);
|
||
const minutes = parseInt(minutesStr, 10);
|
||
|
||
// 驗證時間範圍
|
||
if (Math.abs(hours) > 8760) { // 防止過大數值(約1年)
|
||
alert("小時數值過大!");
|
||
return;
|
||
}
|
||
if (Math.abs(minutes) > 59) {
|
||
alert("分鐘數值需在 0-59 之間");
|
||
return;
|
||
}
|
||
|
||
// 計算時間差
|
||
const currentDate = new Date();
|
||
const timeToAdd =
|
||
hours * 60 * 60 * 1000 +
|
||
minutes * 60 * 1000;
|
||
|
||
// 計算新時間
|
||
const newDate = new Date(currentDate.getTime() + timeToAdd);
|
||
|
||
// 格式化日期函數(不顯示秒數)
|
||
const formatTime = (date) => {
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
const hours = String(date.getHours()).padStart(2, '0');
|
||
const mins = String(date.getMinutes()).padStart(2, '0');
|
||
return `${year}/${month}/${day} ${hours}:${mins}`;
|
||
};
|
||
|
||
// 顯示結果
|
||
alert(
|
||
`當前時間:${formatTime(currentDate)}\n` +
|
||
`加上 ${input.replace('.', '小時')}分鐘 後時間:${formatTime(newDate)}`
|
||
);
|
||
}
|
||
|
||
// 計算46小時后
|
||
function handleDateAddition() {
|
||
// 獲取用戶輸入
|
||
const input = prompt("請輸入日期時間(格式:YYYY/MM/DD HH:mm:ss)");
|
||
|
||
// 驗證輸入是否為空
|
||
if (input === null || input.trim() === "") {
|
||
console.log("輸入已取消或為空!");
|
||
return;
|
||
}
|
||
|
||
// 驗證格式正則表達式
|
||
const formatRegex = /^\d{4}[\/]\d{2}[\/]\d{2} \d{2}:\d{2}:\d{2}$/; // 嚴格匹配斜杠
|
||
if (!formatRegex.test(input)) {
|
||
alert("格式錯誤!請嚴格按照YYYY/MM/DD HH:mm:ss格式輸入");
|
||
return;
|
||
}
|
||
|
||
// 解析日期
|
||
const parseDate = (str) => {
|
||
const [datePart, timePart] = str.split(" ");
|
||
const [year, month, day] = datePart.split("/").map(Number); // 固定使用斜杠分割
|
||
const [hours, minutes, seconds] = timePart.split(":").map(Number);
|
||
return new Date(year, month - 1, day, hours, minutes, seconds);
|
||
};
|
||
|
||
try {
|
||
const targetDate = parseDate(input);
|
||
|
||
// 檢查日期有效性
|
||
if (isNaN(targetDate.getTime())) {
|
||
throw new Error("無效的日期時間");
|
||
}
|
||
|
||
// 加上46小時
|
||
const newDate = new Date(targetDate.getTime() + 46 * 60 * 60 * 1000);
|
||
|
||
// 格式化輸出
|
||
const formatDate = (date) => {
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0'); // 補零
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
const hours = String(date.getHours()).padStart(2, '0');
|
||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
||
};
|
||
|
||
alert(
|
||
`原始時間:${input}\n` +
|
||
`加上46小時後:${formatDate(newDate)}`
|
||
);
|
||
} catch (e) {
|
||
alert(`錯誤:${e.message}`);
|
||
}
|
||
}
|
||
|
||
// 快速导航功能
|
||
let quickNavVisible = false;
|
||
let currentSearchText = ''; // 保存当前的搜索文本
|
||
|
||
// 初始化快速导航
|
||
function initQuickNav() {
|
||
const quickNavToggle = document.getElementById('quickNavToggle');
|
||
const quickNav = document.getElementById('quickNav');
|
||
const quickNavSearch = document.getElementById('quickNavSearch');
|
||
const quickNavExclude = document.getElementById('quickNavExclude');
|
||
|
||
if (!quickNavToggle || !quickNav) return;
|
||
|
||
// 设置输入框的placeholder提示
|
||
if (quickNavSearch) {
|
||
quickNavSearch.placeholder = "搜索配置组... (多个关键词用,分割)";
|
||
}
|
||
|
||
if (quickNavExclude) {
|
||
quickNavExclude.placeholder = "排除配置组... (多个关键词用,分割)";
|
||
}
|
||
|
||
// 切换按钮点击事件
|
||
quickNavToggle.addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
toggleQuickNav();
|
||
});
|
||
|
||
// 搜索功能
|
||
if (quickNavSearch) {
|
||
quickNavSearch.addEventListener('keydown', function (e) {
|
||
e.stopPropagation();
|
||
if (e.keyCode === 27) { // ESC
|
||
hideQuickNav();
|
||
e.preventDefault();
|
||
}
|
||
});
|
||
|
||
quickNavSearch.addEventListener('input', function (e) {
|
||
currentSearchText = this.value;
|
||
filterQuickNavItems(currentSearchText, currentExcludeText);
|
||
});
|
||
}
|
||
|
||
// 排除输入框功能
|
||
if (quickNavExclude) {
|
||
quickNavExclude.addEventListener('keydown', function (e) {
|
||
e.stopPropagation();
|
||
if (e.keyCode === 27) { // ESC
|
||
hideQuickNav();
|
||
e.preventDefault();
|
||
}
|
||
});
|
||
|
||
quickNavExclude.addEventListener('input', function (e) {
|
||
currentExcludeText = this.value;
|
||
filterQuickNavItems(currentSearchText, currentExcludeText);
|
||
});
|
||
}
|
||
|
||
// 点击外部关闭
|
||
document.addEventListener('click', function (e) {
|
||
if (quickNavVisible && !quickNav.contains(e.target) && !quickNavToggle.contains(e.target)) {
|
||
hideQuickNav();
|
||
}
|
||
});
|
||
|
||
// 设置悬停提示
|
||
setupQuickNavTooltips();
|
||
}
|
||
|
||
// 切换快速导航显示状态
|
||
function toggleQuickNav() {
|
||
if (quickNavVisible) {
|
||
hideQuickNav();
|
||
} else {
|
||
showQuickNav();
|
||
}
|
||
}
|
||
|
||
// 显示快速导航
|
||
function showQuickNav() {
|
||
const quickNav = document.getElementById('quickNav');
|
||
if (!quickNav) return;
|
||
|
||
// 更新导航项
|
||
updateQuickNavItems();
|
||
|
||
quickNav.classList.add('visible');
|
||
quickNavVisible = true;
|
||
|
||
// 恢复搜索文本和排除文本
|
||
const searchInput = document.getElementById('quickNavSearch');
|
||
const excludeInput = document.getElementById('quickNavExclude');
|
||
|
||
if (searchInput) {
|
||
searchInput.value = currentSearchText;
|
||
searchInput.focus();
|
||
}
|
||
|
||
if (excludeInput) {
|
||
excludeInput.value = currentExcludeText;
|
||
}
|
||
|
||
// 如果有搜索或排除文本,重新应用筛选
|
||
if (currentSearchText || currentExcludeText) {
|
||
filterQuickNavItems(currentSearchText, currentExcludeText);
|
||
}
|
||
}
|
||
|
||
// 隐藏快速导航
|
||
function hideQuickNav() {
|
||
const quickNav = document.getElementById('quickNav');
|
||
if (!quickNav) return;
|
||
|
||
quickNav.classList.remove('visible');
|
||
quickNavVisible = false;
|
||
|
||
// 注意:不再清空搜索框,保留搜索文本
|
||
}
|
||
|
||
// 更新快速导航项 - 只显示当前可见的配置组和纯配置组名
|
||
function updateQuickNavItems() {
|
||
const quickNavItems = document.getElementById('quickNavItems');
|
||
if (!quickNavItems) return;
|
||
|
||
quickNavItems.innerHTML = '';
|
||
|
||
const groups = document.querySelectorAll('.group-container');
|
||
let hasVisibleGroups = false;
|
||
let totalDurationSeconds = 0; // 用于累计总时长(秒)
|
||
|
||
groups.forEach((group, index) => {
|
||
// 检查配置组是否可见
|
||
if (group.style.display === 'none') {
|
||
return; // 跳过隐藏的配置组
|
||
}
|
||
|
||
const groupHeader = group.querySelector('.group-header h2');
|
||
if (!groupHeader) return;
|
||
|
||
// 从完整标题中提取纯配置组名称
|
||
const fullTitle = groupHeader.textContent.trim();
|
||
const groupName = extractGroupName(fullTitle);
|
||
|
||
const groupId = `group-container-${index}`;
|
||
|
||
group.id = groupId; // 确保组有ID
|
||
|
||
const navItem = document.createElement('div');
|
||
navItem.className = 'quick-nav-item';
|
||
navItem.textContent = groupName;
|
||
navItem.setAttribute('data-group-id', groupId);
|
||
navItem.setAttribute('data-full-title', fullTitle); // 保存完整标题用于悬停提示
|
||
|
||
navItem.addEventListener('click', function () {
|
||
scrollToGroup(groupId);
|
||
// 注意:不再自动隐藏导航
|
||
});
|
||
|
||
quickNavItems.appendChild(navItem);
|
||
hasVisibleGroups = true;
|
||
|
||
// 累加总时长
|
||
const durationInSeconds = extractDurationFromTitle(fullTitle);
|
||
totalDurationSeconds += durationInSeconds;
|
||
});
|
||
|
||
// 更新总时长显示
|
||
updateTotalDurationDisplay(totalDurationSeconds);
|
||
|
||
// 如果没有可见的配置组,显示提示
|
||
if (!hasVisibleGroups) {
|
||
const noResults = document.createElement('div');
|
||
noResults.className = 'quick-nav-item no-results';
|
||
noResults.textContent = '没有可见的配置组';
|
||
noResults.style.cursor = 'default';
|
||
noResults.style.color = '#999';
|
||
noResults.style.fontStyle = 'italic';
|
||
quickNavItems.appendChild(noResults);
|
||
|
||
// 如果没有可见配置组,总时长显示为0
|
||
updateTotalDurationDisplay(0);
|
||
}
|
||
}
|
||
|
||
// 从完整标题中提取纯配置组名称
|
||
function extractGroupName(fullTitle) {
|
||
// 示例完整标题: "配置組:自動釣魚 下 (2025/05/23 07:19:45 - 2025/05/23 09:34:18) 耗时2小时14分钟33秒"
|
||
// 目标: "自動釣魚 下"
|
||
|
||
// 方法1: 使用正则表达式匹配"配置組:"之后,"("之前的部分
|
||
const match = fullTitle.match(/配置組:([^(]+)/);
|
||
if (match && match[1]) {
|
||
return match[1].trim();
|
||
}
|
||
|
||
// 方法2: 如果正则失败,使用字符串分割
|
||
if (fullTitle.startsWith('配置組:')) {
|
||
const withoutPrefix = fullTitle.substring(4); // 去掉"配置組:"
|
||
const bracketIndex = withoutPrefix.indexOf(' (');
|
||
if (bracketIndex !== -1) {
|
||
return withoutPrefix.substring(0, bracketIndex).trim();
|
||
}
|
||
return withoutPrefix.trim();
|
||
}
|
||
|
||
// 如果都不行,返回原文本
|
||
return fullTitle;
|
||
}
|
||
|
||
// 滚动到指定配置组
|
||
function scrollToGroup(groupId) {
|
||
const group = document.getElementById(groupId);
|
||
if (!group) return;
|
||
|
||
const dropZone = document.getElementById('dropZone');
|
||
if (!dropZone) return;
|
||
|
||
// 计算目标位置(考虑固定表头)
|
||
const groupRect = group.getBoundingClientRect();
|
||
const dropZoneRect = dropZone.getBoundingClientRect();
|
||
const targetScrollTop = dropZone.scrollTop + groupRect.top - dropZoneRect.top - 60; // 调整为60px偏移
|
||
|
||
// 平滑滚动
|
||
dropZone.scrollTo({
|
||
top: targetScrollTop,
|
||
behavior: 'smooth'
|
||
});
|
||
|
||
// 高亮目标组
|
||
highlightGroup(group);
|
||
}
|
||
|
||
// 高亮目标配置组
|
||
function highlightGroup(group) {
|
||
// 移除之前的高亮
|
||
document.querySelectorAll('.group-container').forEach(g => {
|
||
g.style.boxShadow = '';
|
||
g.style.transition = 'box-shadow 0.3s ease';
|
||
});
|
||
|
||
// 添加新高亮
|
||
group.style.boxShadow = '0 0 0 3px #4CAF50';
|
||
|
||
// 3秒后移除高亮
|
||
setTimeout(() => {
|
||
group.style.boxShadow = '';
|
||
}, 3000);
|
||
}
|
||
|
||
// 筛选导航项 - 使用纯配置组名进行筛选
|
||
function filterQuickNavItems(searchText, excludeText) {
|
||
const navItems = document.querySelectorAll('.quick-nav-item');
|
||
|
||
// 处理包含关键词:分割并清理
|
||
const includeKeywords = searchText
|
||
? searchText.split(',').map(keyword => keyword.trim().toLowerCase()).filter(keyword => keyword.length > 0)
|
||
: [];
|
||
|
||
// 处理排除关键词:分割并清理
|
||
const excludeKeywords = excludeText
|
||
? excludeText.split(',').map(keyword => keyword.trim().toLowerCase()).filter(keyword => keyword.length > 0)
|
||
: [];
|
||
|
||
let hasMatches = false;
|
||
let totalDurationSeconds = 0; // 用于累计总时长(秒)
|
||
|
||
navItems.forEach(item => {
|
||
// 跳过"没有可见的配置组"提示
|
||
if (item.textContent === '没有可见的配置组') {
|
||
item.style.display = 'none';
|
||
return;
|
||
}
|
||
|
||
// 使用显示的纯配置组名进行筛选
|
||
const displayText = item.textContent.toLowerCase();
|
||
|
||
// 包含条件:如果搜索关键词为空,或者配置组名包含任意一个搜索关键词
|
||
let matchesInclude = true;
|
||
if (includeKeywords.length > 0) {
|
||
matchesInclude = includeKeywords.some(keyword => displayText.includes(keyword));
|
||
}
|
||
|
||
// 排除条件:如果排除关键词为空,或者配置组名不包含任何排除关键词
|
||
let matchesExclude = true;
|
||
if (excludeKeywords.length > 0) {
|
||
matchesExclude = !excludeKeywords.some(keyword => displayText.includes(keyword));
|
||
}
|
||
|
||
// 同时满足包含和排除条件
|
||
if (matchesInclude && matchesExclude) {
|
||
item.style.display = 'block';
|
||
hasMatches = true;
|
||
|
||
// 获取该配置组的时长并累加
|
||
const fullTitle = item.getAttribute('data-full-title');
|
||
if (fullTitle) {
|
||
const durationInSeconds = extractDurationFromTitle(fullTitle);
|
||
totalDurationSeconds += durationInSeconds;
|
||
}
|
||
} else {
|
||
item.style.display = 'none';
|
||
}
|
||
});
|
||
|
||
// 更新总时长显示
|
||
updateTotalDurationDisplay(totalDurationSeconds);
|
||
|
||
// 更新提示信息,显示当前的过滤条件
|
||
const quickNavItems = document.getElementById('quickNavItems');
|
||
let noResults = quickNavItems.querySelector('.no-results');
|
||
|
||
if (!hasMatches && !noResults) {
|
||
noResults = document.createElement('div');
|
||
noResults.className = 'quick-nav-item no-results';
|
||
|
||
let message = '没有找到匹配的配置组';
|
||
if (includeKeywords.length > 0 && excludeKeywords.length > 0) {
|
||
message = `没有找到包含 [${includeKeywords.join(', ')}] 且排除 [${excludeKeywords.join(', ')}] 的配置组`;
|
||
} else if (includeKeywords.length > 0) {
|
||
message = `没有找到包含 [${includeKeywords.join(', ')}] 的配置组`;
|
||
} else if (excludeKeywords.length > 0) {
|
||
message = `没有找到排除 [${excludeKeywords.join(', ')}] 的配置组`;
|
||
}
|
||
|
||
noResults.textContent = message;
|
||
noResults.style.cursor = 'default';
|
||
noResults.style.color = '#999';
|
||
noResults.style.fontStyle = 'italic';
|
||
quickNavItems.appendChild(noResults);
|
||
} else if (hasMatches && noResults) {
|
||
noResults.remove();
|
||
}
|
||
}
|
||
|
||
// 从配置组标题中提取时长(秒)
|
||
function extractDurationFromTitle(fullTitle) {
|
||
// 示例标题格式:"配置組:自動釣魚 下 (2025/05/23 07:19:45 - 2025/05/23 09:34:18) 耗时2小时14分钟33秒"
|
||
// 或 "配置組:鋤JS-精英 (2025/12/26 04:20:24 - 2025/12/26 08:08:24) 耗时3小时48分钟"
|
||
const durationMatch = fullTitle.match(/耗时(.+)$/);
|
||
|
||
if (durationMatch) {
|
||
const durationText = durationMatch[1].trim();
|
||
|
||
// 處理沒有"秒"的情況 - 添加"0秒"
|
||
let textToParse = durationText;
|
||
if (!textToParse.includes('秒')) {
|
||
textToParse += '0秒';
|
||
}
|
||
|
||
return parseDurationToSeconds(textToParse);
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 更新总时长显示
|
||
function updateTotalDurationDisplay(totalSeconds) {
|
||
const totalTimeValueElement = document.getElementById('quickNavTotalTimeValue');
|
||
if (totalTimeValueElement) {
|
||
const formattedDuration = formatDuration(totalSeconds);
|
||
totalTimeValueElement.textContent = formattedDuration;
|
||
}
|
||
}
|
||
|
||
// 刷新导航可见项 - 在筛选或隐藏操作后调用
|
||
function refreshQuickNav() {
|
||
if (quickNavVisible) {
|
||
updateQuickNavItems();
|
||
// 重新应用当前的搜索和排除筛选
|
||
if (currentSearchText || currentExcludeText) {
|
||
filterQuickNavItems(currentSearchText, currentExcludeText);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 在页面加载时初始化快速导航
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', initQuickNav);
|
||
} else {
|
||
initQuickNav();
|
||
}
|
||
|
||
function setupQuickNavTooltips() {
|
||
const quickNavItems = document.getElementById('quickNavItems');
|
||
if (!quickNavItems) return;
|
||
|
||
// 创建提示框元素
|
||
const tooltip = document.createElement('div');
|
||
tooltip.id = 'quickNavTooltip';
|
||
tooltip.style.cssText = `
|
||
position: fixed;
|
||
display: none;
|
||
background: rgba(0, 0, 0, 0.9);
|
||
color: white;
|
||
padding: 12px;
|
||
border-radius: 6px;
|
||
font-size: 12px;
|
||
line-height: 1.4;
|
||
z-index: 1002;
|
||
pointer-events: none;
|
||
max-width: 300px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
||
white-space: pre-line;
|
||
border: 1px solid #555;
|
||
`;
|
||
document.body.appendChild(tooltip);
|
||
|
||
// 暗色主题适配
|
||
if (document.body.classList.contains('dark-theme')) {
|
||
tooltip.style.background = 'rgba(50, 50, 50, 0.95)';
|
||
tooltip.style.borderColor = '#777';
|
||
}
|
||
|
||
// 事件委托处理悬停
|
||
quickNavItems.addEventListener('mouseover', function (e) {
|
||
const target = e.target;
|
||
if (target.classList.contains('quick-nav-item')) {
|
||
const fullTitle = target.getAttribute('data-full-title');
|
||
if (fullTitle) {
|
||
// 解析完整标题,提取配置组名和时间信息
|
||
const parsedInfo = parseGroupTitle(fullTitle);
|
||
tooltip.innerHTML = formatTooltipContent(parsedInfo);
|
||
tooltip.style.display = 'block';
|
||
}
|
||
}
|
||
});
|
||
|
||
quickNavItems.addEventListener('mousemove', function (e) {
|
||
if (tooltip.style.display === 'block') {
|
||
// 定位在鼠标左侧
|
||
const x = e.clientX - tooltip.offsetWidth - 10;
|
||
const y = e.clientY;
|
||
|
||
tooltip.style.left = Math.max(10, x) + 'px';
|
||
tooltip.style.top = y + 'px';
|
||
}
|
||
});
|
||
|
||
quickNavItems.addEventListener('mouseout', function (e) {
|
||
if (e.target.classList.contains('quick-nav-item')) {
|
||
tooltip.style.display = 'none';
|
||
}
|
||
});
|
||
}
|
||
|
||
// 解析配置组标题
|
||
function parseGroupTitle(fullTitle) {
|
||
// 示例格式: "配置組:CD-甜甜花 (2025/10/19 19:27:00 - 2025/10/19 19:37:21) 耗时10分钟21秒"
|
||
const groupNameMatch = fullTitle.match(/配置組:([^(]+)/);
|
||
const timeRangeMatch = fullTitle.match(/\(([^)]+)\)/);
|
||
const durationMatch = fullTitle.match(/耗时(.+)$/);
|
||
|
||
return {
|
||
groupName: groupNameMatch ? groupNameMatch[1].trim() : fullTitle,
|
||
timeRange: timeRangeMatch ? timeRangeMatch[1] : '',
|
||
duration: durationMatch ? durationMatch[1] : ''
|
||
};
|
||
}
|
||
|
||
// 格式化提示框内容
|
||
function formatTooltipContent(parsedInfo) {
|
||
let content = '';
|
||
if (parsedInfo.groupName) {
|
||
content += `<div style="font-weight: bold; margin-bottom: 5px;">${parsedInfo.groupName}</div>`;
|
||
}
|
||
if (parsedInfo.timeRange) {
|
||
content += `<div style="color: #ccc; margin-bottom: 3px;">(${parsedInfo.timeRange})</div>`;
|
||
}
|
||
if (parsedInfo.duration) {
|
||
content += `<div style="color: #aaa; font-size: 11px;">耗时${parsedInfo.duration}</div>`;
|
||
}
|
||
return content;
|
||
}
|
||
</script>
|
||
</body>
|
||
|
||
</html> |