Google Apps脚本附录幻灯片非常慢

我正在尝试通过附加较小的演示文稿(3-4张幻灯片的模块)来创建新的较大的演示文稿。尽管我知道该怎么做,但是我发现性能并不令人满意。仅需花费4-5分钟即可完成最终演示文稿。我想知道是否有一种方法可以加快速度。有人可以看看我到目前为止的POC,指出我要去哪里了吗?非常感谢您的帮助!

//This function should run on open of document
function onOpen() {  
 var ui = SlidesApp
 .getUi()
 .createMenu('Modules')
 .addItem('Create new deck...', 'createNewDeck')
 .addToUi();
}

function createNewDeck() {
  var html = HtmlService
  .createHtmlOutputFromFile('Page')
  .setTitle('Training Deck Builder')
  .setWidth(300);
  
  SlidesApp
  .getUi() // Or DocumentApp or FormApp.
  .showSidebar(html);
}

function doSomething() {
  Logger.log('I just did something');
}

function addSlide(id) {
  Logger.log('We are going to add slide number ' + id);
  
  var currentPresentation = SlidesApp.getActivePresentation();
  var newPresentation = SlidesApp
  .openById(id)
  .getSlides();
  
  var slidesLength = newPresentation.length;
  for (var i = 0; i < slidesLength; i++) {
        currentPresentation.appendSlide(newPresentation[i])
      }
}
Hello, world! <br>
<ul>
<strong>Experimentation</strong>
<br>
<input class="slideDeck" type="checkbox" value="1E8hACPZz3HPYinMQgtGz6ijT2GeTTGOkAb44Y64Yepw" />1| Introduction | Intro<br>
<input class="slideDeck" type="checkbox" value="1j4zyaG-66mV5YMrKVi2YHQRvQMAvEXsXv9UqsMSlTqI" />2| Setup | JS Timing<br>
</ul>
<input type="button" id="submitButton" value="Create Slides" onclick="onSubmit()" />

<script>
function onSubmit() {
document.getElementById('submitButton').disabled = true;
try {
var slides = document.getElementsByClassName('slideDeck');
 [].forEach.call(slides, function (slide) {
  console.dir(slide.value);
  google.script.run.addSlide(slide.value);
 });
} catch(e) {
console.log(e);
}

}
</script>
回答如下:

您设法解决了这个问题吗?我也面临同样的挑战。

Google Apps脚本附录幻灯片非常慢

我正在尝试通过附加较小的演示文稿(3-4张幻灯片的模块)来创建新的较大的演示文稿。尽管我知道该怎么做,但是我发现性能并不令人满意。仅需花费4-5分钟即可完成最终演示文稿。我想知道是否有一种方法可以加快速度。有人可以看看我到目前为止的POC,指出我要去哪里了吗?非常感谢您的帮助!

//This function should run on open of document
function onOpen() {  
 var ui = SlidesApp
 .getUi()
 .createMenu('Modules')
 .addItem('Create new deck...', 'createNewDeck')
 .addToUi();
}

function createNewDeck() {
  var html = HtmlService
  .createHtmlOutputFromFile('Page')
  .setTitle('Training Deck Builder')
  .setWidth(300);
  
  SlidesApp
  .getUi() // Or DocumentApp or FormApp.
  .showSidebar(html);
}

function doSomething() {
  Logger.log('I just did something');
}

function addSlide(id) {
  Logger.log('We are going to add slide number ' + id);
  
  var currentPresentation = SlidesApp.getActivePresentation();
  var newPresentation = SlidesApp
  .openById(id)
  .getSlides();
  
  var slidesLength = newPresentation.length;
  for (var i = 0; i < slidesLength; i++) {
        currentPresentation.appendSlide(newPresentation[i])
      }
}
Hello, world! <br>
<ul>
<strong>Experimentation</strong>
<br>
<input class="slideDeck" type="checkbox" value="1E8hACPZz3HPYinMQgtGz6ijT2GeTTGOkAb44Y64Yepw" />1| Introduction | Intro<br>
<input class="slideDeck" type="checkbox" value="1j4zyaG-66mV5YMrKVi2YHQRvQMAvEXsXv9UqsMSlTqI" />2| Setup | JS Timing<br>
</ul>
<input type="button" id="submitButton" value="Create Slides" onclick="onSubmit()" />

<script>
function onSubmit() {
document.getElementById('submitButton').disabled = true;
try {
var slides = document.getElementsByClassName('slideDeck');
 [].forEach.call(slides, function (slide) {
  console.dir(slide.value);
  google.script.run.addSlide(slide.value);
 });
} catch(e) {
console.log(e);
}

}
</script>
回答如下:

您设法解决了这个问题吗?我也面临同样的挑战。