= (props) => {
+ const [ready, setReady] = useState(false);
+
+ useEffect(() => {
+ console.log('延迟....')
+ const timer = setTimeout(() => {
+ setReady(true);
+ }, 2000);
+ return () => clearTimeout(timer);
+ }, []);
+
+ if (!ready) return null;
+
+ return
;
+};
+
EditorOptimization.displayName = "EditorOptimization";
export default EditorOptimization;
\ No newline at end of file
From 621bdf438f50f5eafbf5c98450a6be46d00e2982 Mon Sep 17 00:00:00 2001
From: Killeriest <3294190485@qq.com>
Date: Tue, 18 Aug 2026 15:09:45 +0800
Subject: [PATCH 2/2] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=B9=B2=E5=87=80?=
=?UTF-8?q?=E4=BD=9C=E5=93=81=E4=B8=8B=E8=BD=BD=E5=8A=9F=E8=83=BD,?=
=?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=B7=BB=E5=8A=A0=E7=BF=BB=E8=AF=91=E6=96=87?=
=?UTF-8?q?=E6=9C=AC=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/l10n/en.json | 1 +
src/l10n/es.json | 1 +
src/l10n/ms.json | 1 +
src/l10n/ru.json | 3 +-
src/l10n/uk.json | 1 +
src/l10n/zh-cn.json | 3 +-
src/plugins/editor-optimization/index.tsx | 74 ++++++++++++++++++++++-
7 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/src/l10n/en.json b/src/l10n/en.json
index abfa9e9..175c52f 100644
--- a/src/l10n/en.json
+++ b/src/l10n/en.json
@@ -355,6 +355,7 @@
"plugins.editorOptimization.enableFullscreenDesc": "Hides the workspace when in fullscreen to reduce unnecessary resource usage.",
"plugins.editorOptimization.enablePixiLabel": "[Experimental] Enable Pixi Renderer",
"plugins.editorOptimization.enablePixiDesc": "Partially renders blocks using Pixi.js to increase FPS in the workspace. Blocks rendered by Pixi are transparent, which are faster but provide limited interactive functionality.",
+ "plugins.editorOptimization.downloadCleanProject": "Download the project without group data",
"plugins.debuggerAddon.title": "Debugger",
"plugins.debuggerAddon.description": "Debug happily in Gandi! Need to be used with GandiTerminal Extension!",
"plugins.debuggerAddon.console": "Console",
diff --git a/src/l10n/es.json b/src/l10n/es.json
index b612042..c39ec24 100644
--- a/src/l10n/es.json
+++ b/src/l10n/es.json
@@ -292,6 +292,7 @@
"plugins.editorOptimization.enableFullscreenDesc": "Oculta el área de bloques cuando el escenario está en pantalla completa, reduciendo la sobrecarga de renderizado innecesaria del área de bloques.",
"plugins.editorOptimization.enablePixiLabel": "[Experimental] Habilitar renderizado acelerado por Pixi",
"plugins.editorOptimization.enablePixiDesc": "Utiliza PixiJS para renderizar el área de bloques como una textura, reduciendo drásticamente el número de nodos DOM y mejorando la fluidez al arrastrar/ampliar. La textura Pixi ofrece funciones interactivas limitadas; haz doble clic para restaurar la visualización DOM nativa.",
+ "plugins.editorOptimization.downloadCleanProject": "Descargar la versión del proyecto sin comentarios de grupo",
"plugins.debuggerAddon.title": "Depurador",
"plugins.debuggerAddon.description": "¡Depura felizmente en Gandi! Debe usarse con la extensión GandiTerminal",
"plugins.debuggerAddon.console": "Consola",
diff --git a/src/l10n/ms.json b/src/l10n/ms.json
index 09b7155..6f70942 100644
--- a/src/l10n/ms.json
+++ b/src/l10n/ms.json
@@ -295,6 +295,7 @@
"plugins.editorOptimization.enableFullscreenDesc": "Menyembunyikan kawasan blok apabila pentas dalam skrin penuh, mengurangkan overhed pemaparan kawasan blok yang tidak perlu.",
"plugins.editorOptimization.enablePixiLabel": "[Eksperimen] Dayakan pemaparan dipercepat Pixi",
"plugins.editorOptimization.enablePixiDesc": "Menggunakan PixiJS untuk memaparkan kawasan blok sebagai tekstur, mengurangkan secara drastik bilangan nod DOM dan meningkatkan kelancaran seret/zoom. Tekstur Pixi menyediakan fungsi interaktif terhad; klik dua kali untuk memulihkan paparan DOM asli.",
+ "plugins.editorOptimization.downloadCleanProject": "Muat turun versi projek tanpa ulasan kumpulan",
"plugins.debuggerAddon.title": "Penyahpepijat",
"plugins.debuggerAddon.description": "Debug dengan gembira di Gandi! Perlu digunakan dengan Sambungan GandiTerminal",
"plugins.debuggerAddon.console": "Konsol",
diff --git a/src/l10n/ru.json b/src/l10n/ru.json
index a1717d9..a15d286 100644
--- a/src/l10n/ru.json
+++ b/src/l10n/ru.json
@@ -313,5 +313,6 @@
"plugins.editorOptimization.enableFullscreenLabel": "[Экспериментально] Включить полноэкранную оптимизацию",
"plugins.editorOptimization.enableFullscreenDesc": "Скрывает область блоков при полноэкранном режиме сцены, уменьшая ненужную нагрузку на рендеринг области блоков.",
"plugins.editorOptimization.enablePixiLabel": "[Экспериментально] Включить ускоренный рендеринг Pixi",
- "plugins.editorOptimization.enablePixiDesc": "Использует PixiJS для рендеринга области блоков в виде текстуры, значительно снижая количество узлов DOM и повышая плавность перетаскивания/масштабирования. Текстура Pixi обеспечивает ограниченную интерактивность; двойной щелчок для восстановления нативного отображения DOM."
+ "plugins.editorOptimization.enablePixiDesc": "Использует PixiJS для рендеринга области блоков в виде текстуры, значительно снижая количество узлов DOM и повышая плавность перетаскивания/масштабирования. Текстура Pixi обеспечивает ограниченную интерактивность; двойной щелчок для восстановления нативного отображения DOM.",
+ "plugins.editorOptimization.downloadCleanProject": "Скачать версию проекта без групповых комментариев"
}
diff --git a/src/l10n/uk.json b/src/l10n/uk.json
index 8e25d3b..f702ff4 100644
--- a/src/l10n/uk.json
+++ b/src/l10n/uk.json
@@ -290,6 +290,7 @@
"plugins.editorOptimization.enableFullscreenDesc": "Приховує область блоків, коли сцена в повноекранному режимі, зменшуючи непотрібне навантаження на рендеринг області блоків.",
"plugins.editorOptimization.enablePixiLabel": "[Експериментально] Увімкнути прискорений рендеринг Pixi",
"plugins.editorOptimization.enablePixiDesc": "Використовує PixiJS для рендерингу області блоків у вигляді текстури, значно зменшуючи кількість вузлів DOM та підвищуючи плавність перетягування/масштабування. Текстура Pixi забезпечує обмежену інтерактивну функціональність; подвійне клацання для відновлення нативного відображення DOM.",
+ "plugins.editorOptimization.downloadCleanProject": "Завантажити версію проєкту без групових коментарів",
"plugins.debuggerAddon.title": "Відладник",
"plugins.debuggerAddon.description": "Відладжуйтеся з задоволенням у Gandi! Потрібне розширення GandiTerminal",
"plugins.debuggerAddon.console": "Консоль",
diff --git a/src/l10n/zh-cn.json b/src/l10n/zh-cn.json
index b610348..8f39b07 100644
--- a/src/l10n/zh-cn.json
+++ b/src/l10n/zh-cn.json
@@ -376,5 +376,6 @@
"plugins.editorOptimization.enableFullscreenLabel": "[实验] 启用全屏优化",
"plugins.editorOptimization.enableFullscreenDesc": "在舞台全屏时隐藏积木区,减少不必要的积木区渲染开销。",
"plugins.editorOptimization.enablePixiLabel": "[实验] 启用 Pixi 加速渲染",
- "plugins.editorOptimization.enablePixiDesc": "使用 PixiJS 将积木区渲染为纹理,大幅降低 DOM 节点数并提升拖拽/缩放流畅度。Pixi纹理提供受限的交互功能,通过双击以恢复原生DOM显示。"
+ "plugins.editorOptimization.enablePixiDesc": "使用 PixiJS 将积木区渲染为纹理,大幅降低 DOM 节点数并提升拖拽/缩放流畅度。Pixi纹理提供受限的交互功能,通过双击以恢复原生DOM显示。",
+ "plugins.editorOptimization.downloadCleanProject": "下载无分组注释版本作品"
}
diff --git a/src/plugins/editor-optimization/index.tsx b/src/plugins/editor-optimization/index.tsx
index eabc1fb..1a2c259 100644
--- a/src/plugins/editor-optimization/index.tsx
+++ b/src/plugins/editor-optimization/index.tsx
@@ -15,6 +15,7 @@ import Tooltip from "components/Tooltip";
import toast from "react-hot-toast";
import { Box, Input, IconButton } from "@gandi-ide/gandi-ui";
import * as PIXI from "pixi.js";
+import JSZip from "jszip";
import {
getGroups, getActiveGroupId, setActiveGroupId, addGroup, deleteGroup, renameGroup,
setBlockGroup, getBlockGroup, restoreBlockGroupFromXml, loadFromLocalStorage,
@@ -176,7 +177,73 @@ const EditorOptimizationInner: React.FC
= ({ vm, blockly, workspa
setEditingName("");
refreshGroups();
};
+ const downloadCleanedProject = async () => {
+ if (!vm) {
+ toast.error("未获取到虚拟机实例");
+ return;
+ }
+
+ try {
+ // 1. 调用 VM 自带的 saveProjectSb3 生成标准 SB3 Blob
+ const originalSb3Blob = await (vm as any).saveProjectSb3?.();
+ if (!originalSb3Blob) {
+ throw new Error("saveProjectSb3 不可用");
+ }
+
+ // 2. 用 JSZip 读取该压缩包
+ const zip = await JSZip.loadAsync(originalSb3Blob);
+ const projectFile = zip.file("project.json");
+ if (!projectFile) {
+ throw new Error("project.json 不存在");
+ }
+
+ // 3. 解析并清理 project.json
+ const projectJson = JSON.parse(await projectFile.async("text"));
+
+ // 删除积木的 comment 引用(分组注释)
+ projectJson.targets?.forEach((target: any) => {
+ if (target.blocks) {
+ Object.values(target.blocks).forEach((block: any) => {
+ if (block && block.comment) {
+ delete block.comment;
+ }
+ });
+ }
+ // 删除 comments 中带分组标记的条目
+ if (target.comments && typeof target.comments === "object") {
+ Object.keys(target.comments).forEach((commentId) => {
+ const comment = target.comments[commentId];
+ if (
+ comment &&
+ typeof comment.text === "string" &&
+ comment.text.includes("|EdiOpt|")
+ ) {
+ delete target.comments[commentId];
+ }
+ });
+ }
+ });
+ // 4. 重新写入 project.json
+ zip.file("project.json", JSON.stringify(projectJson));
+
+ // 5. 生成新的 Blob 并下载
+ const cleanedBlob = await zip.generateAsync({ type: "blob" });
+ const url = URL.createObjectURL(cleanedBlob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${(vm.runtime as any).getTargetForStage()?.getName?.() || "project"}_cleaned.sb3`;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+
+ toast.success("已下载过滤分组注释的作品");
+ } catch (error) {
+ console.error("下载失败", error);
+ toast.error("下载失败,请稍后重试");
+ }
+ };
// 设置注册(无 Fast Clear)
useEffect(() => {
if (!registerSettings) return;
@@ -956,6 +1023,9 @@ const EditorOptimizationInner: React.FC = ({ vm, blockly, workspa
{msg('plugins.editorOptimization.resetCache')}
+