如何让 Google Workspace 插件主页多次触发?

问题描述 投票:0回答:1

我们有一个通过侧边栏运行的 Google Workspace 插件,因此我们使用 homepageTrigger,以便用户可以从右侧菜单打开侧边栏。

这效果很好 - 但每个页面只加载一次 - 因此,如果用户打开侧边栏,关闭它并尝试通过右侧菜单重新打开,我们就会得到此页面:

enter image description here

我们如何让 homepageTrigger 函数每次都运行?

这是 appsscript.json:

{
  "timeZone": "Australia/Sydney",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "dependencies": {
    "enabledAdvancedServices": [
      {
        "userSymbol": "Drive",
        "serviceId": "drive",
        "version": "v2"
      }
    ]
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/documents.currentonly",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/presentations",
    "https://www.googleapis.com/auth/script.container.ui",
    "https://www.googleapis.com/auth/drive",
    "https://www.googleapis.com/auth/drive.apps.readonly",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.locale",
    "https://www.googleapis.com/auth/userinfo.email"
  ],
  "urlFetchWhitelist": [
    "https://cm234-wgs-1.icognition.cloud/",
    "https://docs.google.com/feeds/download/documents/export/Export",
    "https://docs.google.com/spreadsheets/export",
    "https://docs.google.com/feeds/download/presentations/Export"
  ],
  "addOns": {
    "common": {
      "name": "Content Manager",
      "logoUrl": "https://cm234-wgs-1.icognition.cloud/CMServiceApiGoogle/TrimIcon/W64h64/trim.png",
      "homepageTrigger": {
        "runFunction": "showSidebar",
        "enabled": true
      }
    },
    "sheets": {},
    "docs": {},
    "slides": {}
  }
}

这是它正在调用的函数(当我在此函数的开头添加日志行时,它只被调用一次):

function showSidebar() {
  var sidebarName = "sidebar";

  if (getRecordUri() !== 0) {
    sidebarName = "existing_record_sidebar";
  }

  var ui =
    HtmlService.createHtmlOutputFromFile(sidebarName).setTitle(
      "Content Manager",
    );
  getUi().showSidebar(ui);
}
triggers google-drive-api google-workspace-add-ons
1个回答
0
投票

HTML 服务旨在与编辑器插件一起使用。对于工作区附加组件,请使用卡服务构建 UI。参考号附加组件类型

© www.soinside.com 2019 - 2024. All rights reserved.