| 751 | |
| 752 | // 生成密钥预览 |
| 753 | let keyPreview = '无效密钥'; |
| 754 | if (keyData && keyData.length > 20) { |
| 755 | keyPreview = `${keyData.substring(0, 20)}...${keyData.substring(keyData.length - 10)}`; |
| 756 | } |
| 757 | |
| 758 | keyList += `🔑 <b>密钥 ${index + 1}:</b>\n`; |
| 759 | keyList += ` 类型: <code>${htmlEscape(keyType)}</code>\n`; |
| 760 | keyList += ` 备注: <code>${htmlEscape(comment)}</code>\n`; |
| 761 | keyList += ` 预览: <code>${htmlEscape(keyPreview)}</code>\n`; |
| 762 | |
| 763 | // 如果密钥格式有问题,添加警告 |
| 764 | if (keyType.includes('⚠️') || keyType.includes('❌')) { |
| 765 | keyList += ` <i>⚠️ 此密钥可能无法正常使用</i>\n`; |
| 766 | } |
| 767 | |
| 768 | keyList += `\n`; |
| 769 | }); |
| 770 | |
| 771 | keyList += `💡 <b>提示:</b>\n`; |
| 772 | keyList += `• 使用 <code>${mainPrefix}ssh keys clear</code> 清空所有密钥\n`; |
| 773 | keyList += `• 使用 <code>${mainPrefix}ssh gen replace</code> 重新生成并替换所有密钥`; |
| 774 | |
| 775 | await msg.edit({ |
| 776 | text: keyList, |
| 777 | parseMode: "html" |
| 778 | }); |
| 779 | |
| 780 | } catch (error: any) { |
| 781 | throw new Error(`查看授权密钥失败: ${error.message}`); |
| 782 | } |
| 783 | } |