🎨 Add asset type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8895

This commit is contained in:
Daniel 2023-09-21 16:58:24 +08:00
parent be9d61c757
commit 0c05a06aaa
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 142 additions and 13 deletions

View file

@ -65,6 +65,7 @@ const (
KeyTypeURL KeyType = "url"
KeyTypeEmail KeyType = "email"
KeyTypePhone KeyType = "phone"
KeyTypeMAsset KeyType = "asset"
)
// Key 描述了属性视图属性列的基础结构。
@ -107,6 +108,7 @@ type Value struct {
URL *ValueURL `json:"url,omitempty"`
Email *ValueEmail `json:"email,omitempty"`
Phone *ValuePhone `json:"phone,omitempty"`
MAsset []*ValueAsset `json:"mAsset,omitempty"`
}
func (value *Value) String() string {
@ -131,6 +133,12 @@ func (value *Value) String() string {
return value.Email.Content
case KeyTypePhone:
return value.Phone.Content
case KeyTypeMAsset:
var ret []string
for _, v := range value.MAsset {
ret = append(ret, v.Content)
}
return strings.Join(ret, " ")
default:
return ""
}
@ -324,6 +332,19 @@ type ValuePhone struct {
Content string `json:"content"`
}
type AssetType string
const (
AssetTypeFile = "file"
AssetTypeImage = "image"
)
type ValueAsset struct {
Type AssetType `json:"type"`
Name string `json:"name"`
Content string `json:"content"`
}
// View 描述了视图的结构。
type View struct {
ID string `json:"id"` // 视图 ID