mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-06-14 03:32:00 +08:00
feat: 增加 MSD 虚拟盘文件路径编码
This commit is contained in:
@@ -560,15 +560,15 @@ export const msdApi = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
downloadDriveFile: (path: string) =>
|
downloadDriveFile: (path: string) =>
|
||||||
`${API_BASE}/msd/drive/files${path.startsWith('/') ? path : '/' + path}`,
|
`${API_BASE}/msd/drive/files${encodeDrivePath(path)}`,
|
||||||
|
|
||||||
deleteDriveFile: (path: string) =>
|
deleteDriveFile: (path: string) =>
|
||||||
request<{ success: boolean }>(`/msd/drive/files${path.startsWith('/') ? path : '/' + path}`, {
|
request<{ success: boolean }>(`/msd/drive/files${encodeDrivePath(path)}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
createDirectory: (path: string) =>
|
createDirectory: (path: string) =>
|
||||||
request<{ success: boolean }>(`/msd/drive/mkdir${path.startsWith('/') ? path : '/' + path}`, {
|
request<{ success: boolean }>(`/msd/drive/mkdir${encodeDrivePath(path)}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -599,6 +599,22 @@ interface SerialDeviceOption {
|
|||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeDrivePath(path: string): string {
|
||||||
|
if (path === '' || path === '/') {
|
||||||
|
return '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasLeadingSlash = path.startsWith('/')
|
||||||
|
const hasTrailingSlash = path.endsWith('/')
|
||||||
|
const encodedSegments = path
|
||||||
|
.split('/')
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(segment => encodeURIComponent(segment))
|
||||||
|
.join('/')
|
||||||
|
|
||||||
|
return `${hasLeadingSlash ? '/' : ''}${encodedSegments}${hasTrailingSlash ? '/' : ''}`
|
||||||
|
}
|
||||||
|
|
||||||
function getSerialDevicePriority(path: string): number {
|
function getSerialDevicePriority(path: string): number {
|
||||||
if (/^\/dev\/ttyUSB/i.test(path)) return 0
|
if (/^\/dev\/ttyUSB/i.test(path)) return 0
|
||||||
if (/^\/dev\/(ttyS|S)/i.test(path)) return 2
|
if (/^\/dev\/(ttyS|S)/i.test(path)) return 2
|
||||||
|
|||||||
Reference in New Issue
Block a user