62 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
 | 
						|
<head>
 | 
						|
    <meta charset="UTF-8">
 | 
						|
    <style>
 | 
						|
        html,
 | 
						|
        body {
 | 
						|
            width: 99%;
 | 
						|
            height: 99%;
 | 
						|
        }
 | 
						|
    </style>
 | 
						|
    <title></title>
 | 
						|
    <!-- 引入外部JavaScript文件 -->
 | 
						|
    <!-- <script type="text/javascript"
 | 
						|
        src="https://onlyoffice.test.extimaging.com/web-apps/apps/api/documents/api.js"></script> -->
 | 
						|
</head>
 | 
						|
 | 
						|
<body>
 | 
						|
    <div id="placeholder"></div>
 | 
						|
    <script language="javascript" type="text/javascript">
 | 
						|
        var obj = {}
 | 
						|
        var str = window.location.search.substr(1)
 | 
						|
        str = str.split('?')[1]
 | 
						|
        var url = window.location.search.substr(1).split('?')[0].split('=')[1]
 | 
						|
        var arrList = str.split('&')
 | 
						|
        arrList.forEach(function (item) {
 | 
						|
            var arr = item.split('=')
 | 
						|
            obj[arr[0]] = window.decodeURIComponent(arr[1])
 | 
						|
        })
 | 
						|
        function loadScript() {
 | 
						|
            return new Promise((resolve, reject) => {
 | 
						|
                const script = document.createElement('script')
 | 
						|
                script.src = `${obj.onlyOffice_url}/web-apps/apps/api/documents/api.js`
 | 
						|
                script.onload = resolve
 | 
						|
                script.onerror = reject
 | 
						|
                document.head.appendChild(script)
 | 
						|
            })
 | 
						|
        }
 | 
						|
        loadScript().then(() => {
 | 
						|
            console.log('JS 加载完成')
 | 
						|
            var docEditor = new window.DocsAPI.DocEditor("placeholder", {
 | 
						|
                type: "embedded",
 | 
						|
                "document": {
 | 
						|
                    "fileType": obj.type,
 | 
						|
                    "key": "Khirz6zTPdfd7" + Date.now(),
 | 
						|
                    "title": obj.title,
 | 
						|
                    "url": url,
 | 
						|
                },
 | 
						|
                // editorConfig: {
 | 
						|
                //     lang:'zh'
 | 
						|
 | 
						|
                // },
 | 
						|
                "documentType": obj.documentType,
 | 
						|
                "height": "100%",
 | 
						|
 | 
						|
            });
 | 
						|
        })
 | 
						|
    </script>
 | 
						|
</body>
 | 
						|
 | 
						|
</html> |