Update index.html
Browse files- index.html +46 -3
index.html
CHANGED
|
@@ -439,7 +439,7 @@
|
|
| 439 |
>
|
| 440 |
<span v-if="!isGenerating">
|
| 441 |
<i class="fa-solid fa-file-export"></i>
|
| 442 |
-
匯出設計 (PDF / PPTX)
|
| 443 |
</span>
|
| 444 |
<span v-else>
|
| 445 |
<!-- Spinner -->
|
|
@@ -492,7 +492,7 @@
|
|
| 492 |
</div>
|
| 493 |
</div>
|
| 494 |
|
| 495 |
-
<!-- Export PDF/PPTX Modal -->
|
| 496 |
<div v-if="showExportModal" class="absolute inset-0 z-50 bg-slate-900/50 flex items-center justify-center p-4 animate-fade-in">
|
| 497 |
<div class="bg-white rounded-xl shadow-2xl w-full max-w-sm overflow-hidden">
|
| 498 |
<div class="bg-indigo-600 px-6 py-4">
|
|
@@ -511,7 +511,7 @@
|
|
| 511 |
<input type="text" v-model="exportProjectName" placeholder="例如:我的幸運草" class="w-full border-2 border-slate-200 rounded-lg p-2 focus:border-indigo-500 focus:outline-none">
|
| 512 |
</div>
|
| 513 |
|
| 514 |
-
<!--
|
| 515 |
<div class="flex items-center gap-2 border-t border-slate-100 pt-3">
|
| 516 |
<input type="checkbox" id="removeGridPage2" v-model="removeGridOnPage2" class="w-4 h-4 text-indigo-600 rounded border-slate-300 focus:ring-indigo-500">
|
| 517 |
<label for="removeGridPage2" class="text-sm font-bold text-slate-700 cursor-pointer">
|
|
@@ -526,6 +526,10 @@
|
|
| 526 |
<button @click="processExport('pptx')" class="w-full py-3 bg-orange-500 hover:bg-orange-600 text-white font-bold rounded-lg transition-all shadow-md flex items-center justify-center gap-2">
|
| 527 |
<i class="fa-solid fa-file-powerpoint"></i> 下載可編輯 PPTX
|
| 528 |
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
<button @click="showExportModal = false" class="w-full py-2 text-slate-500 hover:text-slate-700 font-bold text-sm mt-1">取消</button>
|
| 530 |
</div>
|
| 531 |
</div>
|
|
@@ -1393,6 +1397,8 @@
|
|
| 1393 |
exportPDF();
|
| 1394 |
} else if (type === 'pptx') {
|
| 1395 |
exportPPTX();
|
|
|
|
|
|
|
| 1396 |
}
|
| 1397 |
};
|
| 1398 |
|
|
@@ -1620,6 +1626,43 @@
|
|
| 1620 |
}
|
| 1621 |
};
|
| 1622 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1623 |
return {
|
| 1624 |
gridOptions,
|
| 1625 |
currentGrid,
|
|
|
|
| 439 |
>
|
| 440 |
<span v-if="!isGenerating">
|
| 441 |
<i class="fa-solid fa-file-export"></i>
|
| 442 |
+
匯出設計 (PDF / PPTX / JPG)
|
| 443 |
</span>
|
| 444 |
<span v-else>
|
| 445 |
<!-- Spinner -->
|
|
|
|
| 492 |
</div>
|
| 493 |
</div>
|
| 494 |
|
| 495 |
+
<!-- Export PDF/PPTX/JPG Modal -->
|
| 496 |
<div v-if="showExportModal" class="absolute inset-0 z-50 bg-slate-900/50 flex items-center justify-center p-4 animate-fade-in">
|
| 497 |
<div class="bg-white rounded-xl shadow-2xl w-full max-w-sm overflow-hidden">
|
| 498 |
<div class="bg-indigo-600 px-6 py-4">
|
|
|
|
| 511 |
<input type="text" v-model="exportProjectName" placeholder="例如:我的幸運草" class="w-full border-2 border-slate-200 rounded-lg p-2 focus:border-indigo-500 focus:outline-none">
|
| 512 |
</div>
|
| 513 |
|
| 514 |
+
<!-- Checkbox for removing grid on page 2 -->
|
| 515 |
<div class="flex items-center gap-2 border-t border-slate-100 pt-3">
|
| 516 |
<input type="checkbox" id="removeGridPage2" v-model="removeGridOnPage2" class="w-4 h-4 text-indigo-600 rounded border-slate-300 focus:ring-indigo-500">
|
| 517 |
<label for="removeGridPage2" class="text-sm font-bold text-slate-700 cursor-pointer">
|
|
|
|
| 526 |
<button @click="processExport('pptx')" class="w-full py-3 bg-orange-500 hover:bg-orange-600 text-white font-bold rounded-lg transition-all shadow-md flex items-center justify-center gap-2">
|
| 527 |
<i class="fa-solid fa-file-powerpoint"></i> 下載可編輯 PPTX
|
| 528 |
</button>
|
| 529 |
+
<!-- JPG Button -->
|
| 530 |
+
<button @click="processExport('jpg')" class="w-full py-3 bg-emerald-600 hover:bg-emerald-700 text-white font-bold rounded-lg transition-all shadow-md flex items-center justify-center gap-2">
|
| 531 |
+
<i class="fa-solid fa-image"></i> 下載 JPG 圖片 (雙頁)
|
| 532 |
+
</button>
|
| 533 |
<button @click="showExportModal = false" class="w-full py-2 text-slate-500 hover:text-slate-700 font-bold text-sm mt-1">取消</button>
|
| 534 |
</div>
|
| 535 |
</div>
|
|
|
|
| 1397 |
exportPDF();
|
| 1398 |
} else if (type === 'pptx') {
|
| 1399 |
exportPPTX();
|
| 1400 |
+
} else if (type === 'jpg') {
|
| 1401 |
+
exportJPG();
|
| 1402 |
}
|
| 1403 |
};
|
| 1404 |
|
|
|
|
| 1626 |
}
|
| 1627 |
};
|
| 1628 |
|
| 1629 |
+
const exportJPG = async () => {
|
| 1630 |
+
if (selectedCellIndices.value.size > 0) clearSelection();
|
| 1631 |
+
isGenerating.value = true;
|
| 1632 |
+
|
| 1633 |
+
// Filename base
|
| 1634 |
+
let fileNameBase = 'magic-origami';
|
| 1635 |
+
const namePart = exportName.value ? exportName.value : '';
|
| 1636 |
+
const projPart = exportProjectName.value ? exportProjectName.value : '';
|
| 1637 |
+
if (namePart || projPart) fileNameBase = `${namePart}${namePart && projPart ? '-' : ''}${projPart || '作品'}`;
|
| 1638 |
+
|
| 1639 |
+
try {
|
| 1640 |
+
// Page 1
|
| 1641 |
+
const canvas1 = await renderPageToCanvas(1, false);
|
| 1642 |
+
const link1 = document.createElement('a');
|
| 1643 |
+
link1.href = canvas1.toDataURL('image/jpeg', 1.0);
|
| 1644 |
+
link1.download = `${fileNameBase}-第1頁.jpg`;
|
| 1645 |
+
link1.click();
|
| 1646 |
+
|
| 1647 |
+
// Small delay to prevent browser blocking multiple downloads
|
| 1648 |
+
await new Promise(r => setTimeout(r, 500));
|
| 1649 |
+
|
| 1650 |
+
// Page 2
|
| 1651 |
+
const canvas2 = await renderPageToCanvas(2, removeGridOnPage2.value);
|
| 1652 |
+
const link2 = document.createElement('a');
|
| 1653 |
+
link2.href = canvas2.toDataURL('image/jpeg', 1.0);
|
| 1654 |
+
link2.download = `${fileNameBase}-第2頁.jpg`;
|
| 1655 |
+
link2.click();
|
| 1656 |
+
|
| 1657 |
+
} catch (err) {
|
| 1658 |
+
console.error(err);
|
| 1659 |
+
alert("JPG 生成發生錯誤");
|
| 1660 |
+
} finally {
|
| 1661 |
+
isGenerating.value = false;
|
| 1662 |
+
document.getElementById('pdf-generator-container').innerHTML = '';
|
| 1663 |
+
}
|
| 1664 |
+
};
|
| 1665 |
+
|
| 1666 |
return {
|
| 1667 |
gridOptions,
|
| 1668 |
currentGrid,
|