简体   繁体   English

如何将 React 应用作为 Gmail 插件运行?

[英]How to run a React app as a Gmail Addon?

I'm trying to build a Gmail Addon using React.我正在尝试使用 React 构建 Gmail 插件。 The problem is, we have to write Gmail Addons using google Apps Script.问题是,我们必须使用 google Apps 脚本编写 Gmail 插件。 The reason I chose React is I already built a plugin for outlook using React.我选择 React 的原因是我已经使用 React 为 Outlook 构建了一个插件。 If I can use the same for Gmail then I can port the same plugin with minimal effort.如果我可以为 Gmail 使用相同的插件,那么我可以毫不费力地移植相同的插件。

In short , we can't do that. 简而言之,我们不能那样做。

Gmail add-on UI is rendered from a google server. Gmail附加用户界面是从Google服务器呈现的。 The code that we write rests on a server (unless you use clasp for local setup) and runs to render the UI. 我们编写的代码位于服务器上(除非您使用clasp进行本地设置),然后运行以呈现UI。 Also Gmail add-ons do not have access to the DOM. 此外,Gmail附加组件也无权访问DOM。

You can not use react in gmail addon, as gmail addon script runs on google cloud engine and the resulting html that is generated by the cardservice is returned to the client. 您无法在gmail插件中使用react,因为gmail插件脚本在Google云引擎上运行,并且cardservice生成的结果html返回给客户端。 For everyaction in the add on, it will go to google app script engine and run the script and return the result. 对于插件中的每个动作,它将转到google app脚本引擎并运行脚本并返回结果。

Is this still true in 2022 that it is simply not possible?这在 2022 年仍然是真的,这根本不可能吗?

I have the same requirements to build a Gmail Addon, with advanced Material UI components which are not included in the Gmail add-on UI offered.我对构建 Gmail 插件有相同的要求,使用高级材料 UI 组件,这些组件未包含在提供的 Gmail 插件 UI 中。

My plan was to use React inside custom HTMLService pages (its possible for eg Google Sheets) but I was not able to get it running with https://github.com/zennbrown/gas-react or https://github.com/enuchi/React-Google-Apps-Script我的计划是在自定义 HTMLService 页面中使用 React(例如 Google Sheets),但我无法使用https://github.com/zennbrown/gas-reacthttps://github.com/运行它enuchi/React-Google-Apps-Script

It would be awesome if someone had an idea of how to achieve this!如果有人知道如何实现这一目标,那就太棒了!

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

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