Google Forms 通知插件使用教程
1. 项目的目录结构及介绍
apps-script-form-notifications-addon/
├── authorizationEmail.html
├── about.html
├── Code.js
├── styles.css
└── README.md
- authorizationEmail.html: 用于授权邮件的HTML模板。
- about.html: 关于插件的介绍页面。
- Code.js: 插件的主要脚本文件,包含事件处理和功能实现。
- styles.css: 插件的样式文件,用于自定义外观。
- README.md: 项目的说明文档,包含安装和使用指南。
2. 项目的启动文件介绍
Code.js 是项目的启动文件,负责初始化插件和处理各种事件。以下是 Code.js
中的一些关键函数:
/**
* Adds a custom menu to the active form to show the add-on sidebar
* @param {object} e The event parameter for a simple onOpen trigger
*/
function onOpen(e) {
FormApp.getUi()
.createAddonMenu()
.addItem('Configure notifications', 'showSidebar')
.addToUi();
}
/**
* Shows the sidebar for configuring notifications
*/
function showSidebar() {
var ui = HtmlService.createHtmlOutputFromFile('about')
.setTitle('Form Notifications');
FormApp.getUi().showSidebar(ui);
}
- onOpen(e): 在表单打开时触发,添加自定义菜单项。
- showSidebar(): 显示配置通知的侧边栏。
3. 项目的配置文件介绍
authorizationEmail.html 和 about.html 是项目的配置文件,分别用于授权邮件和插件介绍。
authorizationEmail.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
</head>
<body>
<div>
<p>The Google Forms add-on <i>Form Notifications</i> is set to run automatically whenever a form is submitted. The add-on was recently updated and it needs you to re-authorize it to continue working.</p>
</div>
</body>
</html>
about.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
</head>
<body>
<div>
<p><i>Form Notifications</i> was created as an sample add-on and is meant for demonstration purposes only. It should not be used for complex or important workflows.</p>
</div>
</body>
</html>
这两个文件主要用于提供用户界面和授权信息,确保插件能够正常运行。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考