feat: 优化 CLI 历史记录输出格式,增加使用提示并规范化 sourceDir 处理

This commit is contained in:
catlog22
2025-12-26 12:18:52 +08:00
parent 0c0301d811
commit e79e33773f
5 changed files with 41 additions and 20 deletions

View File

@@ -145,8 +145,9 @@ function renderCliHistory() {
</span>`
: '';
// Escape sourceDir for use in onclick
const sourceDirEscaped = exec.sourceDir ? exec.sourceDir.replace(/'/g, "\\'") : '';
// Normalize and escape sourceDir for use in onclick
// Convert backslashes to forward slashes to prevent JS escape issues in onclick
const sourceDirEscaped = exec.sourceDir ? exec.sourceDir.replace(/\\/g, '/').replace(/'/g, "\\'") : '';
return `
<div class="cli-history-item ${hasNative ? 'has-native' : ''}">

View File

@@ -96,10 +96,10 @@ async function renderCliHistoryView() {
'<button class="btn-icon" onclick="event.stopPropagation(); copyExecutionId(\'' + exec.id + '\')" title="Copy ID">' +
'<i data-lucide="copy" class="w-4 h-4"></i>' +
'</button>' +
'<button class="btn-icon" onclick="event.stopPropagation(); showExecutionDetail(\'' + exec.id + '\', \'' + (exec.sourceDir || '').replace(/'/g, "\\'") + '\')" title="View Details">' +
'<button class="btn-icon" onclick="event.stopPropagation(); showExecutionDetail(\'' + exec.id + '\', \'' + normalizedSourceDir.replace(/'/g, "\\'") + '\')" title="View Details">' +
'<i data-lucide="eye" class="w-4 h-4"></i>' +
'</button>' +
'<button class="btn-icon btn-danger" onclick="event.stopPropagation(); confirmDeleteExecution(\'' + exec.id + '\', \'' + (exec.sourceDir || '').replace(/'/g, "\\'") + '\')" title="Delete">' +
'<button class="btn-icon btn-danger" onclick="event.stopPropagation(); confirmDeleteExecution(\'' + exec.id + '\', \'' + normalizedSourceDir.replace(/'/g, "\\'") + '\')" title="Delete">' +
'<i data-lucide="trash-2" class="w-4 h-4"></i>' +
'</button>' +
'</div>' +