import {Excel} from '../src'; import {OfficeViewer} from '../src/OfficeViewer'; import {createOfficeViewer} from '../src/createOfficeViewer'; import XMLPackageParser from '../src/package/XMLPackageParser'; let office: OfficeViewer; export class App { dir: string; fileLists: Record; viewerElement: HTMLElement; renderOptions: any; initFile: string; constructor( dir: string, fileLists: Record, viewerElement: HTMLElement, renderOptions: any ) { this.dir = dir; this.fileLists = fileLists; this.viewerElement = viewerElement; this.renderOptions = renderOptions; // 支持临时拖拽文件到页面里显示 document.addEventListener('dragover', function (event) { event.preventDefault(); }); document.addEventListener( 'drop', e => { e.preventDefault(); let dt = e.dataTransfer!; let files = dt.files; this.renderDrop(files[0]); }, false ); const url = new URL(location.href); const initFile = url.searchParams.get('file'); if (initFile) { this.renderFile(initFile); } this.initFile = initFile || ''; this.renderFileList(); const uploadFile = document.getElementById('uploadFile')!; uploadFile.addEventListener('change', e => { const files = (e.target as HTMLInputElement).files; if (files && files.length > 0) { this.renderDrop(files[0]); } e.stopPropagation(); }); } renderFileList() { const fileLists = this.fileLists; const fileListElement = document.getElementById('files')!; const html: string[] = ['