enhance(view):连续视图中的key改为自动生成的文件id。
This commit is contained in:
parent
06f94fe27e
commit
39e4751a9d
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
|
@ -339,6 +339,7 @@ dependencies = [
|
|||
"tauri-build",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"uuid 1.3.0",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ walkdir = "2.3.2"
|
|||
serde_repr = "0.1.10"
|
||||
tokio = { version = "1.23.1", features = ["full"] }
|
||||
image = "0.24.5"
|
||||
uuid = "1.3.0"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
|
|
|
@ -4,6 +4,7 @@ use walkdir::WalkDir;
|
|||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct FileItem {
|
||||
pub id: String,
|
||||
pub filename: String,
|
||||
pub path: String,
|
||||
pub height: u32,
|
||||
|
@ -19,6 +20,7 @@ pub fn scan_directory(target: String) -> Result<Vec<FileItem>, String> {
|
|||
.map(|f| {
|
||||
let (width, height) = image::image_dimensions(f.path())?;
|
||||
Ok(FileItem {
|
||||
id: uuid::Uuid::new_v4().to_string(),
|
||||
filename: f
|
||||
.path()
|
||||
.file_name()
|
||||
|
|
|
@ -21,6 +21,7 @@ export const ContinuationView: FC = () => {
|
|||
},
|
||||
[files]
|
||||
);
|
||||
const fileHeights = useMemo(() => map(item => item.height * (zoom / 100), files), [files, zoom]);
|
||||
|
||||
useEffect(() => {
|
||||
ebus?.addListener('navigate_offset', ({ filename }) => {
|
||||
|
@ -48,7 +49,8 @@ export const ContinuationView: FC = () => {
|
|||
<VariableSizeList
|
||||
itemData={files}
|
||||
itemCount={fileCount}
|
||||
itemSize={index => files[index].height * (zoom / 100)}
|
||||
itemSize={index => fileHeights[index]}
|
||||
itemKey={index => files[index].id}
|
||||
height={viewHeight}
|
||||
width="100%"
|
||||
ref={virtualListRef}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export type FileItem = {
|
||||
sort: number;
|
||||
id: string;
|
||||
filename: string;
|
||||
path: string;
|
||||
width: number;
|
||||
|
|
Loading…
Reference in New Issue
Block a user