From 4e2815ebd3547f95d6b635f7202f527bcda8123e Mon Sep 17 00:00:00 2001 From: Meleki Date: Fri, 17 Apr 2026 10:41:32 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Backslash-Support=20im=20File-Explorer?= =?UTF-8?q?=20f=C3=BCr=20Chat=20und=20Benutzerverwaltung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WorkspaceHelper gibt native Pfade zurück, Frontend-Logik unterstützt beide Separatoren. Co-Authored-By: Claude Opus 4.6 --- Services/WorkspaceHelper.cs | 5 ++--- wwwroot/index.html | 2 +- wwwroot/js/file-explorer.js | 14 +++++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Services/WorkspaceHelper.cs b/Services/WorkspaceHelper.cs index 7f7ece7..ff31357 100644 --- a/Services/WorkspaceHelper.cs +++ b/Services/WorkspaceHelper.cs @@ -27,12 +27,11 @@ public static class WorkspaceHelper } /// - /// Gibt den relativen Pfad zurück – immer mit Forward-Slashes (für Agent-Output/API). + /// Gibt den relativen Pfad zurück – mit nativen Separatoren (Backslash auf Windows, / auf Linux). /// internal static string GetRelativePath(string relativeTo, string path) { - var rel = Path.GetRelativePath(relativeTo, path); - return IsWindows ? rel.Replace('\\', '/') : rel; + return Path.GetRelativePath(relativeTo, path); } /// diff --git a/wwwroot/index.html b/wwwroot/index.html index a6ba14a..2fcb332 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -701,7 +701,7 @@
- +
diff --git a/wwwroot/js/file-explorer.js b/wwwroot/js/file-explorer.js index e966673..468a2ba 100644 --- a/wwwroot/js/file-explorer.js +++ b/wwwroot/js/file-explorer.js @@ -73,7 +73,8 @@ function openFileExplorer(opts = {}) { // Zum Verzeichnis der initialFile navigieren, oder Root if (_feState.initialFile) { const filePath = _feState.initialFile; - const dir = filePath.includes('/') ? filePath.substring(0, filePath.lastIndexOf('/')) : ''; + const lastSep = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\')); + const dir = lastSep >= 0 ? filePath.substring(0, lastSep) : ''; feLoadDir(dir); } else { feLoadDir(''); @@ -128,7 +129,8 @@ async function feLoadDir(path) { upItem.innerHTML = ' ..'; upItem.addEventListener('click', () => { _feState.history.push(path); - const parent = path.includes('/') ? path.substring(0, path.lastIndexOf('/')) : ''; + const lastSep = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')); + const parent = lastSep >= 0 ? path.substring(0, lastSep) : ''; feLoadDir(parent); }); sidebar.appendChild(upItem); @@ -490,7 +492,7 @@ function openFolderBrowser(opts = {}) { mode: 'folder', onSelect: opts.onSelect || null, currentAbsPath: opts.startPath || '/', - basePath: (opts.basePath || '').replace(/\/+$/, '') || null, + basePath: (opts.basePath || '').replace(/[\\/]+$/, '') || null, history: [] }; @@ -635,7 +637,8 @@ async function fbCreateDir() { return; } - const absPath = _feState.currentAbsPath.replace(/\/$/, '') + '/' + dirName; + const sep = _feState.currentAbsPath.includes('\\') ? '\\' : '/'; + const absPath = _feState.currentAbsPath.replace(/[\\/]+$/, '') + sep + dirName; try { const resp = await fetch(`/api/workspace/browse/mkdir?path=${encodeURIComponent(absPath)}`, { method: 'POST' }); @@ -664,7 +667,8 @@ async function feCreateDir() { return; } - const newPath = _feState.currentPath ? _feState.currentPath + '/' + dirName : dirName; + const sep = _feState.currentPath.includes('\\') ? '\\' : '/'; + const newPath = _feState.currentPath ? _feState.currentPath + sep + dirName : dirName; try { const url = _feApiUrl('mkdir', `path=${encodeURIComponent(newPath)}`);