feat(layout):完成基本界面布局以及文件夹扫描功能。
This commit is contained in:
28
src/states/files.ts
Normal file
28
src/states/files.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { addIndex, map, mergeRight } from 'ramda';
|
||||
import { FileItem } from '../models';
|
||||
import { SyncObjectCallback } from '../types';
|
||||
import { createStoreHook } from '../utils/store_creator';
|
||||
|
||||
interface FileListState {
|
||||
files: FileItem[];
|
||||
}
|
||||
|
||||
type FileListActions = {
|
||||
updateFiles: SyncObjectCallback<Omit<FileItem, 'sort'>[]>;
|
||||
};
|
||||
|
||||
const initialState: FileListState = {
|
||||
files: []
|
||||
};
|
||||
|
||||
export const useFileListStore = createStoreHook<FileListState & FileListActions>(set => ({
|
||||
...initialState,
|
||||
updateFiles(files) {
|
||||
set(df => {
|
||||
df.files = addIndex<Omit<FileItem, 'sort'>, FileItem>(map)(
|
||||
(item, index) => mergeRight({ sort: index * 10 }, item),
|
||||
files
|
||||
);
|
||||
});
|
||||
}
|
||||
}));
|
||||
19
src/states/zoom.ts
Normal file
19
src/states/zoom.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createStoreHook } from '../utils/store_creator';
|
||||
|
||||
interface ZoomState {
|
||||
lock: boolean;
|
||||
autoFit: boolean;
|
||||
currentZoom: number;
|
||||
viewMode: 'single' | 'double' | 'continuation';
|
||||
}
|
||||
|
||||
const initialState: ZoomState = {
|
||||
lock: true,
|
||||
autoFit: false,
|
||||
currentZoom: 100,
|
||||
viewMode: 'continuation'
|
||||
};
|
||||
|
||||
export const useZoomState = createStoreHook<ZoomState>(set => ({
|
||||
...initialState
|
||||
}));
|
||||
Reference in New Issue
Block a user