We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在google 添加chrome.sidePanel.close()接口前,可以通过关闭程序页面的方式关闭sidePanel 该技巧来自(w3c/webextensions#515)) 1.在background.js中添加
let isSidePanelOpen = false; chrome.commands.onCommand.addListener((command) => { if (command === "toggle_extension") { if (isSidePanelOpen) { chrome.runtime.sendMessage('closeSidePanel'); } else { chrome.windows.getCurrent({}, (window) => { chrome.sidePanel.open({ windowId: window.id }); }); } isSidePanelOpen = !isSidePanelOpen; // 切换状态 } });
2.修改主页面
<script setup> import { onMounted } from 'vue'; onMounted(() => { chrome.runtime.onMessage.addListener(message => { if (message === 'closeSidePanel') { console.log("Close"); window.close(); } }) }); </script>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在google 添加chrome.sidePanel.close()接口前,可以通过关闭程序页面的方式关闭sidePanel
该技巧来自(w3c/webextensions#515))
1.在background.js中添加
2.修改主页面
The text was updated successfully, but these errors were encountered: