feat(view):基本实现连续视图的功能。

This commit is contained in:
徐涛
2023-03-08 16:28:24 +08:00
parent 848c8c01e7
commit 9437e45b8d
13 changed files with 191 additions and 17 deletions

View File

@@ -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;
});
}
}));

View File

@@ -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;
});
}
}));