refactor(slash-commands): 重命名 goto-floor 命令为 chat-jump - 将命令名称从 'goto-floor' 修改为 'chat-jump',以更好地反映其功能

59ebf2e5b8a23080bec1ed05d152ad1c61a323ec

awaae001 <3271436144@qq.com>

1 files changed, +7 -7Showing whitespace changes
public/scripts/slash-commands.js+7 -7
@@ -2132,7 +2132,7 @@ export function initDefaultSlashCommands() {
2132 }));2132 }));
21332133
2134 SlashCommandParser.addCommandObject(SlashCommand.fromProps({2134 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2135 name: 'goto-floor',2135 name: 'chat-jump',
2136 aliases: ['floor', 'jump', 'scrollto'],2136 aliases: ['floor', 'jump', 'scrollto'],
2137 callback: async (_, index) => {2137 callback: async (_, index) => {
2138 const floorIndex = Number(index);2138 const floorIndex = Number(index);
@@ -2141,16 +2141,16 @@ export function initDefaultSlashCommands() {
2141 if (isNaN(floorIndex) || floorIndex < 0 || (chatLength !== -1 && floorIndex >= chatLength)) {2141 if (isNaN(floorIndex) || floorIndex < 0 || (chatLength !== -1 && floorIndex >= chatLength)) {
2142 const maxIndex = (chatLength !== -1 ? chatLength - 1 : 'unknown');2142 const maxIndex = (chatLength !== -1 ? chatLength - 1 : 'unknown');
2143 toastr.warning(`Invalid message index: ${index}. Please enter a number between 0 and ${maxIndex}.`);2143 toastr.warning(`Invalid message index: ${index}. Please enter a number between 0 and ${maxIndex}.`);
2144 console.warn(`WARN: Invalid message index provided for /goto-floor: ${index}. Max index: ${maxIndex}`);2144 console.warn(`WARN: Invalid message index provided for /chat-jump: ${index}. Max index: ${maxIndex}`);
2145 return '';2145 return '';
2146 }2146 }
21472147
2148 // --- Load all messages first to ensure the target element exists ---2148 // --- Load all messages first to ensure the target element exists ---
2149 console.log(`INFO: Attempting to load all messages before attempting to goto-floor ${index}.`);2149 console.log(`INFO: Attempting to load all messages before attempting to chat-jump ${index}.`);
2150 try {2150 try {
2151 // Assuming showMoreMessages is available globally or within scope2151 // Assuming showMoreMessages is available globally or within scope
2152 await showMoreMessages(Number.MAX_SAFE_INTEGER);2152 await showMoreMessages(Number.MAX_SAFE_INTEGER);
2153 console.log(`INFO: All messages loaded (or loading initiated).`);2153 console.log('INFO: All messages loaded (or loading initiated).');
2154 // Give the rendering a moment to potentially catch up after showMoreMessages2154 // Give the rendering a moment to potentially catch up after showMoreMessages
2155 await new Promise(resolve => setTimeout(resolve, 100)); // Adjust delay if needed2155 await new Promise(resolve => setTimeout(resolve, 100)); // Adjust delay if needed
2156 } catch (error) {2156 } catch (error) {
@@ -2192,7 +2192,7 @@ export function initDefaultSlashCommands() {
2192 } else {2192 } else {
2193 // Only warn if element is not found *after* attempting to load all messages2193 // Only warn if element is not found *after* attempting to load all messages
2194 toastr.warning(`Could not find element for message ${floorIndex} (using [mesid="${floorIndex}"]) even after attempting to load all messages. It might not be rendered yet or the index is invalid.`);2194 toastr.warning(`Could not find element for message ${floorIndex} (using [mesid="${floorIndex}"]) even after attempting to load all messages. It might not be rendered yet or the index is invalid.`);
2195 console.warn(`WARN: Element not found for message index ${floorIndex} using querySelector [mesid="${floorIndex}"] in /goto-floor, even after attempting to load all messages.`);2195 console.warn(`WARN: Element not found for message index ${floorIndex} using querySelector [mesid="${floorIndex}"] in /chat-jump, even after attempting to load all messages.`);
2196 // Do NOT scroll the chat container in this case2196 // Do NOT scroll the chat container in this case
2197 }2197 }
2198 return ''; // Return empty string as expected by some slash command parsers2198 return ''; // Return empty string as expected by some slash command parsers
@@ -2213,12 +2213,12 @@ export function initDefaultSlashCommands() {
2213 A warning is displayed if the message element cannot be located even after attempting to load all messages.2213 A warning is displayed if the message element cannot be located even after attempting to load all messages.
2214 </div>2214 </div>
2215 <div>2215 <div>
2216 <strong>Example:</strong> <pre><code>/goto-floor 10</code></pre> Scrolls to the 11th message (mesid=10).2216 <strong>Example:</strong> <pre><code>/chat-jump 10</code></pre> Scrolls to the 11th message (mesid=10).
2217 </div>2217 </div>
2218 `,2218 `,
2219 }));2219 }));
22202220
2221 const styleId = 'goto-floor-highlight-style';2221 const styleId = 'chat-jump-highlight-style';
2222 if (document.getElementById(styleId)) {2222 if (document.getElementById(styleId)) {
2223 document.getElementById(styleId).remove();2223 document.getElementById(styleId).remove();
2224 }2224 }