Skip to content
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

/api/av/setAttributeViewBlockAttr 不会自动设置颜色 #13439

Closed
3 tasks done
Achuan-2 opened this issue Dec 11, 2024 · 8 comments
Closed
3 tasks done

/api/av/setAttributeViewBlockAttr 不会自动设置颜色 #13439

Achuan-2 opened this issue Dec 11, 2024 · 8 comments
Assignees

Comments

@Achuan-2
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

用api批量设置数据库绑定块的多选字段,发现不会自动添加颜色
PixPin_2024-12-11_22-52-14

Expected result

希望能自动设置多选项的颜色,而不需要指定

Screenshot or screen recording presentation

Version environment

- Version: 3.1.15
- Operating System: win11
- Browser (if used):

Log file

More information

No response

@TCOTC
Copy link
Contributor

TCOTC commented Dec 11, 2024

用开发者工具看看选项?


另外还需要注意颜色的范围 #13263 (comment)

@88250
Copy link
Member

88250 commented Dec 11, 2024

需要给一下实参

@Achuan-2
Copy link
Member Author

PixPin_2024-12-11_23-10-07

@TCOTC
Copy link
Contributor

TCOTC commented Dec 11, 2024

缺了颜色后面的数字

@Achuan-2
Copy link
Member Author

代码

// ------------设置属性 ------------ // 
await fetchSyncPost("/api/av/setAttributeViewBlockAttr", {
    avID: avID,
    keyID: keyID,
    rowID: docId,
    value: {
            "mSelect": [{"content":"Fiction7"}]
        },
});

@88250
Copy link
Member

88250 commented Dec 12, 2024

如果添加不存在的选项的话需要指定 color,如果是已经存在的会自动沿用。

image

稍后改进为没有指定 color 的话随机一个颜色:

image

@TCOTC
Copy link
Contributor

TCOTC commented Dec 12, 2024

我觉得应该用 1+rand.Intn(13)

@88250
Copy link
Member

88250 commented Dec 12, 2024

到 14 应该没问题,14 是默认值。

mouyase pushed a commit to mouyase/siyuan that referenced this issue Feb 28, 2025
mouyase pushed a commit to mouyase/siyuan that referenced this issue Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants