Skip to content

Commit 2e27443

Browse files
committed
perf: 🚀 File management supports returning to the root directory
1 parent 7367ca4 commit 2e27443

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

‎electron/exposes/adb/index.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ const watch = async (callback) => {
195195
return close
196196
}
197197

198-
async function readdir(id, filePath) {
199-
const value = await client.getDevice(id).readdir(filePath)
198+
async function readdir(id, currentPath) {
199+
const value = await client.getDevice(id).readdir(currentPath)
200200

201201
return value.map(item => ({
202202
...item,
203-
id: [filePath, item.name].join('/'),
203+
id: path.posix.join(currentPath, item.name),
204204
type: item.isFile() ? 'file' : 'directory',
205205
name: item.name,
206206
size: formatFileSize(item.size),

‎src/components/ControlBar/FileManage/FileDialog/index.vue‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,20 @@ const loading = ref(false)
191191
192192
const tableData = ref([])
193193
194-
const currentPath = ref('sdcard')
194+
const currentPath = ref('/sdcard')
195195
196196
const presetMap = {
197197
sdcard: {
198198
icon: 'Iphone',
199199
label: 'device.control.file.manager.storage',
200-
value: 'sdcard',
200+
value: '/sdcard',
201201
},
202202
}
203203
204204
const breadcrumbModel = computed(() => {
205-
const list = currentPath.value.split('/')
205+
const slicePath = currentPath.value.slice(1)
206+
207+
const list = slicePath ? slicePath.split('/') : ['/']
206208
207209
const value = list.map(item => ({
208210
label: item,
@@ -243,7 +245,7 @@ function onSelectionChange(selection) {
243245
const scrollableRef = ref()
244246
245247
async function handleDirectory(row) {
246-
currentPath.value += `/${row.name}`
248+
currentPath.value = row.id
247249
getTableData()
248250
249251
await nextTick()
@@ -259,14 +261,14 @@ function handleBreadcrumb(data) {
259261
}
260262
261263
function handlePrev() {
262-
if (breadcrumbModel.value.length <= 1) {
263-
return false
264-
}
264+
let value = '/'
265265
266-
const value = breadcrumbModel.value
267-
.slice(0, -1)
268-
.map(item => item.value)
269-
.join('/')
266+
if (breadcrumbModel.value.length > 1) {
267+
value = breadcrumbModel.value
268+
.slice(0, -1)
269+
.map(item => item.value)
270+
.join('/')
271+
}
270272
271273
currentPath.value = value
272274
@@ -298,7 +300,7 @@ async function handleRemove(row) {
298300
299301
await window.adb.deviceShell(
300302
device.value.id,
301-
`rm -r "/${currentPath.value}/${row.name}"`,
303+
`rm -r "${currentPath.value}/${row.name}"`,
302304
)
303305
304306
getTableData()
@@ -307,7 +309,7 @@ async function handleRemove(row) {
307309
async function handleUpload(device, openType) {
308310
await fileActions.send(device, {
309311
openType,
310-
remotePath: `/${currentPath.value}`,
312+
remotePath: currentPath.value,
311313
})
312314
313315
getTableData()

0 commit comments

Comments
 (0)