Compare commits
No commits in common. "c63da5222e8d39cd8f3279c2a4a9a3f5b4792c3a" and "d7aeb00212cd2dd47a19ee08d50a4e51a452cd93" have entirely different histories.
c63da5222e
...
d7aeb00212
@ -48,12 +48,8 @@ pub async fn scan_directory(target: String) -> Result<Vec<FileItem>, String> {
|
||||
if !entry.path().is_file() {
|
||||
continue;
|
||||
}
|
||||
let image_detect_result = image::image_dimensions(entry.path());
|
||||
if image_detect_result.is_err() {
|
||||
println!("读取图片文件 {} 元信息失败。", entry.path().display());
|
||||
continue;
|
||||
}
|
||||
let (width, height) = image_detect_result.unwrap();
|
||||
let (width, height) = image::image_dimensions(entry.path())
|
||||
.map_err(|_e| format!("读取图片文件 {} 元信息失败。", entry.path().display()))?;
|
||||
let file_hash_id = entry
|
||||
.path()
|
||||
.to_str()
|
||||
@ -64,27 +60,20 @@ pub async fn scan_directory(target: String) -> Result<Vec<FileItem>, String> {
|
||||
let filename = entry
|
||||
.path()
|
||||
.file_name()
|
||||
.ok_or(String::from("不能获取到文件名。"))
|
||||
.map(ToOwned::to_owned)
|
||||
.map(|s| s.into_string().unwrap());
|
||||
if filename.is_err() {
|
||||
println!("不能获取到文件 {} 文件名。", entry.path().display());
|
||||
continue;
|
||||
}
|
||||
.ok_or(String::from("不能获取到文件名。"))?
|
||||
.to_owned()
|
||||
.into_string()
|
||||
.unwrap();
|
||||
let path = entry
|
||||
.path()
|
||||
.clone()
|
||||
.to_str()
|
||||
.ok_or(String::from("不能获取到文件路径。"))
|
||||
.map(ToString::to_string);
|
||||
if path.is_err() {
|
||||
println!("不能获取到文件 {} 路径。", entry.path().display());
|
||||
continue;
|
||||
}
|
||||
.ok_or(String::from("不能获取到文件路径。"))?
|
||||
.to_string();
|
||||
file_items.push(FileItem {
|
||||
id: file_hash_id,
|
||||
filename: filename.unwrap(),
|
||||
path: path.unwrap(),
|
||||
filename,
|
||||
path,
|
||||
height,
|
||||
width,
|
||||
});
|
||||
|
@ -4,7 +4,7 @@ import { ActionIcon, Box, Flex, Stack, Text, Tooltip } from '@mantine/core';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { IconEye, IconSquareMinus, IconSquarePlus } from '@tabler/icons-react';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { equals, isEmpty, isNil, map, not } from 'ramda';
|
||||
import { equals, isEmpty, isNil, length, map, not } from 'ramda';
|
||||
import { FC, PropsWithChildren, useCallback, useContext, useState } from 'react';
|
||||
import { useMeasure, useMount } from 'react-use';
|
||||
import { EventBusContext } from '../EventBus';
|
||||
@ -69,6 +69,7 @@ const Branch: FC<PropsWithChildren<{ current: DirItem; expanded: boolean }>> = (
|
||||
try {
|
||||
selectDir(current.id);
|
||||
const files = await invoke('scan_directory', { target: current.path });
|
||||
console.log('[debug]获取到文件个数:', length(files));
|
||||
storeFiles(files);
|
||||
ebus.emit('reset_views');
|
||||
} catch (e) {
|
||||
@ -121,6 +122,7 @@ export const DirTree: FC = () => {
|
||||
const [viewRef, { width }] = useMeasure();
|
||||
|
||||
const handleFocusAction = useCallback(() => {
|
||||
console.log('[debug]focus action: ', focused, selected);
|
||||
if (isNil(focused) && not(isNil(selected))) {
|
||||
focus(selected);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user