SelectionInput滞后/缓慢的UI性能

时间:2018-08-15 20:43:16

标签: google-apps-script

对于gmail插件,我有一个非常简单的脚本,但是我创建的任何SelectionInput小部件始终滞后。我不知道这是我的代码有问题还是仅仅是性能错误。

我添加了DROPDOWN SelectionInput小部件的gif。 Gif of using the SelectionInput Widget

这是我的清单文件:

{
  "timeZone": "GMT",
  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.addons.execute",
    "https://www.googleapis.com/auth/gmail.addons.current.message.readonly",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/script.storage"
  ],
  "gmail": {
    "version": "TRUSTED_TESTER_V2",
    "name": "Test Project",
    "logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/receipt_black_24dp.png",
    "contextualTriggers": [{
      "unconditional": {
      },
      "onTriggerFunction": "getContextualAddOn"
    }],
    "primaryColor": "#41f470",
    "secondaryColor": "#94f441"
  }
}

这是我的代码:

function getContextualAddOn(event) {
  var card = generateCards();
  return [card.build()];
}

function generateCards() {
  var card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle("RMA Number: "));

  var formSection = generateFormSection(CardService.newCardSection());
  card.addSection(formSection);

  return card
}

function generateFormSection(section) {

  var dropdown = CardService.newSelectionInput()
    .setType(CardService.SelectionInputType.DROPDOWN)
    .setTitle("Test Dropdown")
    .setFieldName("dropdown_field")
    .setOnChangeAction(CardService.newAction()
                        .setFunctionName("handleDropdownChange"))
    .addItem("Pending", "pending", true)
    .addItem("Complete", "complete", false)
    .addItem("N/A", "na", false);

  section.addWidget(dropdown);
  return section
}

0 个答案:

没有答案