import { ComponentOptionsMixin } from 'vue'; import { DefineComponent } from 'vue'; import { ExtractPropTypes } from 'vue'; import { PropType } from 'vue'; /** * 判断文件类型 */ export declare function determineFileType(url?: string, type?: SupportedFileTypes): Promise; declare type EventArgs> = EventMap[EventName] extends (...args: any[]) => any ? Parameters : any[]; declare type EventCallback> = (args: EventResponse) => void; declare type EventNames = EventMap extends { [key: string]: any; } ? keyof EventMap : any; declare type EventResponse> = EventMap[EventName] extends (...args: any[]) => any ? ReturnType : never; /** * iframe 通信channel * @template EventsType 支持发送的事件类型 * @template ListenersType 支持监听的事件类型 */ export declare class FrameChannel { private win; private callbackMap; private eventMap; constructor(iframe?: HTMLIFrameElement); emit>(event: T, ...args: EventArgs): Promise>; addEventListener>(event: T, callback: (resolve: EventCallback, ...args: EventArgs) => void): void; private onMessage; } /** * 根据文件url后缀判断文件类型 * @param url 文件url * @returns 文件类型字符串 */ export declare function getFileTypeByExtension(url: string): SupportedFileTypes | undefined; /** * 通过文件内容的magic number判断文件类型 * @param url 文件url * @returns 文件类型字符串 */ export declare function getFileTypeByMagicNumber(url: string): Promise; export declare const OfficePreview: DefineComponent< { fileUrl: { type: StringConstructor; }; frameUrl: { type: StringConstructor; default: string; }; fileType: { type: PropType; default: null; }; }, () => JSX.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, { loaded: (channel: OfficePreviewChannel) => any; }, string, Readonly; default: null; }; }>>, { frameUrl: string; fileType: SupportedFileTypes; }>; export declare class OfficePreviewChannel extends FrameChannel { } export declare interface PreviewComponentEvents { loadFile?: (fileUrl: string, fileType?: SupportedFileTypes) => void; } export declare class PreviewFrameChannel extends FrameChannel { } export declare interface PreviewFrameEvents { loaded?: () => void; } /** * 文件类型映射表 */ export declare const SupportedFileExtension: { type: SupportedFileTypes; extension: string[]; }[]; export declare const SupportedFileType: SupportedFileTypes[]; export declare type SupportedFileTypes = "word" | "excel" | "ppt" | "pdf"; export { }