Skip to content

✨ feat: support adding to database automatically #21

New issue

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Achuan-2
Copy link
Member

PixPin_2025-05-12_00-50-06
添加功能

  • 添加数据库搜索框和选择框,选择要添加到哪个数据库
  • 剪藏后自动添加文档到对应数据库

Achuan-2 added 3 commits May 12, 2025 00:49
- 简化条件判断,确保只有在选择数据库时才添加
- 保持延迟机制以确保成功添加
@Achuan-2
Copy link
Member Author

目前可能需要改进的地方
background.js这里,调用添加到数据库的API,添加了1s delay(不然无法添加数据库,不知道为什么)

                        // 添加到数据库
                        if (requestData.selectedDatabaseID) {
                            const docId = response.data;
                            const dbInput = {
                                avID: requestData.selectedDatabaseID,
                                srcs: [{
                                    id: docId,
                                    isDetached: false,
                                }]
                            };
                            setTimeout(() => {
                                fetch(requestData.api + '/api/av/addAttributeViewBlocks', {
                                    method: 'POST',
                                    headers: {
                                        'Authorization': 'Token ' + requestData.token,
                                    },
                                    body: JSON.stringify(dbInput),
                                })
                            }, 1000); // 延迟 1 秒, 否则无法添加到数据库成功

                        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant