简体   繁体   English

我可以禁用 Google 附加卡上的“返回”吗?

[英]Can I disable "Back" on a Google add-on card?

I'm building a Google add-on using Google Apps Script.我正在使用 Google Apps 脚本构建一个 Google 插件。

Is there any way to disable the Back button on a card (indicated below)?有什么方法可以禁用卡上的后退按钮(如下所示)?

在此处输入图像描述

Answer:回答:

This is not possible.这不可能。

More Information:更多信息:

From the documentation oncard navigation (emphasis my own):来自卡片导航的文档(强调我自己的):

...the 🡰 button is always available for the user to navigate from your contextual cards to your non-contextual cards. ... 🡰 按钮始终可供用户从上下文卡片导航到非上下文卡片。

I know this is generally bad news, but I hope this is helpful to you!我知道这通常是个坏消息,但我希望这对您有所帮助!

It is actually possible with a get around (might be a bit messy).这实际上是可能的(可能有点乱)。 Here is the way I did it in case someone is looking for this:如果有人正在寻找这个,这是我做的方式:

I manage all navigations from a card to another so that it doesn't stack the cards, but instead pop the current card and add the new one, so I always only have one card in the stack, therefore having no "back" button in the header of the card.我管理从一张卡片到另一张卡片的所有导航,这样它就不会堆叠卡片,而是弹出当前卡片并添加新卡片,所以我总是只有一张卡片在堆栈中,因此没有“后退”按钮卡的header。

So, appart from the homepage trigger from the manifest which return directly a card.build(), I navigate from card to card using a function such as:因此,从直接返回 card.build() 的清单的主页触发器开始,我使用 function 从一个卡导航到另一个卡,例如:

function showMainCard(e) {
    
  var card = buildMainCard();
  var nav = CardService.newNavigation().popCard().pushCard(card);
  var actionresponse =  CardService.newActionResponseBuilder()
        .setNavigation(nav);

  return actionresponse.build();  
}

And the build[something]Card() function returns the card.build()而 build[something]Card() function 返回 card.build()

The only drawback is that when the add-on is reloaded, it goes back to the first card you build in the homepage trigger.唯一的缺点是,当加载项重新加载时,它会返回到您在主页触发器中构建的第一张卡片。 In order to get around this, you need to save page navigation in userProperties when building each card.为了解决这个问题,您需要在构建每张卡片时在 userProperties 中保存页面导航。

Then, the homepageTrigger can work this way to load the right card:然后,homepageTrigger 可以通过这种方式加载正确的卡片:

function onLoad(e) {
  // Create the card
  switch (userProperties.getProperty("pageNavigation")) {
    case pages.MAIN:
      return buildMainCard();
    case pages.CREATE_NEW_FILE_REQUEST:
      return buildNewFileRequestCard();
    case pages.MANAGE_DEFAULT_OPTIONS:
      return buildManageDefaultOptionsCard();
    case pages.MANAGE_OPTIONS:
      return buildManageOptionsCard();
    case pages.CREATE_NEW_FILE_REQUEST_AFTER_AUTHORIZATION:
      return buildNewFileRequestCard();
    case pages.SHOW_FILE_REQUEST_DETAIL:
      return buildFileRequestDetailCard();
    case pages.EDIT_FILE_REQUEST:
      return buildEditFileRequestCard();
    default:
      console.log("Problem with navigation, main card is loaded");
      return buildMainCard();
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM