mirror of
https://github.com/langgenius/dify-plugins.git
synced 2026-07-22 01:55:36 -04:00
redbook-tst #203
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @feitengbj33 on GitHub (Aug 7, 2025).
Plugin Name
redbook插件
Function Description
`// 当插件图标被点击时,打开侧边栏
chrome.action.onClicked.addListener((tab) => {
chrome.sidePanel.open({tabId: tab.id});
});
// 监听来自popup或侧边栏的消息
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'getFeishuToken') {
// 获取飞书访问令牌
getFeishuToken(message.appId, message.appSecret)
.then(token => {
sendResponse({ success: true, token: token });
})
.catch(error => {
sendResponse({ success: false, error: error.message });
});
}
if (message.action === 'submitToFeishu') {
// 提交数据到飞书
submitToFeishu(
message.appToken,
message.tableId,
message.accessToken,
message.data
)
.then(result => {
sendResponse({ success: true, result: result });
})
.catch(error => {
sendResponse({ success: false, error: error.message });
});
}
});
// 获取飞书访问令牌
function getFeishuToken(appId, appSecret) {
return new Promise((resolve, reject) => {
fetch('https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
app_id: appId,
app_secret: appSecret
})
})
.then(response => response.json())
.then(data => {
if (data.code === 0 && data.tenant_access_token) {
resolve(data.tenant_access_token);
} else {
reject(new Error(data.msg || '获取飞书访问令牌失败'));
}
})
.catch(error => {
reject(new Error('网络请求失败: ' + error.message));
});
});
}
// 提交数据到飞书
function submitToFeishu(appToken, tableId, accessToken, data) {
return new Promise((resolve, reject) => {
fetch(
https://open.feishu.cn/open-apis/bitable/v1/apps/${appToken}/tables/${tableId}/records, {method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + accessToken
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => {
if (result.code === 0) {
resolve(result);
} else {
reject(new Error(result.msg || '提交数据到飞书失败'));
}
})
.catch(error => {
reject(new Error('网络请求失败: ' + error.message));
});
});
}`
Official Website URL
No response