123456789101112131415161718192021222324252627 |
- // 监听扩展图标点击事件
- chrome.action.onClicked.addListener(async (tab) => {
- try {
- // 确保tab存在且有效
- if (!tab || !tab.id) {
- console.error('无效的标签页');
- return;
- }
- await chrome.tabs.sendMessage(tab.id, { action: "toggleSidebar" });
- } catch (error) {
- // 处理可能的错误,比如content script未加载等情况
- console.error('发送消息失败:', error);
- }
- });
- fetch('http://180.76.147.97:11435/api/chat', {
- method: 'post',
- body: JSON.stringify({
- model: "deepseek-r1:latest",
- messages: {
- "role": "user",
- "content": "why is the sky blue?"
- },
- stream: false
- })
- }).then(res => { console.log(res) })
|