refactor(slash-commands): 优化 /goto-floor 命令的代码格式和注释 - 修正 EDLint 标记错误

6d0318eb36c864938c2abde8c3a51b391d9cfd76

awaae001 <3271436144@qq.com>

1 files changed, +9 -9Ignore whitespace
public/scripts/slash-commands.js+9 -9
@@ -2135,29 +2135,29 @@ export function initDefaultSlashCommands() {
21352135 aliases: ['floor', 'jump', 'scrollto'],
21362136 callback: async (_, index) => {
21372137 const floorIndex = Number(index);
2138-
2138+
21392139 // Validate input
21402140 if (isNaN(floorIndex) || floorIndex < 0 || (typeof chat !== 'undefined' && floorIndex >= chat.length)) {
21412141 const maxIndex = (typeof chat !== 'undefined' ? chat.length - 1 : 'unknown');
21422142 toastr.warning(`Invalid message index: ${index}. Please enter a number between 0 and ${maxIndex}.`);
21432143 console.warn(`WARN: Invalid message index provided for /goto-floor: ${index}. Max index: ${maxIndex}`);
21442144 return '';
21452145 }
2146-
2146+
21472147 const messageElement = document.querySelector(`[mesid="${floorIndex}"]`);
2148-
2148+
21492149 if (messageElement) {
21502150 const headerElement = messageElement.querySelector('.mes_header') ||
21512151 messageElement.querySelector('.mes_meta') ||
21522152 messageElement.querySelector('.mes_name_area') ||
21532153 messageElement.querySelector('.mes_name');
2154-
2154+
21552155 const elementToScroll = headerElement || messageElement; // Prefer header, fallback to whole message
21562156 const blockPosition = headerElement ? 'center' : 'start'; // Center header, else start of message
2157-
2157+
21582158 elementToScroll.scrollIntoView({ behavior: 'smooth', block: blockPosition });
21592159 console.log(`INFO: Scrolled ${headerElement ? 'header of' : ''} message ${floorIndex} into view (block: ${blockPosition}).`);
2160-
2160+
21612161 // --- Highlight with smooth animation ---
21622162 messageElement.classList.add('highlight-scroll');
21632163 setTimeout(() => {
@@ -2169,7 +2169,7 @@ export function initDefaultSlashCommands() {
21692169 messageElement.classList.remove('highlight-scroll', 'highlight-scroll-fadeout');
21702170 }, 500); // Matches the 0.5s transition duration
21712171 }, 1500); // Start fade out after 1.5 seconds
2172-
2172+
21732173 } else {
21742174 toastr.warning(`Could not find element for message ${floorIndex} (using [mesid="${floorIndex}"]). It might not be rendered yet. Try scrolling up or use /chat-render all.`);
21752175 console.warn(`WARN: Element not found for message index ${floorIndex} using querySelector [mesid="${floorIndex}"] in /goto-floor.`);
@@ -2201,7 +2201,7 @@ export function initDefaultSlashCommands() {
22012201 </div>
22022202 `,
22032203 }));
2204-
2204+
22052205 // --- Improved CSS for highlight ---
22062206 const styleId = 'goto-floor-highlight-style';
22072207 if (!document.getElementById(styleId)) {