feat(view):基本实现连续视图的功能。
This commit is contained in:
@@ -5,14 +5,17 @@ import { createStoreHook } from '../utils/store_creator';
|
||||
|
||||
interface FileListState {
|
||||
files: FileItem[];
|
||||
actives: string[];
|
||||
}
|
||||
|
||||
type FileListActions = {
|
||||
updateFiles: SyncObjectCallback<Omit<FileItem, 'sort'>[]>;
|
||||
updateActiveFiles: SyncObjectCallback<string[]>;
|
||||
};
|
||||
|
||||
const initialState: FileListState = {
|
||||
files: []
|
||||
files: [],
|
||||
actives: []
|
||||
};
|
||||
|
||||
export const useFileListStore = createStoreHook<FileListState & FileListActions>(set => ({
|
||||
@@ -24,5 +27,10 @@ export const useFileListStore = createStoreHook<FileListState & FileListActions>
|
||||
files
|
||||
);
|
||||
});
|
||||
},
|
||||
updateActiveFiles(filenames) {
|
||||
set(df => {
|
||||
df.actives = filenames;
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SyncObjectCallback } from '../types';
|
||||
import { createStoreHook } from '../utils/store_creator';
|
||||
|
||||
interface ZoomState {
|
||||
@@ -5,15 +6,32 @@ interface ZoomState {
|
||||
autoFit: boolean;
|
||||
currentZoom: number;
|
||||
viewMode: 'single' | 'double' | 'continuation';
|
||||
viewHeight: number;
|
||||
}
|
||||
|
||||
type ZoomActions = {
|
||||
zoom: SyncObjectCallback<number>;
|
||||
updateViewHeight: SyncObjectCallback<number>;
|
||||
};
|
||||
|
||||
const initialState: ZoomState = {
|
||||
lock: true,
|
||||
autoFit: false,
|
||||
currentZoom: 100,
|
||||
viewMode: 'continuation'
|
||||
viewMode: 'continuation',
|
||||
viewHeight: 0
|
||||
};
|
||||
|
||||
export const useZoomState = createStoreHook<ZoomState>(set => ({
|
||||
...initialState
|
||||
export const useZoomState = createStoreHook<ZoomState & ZoomActions>(set => ({
|
||||
...initialState,
|
||||
zoom(ratio) {
|
||||
set(df => {
|
||||
df.currentZoom = ratio;
|
||||
});
|
||||
},
|
||||
updateViewHeight(height) {
|
||||
set(df => {
|
||||
df.viewHeight = height;
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user