feat:完成通过自定义Collabora插件实现页面跳转
This commit is contained in:
@@ -24,9 +24,6 @@ import {
|
||||
unoZoomPlus,
|
||||
unoZoomMinus,
|
||||
unoSetZoom,
|
||||
unoGotoPage,
|
||||
unoFirstPage,
|
||||
unoLastPage,
|
||||
} from './lib';
|
||||
import { COLLABORA_URL } from '~/config/api-config';
|
||||
|
||||
@@ -67,7 +64,8 @@ export function useCollaboraConfig(
|
||||
// 检查错误
|
||||
useEffect(() => {
|
||||
if (fetcher.data && 'error' in fetcher.data) {
|
||||
const errorMessage = (fetcher.data as any).error || '加载配置失败';
|
||||
const errorData = fetcher.data as { error: string };
|
||||
const errorMessage = errorData.error || '加载配置失败';
|
||||
setError(errorMessage);
|
||||
toastService.error(`加载文档配置失败: ${errorMessage}`);
|
||||
}
|
||||
@@ -307,51 +305,6 @@ export function useCollaboraUnoCommands(iframeRef: RefObject<HTMLIFrameElement>)
|
||||
[iframeRef]
|
||||
);
|
||||
|
||||
/**
|
||||
* 跳转到指定页面
|
||||
* @param pageNumber - 页码(从1开始)
|
||||
*/
|
||||
const gotoPage = useCallback(
|
||||
async (pageNumber: number) => {
|
||||
if (!iframeRef.current?.contentWindow) {
|
||||
console.warn('[UNO] iframe 不可用');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[UNO] 跳转到第 ${pageNumber} 页`);
|
||||
await unoGotoPage(iframeRef.current.contentWindow, pageNumber);
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
},
|
||||
[iframeRef]
|
||||
);
|
||||
|
||||
/**
|
||||
* 跳转到第一页
|
||||
*/
|
||||
const gotoFirstPage = useCallback(async () => {
|
||||
if (!iframeRef.current?.contentWindow) {
|
||||
console.warn('[UNO] iframe 不可用');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[UNO] 跳转到第一页');
|
||||
await unoFirstPage(iframeRef.current.contentWindow);
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}, [iframeRef]);
|
||||
|
||||
/**
|
||||
* 跳转到最后一页
|
||||
*/
|
||||
const gotoLastPage = useCallback(async () => {
|
||||
if (!iframeRef.current?.contentWindow) {
|
||||
console.warn('[UNO] iframe 不可用');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[UNO] 跳转到最后一页');
|
||||
await unoLastPage(iframeRef.current.contentWindow);
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}, [iframeRef]);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
@@ -366,9 +319,6 @@ export function useCollaboraUnoCommands(iframeRef: RefObject<HTMLIFrameElement>)
|
||||
zoomIn,
|
||||
zoomOut,
|
||||
setZoom,
|
||||
gotoPage,
|
||||
gotoFirstPage,
|
||||
gotoLastPage,
|
||||
}),
|
||||
[
|
||||
searchText,
|
||||
@@ -382,9 +332,6 @@ export function useCollaboraUnoCommands(iframeRef: RefObject<HTMLIFrameElement>)
|
||||
zoomIn,
|
||||
zoomOut,
|
||||
setZoom,
|
||||
gotoPage,
|
||||
gotoFirstPage,
|
||||
gotoLastPage,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user