From b869d5263cf43be231e83b24160b6dc5bfb2b1ca Mon Sep 17 00:00:00 2001 From: rookie4show Date: Sat, 8 Mar 2025 11:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E5=8D=B0=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=85=B7=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 12 +- src/components/ShikigamiProperty.vue | 4 +- src/components/ShikigamiSelect.vue | 181 +++++++++++---------------- src/components/Toolbar.vue | 139 ++++++++++++++++++++ src/components/Yys.vue | 77 +----------- src/locales/zh.json | 3 + 6 files changed, 233 insertions(+), 183 deletions(-) create mode 100644 src/components/Toolbar.vue diff --git a/src/App.vue b/src/App.vue index 365cf03..4b1ed4b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,24 +1,28 @@ \ No newline at end of file diff --git a/src/components/Yys.vue b/src/components/Yys.vue index 5f9adb5..c0fa1f7 100644 --- a/src/components/Yys.vue +++ b/src/components/Yys.vue @@ -12,11 +12,7 @@ @closeProperty="closeProperty" @updateProperty="updateProperty" /> - -
- - {{ t('prepareCapture') }} -
+ @@ -125,17 +121,7 @@ - - -
- Preview -
- - - 取 消 - 下 载 - -
+ @@ -224,6 +210,7 @@ const editShikigami = (groupIndex, positionIndex) => { state.showSelectShikigami = true; state.groupIndex = groupIndex; state.positionIndex = positionIndex; + state.currentShikigami = state.groups[groupIndex].groupInfo[positionIndex]; }; const updateShikigami = (shikigami) => { @@ -274,65 +261,11 @@ const addGroupElement = (groupIndex) => { state.groups[groupIndex].groupInfo.push({}); }; -const ignoreElements = (element) => { - return element.classList.contains('ql-toolbar'); -} -const prepareCapture = async () => { - state.previewVisible = true; // 显示预览弹窗 - - // 创建临时样式 - const style = document.createElement('style') - style.id = 'capture-style' - style.textContent = ` - .ql-container.ql-snow { - border: none !important; - } - ` - document.head.appendChild(style) - // 捕获页面元素并生成图片 - try { - const element = document.querySelector('#main-container'); // 替换为要捕获的元素选择器 - if (!element) { - console.error('Element with ID "main-container" not found.'); - state.previewVisible = false; - return; - } - - const canvas = await html2canvas(element, { - ignoreElements: ignoreElements, - height: element.scrollHeight, - } - ); - state.previewImage = canvas.toDataURL(); - if (!state.previewImage) { - console.error('Failed to generate image data URL.'); - state.previewVisible = false; - state.previewVisible = false; - } - } catch (error) { - console.error('Failed to capture screenshot', error); - state.previewVisible = false; - }finally { - // 清除临时样式 - document.getElementById('capture-style')?.remove() - } -}; -const downloadImage = () => { - if (state.previewImage) { - const link = document.createElement('a'); - link.href = state.previewImage; - link.download = 'screenshot.png'; // 设置下载的文件名 - link.click(); - state.previewVisible = false; // 关闭预览弹窗 - } -}; -const handleClose = (done) => { - state.previewImage = null; // 清除预览图像 - done(); // 关闭弹窗 -}; + +