upload webpage that used to embed devstar webpage
This commit is contained in:
		
							
								
								
									
										71
									
								
								test/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								test/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
			
		||||
<?php
 | 
			
		||||
header("Access-Control-Allow-Origin: *");
 | 
			
		||||
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
 | 
			
		||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
 | 
			
		||||
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
 | 
			
		||||
?>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
			
		||||
    <title>DevStar Home</title>
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
    <iframe src="http://localhost:8080/test/embedded.html" 
 | 
			
		||||
    width="100%" 
 | 
			
		||||
    height="50%"
 | 
			
		||||
    frameborder="0"
 | 
			
		||||
    style="border: 0; left: 0; right: 0; bottom: 0; top: 0; position:absolute;">
 | 
			
		||||
    </iframe>
 | 
			
		||||
 | 
			
		||||
    <!-- <iframe src="http://www.devstar.cn" 
 | 
			
		||||
    width="100%" 
 | 
			
		||||
    height="100%"
 | 
			
		||||
    frameborder="0"
 | 
			
		||||
    style="border: 0; left: 0; right: 0; bottom: 0; top: 0; position:absolute;">
 | 
			
		||||
    </iframe> -->
 | 
			
		||||
    <script>
 | 
			
		||||
        const vscode = acquireVsCodeApi();
 | 
			
		||||
 | 
			
		||||
        function firstOpenRemoteFolder() {
 | 
			
		||||
            vscode.postMessage({ command: 'firstOpenRemoteFolder', host: host, username: username, password: password, port: port, path: path });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function openRemoteFolder() {
 | 
			
		||||
            vscode.postMessage({ command: 'openRemoteFolder', host: host, path: path });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function firstOpenRemoteFolderWithData(host, username, password, port, path) {
 | 
			
		||||
            vscode.postMessage({ command: 'firstOpenRemoteFolder', host: host, username: username, password: password, port: port, path: path });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        function openRemoteFolderWithData(host, path) {
 | 
			
		||||
            vscode.postMessage({ command: 'openRemoteFolder', host: host, path: path });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 监听子页面的消息
 | 
			
		||||
        window.addEventListener('message', (event) => {
 | 
			
		||||
            // 出于安全考虑,检查 event.origin 是否是你预期的源
 | 
			
		||||
            // if (event.origin !== "http://expected-origin.com") {
 | 
			
		||||
            //     return;
 | 
			
		||||
            // }
 | 
			
		||||
        
 | 
			
		||||
            try {
 | 
			
		||||
                const data = JSON.parse(event.data);
 | 
			
		||||
                if (data.action === 'firstOpenRemoteFolder') {
 | 
			
		||||
                    console.log('Received message:', data);
 | 
			
		||||
                    firstOpenRemoteFolderWithData(data.host, data.username, data.password, data.port, data.path);
 | 
			
		||||
                } else if (data.action === 'openRemoteFolder') {
 | 
			
		||||
                    console.log('Received message:', data);
 | 
			
		||||
                    openRemoteFolderWithData(data.host, data.path);
 | 
			
		||||
                }
 | 
			
		||||
            } catch (error) {
 | 
			
		||||
                console.error('Error parsing message:', error);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
		Reference in New Issue
	
	Block a user