diff --git a/frontend/src/views/container/container/file-browser/index.vue b/frontend/src/views/container/container/file-browser/index.vue index 1f59aae71fbc..d43074075a55 100644 --- a/frontend/src/views/container/container/file-browser/index.vue +++ b/frontend/src/views/container/container/file-browser/index.vue @@ -141,13 +141,14 @@ const pathSegments = computed(() => { interface DrawerProps { containerID: string; title: string; + workingDir?: string; } const acceptParams = async (params: DrawerProps): Promise => { visible.value = true; containerID.value = params.containerID; title.value = params.title; - filePath.value = '/'; + filePath.value = params.workingDir || '/'; await loadContainerFiles(); }; diff --git a/frontend/src/views/container/container/index.vue b/frontend/src/views/container/container/index.vue index f7b6cde22ae2..7607530b93a0 100644 --- a/frontend/src/views/container/container/index.vue +++ b/frontend/src/views/container/container/index.vue @@ -677,9 +677,19 @@ const onTerminal = (row: any) => { dialogTerminalRef.value!.acceptParams({ containerID: row.containerID, title: title }); }; const dialogFileBrowserRef = ref(); -const onOpenFileBrowser = (row: any) => { +const onOpenFileBrowser = async (row: any) => { const title = i18n.global.t('menu.container') + ' ' + row.name; - dialogFileBrowserRef.value!.acceptParams({ containerID: row.containerID, title: title }); + let workingDir = '/'; + try { + const res = await inspect({ id: row.containerID, type: 'container', detail: '' }); + const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data; + if (data?.Config?.WorkingDir) { + workingDir = data.Config.WorkingDir; + } + } catch (e) { + /* fallback to root */ + } + dialogFileBrowserRef.value!.acceptParams({ containerID: row.containerID, title: title, workingDir: workingDir }); }; const onInspect = async (row: any) => {