[英]Google Script Run Improve Performance with frontend calls in Apps Script
我正在為 Apps Script 的 google.script.run 響應時間而苦苦掙扎。 有一個 function 返回用戶權限,因為 boolean: initFunction() { // function code }
返回true 。
我前端的一些 div 顯示基於 initFunction boolean,我不知道為什么回調時間很慢(比如 4-5 秒)
索引.HTML
<script>
function check_permission () {
google.script.run.withSuccessHandler(function(data){
if (data === true) {
document.getElementById('hidden_div').style.display = 'block';
} else {
document.getElementById('hidden_div').style.display = 'none';
}
}).initFunction();
}
document.addEventListener('DOMContentLoaded', () => { check_permission() });
</script>
I've tried calling initFunction just after sidebar load function just to check the function time and it returns true in 0.5 seconds, so it's not about the function, i suppose it's about google.script.run
function sidebarLoad() {
let route = HtmlService.createTemplateFromFile('index').evaluate();
SpreadsheetApp.getUi().showSidebar(route);
let permission = initFunction(); SpreadsheetApp.getUi().alert(permission)
}
我該如何解決這個問題並減少響應時間?
編輯:閱讀您的評論后,我仍然不知道問題出在哪里,但我一直在做測試並且:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.