我们有一个通过侧边栏运行的 Google Workspace 插件,因此我们使用 homepageTrigger,以便用户可以从右侧菜单打开侧边栏。
这效果很好 - 但每个页面只加载一次 - 因此,如果用户打开侧边栏,关闭它并尝试通过右侧菜单重新打开,我们就会得到此页面:
我们如何让 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);
}
HTML 服务旨在与编辑器插件一起使用。对于工作区附加组件,请使用卡服务构建 UI。参考号附加组件类型。