28fc3b409f2d4856513696e8e0ca346cd91d8a37
- 引入 ScriptManager、TimerManager 和 EventManager 统一管理资源 - 路由配置支持默认重定向路径 '/' - 移除旧版 scriptLoader 与 routeUtils,使用新的模块化加载机制 - 增加路由生命周期控制,自动清理定时器和事件监听器 - 改进点击代理逻辑,增强按钮激活状态切换 - 页面切换时卸载旧脚本及资源,防止内存泄漏 - 修复初始化日志冗余问题,提升代码可维护性
Using the Gemini API in a Chrome Extension.
This sample demonstrates how to use the Gemini Cloud API in a Chrome Extension.
Overview
The extension provides a chat interface for the Gemini API. To learn more about the API head over to https://ai.google.dev/.
Running this extension
- Clone this repository.
- Download the Gemini API client by running:
npm install - Retrieve an API key and update functional-samples/ai.gemini-in-the-cloud/sidepanel/index.js (only for testing).
- Compile the JS bundle for the sidepanel implementation by running:
npm run build - Load this directory in Chrome as an unpacked extension.
- Click the extension icon.
- Interact with the prompt API in the sidebar.
Languages
TypeScript
98.9%
CSS
0.5%
JavaScript
0.4%
HTML
0.2%