HTML 服务不会在 V8 运行时打开侧边栏 [英] HTML Service does not open a sidebar in V8 runtime
问题描述
我有一个在 Rhino 上运行的非常大的项目,但是当我将其切换到 V8 时,其中一项基本功能就中断了 - 无法再打开 Google 表格中的侧边栏.
I have a very large project running on Rhino, but when I switch it to V8 one of the basic functionalities breaks - the sidebar in Google Sheets can no longer be opened.
基本架构:
A) 带有导入 GAS 库 (V8) 的脚本 (Rhino) 的 Google Sheet A.侧边栏位于库中.
A) Google Sheet A with a script (Rhino) importing a GAS Library (V8). The sidebar is in the Library.
对比
B) 带有导入 GAS 库 (V8) 的脚本 (V8) 的 Google Sheet B.侧边栏位于库中.
B) Google Sheet B with a script (V8) importing a GAS Library (V8). The sidebar is in the Library.
此代码在库中(独立脚本文件,在 V8 中运行):
This code is in the Library (standalone script file, running in V8):
// called from parent script as LIB.showSidebar()
function showSidebar() {
try {
var ui = HtmlService.createTemplateFromFile("sidebar/sidebarClient.html")
.evaluate()
.setTitle("tools sidebar");
SpreadsheetApp.getUi().showSidebar(ui);
} catch (error) {
var ui = SpreadsheetApp.getUi();
ui.alert("Couldn't render sidebar: " + error);
return;
}
}
之前的库函数是通过LIB"从父工作表 A/B 脚本运行的.命名空间描述符:
The previous library function is ran from the parent Sheet A/B script via the "LIB" namespace descriptor:
// simple trigger
function onOpen(e) {
buildMenu();
}
// builds menu
function buildMenu() {
SpreadsheetApp.getUi()
.createMenu("My menu")
.addItem("Open sidebar", "openSidebar")
.addToUi();
}
// opens sidebar
function openSidebar() {
LIB.showSidebar();
}
行为:
A) 一切正常,上面的代码按预期打开了工作表 A 中的侧边栏.
A) Everything works fine, the code above opens up the Sidebar in Sheet A as expected.
B) 结果是警报显示:
无法呈现侧边栏:异常:未找到."
"Couldn't render sidebar: Exception: Not found."
将 Sheet B 中的脚本切换回 Rhino 即可解决问题,并且侧边栏也会在 Sheet B 中打开.
Switching the script in Sheet B back to Rhino solves the issue, and the Sidebar opens in Sheet B too.
因此,问题在于切换到 V8.
Therefore, the issue is the switch to V8.
路径形式的文件名是否是 V8 上的问题(sidebar/sidebarClient.html")?我正在使用 clasp 将文件同步到子文件夹中 - 这确实是一个庞大的项目,我不能(或者拒绝)没有它.
Is the filename in the form of a path the issue on V8 ("sidebar/sidebarClient.html")? I'm using clasp to sync files into subfolders - it's really a huge project and I can't (or rather refuse to) do without that.
我尝试使用带和不带 .html 扩展名的文件名,以及带和不带路径的文件名.行为相同(文件路径sidebar/sidebarClient"、sidebar/sidebarClient.html"、sidebarClient"和sidebarClient.html"的所有变体的行为相同,在工作表 A 中打开,未找到在工作表 B 中).
I tried using the filename with and without the .html extension, and with and without the path. The behavior is the same (all variations of the file path "sidebar/sidebarClient", "sidebar/sidebarClient.html", "sidebarClient" and "sidebarClient.html" behave the same, opening in sheet A, not found in sheet B).
有人知道会发生什么吗?
Anyone got any ideas what might be going on?
推荐答案
我还在 Google 的问题跟踪器上打开了一个问题,目前仍未解决:https://issuetracker.google.com/issues/150054572
I also opened an issue on Google's Issue Tracker, currently still unresolved: https://issuetracker.google.com/issues/150054572
这篇关于HTML 服务不会在 V8 运行时打开侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!