123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>EPS to SVG Converter</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- max-width: 800px;
- margin: 20px auto;
- padding: 20px;
- }
- .upload-container {
- border: 2px dashed #ccc;
- padding: 20px;
- text-align: center;
- margin: 20px 0;
- }
- .upload-container.dragover {
- border-color: #4CAF50;
- background: #e8f5e9;
- }
- #uploadForm {
- margin-bottom: 20px;
- }
- #result {
- margin-top: 20px;
- padding: 10px;
- border-radius: 4px;
- }
- .success {
- background-color: #e8f5e9;
- color: #2e7d32;
- }
- .error {
- background-color: #ffebee;
- color: #c62828;
- }
- button {
- background-color: #4CAF50;
- color: white;
- padding: 10px 20px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- }
- button:hover {
- background-color: #45a049;
- }
- </style>
- </head>
- <body>
- <h1>EPS to SVG Converter</h1>
-
- <div class="upload-container" id="dropZone">
- <form id="uploadForm">
- <input type="file" id="fileInput" accept=".eps" style="display: none">
- <button type="button" onclick="document.getElementById('fileInput').click()">选择EPS文件</button>
- <p>或拖拽文件到此处</p>
- </form>
- <div id="fileName"></div>
- </div>
- <div id="result"></div>
- <script>
- const dropZone = document.getElementById('dropZone');
- const fileInput = document.getElementById('fileInput');
- const resultDiv = document.getElementById('result');
- const fileNameDiv = document.getElementById('fileName');
- // Drag and drop handlers
- dropZone.addEventListener('dragover', (e) => {
- e.preventDefault();
- dropZone.classList.add('dragover');
- });
- dropZone.addEventListener('dragleave', () => {
- dropZone.classList.remove('dragover');
- });
- dropZone.addEventListener('drop', (e) => {
- e.preventDefault();
- dropZone.classList.remove('dragover');
- const files = e.dataTransfer.files;
- if (files.length > 0) {
- handleFile(files[0]);
- }
- });
- fileInput.addEventListener('change', (e) => {
- if (e.target.files.length > 0) {
- handleFile(e.target.files[0]);
- }
- });
- function handleFile(file) {
- if (!file.name.toLowerCase().endsWith('.eps')) {
- showResult('请选择EPS文件', false);
- return;
- }
- if (file.size > 10 * 1024 * 1024) {
- showResult('文件大小不能超过10MB', false);
- return;
- }
- fileNameDiv.textContent = `已选择: ${file.name}`;
- uploadFile(file);
- }
- async function uploadFile(file) {
- const formData = new FormData();
- formData.append('file', file);
- try {
- const response = await fetch('https://www.infish.cn/sku3d/v1/eps2svg/convert', {
- method: 'POST',
- body: formData
- });
- const data = await response.json();
- if (response.ok) {
- showResult(`转换成功! OBS路径: ${data.obs_key}`, true);
- } else {
- showResult(`错误: ${data.detail || '转换失败'}`, false);
- }
- } catch (error) {
- showResult(`错误: ${error.message}`, false);
- }
- }
- function showResult(message, isSuccess) {
- resultDiv.textContent = message;
- resultDiv.className = isSuccess ? 'success' : 'error';
- }
- </script>
- </body>
- </html>
|