Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: Replace interface{} with any (#17415)

Jeffrey Chen5c674d7249a0
diff --git a/kernel/api/ai.go b/kernel/api/ai.go
index da318e40ed..fea32e145d 100644
--- a/kernel/api/ai.go
+++ b/kernel/api/ai.go
@@ -50,7 +50,7 @@ func chatGPTWithAction(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
diff --git a/kernel/api/asset.go b/kernel/api/asset.go
index 877ed268d1..59a43c603c 100644
--- a/kernel/api/asset.go
+++ b/kernel/api/asset.go
@@ -86,7 +86,7 @@ func statAsset(c *gin.Context) {
hCreated = t.BirthTime().Format("2006-01-02 15:04:05")
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"size": info.Size(),
"hSize": humanize.IBytesCustomCeil(uint64(info.Size()), 2),
"created": created,
@@ -114,7 +114,7 @@ func getImageOCRText(c *gin.Context) {
var path string
if nil == arg["path"] {
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"text": "",
}
return
@@ -122,7 +122,7 @@ func getImageOCRText(c *gin.Context) {
path = arg["path"].(string)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"text": util.GetAssetText(path),
}
}
@@ -164,11 +164,11 @@ func ocr(c *gin.Context) {
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"text": util.GetOcrJsonText(ocrJSON),
"ocrJSON": ocrJSON,
}
@@ -189,10 +189,10 @@ func renameAsset(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"newPath": newPath,
}
}
@@ -293,7 +293,7 @@ func getFileAnnotation(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
if !filelock.IsExist(readPath) {
@@ -307,7 +307,7 @@ func getFileAnnotation(c *gin.Context) {
ret.Msg = err.Error()
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"data": string(data),
}
}
@@ -335,7 +335,7 @@ func removeUnusedAsset(c *gin.Context) {
p := arg["path"].(string)
asset := model.RemoveUnusedAsset(p)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": asset,
}
}
@@ -345,7 +345,7 @@ func removeUnusedAssets(c *gin.Context) {
defer c.JSON(http.StatusOK, ret)
paths := model.RemoveUnusedAssets()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"paths": paths,
}
}
@@ -389,7 +389,7 @@ func resolveAssetPath(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 3000}
+ ret.Data = map[string]any{"closeTimeout": 3000}
return
}
ret.Data = p
@@ -415,7 +415,7 @@ func uploadCloud(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 3000}
+ ret.Data = map[string]any{"closeTimeout": 3000}
return
}
@@ -437,7 +437,7 @@ func uploadCloudByAssetsPaths(c *gin.Context) {
return
}
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var assets []string
for _, pathArg := range pathsArg {
assets = append(assets, pathArg.(string))
@@ -452,7 +452,7 @@ func uploadCloudByAssetsPaths(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 3000}
+ ret.Data = map[string]any{"closeTimeout": 3000}
return
}
@@ -470,7 +470,7 @@ func insertLocalAssets(c *gin.Context) {
return
}
- assetPathsArg := arg["assetPaths"].([]interface{})
+ assetPathsArg := arg["assetPaths"].([]any)
var assetPaths []string
for _, pathArg := range assetPathsArg {
assetPaths = append(assetPaths, pathArg.(string))
@@ -487,7 +487,7 @@ func insertLocalAssets(c *gin.Context) {
ret.Msg = err.Error()
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"succMap": succMap,
}
}
diff --git a/kernel/api/attr.go b/kernel/api/attr.go
index 6e5f9a36d0..4611e9c217 100644
--- a/kernel/api/attr.go
+++ b/kernel/api/attr.go
@@ -44,7 +44,7 @@ func batchGetBlockAttrs(c *gin.Context) {
return
}
- ids := arg["ids"].([]interface{})
+ ids := arg["ids"].([]any)
var idList []string
for _, id := range ids {
idList = append(idList, id.(string))
@@ -84,7 +84,7 @@ func setBlockAttrs(c *gin.Context) {
return
}
- attrs := arg["attrs"].(map[string]interface{})
+ attrs := arg["attrs"].(map[string]any)
if 1 == len(attrs) && "" != attrs["scroll"] {
// 不记录用户指南滚动位置
if b := treenode.GetBlockTree(id); nil != b && (model.IsUserGuide(b.BoxID)) {
@@ -123,16 +123,16 @@ func batchSetBlockAttrs(c *gin.Context) {
return
}
- blockAttrsArg := arg["blockAttrs"].([]interface{})
- var blockAttrs []map[string]interface{}
+ blockAttrsArg := arg["blockAttrs"].([]any)
+ var blockAttrs []map[string]any
for _, blockAttrArg := range blockAttrsArg {
- blockAttr := blockAttrArg.(map[string]interface{})
+ blockAttr := blockAttrArg.(map[string]any)
id := blockAttr["id"].(string)
if util.InvalidIDPattern(id, ret) {
return
}
- attrs := blockAttr["attrs"].(map[string]interface{})
+ attrs := blockAttr["attrs"].(map[string]any)
nameValues := map[string]string{}
for name, value := range attrs {
if nil == value {
@@ -148,7 +148,7 @@ func batchSetBlockAttrs(c *gin.Context) {
}
}
- blockAttrs = append(blockAttrs, map[string]interface{}{
+ blockAttrs = append(blockAttrs, map[string]any{
"id": id,
"attrs": nameValues,
})
@@ -172,7 +172,7 @@ func resetBlockAttrs(c *gin.Context) {
}
id := arg["id"].(string)
- attrs := arg["attrs"].(map[string]interface{})
+ attrs := arg["attrs"].(map[string]any)
nameValues := map[string]string{}
for name, value := range attrs {
if nil == value {
diff --git a/kernel/api/av.go b/kernel/api/av.go
index 49cf7b1227..651145cdb9 100644
--- a/kernel/api/av.go
+++ b/kernel/api/av.go
@@ -40,7 +40,7 @@ func removeUnusedAttributeView(c *gin.Context) {
avID := arg["id"].(string)
model.RemoveUnusedAttributeView(avID)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": avID,
}
}
@@ -50,7 +50,7 @@ func removeUnusedAttributeViews(c *gin.Context) {
defer c.JSON(http.StatusOK, ret)
paths := model.RemoveUnusedAttributeViews()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"paths": paths,
}
}
@@ -81,7 +81,7 @@ func getAttributeViewItemIDsByBoundIDs(c *gin.Context) {
}
avID := arg["avID"].(string)
- blockIDsArg := arg["blockIDs"].([]interface{})
+ blockIDsArg := arg["blockIDs"].([]any)
var blockIDs []string
for _, v := range blockIDsArg {
blockIDs = append(blockIDs, v.(string))
@@ -100,7 +100,7 @@ func getAttributeViewBoundBlockIDsByItemIDs(c *gin.Context) {
}
avID := arg["avID"].(string)
- itemIDsArg := arg["itemIDs"].([]interface{})
+ itemIDsArg := arg["itemIDs"].([]any)
var itemIDs []string
for _, v := range itemIDsArg {
itemIDs = append(itemIDs, v.(string))
@@ -142,7 +142,7 @@ func getAttributeViewAddingBlockDefaultValues(c *gin.Context) {
if 1 > len(values) {
values = nil
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"values": values,
}
}
@@ -159,10 +159,10 @@ func batchReplaceAttributeViewBlocks(c *gin.Context) {
avID := arg["avID"].(string)
isDetached := arg["isDetached"].(bool)
- oldNewArg := arg["oldNew"].([]interface{})
+ oldNewArg := arg["oldNew"].([]any)
var oldNew []map[string]string
for _, v := range oldNewArg {
- for o, n := range v.(map[string]interface{}) {
+ for o, n := range v.(map[string]any) {
oldNew = append(oldNew, map[string]string{o: n.(string)})
}
}
@@ -187,7 +187,7 @@ func setAttrViewGroup(c *gin.Context) {
avID := arg["avID"].(string)
blockID := arg["blockID"].(string)
- groupArg := arg["group"].(map[string]interface{})
+ groupArg := arg["group"].(map[string]any)
data, err := gulu.JSON.MarshalJSON(groupArg)
if nil != err {
@@ -216,7 +216,7 @@ func setAttrViewGroup(c *gin.Context) {
ret = renderAttrView(blockID, avID, "", "", 1, -1, nil, false)
if ret.Code == 0 && model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
- retDataMap := ret.Data.(map[string]interface{})
+ retDataMap := ret.Data.(map[string]any)
retDataMap["view"] = model.FilterViewByPublishAccess(c, publishAccess, retDataMap["view"].(av.Viewable))
}
@@ -245,7 +245,7 @@ func changeAttrViewLayout(c *gin.Context) {
ret = renderAttrView(blockID, avID, "", "", 1, -1, nil, false)
if ret.Code == 0 && model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
- retDataMap := ret.Data.(map[string]interface{})
+ retDataMap := ret.Data.(map[string]any)
retDataMap["view"] = model.FilterViewByPublishAccess(c, publishAccess, retDataMap["view"].(av.Viewable))
}
@@ -269,7 +269,7 @@ func duplicateAttributeViewBlock(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"avID": newAvID,
"blockID": newBlockID,
}
@@ -296,7 +296,7 @@ func getAttributeViewKeysByID(c *gin.Context) {
return
}
avID := arg["avID"].(string)
- keyIDsArg := arg["keyIDs"].([]interface{})
+ keyIDsArg := arg["keyIDs"].([]any)
var keyIDs []string
for _, v := range keyIDsArg {
keyIDs = append(keyIDs, v.(string))
@@ -382,7 +382,7 @@ func getAttributeViewPrimaryKeyValues(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": attributeViewName,
"blockIDs": databaseBlockIDs,
"rows": rows,
@@ -402,8 +402,8 @@ func appendAttributeViewDetachedBlocksWithValues(c *gin.Context) {
avID := arg["avID"].(string)
var values [][]*av.Value
- for _, blocksVals := range arg["blocksValues"].([]interface{}) {
- vals := blocksVals.([]interface{})
+ for _, blocksVals := range arg["blocksValues"].([]any) {
+ vals := blocksVals.([]any)
var rowValues []*av.Value
for _, val := range vals {
data, marshalErr := gulu.JSON.MarshalJSON(val)
@@ -458,9 +458,9 @@ func addAttributeViewBlocks(c *gin.Context) {
previousID = arg["previousID"].(string)
}
- var srcs []map[string]interface{}
- for _, v := range arg["srcs"].([]interface{}) {
- src := v.(map[string]interface{})
+ var srcs []map[string]any
+ for _, v := range arg["srcs"].([]any) {
+ src := v.(map[string]any)
srcs = append(srcs, src)
}
@@ -490,7 +490,7 @@ func removeAttributeViewBlocks(c *gin.Context) {
avID := arg["avID"].(string)
var srcIDs []string
- for _, v := range arg["srcIDs"].([]interface{}) {
+ for _, v := range arg["srcIDs"].([]any) {
srcIDs = append(srcIDs, v.(string))
}
@@ -619,7 +619,7 @@ func getAttributeViewFilterSort(c *gin.Context) {
blockID := arg["blockID"].(string)
filters, sorts := model.GetAttributeViewFilterSort(avID, blockID)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"filters": filters,
"sorts": sorts,
}
@@ -638,7 +638,7 @@ func searchAttributeViewNonRelationKey(c *gin.Context) {
keyword := arg["keyword"].(string)
nonRelationKeys := model.SearchAttributeViewNonRelationKey(avID, keyword)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"keys": nonRelationKeys,
}
}
@@ -656,7 +656,7 @@ func searchAttributeViewRollupDestKeys(c *gin.Context) {
keyword := arg["keyword"].(string)
rollupDestKeys := model.SearchAttributeViewRollupDestKeys(avID, keyword)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"keys": rollupDestKeys,
}
}
@@ -674,7 +674,7 @@ func searchAttributeViewRelationKey(c *gin.Context) {
keyword := arg["keyword"].(string)
relationKeys := model.SearchAttributeViewRelationKey(avID, keyword)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"keys": relationKeys,
}
}
@@ -689,7 +689,7 @@ func getAttributeView(c *gin.Context) {
}
id := arg["id"].(string)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"av": model.GetAttributeView(id),
}
}
@@ -706,12 +706,12 @@ func searchAttributeView(c *gin.Context) {
keyword := arg["keyword"].(string)
var excludes []string
if nil != arg["excludes"] {
- for _, e := range arg["excludes"].([]interface{}) {
+ for _, e := range arg["excludes"].([]any) {
excludes = append(excludes, e.(string))
}
}
results := model.SearchAttributeView(keyword, excludes)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"results": results,
}
}
@@ -747,7 +747,7 @@ func renderSnapshotAttributeView(c *gin.Context) {
})
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": attrView.Name,
"id": attrView.ID,
"viewType": view.GetType(),
@@ -797,10 +797,10 @@ func renderHistoryAttributeView(c *gin.Context) {
query = queryArg.(string)
}
- groupPaging := map[string]interface{}{}
+ groupPaging := map[string]any{}
groupPagingArg := arg["groupPaging"]
if nil != groupPagingArg {
- groupPaging = groupPagingArg.(map[string]interface{})
+ groupPaging = groupPagingArg.(map[string]any)
}
view, attrView, err := model.RenderHistoryAttributeView(blockID, id, viewID, query, page, pageSize, groupPaging, created)
@@ -823,7 +823,7 @@ func renderHistoryAttributeView(c *gin.Context) {
})
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": attrView.Name,
"id": attrView.ID,
"viewType": view.GetType(),
@@ -871,10 +871,10 @@ func renderAttributeView(c *gin.Context) {
query = queryArg.(string)
}
- groupPaging := map[string]interface{}{}
+ groupPaging := map[string]any{}
groupPagingArg := arg["groupPaging"]
if nil != groupPagingArg {
- groupPaging = groupPagingArg.(map[string]interface{})
+ groupPaging = groupPagingArg.(map[string]any)
}
createIfNotExist := true
@@ -886,14 +886,14 @@ func renderAttributeView(c *gin.Context) {
ret = renderAttrView(blockID, id, viewID, query, page, pageSize, groupPaging, createIfNotExist)
if ret.Code == 0 && model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
- retDataMap := ret.Data.(map[string]interface{})
+ retDataMap := ret.Data.(map[string]any)
retDataMap["view"] = model.FilterViewByPublishAccess(c, publishAccess, retDataMap["view"].(av.Viewable))
}
c.JSON(http.StatusOK, ret)
}
-func renderAttrView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]interface{}, createIfNotExist bool) (ret *gulu.Result) {
+func renderAttrView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]any, createIfNotExist bool) (ret *gulu.Result) {
ret = gulu.Ret.NewResult()
view, attrView, err := model.RenderAttributeView(blockID, avID, viewID, query, page, pageSize, groupPaging, createIfNotExist)
if err != nil {
@@ -915,7 +915,7 @@ func renderAttrView(blockID, avID, viewID, query string, page, pageSize int, gro
})
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": attrView.Name,
"id": attrView.ID,
"viewType": view.GetType(),
@@ -996,7 +996,7 @@ func setAttributeViewBlockAttr(c *gin.Context) {
logging.LogWarnf("[%s] parameter [%s] is deprecated, it will be removed at [%s], visit [https://github.com/siyuan-note/siyuan/issues/15727] for details",
c.Request.RequestURI, "rowID", "2026-06-30")
}
- value := arg["value"].(interface{})
+ value := arg["value"].(any)
updatedVal, err := model.UpdateAttributeViewCell(nil, avID, keyID, itemID, value)
if err != nil {
ret.Code = -1
@@ -1004,7 +1004,7 @@ func setAttributeViewBlockAttr(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"value": updatedVal,
}
@@ -1022,7 +1022,7 @@ func batchSetAttributeViewBlockAttrs(c *gin.Context) {
}
avID := arg["avID"].(string)
- values := arg["values"].([]interface{})
+ values := arg["values"].([]any)
err := model.BatchUpdateAttributeViewCells(nil, avID, values)
if err != nil {
ret.Code = -1
diff --git a/kernel/api/bazaar.go b/kernel/api/bazaar.go
index d8fb93e2b3..36c1197401 100644
--- a/kernel/api/bazaar.go
+++ b/kernel/api/bazaar.go
@@ -64,7 +64,7 @@ func getUpdatedPackage(c *gin.Context) {
}
plugins, widgets, icons, themes, templates := model.GetUpdatedPackages(frontend)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"plugins": plugins,
"widgets": widgets,
"icons": icons,
@@ -95,7 +95,7 @@ func getBazaarPackageREADME(c *gin.Context) {
ret.Msg = "Invalid package type"
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"html": model.GetBazaarPackageREADME(c.Request.Context(), repoURL, repoHash, pkgType),
}
}
@@ -117,7 +117,7 @@ func getBazaarPlugin(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("plugins", frontend, keyword),
}
}
@@ -139,7 +139,7 @@ func getInstalledPlugin(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetInstalledPackages("plugins", frontend, keyword),
}
}
@@ -171,7 +171,7 @@ func installBazaarPlugin(c *gin.Context) {
}
util.PushMsg(model.Conf.Language(69), 3000)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("plugins", frontend, keyword),
}
}
@@ -227,7 +227,7 @@ func getBazaarWidget(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("widgets", "", keyword),
}
}
@@ -246,7 +246,7 @@ func getInstalledWidget(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetInstalledPackages("widgets", "", keyword),
}
}
@@ -277,7 +277,7 @@ func installBazaarWidget(c *gin.Context) {
}
util.PushMsg(model.Conf.Language(69), 3000)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("widgets", "", keyword),
}
}
@@ -305,7 +305,7 @@ func uninstallBazaarWidget(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("widgets", "", keyword),
}
}
@@ -324,7 +324,7 @@ func getBazaarIcon(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("icons", "", keyword),
}
}
@@ -343,7 +343,7 @@ func getInstalledIcon(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetInstalledPackages("icons", "", keyword),
}
}
@@ -374,7 +374,7 @@ func installBazaarIcon(c *gin.Context) {
}
util.PushMsg(model.Conf.Language(69), 3000)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("icons", "", keyword),
"appearance": model.Conf.Appearance,
}
@@ -403,7 +403,7 @@ func uninstallBazaarIcon(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("icons", "", keyword),
"appearance": model.Conf.Appearance,
}
@@ -423,7 +423,7 @@ func getBazaarTemplate(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("templates", "", keyword),
}
}
@@ -442,7 +442,7 @@ func getInstalledTemplate(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetInstalledPackages("templates", "", keyword),
}
}
@@ -472,7 +472,7 @@ func installBazaarTemplate(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("templates", "", keyword),
}
@@ -502,7 +502,7 @@ func uninstallBazaarTemplate(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("templates", "", keyword),
}
}
@@ -521,7 +521,7 @@ func getBazaarTheme(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("themes", "", keyword),
}
}
@@ -540,7 +540,7 @@ func getInstalledTheme(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetInstalledPackages("themes", "", keyword),
}
}
@@ -578,7 +578,7 @@ func installBazaarTheme(c *gin.Context) {
model.Conf.Save()
util.PushMsg(model.Conf.Language(69), 3000)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("themes", "", keyword),
"appearance": model.Conf.Appearance,
}
@@ -607,7 +607,7 @@ func uninstallBazaarTheme(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"packages": model.GetBazaarPackages("themes", "", keyword),
"appearance": model.Conf.Appearance,
}
diff --git a/kernel/api/block.go b/kernel/api/block.go
index 8f9d3f4030..bd4c088223 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -41,7 +41,7 @@ func checkBlockRef(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -61,7 +61,7 @@ func getBlockTreeInfos(c *gin.Context) {
}
var ids []string
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
for _, id := range idsArg {
ids = append(ids, id.(string))
}
@@ -101,7 +101,7 @@ func getBlockRelevantIDs(c *gin.Context) {
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -137,7 +137,7 @@ func transferBlockRef(c *gin.Context) {
var refIDs []string
if nil != arg["refIDs"] {
- for _, refID := range arg["refIDs"].([]interface{}) {
+ for _, refID := range arg["refIDs"].([]any) {
refIDs = append(refIDs, refID.(string))
}
}
@@ -146,7 +146,7 @@ func transferBlockRef(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -171,7 +171,7 @@ func swapBlockRef(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -237,7 +237,7 @@ func getHeadingDeleteTransaction(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -259,7 +259,7 @@ func getHeadingInsertTransaction(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -282,7 +282,7 @@ func getHeadingLevelTransaction(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -304,7 +304,7 @@ func setBlockReminder(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -320,7 +320,7 @@ func getUnfoldedParentID(c *gin.Context) {
id := arg["id"].(string)
parentID := model.GetUnfoldedParentID(id)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"parentID": parentID,
}
}
@@ -336,7 +336,7 @@ func checkBlockFold(c *gin.Context) {
id := arg["id"].(string)
isFolded, isRoot := model.IsBlockFolded(id)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"isFolded": isFolded,
"isRoot": isRoot,
}
@@ -392,7 +392,7 @@ func getDocsInfo(c *gin.Context) {
if !ok {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -451,7 +451,7 @@ func getBlocksWordCount(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -583,7 +583,7 @@ func getBlockDefIDsByRefText(c *gin.Context) {
}
anchor := arg["anchor"].(string)
- excludeIDsArg := arg["excludeIDs"].([]interface{})
+ excludeIDsArg := arg["excludeIDs"].([]any)
var excludeIDs []string
for _, excludeID := range excludeIDsArg {
excludeIDs = append(excludeIDs, excludeID.(string))
@@ -616,7 +616,7 @@ func getBlockBreadcrumb(c *gin.Context) {
excludeTypesArg := arg["excludeTypes"]
var excludeTypes []string
if nil != excludeTypesArg {
- for _, excludeType := range excludeTypesArg.([]interface{}) {
+ for _, excludeType := range excludeTypesArg.([]any) {
excludeTypes = append(excludeTypes, excludeType.(string))
}
}
@@ -654,7 +654,7 @@ func getBlocksIndexes(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -772,7 +772,7 @@ func getBlockDOMs(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -840,7 +840,7 @@ func getBlockDOMsWithEmbed(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -925,7 +925,7 @@ func getBlockKramdowns(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
idStr := id.(string)
diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go
index 955da40107..7694f7c15c 100644
--- a/kernel/api/block_op.go
+++ b/kernel/api/block_op.go
@@ -226,7 +226,7 @@ func unfoldBlock(c *gin.Context) {
},
}
} else {
- data, _ := gulu.JSON.MarshalJSON(map[string]interface{}{"fold": ""})
+ data, _ := gulu.JSON.MarshalJSON(map[string]any{"fold": ""})
transactions = []*model.Transaction{
{
DoOperations: []*model.Operation{
@@ -286,7 +286,7 @@ func foldBlock(c *gin.Context) {
},
}
} else {
- data, _ := gulu.JSON.MarshalJSON(map[string]interface{}{"fold": "1"})
+ data, _ := gulu.JSON.MarshalJSON(map[string]any{"fold": "1"})
transactions = []*model.Transaction{
{
DoOperations: []*model.Operation{
@@ -437,11 +437,11 @@ func batchAppendBlock(c *gin.Context) {
return
}
- blocksArg := arg["blocks"].([]interface{})
+ blocksArg := arg["blocks"].([]any)
var transactions []*model.Transaction
luteEngine := util.NewLute()
for _, blockArg := range blocksArg {
- blockMap := blockArg.(map[string]interface{})
+ blockMap := blockArg.(map[string]any)
data := blockMap["data"].(string)
dataType := blockMap["dataType"].(string)
parentID := blockMap["parentID"].(string)
@@ -530,11 +530,11 @@ func batchPrependBlock(c *gin.Context) {
return
}
- blocksArg := arg["blocks"].([]interface{})
+ blocksArg := arg["blocks"].([]any)
var transactions []*model.Transaction
luteEngine := util.NewLute()
for _, blockArg := range blocksArg {
- blockMap := blockArg.(map[string]interface{})
+ blockMap := blockArg.(map[string]any)
data := blockMap["data"].(string)
dataType := blockMap["dataType"].(string)
parentID := blockMap["parentID"].(string)
@@ -684,7 +684,7 @@ func updateBlock(c *gin.Context) {
var ops []*model.Operation
for n := oldTree.Root.FirstChild; nil != n; n = n.Next {
toRemoves = append(toRemoves, n)
- ops = append(ops, &model.Operation{Action: "delete", ID: n.ID, Data: map[string]interface{}{
+ ops = append(ops, &model.Operation{Action: "delete", ID: n.ID, Data: map[string]any{
"createEmptyParagraph": false, // 清空文档后前端不要创建空段落
}})
}
@@ -740,11 +740,11 @@ func batchInsertBlock(c *gin.Context) {
return
}
- blocksArg := arg["blocks"].([]interface{})
+ blocksArg := arg["blocks"].([]any)
var transactions []*model.Transaction
luteEngine := util.NewLute()
for _, blockArg := range blocksArg {
- blockMap := blockArg.(map[string]interface{})
+ blockMap := blockArg.(map[string]any)
data := blockMap["data"].(string)
dataType := blockMap["dataType"].(string)
var parentID, previousID, nextID string
@@ -822,7 +822,7 @@ func batchUpdateBlock(c *gin.Context) {
var blocks []*updateBlockArg
luteEngine := util.NewLute()
for _, blockArg := range blocksArg {
- blockMap := blockArg.(map[string]interface{})
+ blockMap := blockArg.(map[string]any)
id := blockMap["id"].(string)
if util.InvalidIDPattern(id, ret) {
return
@@ -881,7 +881,7 @@ func batchUpdateBlock(c *gin.Context) {
for n := oldTree.Root.FirstChild; nil != n; n = n.Next {
toRemoves = append(toRemoves, n)
- ops = append(ops, &model.Operation{Action: "delete", ID: n.ID, Data: map[string]interface{}{
+ ops = append(ops, &model.Operation{Action: "delete", ID: n.ID, Data: map[string]any{
"createEmptyParagraph": false, // 清空文档后前端不要创建空段落
}})
}
diff --git a/kernel/api/bookmark.go b/kernel/api/bookmark.go
index 2d452c4342..acc9234449 100644
--- a/kernel/api/bookmark.go
+++ b/kernel/api/bookmark.go
@@ -61,7 +61,7 @@ func removeBookmark(c *gin.Context) {
if err := model.RemoveBookmark(bookmark); err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -85,7 +85,7 @@ func renameBookmark(c *gin.Context) {
if err := model.RenameBookmark(oldBookmark, newBookmark); err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
diff --git a/kernel/api/broadcast.go b/kernel/api/broadcast.go
index 1f6bc41bd9..589742a879 100644
--- a/kernel/api/broadcast.go
+++ b/kernel/api/broadcast.go
@@ -120,7 +120,7 @@ func (b *BroadcastChannel) HandleRequest(c *gin.Context) {
if err := b.WebSocket.HandleRequestWithKeys(
c.Writer,
c.Request,
- map[string]interface{}{
+ map[string]any{
"channel": b.Name,
},
); err != nil {
@@ -684,7 +684,7 @@ func broadcastPublish(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"results": results,
}
}
@@ -745,7 +745,7 @@ func postMessage(c *gin.Context) {
return
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"channel": channel,
}
}
@@ -796,7 +796,7 @@ func getChannelInfo(c *gin.Context) {
channel.Count = broadcastChannel.SubscriberCount()
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"channel": channel,
}
}
@@ -828,7 +828,7 @@ func getChannels(c *gin.Context) {
})
return true
})
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"channels": channels,
}
}
diff --git a/kernel/api/clipboard.go b/kernel/api/clipboard.go
index d739ac74f9..d4b7ab9c68 100644
--- a/kernel/api/clipboard.go
+++ b/kernel/api/clipboard.go
@@ -75,7 +75,7 @@ func writeFilePath(c *gin.Context) {
logging.LogErrorf("get asset [%s] abs path failed: %s", pathArg, err)
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -83,7 +83,7 @@ func writeFilePath(c *gin.Context) {
logging.LogErrorf("write file path to clipboard failed: %s", err)
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
diff --git a/kernel/api/export.go b/kernel/api/export.go
index 657c88e1b2..c06060659a 100644
--- a/kernel/api/export.go
+++ b/kernel/api/export.go
@@ -55,11 +55,11 @@ func exportCodeBlock(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": filePath,
}
}
@@ -84,11 +84,11 @@ func exportAttributeView(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -107,7 +107,7 @@ func exportEPUB(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "epub", ".epub")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -127,7 +127,7 @@ func exportRTF(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "rtf", ".rtf")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -147,7 +147,7 @@ func exportODT(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "odt", ".odt")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -167,7 +167,7 @@ func exportMediaWiki(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "mediawiki", ".wiki")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -187,7 +187,7 @@ func exportOrgMode(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "org", ".org")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -207,7 +207,7 @@ func exportOPML(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "opml", ".opml")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -227,7 +227,7 @@ func exportTextile(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "textile", ".textile")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -247,7 +247,7 @@ func exportAsciiDoc(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "asciidoc", ".adoc")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -267,7 +267,7 @@ func exportReStructuredText(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "rst", ".rst")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -311,10 +311,10 @@ func exportDataInFolder(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
}
}
@@ -327,10 +327,10 @@ func exportData(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -360,7 +360,7 @@ func exportResources(c *gin.Context) {
}
var resourcePaths []string // 文件/文件夹在工作空间中的路径
- for _, resourcePath := range arg["paths"].([]interface{}) {
+ for _, resourcePath := range arg["paths"].([]any) {
resourcePaths = append(resourcePaths, resourcePath.(string))
}
@@ -368,10 +368,10 @@ func exportResources(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": zipFilePath, // 相对于工作空间目录的路径
}
}
@@ -390,7 +390,7 @@ func exportNotebookMd(c *gin.Context) {
return
}
zipPath := model.ExportNotebookMarkdown(notebook)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": path.Base(zipPath),
"zip": zipPath,
}
@@ -405,14 +405,14 @@ func exportMds(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
name, zipPath := model.ExportPandocConvertZip(ids, "", ".md")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -432,7 +432,7 @@ func exportMd(c *gin.Context) {
return
}
name, zipPath := model.ExportPandocConvertZip([]string{id}, "", ".md")
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -452,7 +452,7 @@ func exportNotebookSY(c *gin.Context) {
return
}
zipPath := model.ExportNotebookSY(id)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -466,14 +466,14 @@ func exportSYs(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
}
zipPath := model.ExportSYs(ids)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -492,7 +492,7 @@ func exportSY(c *gin.Context) {
return
}
zipPath := model.ExportSYs([]string{id})
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -548,7 +548,7 @@ func exportMdContent(c *gin.Context) {
}
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag, addTitle)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"hPath": hPath,
"content": content,
}
@@ -578,10 +578,10 @@ func exportDocx(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": fullPath,
}
}
@@ -608,7 +608,7 @@ func exportMdHTML(c *gin.Context) {
folderName := "htmlmd-" + id + "-" + util.CurrentTimeSecondsStr()
tmpDir := filepath.Join(util.TempDir, "export", folderName)
name, content := model.ExportMarkdownHTML(id, tmpDir, false, false)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"name": name,
"content": content,
@@ -618,7 +618,7 @@ func exportMdHTML(c *gin.Context) {
}
name, content := model.ExportMarkdownHTML(id, savePath, false, false)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"name": name,
"content": content,
@@ -642,18 +642,18 @@ func exportTempContent(c *gin.Context) {
if err := os.MkdirAll(tmpExport, 0755); err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
p := filepath.Join(tmpExport, gulu.Rand.String(7))
if err := os.WriteFile(p, []byte(content), 0644); err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
urlPath := path.Join("/export/temp/", filepath.Base(p))
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"url": "http://" + util.LocalHost + ":" + util.ServerPort + urlPath,
}
}
@@ -714,7 +714,7 @@ func exportBrowserHTML(c *gin.Context) {
os.RemoveAll(tmpDir)
zipURL := "/export/" + url.PathEscape(filepath.Base(zipPath))
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipURL,
}
}
@@ -750,7 +750,7 @@ func exportPreviewHTML(c *gin.Context) {
typ = node.Type.String()
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"name": name,
"content": content,
@@ -785,7 +785,7 @@ func exportHTML(c *gin.Context) {
folderName := "html-" + id + "-" + util.CurrentTimeSecondsStr()
tmpDir := filepath.Join(util.TempDir, "export", folderName)
name, content, _ := model.ExportHTML(id, tmpDir, pdf, keepFold, merge)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"name": name,
"content": content,
@@ -795,7 +795,7 @@ func exportHTML(c *gin.Context) {
}
name, content, _ := model.ExportHTML(id, savePath, pdf, keepFold, merge)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"name": name,
"content": content,
@@ -863,7 +863,7 @@ func exportPreview(c *gin.Context) {
stdHTML = model.FilterContentByPublishAccess(c, publishAccess, bt.BoxID, bt.Path, stdHTML, true)
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"html": stdHTML,
"fillCSSVar": fillCSSVar,
}
@@ -924,7 +924,7 @@ func exportAsFile(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"file": path.Join("/export/", name),
}
}
diff --git a/kernel/api/extension.go b/kernel/api/extension.go
index 5aecf57b18..79d6cac82a 100644
--- a/kernel/api/extension.go
+++ b/kernel/api/extension.go
@@ -283,7 +283,7 @@ func extensionCopy(c *gin.Context) {
parse.NestedInlines2FlattedSpansHybrid(tree, false)
md, _ = lute.FormatNodeSync(tree.Root, luteEngine.ParseOptions, luteEngine.RenderOptions)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"md": md,
"withMath": withMath,
}
diff --git a/kernel/api/file.go b/kernel/api/file.go
index a54233411e..396ebe2f74 100644
--- a/kernel/api/file.go
+++ b/kernel/api/file.go
@@ -48,7 +48,7 @@ func getUniqueFilename(c *gin.Context) {
}
filePath := arg["path"].(string)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": util.GetUniqueFilename(filePath),
}
}
@@ -63,7 +63,7 @@ func globalCopyFiles(c *gin.Context) {
}
var srcs []string
- srcsArg := arg["srcs"].([]interface{})
+ srcsArg := arg["srcs"].([]any)
for _, s := range srcsArg {
srcs = append(srcs, s.(string))
}
@@ -120,7 +120,7 @@ func copyFile(c *gin.Context) {
logging.LogErrorf("get asset [%s] abs path failed: %s", src, err)
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -129,14 +129,14 @@ func copyFile(c *gin.Context) {
logging.LogErrorf("stat [%s] failed: %s", src, err)
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
if info.IsDir() {
ret.Code = -1
ret.Msg = "file is a directory"
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -153,7 +153,7 @@ func copyFile(c *gin.Context) {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", src, dest, err)
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -356,7 +356,7 @@ func readDir(c *gin.Context) {
return
}
- files := []map[string]interface{}{}
+ files := []map[string]any{}
for _, entry := range entries {
path := filepath.Join(dirAbsPath, entry.Name())
info, err = os.Stat(path)
@@ -366,7 +366,7 @@ func readDir(c *gin.Context) {
ret.Msg = err.Error()
return
}
- files = append(files, map[string]interface{}{
+ files = append(files, map[string]any{
"name": entry.Name(),
"isDir": info.IsDir(),
"isSymlink": util.IsSymlink(entry),
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go
index d2acfa1034..6c59be482c 100644
--- a/kernel/api/filetree.go
+++ b/kernel/api/filetree.go
@@ -149,7 +149,7 @@ func listDocTree(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"tree": doctree,
}
}
@@ -203,7 +203,7 @@ func upsertIndexes(c *gin.Context) {
return
}
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
@@ -220,7 +220,7 @@ func removeIndexes(c *gin.Context) {
return
}
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
@@ -244,11 +244,11 @@ func doc2Heading(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"srcTreeBox": srcTreeBox,
"srcTreePath": srcTreePath,
}
@@ -277,7 +277,7 @@ func heading2Doc(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -285,7 +285,7 @@ func heading2Doc(c *gin.Context) {
box := model.Conf.Box(targetNotebook)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"path": targetPath,
"srcRootBlockID": srcRootBlockID,
@@ -316,7 +316,7 @@ func li2Doc(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -324,7 +324,7 @@ func li2Doc(c *gin.Context) {
box := model.Conf.Box(targetNotebook)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"path": targetPath,
"srcRootBlockID": srcRootBlockID,
@@ -366,7 +366,7 @@ func getHPathsByPaths(c *gin.Context) {
return
}
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
@@ -423,7 +423,7 @@ func getPathByID(c *gin.Context) {
ret.Msg = err.Error()
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": p,
"notebook": notebook,
}
@@ -491,7 +491,7 @@ func moveDocs(c *gin.Context) {
}
var fromPaths []string
- fromPathsArg := arg["fromPaths"].([]interface{})
+ fromPathsArg := arg["fromPaths"].([]any)
for _, fromPath := range fromPathsArg {
fromPaths = append(fromPaths, fromPath.(string))
}
@@ -505,7 +505,7 @@ func moveDocs(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -539,7 +539,7 @@ func moveDocsByID(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
fromPaths = append(fromPaths, tree.Path)
@@ -553,7 +553,7 @@ func moveDocsByID(c *gin.Context) {
if nil == box {
ret.Code = -1
ret.Msg = "can't found box or tree by id [" + toID + "]"
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -571,7 +571,7 @@ func moveDocsByID(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -612,7 +612,7 @@ func removeDocByID(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -628,7 +628,7 @@ func removeDocs(c *gin.Context) {
return
}
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var paths []string
for _, path := range pathsArg {
paths = append(paths, path.(string))
@@ -685,7 +685,7 @@ func renameDocByID(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -711,7 +711,7 @@ func duplicateDoc(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -721,7 +721,7 @@ func duplicateDoc(c *gin.Context) {
arg["listDocTree"] = true
pushCreate(box, tree.Path, arg)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": tree.Root.ID,
"notebook": notebook,
"path": tree.Path,
@@ -745,7 +745,7 @@ func createDoc(c *gin.Context) {
sortsArg := arg["sorts"]
var sorts []string
if nil != sortsArg {
- for _, sort := range sortsArg.([]interface{}) {
+ for _, sort := range sortsArg.([]any) {
sorts = append(sorts, sort.(string))
}
}
@@ -754,7 +754,7 @@ func createDoc(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -762,7 +762,7 @@ func createDoc(c *gin.Context) {
box := model.Conf.Box(notebook)
pushCreate(box, p, arg)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": tree.Root.ID,
}
}
@@ -808,14 +808,14 @@ func createDailyNote(c *gin.Context) {
}
evt := util.NewCmdResult("createdailynote", 0, util.PushModeBroadcast)
evt.AppId = app
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"path": p,
}
util.PushEvent(evt)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": tree.Root.ID,
}
}
@@ -941,7 +941,7 @@ func getDocCreateSavePath(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"box": docCreateSaveBox,
"path": docCreateSavePath,
}
@@ -994,7 +994,7 @@ func getRefCreateSavePath(c *gin.Context) {
ret.Msg = err.Error()
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"box": refCreateSaveBox,
"path": refCreateSavePath,
}
@@ -1010,7 +1010,7 @@ func changeSort(c *gin.Context) {
}
notebook := arg["notebook"].(string)
- pathsArg := arg["paths"].([]interface{})
+ pathsArg := arg["paths"].([]any)
var paths []string
for _, p := range pathsArg {
paths = append(paths, p.(string))
@@ -1034,7 +1034,7 @@ func searchDocs(c *gin.Context) {
var excludeIDs []string
if arg["excludeIDs"] != nil {
- excludeIDsArg := arg["excludeIDs"].([]interface{})
+ excludeIDsArg := arg["excludeIDs"].([]any)
for _, excludeID := range excludeIDsArg {
excludeIDs = append(excludeIDs, excludeID.(string))
}
@@ -1107,7 +1107,7 @@ func listDocsByPath(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"box": notebook,
"path": p,
"files": files,
@@ -1140,7 +1140,7 @@ func getDoc(c *gin.Context) {
}
var queryTypes map[string]bool
if queryTypesArg := arg["queryTypes"]; nil != queryTypesArg {
- typesArg := queryTypesArg.(map[string]interface{})
+ typesArg := queryTypesArg.(map[string]any)
queryTypes = map[string]bool{}
for t, b := range typesArg {
queryTypes[t] = b.(bool)
@@ -1174,7 +1174,7 @@ func getDoc(c *gin.Context) {
originalRefBlockIDsArg := arg["originalRefBlockIDs"]
originalRefBlockIDs := map[string]string{}
if nil != originalRefBlockIDsArg {
- m := originalRefBlockIDsArg.(map[string]interface{})
+ m := originalRefBlockIDsArg.(map[string]any)
for k, v := range m {
originalRefBlockIDs[k] = v.(string)
}
@@ -1210,7 +1210,7 @@ func getDoc(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"mode": mode,
"parentID": parentID,
@@ -1230,7 +1230,7 @@ func getDoc(c *gin.Context) {
}
}
-func pushCreate(box *model.Box, p string, arg map[string]interface{}) {
+func pushCreate(box *model.Box, p string, arg map[string]any) {
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
listDocTree := false
listDocTreeArg := arg["listDocTree"]
@@ -1238,7 +1238,7 @@ func pushCreate(box *model.Box, p string, arg map[string]interface{}) {
listDocTree = listDocTreeArg.(bool)
}
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"path": p,
"listDocTree": listDocTree,
@@ -1312,7 +1312,7 @@ func getPublishAccess(c *gin.Context) {
}
var IDs []string
- for _, ID := range arg["ids"].([]interface{}) {
+ for _, ID := range arg["ids"].([]any) {
IDs = append(IDs, ID.(string))
}
diff --git a/kernel/api/format.go b/kernel/api/format.go
index a67e31e501..b105c87997 100644
--- a/kernel/api/format.go
+++ b/kernel/api/format.go
@@ -42,7 +42,7 @@ func netAssets2LocalAssets(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -65,7 +65,7 @@ func netImg2LocalAssets(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -87,7 +87,7 @@ func autoSpace(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
diff --git a/kernel/api/graph.go b/kernel/api/graph.go
index 8d1624c5bd..9cf6be43d7 100644
--- a/kernel/api/graph.go
+++ b/kernel/api/graph.go
@@ -33,7 +33,7 @@ func resetGraph(c *gin.Context) {
graph := conf.NewGlobalGraph()
model.Conf.Graph.Global = graph
model.Conf.Save()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"conf": graph,
}
}
@@ -45,7 +45,7 @@ func resetLocalGraph(c *gin.Context) {
graph := conf.NewLocalGraph()
model.Conf.Graph.Local = graph
model.Conf.Save()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"conf": graph,
}
}
@@ -60,7 +60,7 @@ func getGraph(c *gin.Context) {
}
reqId := arg["reqId"]
- ret.Data = map[string]interface{}{"reqId": reqId}
+ ret.Data = map[string]any{"reqId": reqId}
var query string
var confArg map[string]any
@@ -93,7 +93,7 @@ func getGraph(c *gin.Context) {
publishIgnore := model.GetInvisiblePublishAccess(publishAccess)
nodes, links = model.FilterGraphByPublishIgnore(publishIgnore, nodes, links)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"nodes": nodes,
"links": links,
"conf": global,
@@ -113,7 +113,7 @@ func getLocalGraph(c *gin.Context) {
}
reqId := arg["reqId"]
- ret.Data = map[string]interface{}{"reqId": reqId}
+ ret.Data = map[string]any{"reqId": reqId}
if nil == arg["id"] {
return
}
@@ -151,7 +151,7 @@ func getLocalGraph(c *gin.Context) {
publishIgnore := model.GetInvisiblePublishAccess(publishAccess)
nodes, links = model.FilterGraphByPublishIgnore(publishIgnore, nodes, links)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"box": boxID,
"nodes": nodes,
diff --git a/kernel/api/history.go b/kernel/api/history.go
index 86d2a362f6..08fa3a3133 100644
--- a/kernel/api/history.go
+++ b/kernel/api/history.go
@@ -54,7 +54,7 @@ func searchHistory(c *gin.Context) {
op = arg["op"].(string)
}
histories, pageCount, totalCount := model.FullTextSearchHistory(query, notebook, op, typ, page)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"histories": histories,
"pageCount": pageCount,
"totalCount": totalCount,
@@ -87,7 +87,7 @@ func getHistoryItems(c *gin.Context) {
op = arg["op"].(string)
}
histories := model.FullTextSearchHistoryItems(created, query, notebook, op, typ)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"items": histories,
}
}
@@ -110,7 +110,7 @@ func getNotebookHistory(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"histories": histories,
}
}
@@ -156,7 +156,7 @@ func getDocHistoryContent(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"id": id,
"rootID": rootID,
"content": content,
@@ -187,7 +187,7 @@ func rollbackDocHistory(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"box": notebook,
}
}
diff --git a/kernel/api/icon.go b/kernel/api/icon.go
index 008a7aaf9a..f2ea6c06f4 100644
--- a/kernel/api/icon.go
+++ b/kernel/api/icon.go
@@ -174,7 +174,7 @@ func getDynamicIcon(c *gin.Context) {
c.String(http.StatusOK, svg)
}
-func getDateInfo(dateStr string, lang string, weekdayType string) map[string]interface{} {
+func getDateInfo(dateStr string, lang string, weekdayType string) map[string]any {
// 设置默认值
var date time.Time
var err error
@@ -261,7 +261,7 @@ func getDateInfo(dateStr string, lang string, weekdayType string) map[string]int
// countDown := int(math.Floor(date.Sub(today).Hours() / 24)) // 注意最大返回106751天,go的时间戳最大值
countDown := daysBetween(today, date)
- return map[string]interface{}{
+ return map[string]any{
"year": year,
"isoYear": isoYear,
"month": month,
@@ -312,7 +312,7 @@ func isLeapYear(year int) bool {
}
// Type 1: 显示年月日星期
-func generateTypeOneSVG(color string, dateInfo map[string]interface{}) string {
+func generateTypeOneSVG(color string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
return fmt.Sprintf(`
@@ -328,7 +328,7 @@ func generateTypeOneSVG(color string, dateInfo map[string]interface{}) string {
}
// Type 2: 显示年月日
-func generateTypeTwoSVG(color string, dateInfo map[string]interface{}) string {
+func generateTypeTwoSVG(color string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
return fmt.Sprintf(`
@@ -343,7 +343,7 @@ func generateTypeTwoSVG(color string, dateInfo map[string]interface{}) string {
}
// Type 3: 显示年月
-func generateTypeThreeSVG(color string, dateInfo map[string]interface{}) string {
+func generateTypeThreeSVG(color string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
return fmt.Sprintf(`
@@ -365,7 +365,7 @@ func generateTypeThreeSVG(color string, dateInfo map[string]interface{}) string
}
// Type 4: 仅显示年
-func generateTypeFourSVG(color string, dateInfo map[string]interface{}) string {
+func generateTypeFourSVG(color string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
return fmt.Sprintf(`
@@ -386,7 +386,7 @@ func generateTypeFourSVG(color string, dateInfo map[string]interface{}) string {
}
// Type 5:: 显示周数
-func generateTypeFiveSVG(color string, dateInfo map[string]interface{}) string {
+func generateTypeFiveSVG(color string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
return fmt.Sprintf(`
@@ -408,7 +408,7 @@ func generateTypeFiveSVG(color string, dateInfo map[string]interface{}) string {
}
// Type 6: 仅显示星期
-func generateTypeSixSVG(color string, lang string, weekdayType string, dateInfo map[string]interface{}) string {
+func generateTypeSixSVG(color string, lang string, weekdayType string, dateInfo map[string]any) string {
weekday := dateInfo["weekday"].(string)
isWeekend := dateInfo["isWeekend"].(bool)
@@ -461,7 +461,7 @@ func generateTypeSixSVG(color string, lang string, weekdayType string, dateInfo
}
// Type7: 倒数日
-func generateTypeSevenSVG(color string, lang string, dateInfo map[string]interface{}) string {
+func generateTypeSevenSVG(color string, lang string, dateInfo map[string]any) string {
colorScheme := getColorScheme(color)
diffDays := dateInfo["countDown"].(int)
diff --git a/kernel/api/inbox.go b/kernel/api/inbox.go
index 0ed32366d0..1764ab2e61 100644
--- a/kernel/api/inbox.go
+++ b/kernel/api/inbox.go
@@ -34,7 +34,7 @@ func removeShorthands(c *gin.Context) {
return
}
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
diff --git a/kernel/api/lute.go b/kernel/api/lute.go
index 717b0e4750..be3af2cdc4 100644
--- a/kernel/api/lute.go
+++ b/kernel/api/lute.go
@@ -217,7 +217,7 @@ func spinBlockDOM(c *gin.Context) {
luteEngine := model.NewLute()
dom = luteEngine.SpinBlockDOM(dom)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"dom": dom,
}
}
diff --git a/kernel/api/network.go b/kernel/api/network.go
index 53fdaece84..93dbe3e16a 100644
--- a/kernel/api/network.go
+++ b/kernel/api/network.go
@@ -100,8 +100,8 @@ func echo(c *gin.Context) {
c.Request.ParseForm()
c.Request.ParseMultipartForm(math.MaxInt64)
- ret.Data = map[string]interface{}{
- "Context": map[string]interface{}{
+ ret.Data = map[string]any{
+ "Context": map[string]any{
"Params": c.Params,
"HandlerNames": c.HandlerNames(),
"FullPath": c.FullPath(),
@@ -111,7 +111,7 @@ func echo(c *gin.Context) {
"IsWebsocket": c.IsWebsocket(),
"RawData": rawData,
},
- "Request": map[string]interface{}{
+ "Request": map[string]any{
"Method": c.Request.Method,
"URL": c.Request.URL,
"Proto": c.Request.Proto,
@@ -132,7 +132,7 @@ func echo(c *gin.Context) {
"Cookies": c.Request.Cookies(),
"Referer": c.Request.Referer(),
},
- "URL": map[string]interface{}{
+ "URL": map[string]any{
"EscapedPath": c.Request.URL.EscapedPath(),
"EscapedFragment": c.Request.URL.EscapedFragment(),
"String": c.Request.URL.String(),
@@ -143,7 +143,7 @@ func echo(c *gin.Context) {
"Hostname": c.Request.URL.Hostname(),
"Port": c.Request.URL.Port(),
},
- "User": map[string]interface{}{
+ "User": map[string]any{
"Username": c.Request.URL.User.Username(),
"Password": password,
"PasswordSet": passwordSet,
@@ -192,9 +192,9 @@ func forwardProxy(c *gin.Context) {
client := getSafeClient(time.Duration(timeout) * time.Millisecond)
request := client.R()
- if headers, ok := arg["headers"].([]interface{}); ok {
+ if headers, ok := arg["headers"].([]any); ok {
for _, pair := range headers {
- if m, ok := pair.(map[string]interface{}); ok {
+ if m, ok := pair.(map[string]any); ok {
for k, v := range m {
request.SetHeader(k, fmt.Sprintf("%v", v))
}
@@ -308,7 +308,7 @@ func forwardProxy(c *gin.Context) {
body = string(bodyData)
}
- data := map[string]interface{}{
+ data := map[string]any{
"url": destURL,
"status": resp.StatusCode,
"contentType": resp.GetHeader("content-type"),
diff --git a/kernel/api/notebook.go b/kernel/api/notebook.go
index 545f83ab99..1bfbf28238 100644
--- a/kernel/api/notebook.go
+++ b/kernel/api/notebook.go
@@ -53,7 +53,7 @@ func getNotebookInfo(c *gin.Context) {
}
boxInfo := box.GetInfo()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"boxInfo": boxInfo,
}
}
@@ -86,7 +86,7 @@ func changeSortNotebook(c *gin.Context) {
return
}
- idsArg := arg["notebooks"].([]interface{})
+ idsArg := arg["notebooks"].([]any)
var ids []string
for _, p := range idsArg {
ids = append(ids, p.(string))
@@ -119,12 +119,12 @@ func renameNotebook(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": notebook,
"name": name,
}
@@ -151,7 +151,7 @@ func removeNotebook(c *gin.Context) {
if util.ReadOnly && !model.IsUserGuide(notebook) {
ret.Code = -1
ret.Msg = model.Conf.Language(34)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -163,7 +163,7 @@ func removeNotebook(c *gin.Context) {
}
evt := util.NewCmdResult("removeBox", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": notebook,
}
util.PushEvent(evt)
@@ -203,12 +203,12 @@ func createNotebook(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"notebook": box,
}
evt := util.NewCmdResult("createnotebook", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"existed": existed,
}
@@ -236,7 +236,7 @@ func openNotebook(c *gin.Context) {
if util.ReadOnly && !isUserGuide {
ret.Code = -1
ret.Msg = model.Conf.Language(34)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -246,7 +246,7 @@ func openNotebook(c *gin.Context) {
// Opening the user guide is no longer supported on iOS https://github.com/siyuan-note/siyuan/issues/11492
ret.Code = -1
ret.Msg = model.Conf.Language(215)
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -267,7 +267,7 @@ func openNotebook(c *gin.Context) {
}
evt := util.NewCmdResult("mount", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": box,
"existed": existed,
}
@@ -293,7 +293,7 @@ func openNotebook(c *gin.Context) {
}
startID = guideStartID[notebook]
if treenode.ExistBlockTree(startID) {
- util.BroadcastByTypeAndApp("main", app, "openFileById", 0, "", map[string]interface{}{
+ util.BroadcastByTypeAndApp("main", app, "openFileById", 0, "", map[string]any{
"id": startID,
})
break
@@ -340,7 +340,7 @@ func getNotebookConf(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"box": box.ID,
"name": box.Name,
"conf": box.GetConf(),
@@ -424,7 +424,7 @@ func lsNotebooks(c *gin.Context) {
flashcard := false
// 兼容旧版接口,不能直接使用 util.JsonArg()
- arg := map[string]interface{}{}
+ arg := map[string]any{}
if err := c.ShouldBindJSON(&arg); err == nil {
if arg["flashcard"] != nil {
flashcard = arg["flashcard"].(bool)
@@ -467,7 +467,7 @@ func lsNotebooks(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"notebooks": notebooks,
}
}
diff --git a/kernel/api/ref.go b/kernel/api/ref.go
index 028734d0ba..65bf0f57af 100644
--- a/kernel/api/ref.go
+++ b/kernel/api/ref.go
@@ -61,7 +61,7 @@ func getBackmentionDoc(c *gin.Context) {
highlight = val.(bool)
}
backlinks, keywords := model.GetBackmentionDoc(defID, refTreeID, keyword, containChildren, highlight)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"backmentions": backlinks,
"keywords": keywords,
}
@@ -88,7 +88,7 @@ func getBacklinkDoc(c *gin.Context) {
highlight = val.(bool)
}
backlinks, keywords := model.GetBacklinkDoc(defID, refTreeID, keyword, containChildren, highlight)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"backlinks": backlinks,
"keywords": keywords,
}
@@ -130,7 +130,7 @@ func getBacklink2(c *gin.Context) {
backlinks = model.FilterPathsByPublishAccess(c, publishAccess, backlinks)
backmentions = model.FilterPathsByPublishAccess(c, publishAccess, backmentions)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"backlinks": backlinks,
"linkRefsCount": linkRefsCount,
"backmentions": backmentions,
@@ -171,7 +171,7 @@ func getBacklink(c *gin.Context) {
backlinks = model.FilterPathsByPublishAccess(c, publishAccess, backlinks)
backmentions = model.FilterPathsByPublishAccess(c, publishAccess, backmentions)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"backlinks": backlinks,
"linkRefsCount": linkRefsCount,
"backmentions": backmentions,
diff --git a/kernel/api/repo.go b/kernel/api/repo.go
index 94073f99b8..f6a7f79f70 100644
--- a/kernel/api/repo.go
+++ b/kernel/api/repo.go
@@ -150,7 +150,7 @@ func openRepoSnapshotFile(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"title": title,
"content": content,
"displayInText": displayInText,
@@ -181,7 +181,7 @@ func diffRepoSnapshots(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"addsLeft": diff.AddsLeft,
"updatesLeft": diff.UpdatesLeft,
"updatesRight": diff.UpdatesRight,
@@ -203,7 +203,7 @@ func getCloudSpace(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"sync": sync,
"backup": backup,
"hAssetSize": hAssetSize,
@@ -298,7 +298,7 @@ func getRepoSnapshots(c *gin.Context) {
ret.Msg = err.Error()
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"snapshots": snapshots,
"pageCount": pageCount,
"totalCount": totalCount,
@@ -326,7 +326,7 @@ func getCloudRepoSnapshots(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"snapshots": snapshots,
"pageCount": pageCount,
"totalCount": totalCount,
@@ -344,7 +344,7 @@ func getCloudRepoTagSnapshots(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"snapshots": snapshots,
}
}
@@ -381,7 +381,7 @@ func getRepoTagSnapshots(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"snapshots": snapshots,
}
}
@@ -423,7 +423,7 @@ func createSnapshot(c *gin.Context) {
if err := model.IndexRepo(memo); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(140), err)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -447,7 +447,7 @@ func tagSnapshot(c *gin.Context) {
if err := model.TagSnapshot(id, name); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(140), err)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -469,11 +469,11 @@ func importRepoKey(c *gin.Context) {
if err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(137), err)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"key": retKey,
}
}
@@ -494,11 +494,11 @@ func initRepoKeyFromPassphrase(c *gin.Context) {
if err := model.InitRepoKeyFromPassphrase(pass); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(137), err)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"key": model.Conf.Repo.Key,
}
}
@@ -510,11 +510,11 @@ func initRepoKey(c *gin.Context) {
if err := model.InitRepoKey(); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(137), err)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"key": model.Conf.Repo.Key,
}
}
@@ -526,7 +526,7 @@ func resetRepo(c *gin.Context) {
if err := model.ResetRepo(); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(146), err.Error())
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -538,7 +538,7 @@ func purgeRepo(c *gin.Context) {
if err := model.PurgeRepo(); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(201), err.Error())
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -550,7 +550,7 @@ func purgeCloudRepo(c *gin.Context) {
if err := model.PurgeCloud(); err != nil {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(201), err.Error())
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
diff --git a/kernel/api/riff.go b/kernel/api/riff.go
index 60749b2bf4..4338b09383 100644
--- a/kernel/api/riff.go
+++ b/kernel/api/riff.go
@@ -35,14 +35,14 @@ func getRiffCardsByBlockIDs(c *gin.Context) {
if !ok {
return
}
- blockIDsArg := arg["blockIDs"].([]interface{})
+ blockIDsArg := arg["blockIDs"].([]any)
var blockIDs []string
for _, blockID := range blockIDsArg {
blockIDs = append(blockIDs, blockID.(string))
}
blocks := model.GetFlashcardsByBlockIDs(blockIDs)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
}
}
@@ -57,8 +57,8 @@ func batchSetRiffCardsDueTime(c *gin.Context) {
}
var cardDues []*model.SetFlashcardDueTime
- for _, cardDueArg := range arg["cardDues"].([]interface{}) {
- cardDue := cardDueArg.(map[string]interface{})
+ for _, cardDueArg := range arg["cardDues"].([]any) {
+ cardDue := cardDueArg.(map[string]any)
cardDues = append(cardDues, &model.SetFlashcardDueTime{
ID: cardDue["id"].(string),
Due: cardDue["due"].(string),
@@ -87,7 +87,7 @@ func resetRiffCards(c *gin.Context) {
blockIDsArg := arg["blockIDs"] // 如果不传入 blockIDs (或者传入实参为空数组),则重置所有卡片
var blockIDs []string
if nil != blockIDsArg {
- for _, blockID := range blockIDsArg.([]interface{}) {
+ for _, blockID := range blockIDsArg.([]any) {
blockIDs = append(blockIDs, blockID.(string))
}
}
@@ -111,7 +111,7 @@ func getNotebookRiffCards(c *gin.Context) {
pageSize = int(arg["pageSize"].(float64))
}
blockIDs, total, pageCount := model.GetNotebookFlashcards(notebookID, page, pageSize)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blockIDs,
"total": total,
"pageCount": pageCount,
@@ -134,7 +134,7 @@ func getTreeRiffCards(c *gin.Context) {
pageSize = int(arg["pageSize"].(float64))
}
blockIDs, total, pageCount := model.GetTreeFlashcards(rootID, page, pageSize)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blockIDs,
"total": total,
"pageCount": pageCount,
@@ -157,7 +157,7 @@ func getRiffCards(c *gin.Context) {
pageSize = int(arg["pageSize"].(float64))
}
blocks, total, pageCount := model.GetDeckFlashcards(deckID, page, pageSize)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
"total": total,
"pageCount": pageCount,
@@ -222,7 +222,7 @@ func getNotebookRiffDueCards(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"cards": cards,
"unreviewedCount": unreviewedCount,
"unreviewedNewCardCount": unreviewedNewCardCount,
@@ -248,7 +248,7 @@ func getTreeRiffDueCards(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"cards": cards,
"unreviewedCount": unreviewedCount,
"unreviewedNewCardCount": unreviewedNewCardCount,
@@ -274,7 +274,7 @@ func getRiffDueCards(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"cards": cards,
"unreviewedCount": unreviewedCount,
"unreviewedNewCardCount": unreviewedNewCardCount,
@@ -282,14 +282,14 @@ func getRiffDueCards(c *gin.Context) {
}
}
-func getReviewedCards(arg map[string]interface{}) (ret []string) {
+func getReviewedCards(arg map[string]any) (ret []string) {
if nil == arg["reviewedCards"] {
return
}
- reviewedCardsArg := arg["reviewedCards"].([]interface{})
+ reviewedCardsArg := arg["reviewedCards"].([]any)
for _, card := range reviewedCardsArg {
- c := card.(map[string]interface{})
+ c := card.(map[string]any)
cardID := c["cardID"].(string)
ret = append(ret, cardID)
}
@@ -306,7 +306,7 @@ func removeRiffCards(c *gin.Context) {
}
deckID := arg["deckID"].(string)
- blockIDsArg := arg["blockIDs"].([]interface{})
+ blockIDsArg := arg["blockIDs"].([]any)
var blockIDs []string
for _, blockID := range blockIDsArg {
blockIDs = append(blockIDs, blockID.(string))
@@ -344,7 +344,7 @@ func addRiffCards(c *gin.Context) {
}
deckID := arg["deckID"].(string)
- blockIDsArg := arg["blockIDs"].([]interface{})
+ blockIDsArg := arg["blockIDs"].([]any)
var blockIDs []string
for _, blockID := range blockIDsArg {
blockIDs = append(blockIDs, blockID.(string))
@@ -430,18 +430,18 @@ func getRiffDecks(c *gin.Context) {
defer c.JSON(http.StatusOK, ret)
decks := model.GetDecks()
- var data []interface{}
+ var data []any
for _, deck := range decks {
data = append(data, deckData(deck))
}
if 1 > len(data) {
- data = []interface{}{}
+ data = []any{}
}
ret.Data = data
}
-func deckData(deck *riff.Deck) map[string]interface{} {
- return map[string]interface{}{
+func deckData(deck *riff.Deck) map[string]any {
+ return map[string]any{
"id": deck.ID,
"name": deck.Name,
"size": deck.CountCards(),
diff --git a/kernel/api/search.go b/kernel/api/search.go
index fbb845792b..7fe6947ab6 100644
--- a/kernel/api/search.go
+++ b/kernel/api/search.go
@@ -56,7 +56,7 @@ func listInvalidBlockRefs(c *gin.Context) {
publishAccess := model.GetPublishAccess()
blocks = model.FilterBlocksByPublishAccess(c, publishAccess, blocks)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
"matchedBlockCount": matchedBlockCount,
"matchedRootCount": matchedRootCount,
@@ -86,7 +86,7 @@ func getAssetContent(c *gin.Context) {
assetContent = nil
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"assetContent": assetContent,
}
return
@@ -107,7 +107,7 @@ func fullTextSearchAssetContent(c *gin.Context) {
publishAccess := model.GetPublishAccess()
assetContents = model.FilterAssetContentByPublishAccess(c, publishAccess, assetContents)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"assetContents": assetContents,
"matchedAssetCount": matchedAssetCount,
"pageCount": pageCount,
@@ -127,7 +127,7 @@ func findReplace(c *gin.Context) {
k := arg["k"].(string)
r := arg["r"].(string)
- idsArg := arg["ids"].([]interface{})
+ idsArg := arg["ids"].([]any)
var ids []string
for _, id := range idsArg {
ids = append(ids, id.(string))
@@ -137,7 +137,7 @@ func findReplace(c *gin.Context) {
// text, imgText, imgTitle, imgSrc, aText, aTitle, aHref, code, em, strong, inlineMath, inlineMemo, blockRef, fileAnnotationRef kbd, mark, s, sub, sup, tag, u
// docTitle, codeBlock, mathBlock, htmlBlock
if nil != arg["replaceTypes"] {
- replaceTypesArg := arg["replaceTypes"].(map[string]interface{})
+ replaceTypesArg := arg["replaceTypes"].(map[string]any)
for t, b := range replaceTypesArg {
replaceTypes[t] = b.(bool)
}
@@ -147,7 +147,7 @@ func findReplace(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
return
@@ -166,7 +166,7 @@ func searchAsset(c *gin.Context) {
var exts []string
if extsArg := arg["exts"]; nil != extsArg {
- for _, ext := range extsArg.([]interface{}) {
+ for _, ext := range extsArg.([]any) {
exts = append(exts, ext.(string))
}
}
@@ -189,7 +189,7 @@ func searchTag(c *gin.Context) {
if 1 > len(tags) {
tags = []string{}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"tags": tags,
"k": k,
}
@@ -206,7 +206,7 @@ func searchWidget(c *gin.Context) {
keyword := arg["k"].(string)
widgets := model.SearchWidget(keyword)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"widgets": widgets,
"k": keyword,
}
@@ -241,7 +241,7 @@ func searchTemplate(c *gin.Context) {
keyword := arg["k"].(string)
templates := model.SearchTemplate(keyword)
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"templates": templates,
"k": keyword,
}
@@ -258,7 +258,7 @@ func getEmbedBlock(c *gin.Context) {
}
embedBlockID := arg["embedBlockID"].(string)
- includeIDsArg := arg["includeIDs"].([]interface{})
+ includeIDsArg := arg["includeIDs"].([]any)
var includeIDs []string
for _, includeID := range includeIDsArg {
includeIDs = append(includeIDs, includeID.(string))
@@ -279,7 +279,7 @@ func getEmbedBlock(c *gin.Context) {
publishAccess := model.GetPublishAccess()
blocks = model.FilterEmbedBlocksByPublishAccess(c, publishAccess, blocks)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
}
}
@@ -315,7 +315,7 @@ func searchEmbedBlock(c *gin.Context) {
embedBlockID := arg["embedBlockID"].(string)
stmt := arg["stmt"].(string)
- excludeIDsArg := arg["excludeIDs"].([]interface{})
+ excludeIDsArg := arg["excludeIDs"].([]any)
var excludeIDs []string
for _, excludeID := range excludeIDsArg {
if nil == excludeID {
@@ -339,7 +339,7 @@ func searchEmbedBlock(c *gin.Context) {
publishAccess := model.GetPublishAccess()
blocks = model.FilterEmbedBlocksByPublishAccess(c, publishAccess, blocks)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
}
}
@@ -354,7 +354,7 @@ func searchRefBlock(c *gin.Context) {
}
reqId := arg["reqId"]
- ret.Data = map[string]interface{}{"reqId": reqId}
+ ret.Data = map[string]any{"reqId": reqId}
if nil == arg["id"] {
return
}
@@ -378,7 +378,7 @@ func searchRefBlock(c *gin.Context) {
publishAccess := model.GetPublishAccess()
blocks = model.FilterBlocksByPublishAccess(c, publishAccess, blocks)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
"newDoc": newDoc,
"k": util.EscapeHTML(keyword),
@@ -409,7 +409,7 @@ func fullTextSearchBlock(c *gin.Context) {
publishAccess := model.GetPublishAccess()
blocks = model.FilterBlocksByPublishAccess(c, publishAccess, blocks)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"blocks": blocks,
"matchedBlockCount": matchedBlockCount,
"matchedRootCount": matchedRootCount,
@@ -418,7 +418,7 @@ func fullTextSearchBlock(c *gin.Context) {
}
}
-func parseSearchBlockArgs(arg map[string]interface{}) (page, pageSize int, query string, paths, boxes []string, types map[string]bool, method, orderBy, groupBy int) {
+func parseSearchBlockArgs(arg map[string]any) (page, pageSize int, query string, paths, boxes []string, types map[string]bool, method, orderBy, groupBy int) {
page = 1
if nil != arg["page"] {
page = int(arg["page"].(float64))
@@ -442,7 +442,7 @@ func parseSearchBlockArgs(arg map[string]interface{}) (page, pageSize int, query
pathsArg := arg["paths"]
if nil != pathsArg {
- for _, p := range pathsArg.([]interface{}) {
+ for _, p := range pathsArg.([]any) {
path := p.(string)
box := strings.TrimSpace(strings.Split(path, "/")[0])
if "" != box {
@@ -458,7 +458,7 @@ func parseSearchBlockArgs(arg map[string]interface{}) (page, pageSize int, query
}
if nil != arg["types"] {
- typesArg := arg["types"].(map[string]interface{})
+ typesArg := arg["types"].(map[string]any)
types = map[string]bool{}
for t, b := range typesArg {
types[t] = b.(bool)
@@ -485,7 +485,7 @@ func parseSearchBlockArgs(arg map[string]interface{}) (page, pageSize int, query
return
}
-func parseSearchAssetContentArgs(arg map[string]interface{}) (page, pageSize int, query string, types map[string]bool, method, orderBy int) {
+func parseSearchAssetContentArgs(arg map[string]any) (page, pageSize int, query string, types map[string]bool, method, orderBy int) {
page = 1
if nil != arg["page"] {
page = int(arg["page"].(float64))
@@ -508,7 +508,7 @@ func parseSearchAssetContentArgs(arg map[string]interface{}) (page, pageSize int
}
if nil != arg["types"] {
- typesArg := arg["types"].(map[string]interface{})
+ typesArg := arg["types"].(map[string]any)
types = map[string]bool{}
for t, b := range typesArg {
types[t] = b.(bool)
diff --git a/kernel/api/setting.go b/kernel/api/setting.go
index 9f843bd333..beceae7d81 100644
--- a/kernel/api/setting.go
+++ b/kernel/api/setting.go
@@ -94,7 +94,7 @@ func addVirtualBlockRefExclude(c *gin.Context) {
keywordsArg := arg["keywords"]
var keywords []string
- for _, k := range keywordsArg.([]interface{}) {
+ for _, k := range keywordsArg.([]any) {
keywords = append(keywords, k.(string))
}
@@ -115,7 +115,7 @@ func addVirtualBlockRefInclude(c *gin.Context) {
keywordsArg := arg["keywords"]
var keywords []string
- for _, k := range keywordsArg.([]interface{}) {
+ for _, k := range keywordsArg.([]any) {
keywords = append(keywords, k.(string))
}
@@ -372,7 +372,7 @@ func setExport(c *gin.Context) {
if err = gulu.JSON.UnmarshalJSON(param, export); err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -752,7 +752,7 @@ func setEmoji(c *gin.Context) {
return
}
- argEmoji := arg["emoji"].([]interface{})
+ argEmoji := arg["emoji"].([]any)
var emoji []string
for _, ae := range argEmoji {
e := ae.(string)
diff --git a/kernel/api/snippet.go b/kernel/api/snippet.go
index 981bf682ef..747e2e8425 100644
--- a/kernel/api/snippet.go
+++ b/kernel/api/snippet.go
@@ -92,7 +92,7 @@ func getSnippet(c *gin.Context) {
snippets = []*conf.Snippet{}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"snippets": snippets,
}
}
@@ -106,10 +106,10 @@ func setSnippet(c *gin.Context) {
return
}
- snippetsArg := arg["snippets"].([]interface{})
+ snippetsArg := arg["snippets"].([]any)
var snippets []*conf.Snippet
for _, s := range snippetsArg {
- m := s.(map[string]interface{})
+ m := s.(map[string]any)
snippet := &conf.Snippet{
ID: m["id"].(string),
Name: m["name"].(string),
diff --git a/kernel/api/storage.go b/kernel/api/storage.go
index aa97a7df38..a133c6620a 100644
--- a/kernel/api/storage.go
+++ b/kernel/api/storage.go
@@ -33,7 +33,7 @@ func getRecentDocs(c *gin.Context) {
sortBy := "viewedAt" // 默认按浏览时间排序,openAt:按打开时间排序,closedAt:按关闭时间排序
// 兼容旧版接口,不能直接使用 util.JsonArg()
- arg := map[string]interface{}{}
+ arg := map[string]any{}
if err := c.ShouldBindJSON(&arg); err == nil {
if arg["sortBy"] != nil {
sortBy = arg["sortBy"].(string)
@@ -120,7 +120,7 @@ func removeLocalStorageVals(c *gin.Context) {
}
var keys []string
- keysArg := arg["keys"].([]interface{})
+ keysArg := arg["keys"].([]any)
for _, key := range keysArg {
keys = append(keys, key.(string))
}
@@ -135,7 +135,7 @@ func removeLocalStorageVals(c *gin.Context) {
app := arg["app"].(string)
evt := util.NewCmdResult("removeLocalStorageVals", 0, util.PushModeBroadcastMainExcludeSelfApp)
evt.AppId = app
- evt.Data = map[string]interface{}{"keys": keys}
+ evt.Data = map[string]any{"keys": keys}
util.PushEvent(evt)
}
@@ -149,7 +149,7 @@ func setLocalStorageVal(c *gin.Context) {
}
key := arg["key"].(string)
- val := arg["val"].(interface{})
+ val := arg["val"].(any)
err := model.SetLocalStorageVal(key, val)
if err != nil {
ret.Code = -1
@@ -160,7 +160,7 @@ func setLocalStorageVal(c *gin.Context) {
app := arg["app"].(string)
evt := util.NewCmdResult("setLocalStorageVal", 0, util.PushModeBroadcastMainExcludeSelfApp)
evt.AppId = app
- evt.Data = map[string]interface{}{"key": key, "val": val}
+ evt.Data = map[string]any{"key": key, "val": val}
util.PushEvent(evt)
}
@@ -173,7 +173,7 @@ func setLocalStorage(c *gin.Context) {
return
}
- val := arg["val"].(interface{})
+ val := arg["val"].(any)
err := model.SetLocalStorage(val)
if err != nil {
ret.Code = -1
@@ -223,7 +223,7 @@ func setOutlineStorage(c *gin.Context) {
}
docID := arg["docID"].(string)
- val := arg["val"].(interface{})
+ val := arg["val"].(any)
err := model.SetOutlineStorage(docID, val)
if err != nil {
ret.Code = -1
@@ -325,7 +325,7 @@ func batchUpdateRecentDocCloseTime(c *gin.Context) {
return
}
- rootIDsArg := arg["rootIDs"].([]interface{})
+ rootIDsArg := arg["rootIDs"].([]any)
var rootIDs []string
for _, id := range rootIDsArg {
rootIDs = append(rootIDs, id.(string))
diff --git a/kernel/api/system.go b/kernel/api/system.go
index 3c6a32876c..c8b5d1089d 100644
--- a/kernel/api/system.go
+++ b/kernel/api/system.go
@@ -104,7 +104,7 @@ func getNetwork(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"proxy": maskedConf.System.NetworkProxy,
}
}
@@ -113,7 +113,7 @@ func getChangelog(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
- data := map[string]interface{}{"show": false, "html": ""}
+ data := map[string]any{"show": false, "html": ""}
ret.Data = data
changelogsDir := filepath.Join(util.WorkingDir, "changelogs")
@@ -163,7 +163,7 @@ func getEmojiConf(c *gin.Context) {
return
}
- var conf []map[string]interface{}
+ var conf []map[string]any
if err = gulu.JSON.UnmarshalJSON(data, &conf); err != nil {
logging.LogErrorf("unmarshal emojis conf.json failed: %s", err)
ret.Code = -1
@@ -172,13 +172,13 @@ func getEmojiConf(c *gin.Context) {
}
customConfDir := filepath.Join(util.DataDir, "emojis")
- custom := map[string]interface{}{
+ custom := map[string]any{
"id": "custom",
"title": "Custom",
"title_zh_cn": "自定义",
"title_ja_jp": "カスタム",
}
- items := []map[string]interface{}{}
+ items := []map[string]any{}
custom["items"] = items
if gulu.File.IsDir(customConfDir) {
model.ClearCustomEmojis()
@@ -241,16 +241,16 @@ func getEmojiConf(c *gin.Context) {
}
}
custom["items"] = items
- conf = append([]map[string]interface{}{custom}, conf...)
+ conf = append([]map[string]any{custom}, conf...)
ret.Data = conf
return
}
-func addCustomEmoji(name string, items *[]map[string]interface{}) {
+func addCustomEmoji(name string, items *[]map[string]any) {
ext := filepath.Ext(name)
nameWithoutExt := strings.TrimSuffix(name, ext)
- emoji := map[string]interface{}{
+ emoji := map[string]any{
"unicode": name,
"description": nameWithoutExt,
"description_zh_cn": nameWithoutExt,
@@ -281,7 +281,7 @@ func exportLog(c *gin.Context) {
defer c.JSON(http.StatusOK, ret)
zipPath := model.ExportSystemLog()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"zip": zipPath,
}
}
@@ -388,7 +388,7 @@ func exportConf(c *gin.Context) {
logging.LogInfof("exported conf")
zipPath := "/export/" + name + ".zip"
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"name": name,
"zip": zipPath,
}
@@ -560,7 +560,7 @@ func getConf(c *gin.Context) {
maskedConf = model.FilterConfByPublishIgnore(publishIgnore, maskedConf)
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"conf": maskedConf,
"start": !util.IsUILoaded,
"isPublish": isPublish,
@@ -690,7 +690,7 @@ func bootProgress(c *gin.Context) {
defer c.JSON(http.StatusOK, ret)
progress, details := util.GetBootProgressDetails()
- ret.Data = map[string]interface{}{"progress": progress, "details": details}
+ ret.Data = map[string]any{"progress": progress, "details": details}
}
func setAppearanceMode(c *gin.Context) {
@@ -711,7 +711,7 @@ func setAppearanceMode(c *gin.Context) {
}
model.Conf.Save()
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"appearance": model.Conf.Appearance,
}
}
@@ -775,7 +775,7 @@ func exportTLSCACert(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": "/export/" + util.TLSCACertFilename,
}
}
@@ -833,7 +833,7 @@ func exportTLSCABundle(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": "/export/ca-bundle.zip",
}
}
@@ -895,7 +895,7 @@ func importTLSCABundle(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"msg": "CA bundle imported successfully. Please restart to apply changes.",
}
}
@@ -990,9 +990,9 @@ func exit(c *gin.Context) {
case 0:
case 1: // 同步执行失败
ret.Msg = model.Conf.Language(96) + "<div class=\"fn__space\"></div><button class=\"b3-button b3-button--white\">" + model.Conf.Language(97) + "</button>"
- ret.Data = map[string]interface{}{"closeTimeout": 0}
+ ret.Data = map[string]any{"closeTimeout": 0}
case 2: // 提示新安装包
ret.Msg = model.Conf.Language(61)
- ret.Data = map[string]interface{}{"closeTimeout": 0}
+ ret.Data = map[string]any{"closeTimeout": 0}
}
}
diff --git a/kernel/api/tag.go b/kernel/api/tag.go
index 2034bcea07..431290fc18 100644
--- a/kernel/api/tag.go
+++ b/kernel/api/tag.go
@@ -83,7 +83,7 @@ func renameTag(c *gin.Context) {
if err := model.RenameTag(oldLabel, newLabel); err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -104,7 +104,7 @@ func removeTag(c *gin.Context) {
if err := model.RemoveTag(label); err != nil {
ret.Code = -1
ret.Msg = err.Error()
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
diff --git a/kernel/api/template.go b/kernel/api/template.go
index 82e7d504a5..8616275dcf 100644
--- a/kernel/api/template.go
+++ b/kernel/api/template.go
@@ -98,7 +98,7 @@ func renderTemplate(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"path": p,
"content": content,
}
diff --git a/kernel/api/workspace.go b/kernel/api/workspace.go
index c0bf2de302..a8dca59cb8 100644
--- a/kernel/api/workspace.go
+++ b/kernel/api/workspace.go
@@ -47,7 +47,7 @@ func checkWorkspaceDir(c *gin.Context) {
if util.IsPartitionRootPath(path) {
ret.Code = -1
ret.Msg = model.Conf.Language(273)
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -62,7 +62,7 @@ func checkWorkspaceDir(c *gin.Context) {
if 0 < len(entries) {
ret.Code = -1
ret.Msg = model.Conf.Language(274)
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
@@ -79,7 +79,7 @@ func checkWorkspaceDir(c *gin.Context) {
return
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"isWorkspace": util.IsWorkspaceDir(path),
}
}
@@ -141,7 +141,7 @@ func removeWorkspaceDir(c *gin.Context) {
msg := "Cannot remove current workspace"
ret.Code = -1
ret.Msg = msg
- ret.Data = map[string]interface{}{"closeTimeout": 3000}
+ ret.Data = map[string]any{"closeTimeout": 3000}
return
}
@@ -274,14 +274,14 @@ func setWorkspaceDir(c *gin.Context) {
if util.WorkspaceDir == path {
ret.Code = -1
ret.Msg = model.Conf.Language(78)
- ret.Data = map[string]interface{}{"closeTimeout": 3000}
+ ret.Data = map[string]any{"closeTimeout": 3000}
return
}
if util.IsCloudDrivePath(path) {
ret.Code = -1
ret.Msg = model.Conf.Language(196)
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
@@ -292,7 +292,7 @@ func setWorkspaceDir(c *gin.Context) {
if strings.HasPrefix(pathLower, installDirLower) && (util.IsSubPath(installDirLower, pathLower) || filepath.Clean(installDirLower) == filepath.Clean(pathLower)) {
ret.Code = -1
ret.Msg = model.Conf.Language(98)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
}
@@ -304,7 +304,7 @@ func setWorkspaceDir(c *gin.Context) {
if util.IsWorkspaceDir(p) {
ret.Code = -1
ret.Msg = fmt.Sprintf(model.Conf.Language(256), path, p)
- ret.Data = map[string]interface{}{"closeTimeout": 7000}
+ ret.Data = map[string]any{"closeTimeout": 7000}
return
}
}
diff --git a/kernel/av/av.go b/kernel/av/av.go
index f977a5efc1..c67c95a5d0 100644
--- a/kernel/av/av.go
+++ b/kernel/av/av.go
@@ -519,7 +519,7 @@ func ParseAttributeViewByPath(avJSONPath string) (ret *AttributeView, err error)
ret = &AttributeView{RenderedViewables: map[string]Viewable{}}
if err = gulu.JSON.UnmarshalJSON(data, ret); err != nil {
if strings.Contains(err.Error(), ".relation.contents of type av.Value") {
- mapAv := map[string]interface{}{}
+ mapAv := map[string]any{}
if err = gulu.JSON.UnmarshalJSON(data, &mapAv); err != nil {
logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
return
@@ -527,30 +527,30 @@ func ParseAttributeViewByPath(avJSONPath string) (ret *AttributeView, err error)
// v3.0.3 兼容之前旧版本,将 relation.contents[""] 转换为 null
keyValues := mapAv["keyValues"]
- keyValuesMap := keyValues.([]interface{})
+ keyValuesMap := keyValues.([]any)
for _, kv := range keyValuesMap {
- kvMap := kv.(map[string]interface{})
+ kvMap := kv.(map[string]any)
if values := kvMap["values"]; nil != values {
- valuesMap := values.([]interface{})
+ valuesMap := values.([]any)
for _, v := range valuesMap {
- if vMap := v.(map[string]interface{}); nil != vMap["relation"] {
- vMap["relation"].(map[string]interface{})["contents"] = nil
+ if vMap := v.(map[string]any); nil != vMap["relation"] {
+ vMap["relation"].(map[string]any)["contents"] = nil
}
}
}
}
views := mapAv["views"]
- viewsMap := views.([]interface{})
+ viewsMap := views.([]any)
for _, view := range viewsMap {
- if table := view.(map[string]interface{})["table"]; nil != table {
- tableMap := table.(map[string]interface{})
+ if table := view.(map[string]any)["table"]; nil != table {
+ tableMap := table.(map[string]any)
if filters := tableMap["filters"]; nil != filters {
- filtersMap := filters.([]interface{})
+ filtersMap := filters.([]any)
for _, f := range filtersMap {
- if fMap := f.(map[string]interface{}); nil != fMap["value"] {
- if valueMap := fMap["value"].(map[string]interface{}); nil != valueMap["relation"] {
- valueMap["relation"].(map[string]interface{})["contents"] = nil
+ if fMap := f.(map[string]any); nil != fMap["value"] {
+ if valueMap := fMap["value"].(map[string]any); nil != valueMap["relation"] {
+ valueMap["relation"].(map[string]any)["contents"] = nil
}
}
}
diff --git a/kernel/av/value.go b/kernel/av/value.go
index 9a098365e0..501067353b 100644
--- a/kernel/av/value.go
+++ b/kernel/av/value.go
@@ -381,7 +381,7 @@ func (value *Value) IsEmpty() bool {
return false
}
-func (value *Value) SetValByType(typ KeyType, val interface{}) {
+func (value *Value) SetValByType(typ KeyType, val any) {
switch typ {
case KeyTypeBlock:
value.Block = val.(*ValueBlock)
@@ -418,7 +418,7 @@ func (value *Value) SetValByType(typ KeyType, val interface{}) {
}
}
-func (value *Value) GetValByType(typ KeyType) (ret interface{}) {
+func (value *Value) GetValByType(typ KeyType) (ret any) {
// 单独处理汇总
if KeyTypeRollup == value.Type {
if 1 > len(value.Rollup.Contents) {
diff --git a/kernel/bazaar/install.go b/kernel/bazaar/install.go
index b41a6a1f27..d8b28b20c7 100644
--- a/kernel/bazaar/install.go
+++ b/kernel/bazaar/install.go
@@ -39,7 +39,7 @@ var downloadPackageFlight singleflight.Group
// downloadBazaarFile 下载集市文件
func downloadBazaarFile(repoURLHash string, pushProgress bool) (data []byte, err error) {
repoURLHashTrimmed := strings.TrimPrefix(repoURLHash, "https://github.com/")
- v, err, _ := downloadPackageFlight.Do(repoURLHash, func() (interface{}, error) {
+ v, err, _ := downloadPackageFlight.Do(repoURLHash, func() (any, error) {
// repoURLHash: https://github.com/88250/Comfortably-Numb@6286912c381ef3f83e455d06ba4d369c498238dc 或带路径 /README.md
repoURL := repoURLHash[:strings.LastIndex(repoURLHash, "@")]
u := util.BazaarOSSServer + "/package/" + repoURLHashTrimmed
@@ -75,7 +75,7 @@ func incPackageDownloads(repoURL, systemID string) {
repo := strings.TrimPrefix(repoURL, "https://github.com/")
u := util.GetCloudServer() + "/apis/siyuan/bazaar/addBazaarPackageDownloadCount"
httpclient.NewCloudRequest30s().SetBody(
- map[string]interface{}{
+ map[string]any{
"systemID": systemID,
"repo": repo,
}).Post(u)
diff --git a/kernel/bazaar/installed.go b/kernel/bazaar/installed.go
index 23fd6a4625..29bb05b327 100644
--- a/kernel/bazaar/installed.go
+++ b/kernel/bazaar/installed.go
@@ -144,7 +144,7 @@ func getBazaarInfo() {
return
}
- _, _, _ = bazaarInfoSingleFlight.Do("loadBazaarInfo", func() (interface{}, error) {
+ _, _, _ = bazaarInfoSingleFlight.Do("loadBazaarInfo", func() (any, error) {
// 缓存失效时从磁盘加载
newRet := loadBazaarInfo()
// 更新缓存和修改时间
diff --git a/kernel/bazaar/stage.go b/kernel/bazaar/stage.go
index 9d80fa4f08..1900884978 100644
--- a/kernel/bazaar/stage.go
+++ b/kernel/bazaar/stage.go
@@ -130,7 +130,7 @@ func getStageAndBazaar0(pkgType string) (result StageBazaarResult) {
}
func isBazaarOnline() bool {
- v, err, _ := onlineCheckFlight.Do("bazaarOnline", func() (interface{}, error) {
+ v, err, _ := onlineCheckFlight.Do("bazaarOnline", func() (any, error) {
return isBazaarOnline0(), nil
})
if err != nil {
@@ -227,7 +227,7 @@ func getBazaarStats(ctx context.Context) map[string]*bazaarStats {
return cached
}
- v, _, _ := bazaarStatsFlight.Do("bazaarStats", func() (interface{}, error) {
+ v, _, _ := bazaarStatsFlight.Do("bazaarStats", func() (any, error) {
return getBazaarStats0(ctx), nil
})
return v.(map[string]*bazaarStats)
diff --git a/kernel/cmd/cmd.go b/kernel/cmd/cmd.go
index 43270a2106..24f8325fb7 100644
--- a/kernel/cmd/cmd.go
+++ b/kernel/cmd/cmd.go
@@ -31,7 +31,7 @@ type Cmd interface {
type BaseCmd struct {
id float64
- param map[string]interface{}
+ param map[string]any
session *melody.Session
PushPayload *util.Result
}
@@ -49,7 +49,7 @@ func (cmd *BaseCmd) Push() {
util.PushEvent(cmd.PushPayload)
}
-func NewCommand(cmdStr string, cmdId float64, param map[string]interface{}, session *melody.Session) (ret Cmd) {
+func NewCommand(cmdStr string, cmdId float64, param map[string]any, session *melody.Session) (ret Cmd) {
baseCmd := &BaseCmd{id: cmdId, param: param, session: session}
switch cmdStr {
case "closews":
diff --git a/kernel/conf/layout.go b/kernel/conf/layout.go
index a8731f79bd..1d86a5d69e 100644
--- a/kernel/conf/layout.go
+++ b/kernel/conf/layout.go
@@ -16,5 +16,5 @@
package conf
-type UILayout map[string]interface{} // 界面布局
-type Keymap map[string]interface{} // 快捷键
+type UILayout map[string]any // 界面布局
+type Keymap map[string]any // 快捷键
diff --git a/kernel/filesys/template.go b/kernel/filesys/template.go
index 2e22f416e9..dfb3bf9eee 100644
--- a/kernel/filesys/template.go
+++ b/kernel/filesys/template.go
@@ -92,12 +92,12 @@ func wordCount(s string) (ret int) {
return
}
-func pow(a, b interface{}) int64 { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) }
-func powf(a, b interface{}) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) }
-func log(a, b interface{}) int64 {
+func pow(a, b any) int64 { return int64(math.Pow(cast.ToFloat64(a), cast.ToFloat64(b))) }
+func powf(a, b any) float64 { return math.Pow(cast.ToFloat64(a), cast.ToFloat64(b)) }
+func log(a, b any) int64 {
return int64(math.Log(cast.ToFloat64(a)) / math.Log(cast.ToFloat64(b)))
}
-func logf(a, b interface{}) float64 { return math.Log(cast.ToFloat64(a)) / math.Log(cast.ToFloat64(b)) }
+func logf(a, b any) float64 { return math.Log(cast.ToFloat64(a)) / math.Log(cast.ToFloat64(b)) }
func parseTime(dateStr string) time.Time {
now := time.Now()
diff --git a/kernel/filesys/tree.go b/kernel/filesys/tree.go
index 0bc165fc04..7d2e4beb17 100644
--- a/kernel/filesys/tree.go
+++ b/kernel/filesys/tree.go
@@ -85,7 +85,7 @@ func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse
lock := sync.Mutex{}
poolSize := min(runtime.NumCPU(), 8)
- p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
+ p, _ := ants.NewPoolWithFunc(poolSize, func(arg any) {
defer waitGroup.Done()
i := arg.(int)
diff --git a/kernel/model/appearance.go b/kernel/model/appearance.go
index a024d1c0a8..40506bd9b7 100644
--- a/kernel/model/appearance.go
+++ b/kernel/model/appearance.go
@@ -270,7 +270,7 @@ func broadcastRefreshThemeIfCurrent(themeCssPath string) {
if themeName == "" {
return
}
- util.BroadcastByType("main", "refreshtheme", 0, "", map[string]interface{}{
+ util.BroadcastByType("main", "refreshtheme", 0, "", map[string]any{
"theme": "/appearance/themes/" + themeName + "/theme.css?" + fmt.Sprintf("%d", time.Now().Unix()),
})
}
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 75d5213917..14056a6cfe 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -2521,7 +2521,7 @@ func updateAttributeViewColRollup(operation *Operation) (err error) {
return
}
- data := operation.Data.(map[string]interface{})
+ data := operation.Data.(map[string]any)
if nil != data["calc"] {
calcData, jsonErr := gulu.JSON.MarshalJSON(data["calc"])
if nil != jsonErr {
@@ -3339,7 +3339,7 @@ func setAttributeViewFilters(operation *Operation) (err error) {
return
}
- operationData := operation.Data.([]interface{})
+ operationData := operation.Data.([]any)
data, err := gulu.JSON.MarshalJSON(operationData)
if err != nil {
return
@@ -3372,7 +3372,7 @@ func setAttributeViewSorts(operation *Operation) (err error) {
return
}
- operationData := operation.Data.([]interface{})
+ operationData := operation.Data.([]any)
data, err := gulu.JSON.MarshalJSON(operationData)
if err != nil {
return
@@ -3430,7 +3430,7 @@ func setAttributeViewColumnCalc(operation *Operation) (err error) {
return
}
- operationData := operation.Data.(interface{})
+ operationData := operation.Data.(any)
data, err := gulu.JSON.MarshalJSON(operationData)
if err != nil {
return
@@ -3465,7 +3465,7 @@ func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr)
return
}
-func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, dbBlockID, viewID, groupID, previousItemID string, ignoreDefaultFill bool) (err error) {
+func AddAttributeViewBlock(tx *Transaction, srcs []map[string]any, avID, dbBlockID, viewID, groupID, previousItemID string, ignoreDefaultFill bool) (err error) {
slices.Reverse(srcs) // https://github.com/siyuan-note/siyuan/issues/11286
now := time.Now().UnixMilli()
@@ -4988,14 +4988,14 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {
return
}
-func BatchUpdateAttributeViewCells(tx *Transaction, avID string, values []interface{}) (err error) {
+func BatchUpdateAttributeViewCells(tx *Transaction, avID string, values []any) (err error) {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
return
}
for _, value := range values {
- v := value.(map[string]interface{})
+ v := value.(map[string]any)
keyID := v["keyID"].(string)
var itemID string
if _, ok := v["itemID"]; ok {
@@ -5015,7 +5015,7 @@ func BatchUpdateAttributeViewCells(tx *Transaction, avID string, values []interf
return
}
-func UpdateAttributeViewCell(tx *Transaction, avID, keyID, itemID string, valueData interface{}) (val *av.Value, err error) {
+func UpdateAttributeViewCell(tx *Transaction, avID, keyID, itemID string, valueData any) (val *av.Value, err error) {
attrView, err := av.ParseAttributeView(avID)
if err != nil {
return
@@ -5028,7 +5028,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, itemID string, valueD
return
}
-func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID, itemID string, valueData interface{}) (val *av.Value, err error) {
+func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID, itemID string, valueData any) (val *av.Value, err error) {
avID := attrView.ID
var blockVal *av.Value
for _, kv := range attrView.KeyValues {
@@ -5621,7 +5621,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
return
}
- data := operation.Data.(map[string]interface{})
+ data := operation.Data.(map[string]any)
rename := false
oldName := strings.TrimSpace(data["oldName"].(string))
@@ -5740,7 +5740,7 @@ func setAttributeViewColumnOptionDesc(operation *Operation) (err error) {
return
}
- data := operation.Data.(map[string]interface{})
+ data := operation.Data.(map[string]any)
name := data["name"].(string)
desc := data["desc"].(string)
diff --git a/kernel/model/attribute_view_render.go b/kernel/model/attribute_view_render.go
index 48acdb61ac..97ae24956d 100644
--- a/kernel/model/attribute_view_render.go
+++ b/kernel/model/attribute_view_render.go
@@ -35,7 +35,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func RenderAttributeView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]interface{}, createIfNotExist bool) (viewable av.Viewable, attrView *av.AttributeView, err error) {
+func RenderAttributeView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]any, createIfNotExist bool) (viewable av.Viewable, attrView *av.AttributeView, err error) {
waitForSyncingStorages()
if avJSONPath := av.GetAttributeViewDataPath(avID); !filelock.IsExist(avJSONPath) {
@@ -74,7 +74,7 @@ const (
groupValueNext7Days, groupValueNext30Days = "_@next7Days@_", "_@next30Days@_"
)
-func renderAttributeView(attrView *av.AttributeView, nodeID, viewID, query string, page, pageSize int, groupPaging map[string]interface{}) (viewable av.Viewable, err error) {
+func renderAttributeView(attrView *av.AttributeView, nodeID, viewID, query string, page, pageSize int, groupPaging map[string]any) (viewable av.Viewable, err error) {
// 获取待渲染的视图
view, err := getRenderAttributeViewView(attrView, viewID, nodeID)
if nil != err {
@@ -97,7 +97,7 @@ func renderAttributeView(attrView *av.AttributeView, nodeID, viewID, query strin
return
}
-func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView, view *av.View, query string, page, pageSize int, groupPaging map[string]interface{}) (err error) {
+func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView, view *av.View, query string, page, pageSize int, groupPaging map[string]any) (err error) {
groupKey := view.GetGroupKey(attrView)
if nil == groupKey {
if view.LayoutType == av.LayoutTypeKanban {
@@ -180,7 +180,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
groupPage, groupPageSize := page, pageSize
if nil != groupPaging {
if paging := groupPaging[groupView.ID]; nil != paging {
- pagingMap := paging.(map[string]interface{})
+ pagingMap := paging.(map[string]any)
if nil != pagingMap["page"] {
groupPage = int(pagingMap["page"].(float64))
}
@@ -551,7 +551,7 @@ func RenderRepoSnapshotAttributeView(indexID, avID string) (viewable av.Viewable
return
}
-func RenderHistoryAttributeView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]interface{}, created string) (viewable av.Viewable, attrView *av.AttributeView, err error) {
+func RenderHistoryAttributeView(blockID, avID, viewID, query string, page, pageSize int, groupPaging map[string]any, created string) (viewable av.Viewable, attrView *av.AttributeView, err error) {
createdUnix, parseErr := strconv.ParseInt(created, 10, 64)
if nil != parseErr {
logging.LogErrorf("parse created [%s] failed: %s", created, parseErr)
diff --git a/kernel/model/auth.go b/kernel/model/auth.go
index 40172c3057..470880fa14 100644
--- a/kernel/model/auth.go
+++ b/kernel/model/auth.go
@@ -128,7 +128,7 @@ func ParseJWT(tokenString string) (*jwt.Token, error) {
// REF: https://golang-jwt.github.io/jwt/usage/parse/
return jwt.Parse(
tokenString,
- func(token *jwt.Token) (interface{}, error) {
+ func(token *jwt.Token) (any, error) {
return jwtKey, nil
},
jwt.WithIssuer(iss),
diff --git a/kernel/model/bazaar.go b/kernel/model/bazaar.go
index 10479c80c9..9274649ef1 100644
--- a/kernel/model/bazaar.go
+++ b/kernel/model/bazaar.go
@@ -216,7 +216,7 @@ var getInstalledPackagesFlight singleflight.Group
// GetInstalledPackages 获取本地集市包列表
func GetInstalledPackages(pkgType, frontend, keyword string) (installedPackages []*bazaar.Package) {
key := "getInstalledPackages:" + pkgType + ":" + frontend + ":" + keyword
- v, err, _ := getInstalledPackagesFlight.Do(key, func() (interface{}, error) {
+ v, err, _ := getInstalledPackagesFlight.Do(key, func() (any, error) {
return getInstalledPackages0(pkgType, frontend, keyword), nil
})
if err != nil {
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index e1d8ddcf4d..89f34c870f 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -98,7 +98,7 @@ func SetBlockReminder(id string, timed string) (err error) {
return
}
-func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {
+func BatchSetBlockAttrs(blockAttrs []map[string]any) (err error) {
if util.ReadOnly {
return
}
@@ -350,7 +350,7 @@ func validateChars(name string, startIdx, n int) bool {
func pushBlockAttrs(oldAttrs map[string]string, node *ast.Node) {
newAttrs := parse.IAL2Map(node.KramdownIAL)
- data := map[string]interface{}{"old": oldAttrs, "new": newAttrs}
+ data := map[string]any{"old": oldAttrs, "new": newAttrs}
if "" != node.AttributeViewType {
data["data-av-type"] = node.AttributeViewType
}
diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go
index 976cf0b003..09f3d573cc 100644
--- a/kernel/model/blockinfo.go
+++ b/kernel/model/blockinfo.go
@@ -67,7 +67,7 @@ func GetDocInfo(blockID string) (ret *BlockInfo) {
ret.IAL = parse.IAL2Map(tree.Root.KramdownIAL)
scrollData := ret.IAL["scroll"]
if 0 < len(scrollData) {
- scroll := map[string]interface{}{}
+ scroll := map[string]any{}
if parseErr := gulu.JSON.UnmarshalJSON([]byte(scrollData), &scroll); nil != parseErr {
logging.LogWarnf("parse scroll data [%s] failed: %s", scrollData, parseErr)
delete(ret.IAL, "scroll")
@@ -150,7 +150,7 @@ func GetDocsInfo(blockIDs []string, queryRefCount bool, queryAv bool) (rets []*B
ret.IAL = parse.IAL2Map(tree.Root.KramdownIAL)
scrollData := ret.IAL["scroll"]
if 0 < len(scrollData) {
- scroll := map[string]interface{}{}
+ scroll := map[string]any{}
if parseErr := gulu.JSON.UnmarshalJSON([]byte(scrollData), &scroll); nil != parseErr {
logging.LogWarnf("parse scroll data [%s] failed: %s", scrollData, parseErr)
delete(ret.IAL, "scroll")
diff --git a/kernel/model/box.go b/kernel/model/box.go
index 964a633fad..7d9a694bed 100644
--- a/kernel/model/box.go
+++ b/kernel/model/box.go
@@ -580,7 +580,7 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) {
if ast.NodeYamlFrontMatterContent == n.Type {
// Parsing YAML Front Matter as document custom attributes when importing Markdown files https://github.com/siyuan-note/siyuan/issues/10878
- attrs := map[string]interface{}{}
+ attrs := map[string]any{}
parseErr := yaml.Unmarshal(n.Tokens, &attrs)
if parseErr != nil {
logging.LogWarnf("parse YAML front matter [%s] failed: %s", n.Tokens, parseErr)
diff --git a/kernel/model/cloud_service.go b/kernel/model/cloud_service.go
index 7ff30606bb..d1fb103895 100644
--- a/kernel/model/cloud_service.go
+++ b/kernel/model/cloud_service.go
@@ -44,15 +44,15 @@ func CloudChatGPT(msg string, contextMsgs []string) (ret string, stop bool, err
return
}
- payload := map[string]interface{}{}
- var messages []map[string]interface{}
+ payload := map[string]any{}
+ var messages []map[string]any
for _, contextMsg := range contextMsgs {
- messages = append(messages, map[string]interface{}{
+ messages = append(messages, map[string]any{
"role": "user",
"content": contextMsg,
})
}
- messages = append(messages, map[string]interface{}{
+ messages = append(messages, map[string]any{
"role": "user",
"content": msg,
})
@@ -76,14 +76,14 @@ func CloudChatGPT(msg string, contextMsgs []string) (ret string, stop bool, err
return
}
- data := requestResult.Data.(map[string]interface{})
- choices := data["choices"].([]interface{})
+ data := requestResult.Data.(map[string]any)
+ choices := data["choices"].([]any)
if 1 > len(choices) {
stop = true
return
}
- choice := choices[0].(map[string]interface{})
- message := choice["message"].(map[string]interface{})
+ choice := choices[0].(map[string]any)
+ message := choice["message"].(map[string]any)
ret = message["content"].(string)
if nil != choice["finish_reason"] {
@@ -150,7 +150,7 @@ func DeactivateUser() (err error) {
func SetCloudBlockReminder(id, data string, timed int64) (err error) {
requestResult := gulu.Ret.NewResult()
- payload := map[string]interface{}{"dataId": id, "data": data, "timed": timed}
+ payload := map[string]any{"dataId": id, "data": data, "timed": timed}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(requestResult).
@@ -204,7 +204,7 @@ func LoadUploadToken() (err error) {
return
}
- resultData := requestResult.Data.(map[string]interface{})
+ resultData := requestResult.Data.(map[string]any)
uploadToken = resultData["uploadToken"].(string)
uploadTokenTime = now
return
@@ -410,9 +410,9 @@ func loadUserFromConf() *conf.User {
}
func RemoveCloudShorthands(ids []string) (err error) {
- result := map[string]interface{}{}
+ result := map[string]any{}
request := httpclient.NewCloudRequest30s()
- body := map[string]interface{}{
+ body := map[string]any{
"ids": ids,
}
resp, err := request.
@@ -440,8 +440,8 @@ func RemoveCloudShorthands(ids []string) (err error) {
return
}
-func GetCloudShorthand(id string) (ret map[string]interface{}, err error) {
- result := map[string]interface{}{}
+func GetCloudShorthand(id string) (ret map[string]any, err error) {
+ result := map[string]any{}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(&result).
@@ -464,7 +464,7 @@ func GetCloudShorthand(id string) (ret map[string]interface{}, err error) {
err = errors.New(result["msg"].(string))
return
}
- ret = result["data"].(map[string]interface{})
+ ret = result["data"].(map[string]any)
t, _ := strconv.ParseInt(id, 10, 64)
hCreated := util.Millisecond2Time(t)
ret["hCreated"] = hCreated.Format("2006-01-02 15:04")
@@ -481,8 +481,8 @@ func GetCloudShorthand(id string) (ret map[string]interface{}, err error) {
return
}
-func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
- result = map[string]interface{}{}
+func GetCloudShorthands(page int) (result map[string]any, err error) {
+ result = map[string]any{}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(&result).
@@ -510,9 +510,9 @@ func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
audioRegexp := regexp.MustCompile("<audio.*>.*</audio>")
videoRegexp := regexp.MustCompile("<video.*>.*</video>")
fileRegexp := regexp.MustCompile("\\[文件]\\(.*\\)")
- shorthands := result["data"].(map[string]interface{})["shorthands"].([]interface{})
+ shorthands := result["data"].(map[string]any)["shorthands"].([]any)
for _, item := range shorthands {
- shorthand := item.(map[string]interface{})
+ shorthand := item.(map[string]any)
id := shorthand["oId"].(string)
t, _ := strconv.ParseInt(id, 10, 64)
hCreated := util.Millisecond2Time(t)
@@ -542,7 +542,7 @@ var (
)
func getUser(token string) (*conf.User, error) {
- result := map[string]interface{}{}
+ result := map[string]any{}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(&result).
@@ -633,7 +633,7 @@ func Login(userName, password, captcha string, cloudRegion int) (ret *gulu.Resul
Conf.Save()
util.CurrentCloudRegion = cloudRegion
- result := map[string]interface{}{}
+ result := map[string]any{}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(&result).
@@ -657,7 +657,7 @@ func Login(userName, password, captcha string, cloudRegion int) (ret *gulu.Resul
ret = &gulu.Result{
Code: int(result["code"].(float64)),
Msg: result["msg"].(string),
- Data: map[string]interface{}{
+ Data: map[string]any{
"userName": result["userName"],
"token": result["token"],
"needCaptcha": result["needCaptcha"],
@@ -669,8 +669,8 @@ func Login(userName, password, captcha string, cloudRegion int) (ret *gulu.Resul
return
}
-func Login2fa(token, code string) (map[string]interface{}, error) {
- result := map[string]interface{}{}
+func Login2fa(token, code string) (map[string]any, error) {
+ result := map[string]any{}
request := httpclient.NewCloudRequest30s()
_, err := request.
SetSuccessResult(&result).
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index 30e799e623..d2e4c7b2fe 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -675,7 +675,7 @@ func initLang() {
logging.LogErrorf("read language configuration [%s] failed: %s", jsonPath, err)
continue
}
- langMap := map[string]interface{}{}
+ langMap := map[string]any{}
if err := gulu.JSON.UnmarshalJSON(data, &langMap); err != nil {
logging.LogErrorf("parse language configuration failed [%s] failed: %s", jsonPath, err)
continue
@@ -683,7 +683,7 @@ func initLang() {
kernelMap := map[int]string{}
label := langMap["_label"].(string)
- kernelLangs := langMap["_kernel"].(map[string]interface{})
+ kernelLangs := langMap["_kernel"].(map[string]any)
for k, v := range kernelLangs {
num, convErr := strconv.Atoi(k)
if nil != convErr {
@@ -696,10 +696,10 @@ func initLang() {
name := langName[:strings.LastIndex(langName, ".")]
util.Langs[name] = kernelMap
- util.TimeLangs[name] = langMap["_time"].(map[string]interface{})
- util.TaskActionLangs[name] = langMap["_taskAction"].(map[string]interface{})
- util.TrayMenuLangs[name] = langMap["_trayMenu"].(map[string]interface{})
- util.AttrViewLangs[name] = langMap["_attrView"].(map[string]interface{})
+ util.TimeLangs[name] = langMap["_time"].(map[string]any)
+ util.TaskActionLangs[name] = langMap["_taskAction"].(map[string]any)
+ util.TrayMenuLangs[name] = langMap["_trayMenu"].(map[string]any)
+ util.AttrViewLangs[name] = langMap["_attrView"].(map[string]any)
}
}
@@ -849,7 +849,7 @@ func NewLute() (ret *lute.Lute) {
ret.SetSpellcheck(Conf.Editor.Spellcheck)
customEmojiMap := map[string]string{}
- customEmojis.Range(func(key, value interface{}) bool {
+ customEmojis.Range(func(key, value any) bool {
customEmojiMap[key.(string)] = value.(string)
return true
})
@@ -1257,7 +1257,7 @@ func closeUserGuide() {
if removeErr := RemoveBox(boxID); nil == removeErr {
evt := util.NewCmdResult("removeBox", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": boxID,
}
util.PushEvent(evt)
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 1430db4ce7..885e53c7dc 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -397,7 +397,7 @@ func Export2Liandi(id string) (err error) {
request = request.
SetSuccessResult(result).
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.GetUser().UserToken}).
- SetBody(map[string]interface{}{
+ SetBody(map[string]any{
"articleTitle": title,
"articleTags": tags,
"articleContent": content})
@@ -3323,7 +3323,7 @@ func processFileAnnotationRef(refID string, n *ast.Node, fileAnnotationRefMode i
logging.LogErrorf("read file [%s] failed: %s", sya, err)
return ast.WalkSkipChildren
}
- syaJSON := map[string]interface{}{}
+ syaJSON := map[string]any{}
if err = gulu.JSON.UnmarshalJSON(syaData, &syaJSON); err != nil {
logging.LogErrorf("unmarshal file [%s] failed: %s", sya, err)
return ast.WalkSkipChildren
@@ -3334,8 +3334,8 @@ func processFileAnnotationRef(refID string, n *ast.Node, fileAnnotationRefMode i
logging.LogErrorf("not found annotation [%s] in .sya", annotationID)
return ast.WalkSkipChildren
}
- pages := annotationData.(map[string]interface{})["pages"].([]interface{})
- page := int(pages[0].(map[string]interface{})["index"].(float64)) + 1
+ pages := annotationData.(map[string]any)["pages"].([]any)
+ page := int(pages[0].(map[string]any)["index"].(float64)) + 1
pageStr := strconv.Itoa(page)
refText := n.TextMarkTextContent
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 074dc604c9..e55a6939e1 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1293,7 +1293,7 @@ func GetIDsByHPath(hpath, boxID string) (ret []string, err error) {
return
}
-func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{}) (err error) {
+func MoveDocs(fromPaths []string, toBoxID, toPath string, callback any) (err error) {
toBox := Conf.Box(toBoxID)
if nil == toBox {
err = errors.New(Conf.Language(0))
@@ -1372,7 +1372,7 @@ func countSubDocs(box, p string) (ret int) {
return
}
-func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngine *lute.Lute, callback interface{}) (newPath string, err error) {
+func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngine *lute.Lute, callback any) (newPath string, err error) {
isSameBox := fromBox.ID == toBox.ID
if isSameBox {
@@ -1491,7 +1491,7 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
subToPath := path.Join(toFolder, relPath)
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"fromNotebook": fromBox.ID,
"fromPath": subFromPath,
"toNotebook": toBox.ID,
@@ -1504,7 +1504,7 @@ func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string, luteEngin
}
evt := util.NewCmdResult("moveDoc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"fromNotebook": fromBox.ID,
"fromPath": fromPath,
"toNotebook": toBox.ID,
@@ -1635,7 +1635,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) (ret *parse.Tree) {
cache.RemoveTreeData(ret.ID)
evt := util.NewCmdResult("removeDoc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"ids": removeIDs,
}
util.PushEvent(evt)
@@ -1710,7 +1710,7 @@ func RenameDoc(boxID, p, title string) (err error) {
refText := getNodeRefText(tree.Root)
evt := util.NewCmdResult("rename", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": boxID,
"id": tree.Root.ID,
"path": p,
diff --git a/kernel/model/heading.go b/kernel/model/heading.go
index bd6e709983..5ccfeca2ac 100644
--- a/kernel/model/heading.go
+++ b/kernel/model/heading.go
@@ -282,7 +282,7 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
}
box.removeSort([]string{srcTree.ID})
evt := util.NewCmdResult("removeDoc", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"ids": []string{srcTree.ID},
}
util.PushEvent(evt)
diff --git a/kernel/model/history.go b/kernel/model/history.go
index eba3c5fde1..45e5ef45f7 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -358,7 +358,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
// 刷新页签名
refText := getNodeRefText(tree.Root)
evt := util.NewCmdResult("rename", 0, util.PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"box": boxID,
"id": tree.Root.ID,
"path": tree.Path,
diff --git a/kernel/model/index.go b/kernel/model/index.go
index b6ff613087..1384d3633f 100644
--- a/kernel/model/index.go
+++ b/kernel/model/index.go
@@ -155,7 +155,7 @@ func indexBox(boxID string) {
poolSize := min(runtime.NumCPU(), 4)
waitGroup := &sync.WaitGroup{}
var avNodes []*ast.Node
- p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
+ p, _ := ants.NewPoolWithFunc(poolSize, func(arg any) {
defer waitGroup.Done()
file := arg.(*FileInfo)
@@ -366,13 +366,13 @@ var (
func subscribeSQLEvents() {
// 使用下面的 EvtSQLInsertBlocksFTS 就可以了
- //eventbus.Subscribe(eventbus.EvtSQLInsertBlocks, func(context map[string]interface{}, current, total, blockCount int, hash string) {
+ //eventbus.Subscribe(eventbus.EvtSQLInsertBlocks, func(context map[string]any, current, total, blockCount int, hash string) {
//
// msg := fmt.Sprintf(Conf.Language(89), current, total, blockCount, hash)
// util.SetBootDetails(msg)
// util.ContextPushMsg(context, msg)
//})
- eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]interface{}, blockCount int, hash string) {
+ eventbus.Subscribe(eventbus.EvtSQLInsertBlocksFTS, func(context map[string]any, blockCount int, hash string) {
if !pushSQLInsertBlocksFTSMsg {
return
}
@@ -383,7 +383,7 @@ func subscribeSQLEvents() {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtSQLDeleteBlocks, func(context map[string]interface{}, rootID string) {
+ eventbus.Subscribe(eventbus.EvtSQLDeleteBlocks, func(context map[string]any, rootID string) {
if !pushSQLDeleteBlocksMsg {
return
}
@@ -394,7 +394,7 @@ func subscribeSQLEvents() {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtSQLUpdateBlocksHPaths, func(context map[string]interface{}, blockCount int, hash string) {
+ eventbus.Subscribe(eventbus.EvtSQLUpdateBlocksHPaths, func(context map[string]any, blockCount int, hash string) {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {
return
}
@@ -406,7 +406,7 @@ func subscribeSQLEvents() {
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtSQLInsertHistory, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtSQLInsertHistory, func(context map[string]any) {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {
return
}
@@ -418,7 +418,7 @@ func subscribeSQLEvents() {
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtSQLInsertAssetContent, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtSQLInsertAssetContent, func(context map[string]any) {
if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {
return
}
diff --git a/kernel/model/outline.go b/kernel/model/outline.go
index 61e49696a8..d7b47d1b2a 100644
--- a/kernel/model/outline.go
+++ b/kernel/model/outline.go
@@ -262,7 +262,7 @@ func Outline(rootID string, preview bool) (ret []*Path, err error) {
}
}
- expandIDsArg := storage["expandIds"].([]interface{})
+ expandIDsArg := storage["expandIds"].([]any)
var expandIDs []string
for _, id := range expandIDsArg {
expandIDs = append(expandIDs, id.(string))
diff --git a/kernel/model/plugin.go b/kernel/model/plugin.go
index e514964265..a151765ebe 100644
--- a/kernel/model/plugin.go
+++ b/kernel/model/plugin.go
@@ -39,9 +39,9 @@ type Petal struct {
DisabledInPublish bool `json:"disabledInPublish"` // Whether disabled in publish mode
DisallowInstall bool `json:"disallowInstall"` // Whether disallow install
- JS string `json:"js"` // JS code
- CSS string `json:"css"` // CSS code
- I18n map[string]interface{} `json:"i18n"` // i18n text
+ JS string `json:"js"` // JS code
+ CSS string `json:"css"` // CSS code
+ I18n map[string]any `json:"i18n"` // i18n text
}
func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) {
@@ -192,7 +192,7 @@ func loadCode(petal *Petal) {
if err != nil {
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, err)
} else {
- petal.I18n = map[string]interface{}{}
+ petal.I18n = map[string]any{}
if err = gulu.JSON.UnmarshalJSON(data, &petal.I18n); err != nil {
logging.LogErrorf("unmarshal plugin [%s] i18n failed: %s", petal.Name, err)
}
diff --git a/kernel/model/process.go b/kernel/model/process.go
index 6cb37bb5dd..f95322374c 100644
--- a/kernel/model/process.go
+++ b/kernel/model/process.go
@@ -85,7 +85,7 @@ var uiProcNames = []string{"siyuan", "electron"}
// getAttachedUIProcCount 获取已经附加的 UI 进程数。
func getAttachedUIProcCount() (ret int) {
- util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {
+ util.UIProcessIDs.Range(func(uiProcIDArg, _ any) bool {
uiProcID, err := strconv.Atoi(uiProcIDArg.(string))
if err != nil {
logging.LogErrorf("invalid UI proc ID [%s]: %s", uiProcIDArg, err)
diff --git a/kernel/model/publish_access.go b/kernel/model/publish_access.go
index f11a1c4f7c..82442c058f 100644
--- a/kernel/model/publish_access.go
+++ b/kernel/model/publish_access.go
@@ -628,7 +628,7 @@ func FilterUILayoutByPublishIgnore(publishIgnore PublishAccess, uiLayout *conf.U
return
}
- layout, ok := (*uiLayout)["layout"].(map[string]interface{})
+ layout, ok := (*uiLayout)["layout"].(map[string]any)
if !ok {
return
}
@@ -637,7 +637,7 @@ func FilterUILayoutByPublishIgnore(publishIgnore PublishAccess, uiLayout *conf.U
return
}
-func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[string]interface{}) (ret map[string]interface{}) {
+func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[string]any) (ret map[string]any) {
ret = item
if item == nil {
return
@@ -653,7 +653,7 @@ func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[strin
if !exists {
return
}
- children := childrenItem.(map[string]interface{})
+ children := childrenItem.(map[string]any)
if children == nil {
return
}
@@ -674,14 +674,14 @@ func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[strin
if !exists {
return
}
- children := childrenItem.([]interface{})
+ children := childrenItem.([]any)
if children == nil {
return
}
- newChildren := []interface{}{}
+ newChildren := []any{}
updateTabs := false
for _, childItem := range children {
- child := childItem.(map[string]interface{})
+ child := childItem.(map[string]any)
if child == nil {
return
}
@@ -696,7 +696,7 @@ func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[strin
hasActive := false
activeTimes := []int64{}
for _, childItem := range newChildren {
- child := childItem.(map[string]interface{})
+ child := childItem.(map[string]any)
activeTimeStr := child["activeTime"].(string)
var activeTime int64
if len(activeTimeStr) > 0 {
@@ -715,12 +715,12 @@ func filterLayoutItemByPublishIgnore(publishIgnore PublishAccess, item map[strin
maxIndex = i
}
}
- newChildren[maxIndex].(map[string]interface{})["active"] = true
+ newChildren[maxIndex].(map[string]any)["active"] = true
}
if len(newChildren) == 0 {
- child := make(map[string]interface{})
+ child := make(map[string]any)
child["instance"] = "Tab"
- child["children"] = make(map[string]interface{})
+ child["children"] = make(map[string]any)
newChildren = append(newChildren, child)
}
}
@@ -791,20 +791,20 @@ func reassignTagCounts(tag *Tag, counts map[string]int) (ret *Tag) {
return tag
}
-func FilterLocalStorageByPublishAccess(publishAccess PublishAccess, localStorage map[string]interface{}) (ret map[string]interface{}) {
+func FilterLocalStorageByPublishAccess(publishAccess PublishAccess, localStorage map[string]any) (ret map[string]any) {
ret = localStorage
publishIgnore := GetInvisiblePublishAccess(publishAccess)
// 清空搜索历史记录
searchKeysItem := ret["local-searchkeys"]
if searchKeysItem != nil {
- searchKeys := searchKeysItem.(map[string]interface{})
+ searchKeys := searchKeysItem.(map[string]any)
if searchKeys != nil {
searchKeys["keys"] = []string{}
}
}
searchAssetItem := ret["local-searchasset"]
if searchAssetItem != nil {
- searchAsset := searchAssetItem.(map[string]interface{})
+ searchAsset := searchAssetItem.(map[string]any)
if searchAsset != nil {
searchAsset["k"] = ""
searchAsset["keys"] = []string{}
@@ -812,7 +812,7 @@ func FilterLocalStorageByPublishAccess(publishAccess PublishAccess, localStorage
}
docInfoItem := ret["local-docinfo"]
if docInfoItem != nil {
- docInfo := docInfoItem.(map[string]interface{})
+ docInfo := docInfoItem.(map[string]any)
if docInfo != nil {
idItem := docInfo["id"]
if idItem != nil {
diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.go
index bc0cd8b56f..35e48e57d2 100644
--- a/kernel/model/push_reload.go
+++ b/kernel/model/push_reload.go
@@ -75,7 +75,7 @@ func PushReloadPlugin(uninstallPluginNameSet, unloadPluginNameSet, reloadPluginS
}
logging.LogInfof("reload plugins, uninstalls=%v, unloads=%v, reloads=%v, dataChanges=%v", slices[0], slices[1], slices[2], slices[3])
- payload := map[string]interface{}{
+ payload := map[string]any{
"uninstallPlugins": slices[0], // 插件卸载
"unloadPlugins": slices[1], // 插件禁用
"reloadPlugins": slices[2], // 插件启用,或插件代码变更
@@ -148,7 +148,7 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
}
}
- docInfo := map[string]interface{}{
+ docInfo := map[string]any{
"rootID": tree.ID,
"name": tree.Root.IALAttr("title"),
"alias": tree.Root.IALAttr("alias"),
@@ -412,5 +412,5 @@ func ReloadAttrView(avID string) {
}
func pushReloadAttrView(avID string) {
- util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
+ util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]any{"id": avID})
}
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index 81f6d3ad99..057a462c70 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -871,7 +871,7 @@ func checkoutRepo(id string) {
// 回滚快照时默认为当前数据创建一个快照
// When rolling back a snapshot, a snapshot is created for the current data by default https://github.com/siyuan-note/siyuan/issues/12470
FlushTxQueue()
- _, err = repo.Index("Backup before checkout", false, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+ _, err = repo.Index("Backup before checkout", false, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
if err != nil {
logging.LogErrorf("index repository failed: %s", err)
util.PushClearProgress()
@@ -879,7 +879,7 @@ func checkoutRepo(id string) {
return
}
- _, _, err = repo.Checkout(id, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+ _, _, err = repo.Checkout(id, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
if err != nil {
logging.LogErrorf("checkout repository failed: %s", err)
util.PushClearProgress()
@@ -924,9 +924,9 @@ func DownloadCloudSnapshot(tag, id string) (err error) {
var downloadFileCount, downloadChunkCount int
var downloadBytes int64
if "" == tag {
- downloadFileCount, downloadChunkCount, downloadBytes, err = repo.DownloadIndex(id, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+ downloadFileCount, downloadChunkCount, downloadBytes, err = repo.DownloadIndex(id, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
} else {
- downloadFileCount, downloadChunkCount, downloadBytes, err = repo.DownloadTagIndex(tag, id, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+ downloadFileCount, downloadChunkCount, downloadBytes, err = repo.DownloadTagIndex(tag, id, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
}
if err != nil {
return
@@ -963,7 +963,7 @@ func UploadCloudSnapshot(tag, id string) (err error) {
util.PushEndlessProgress(Conf.Language(116))
defer util.PushClearProgress()
- uploadFileCount, uploadChunkCount, uploadBytes, err := repo.UploadTagIndex(tag, id, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
+ uploadFileCount, uploadChunkCount, uploadBytes, err := repo.UploadTagIndex(tag, id, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
if err != nil {
if errors.Is(err, dejavu.ErrCloudBackupCountExceeded) {
err = fmt.Errorf(Conf.Language(84), Conf.Language(154))
@@ -1039,7 +1039,7 @@ func GetCloudRepoTagSnapshots() (ret []*dejavu.Log, err error) {
}
}
- logs, err := repo.GetCloudRepoTagLogs(map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
+ logs, err := repo.GetCloudRepoTagLogs(map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
if err != nil {
return
}
@@ -1187,7 +1187,7 @@ func IndexRepo(memo string) (err error) {
start := time.Now()
latest, _ := repo.Latest()
FlushTxQueue()
- index, err := repo.Index(memo, true, map[string]interface{}{
+ index, err := repo.Index(memo, true, map[string]any{
eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress,
})
if err != nil {
@@ -1266,7 +1266,7 @@ func syncRepoDownload() (err error) {
beforeSyncPetals := getPetals()
- syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ syncContext := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
mergeResult, trafficStat, err := repo.SyncDownload(syncContext)
elapsed := time.Since(start)
if err != nil {
@@ -1338,7 +1338,7 @@ func syncRepoUpload() (err error) {
return
}
- syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ syncContext := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
trafficStat, err := repo.SyncUpload(syncContext)
elapsed := time.Since(start)
if err != nil {
@@ -1429,7 +1429,7 @@ func bootSyncRepo() (err error) {
defer logging.Recover()
start := time.Now()
- syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ syncContext := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
cloudLatest, getErr := repo.GetCloudLatest(syncContext)
if nil != getErr {
errs = append(errs, getErr)
@@ -1559,7 +1559,7 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
beforeSyncPetals := getPetals()
- syncContext := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ syncContext := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
mergeResult, trafficStat, err := repo.Sync(syncContext)
elapsed := time.Since(start)
if err != nil {
@@ -1875,7 +1875,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
if 0 < len(upsertRootIDs) || 0 < len(removeRootIDs) {
util.BroadcastByType("main", "syncMergeResult", 0, "",
- map[string]interface{}{"upsertRootIDs": upsertRootIDs, "removeRootIDs": removeRootIDs})
+ map[string]any{"upsertRootIDs": upsertRootIDs, "removeRootIDs": removeRootIDs})
}
time.Sleep(2 * time.Second)
@@ -1957,7 +1957,7 @@ func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entit
}
afterIndex, err = repo.Index("[Sync] Cloud sync", checkChunks,
- map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
+ map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar})
if err != nil {
logging.LogErrorf("index data repo before cloud sync failed: %s", err)
return
@@ -2042,14 +2042,14 @@ func init() {
}
func subscribeRepoEvents() {
- eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]interface{}, path string) {
+ eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]any, path string) {
msg := fmt.Sprintf(Conf.Language(158), path)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
indexWalkDataCount := 0
- eventbus.Subscribe(eventbus.EvtIndexWalkData, func(context map[string]interface{}, path string) {
+ eventbus.Subscribe(eventbus.EvtIndexWalkData, func(context map[string]any, path string) {
msg := fmt.Sprintf(Conf.Language(158), filepath.Base(path))
if 0 == indexWalkDataCount%1024 {
util.SetBootDetails(msg)
@@ -2057,25 +2057,25 @@ func subscribeRepoEvents() {
}
indexWalkDataCount++
})
- eventbus.Subscribe(eventbus.EvtIndexBeforeGetLatestFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtIndexBeforeGetLatestFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(159), 0, total)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtIndexGetLatestFile, func(context map[string]interface{}, count int, total int) {
+ eventbus.Subscribe(eventbus.EvtIndexGetLatestFile, func(context map[string]any, count int, total int) {
msg := fmt.Sprintf(Conf.Language(159), count, total)
if 0 == count%64 {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
}
})
- eventbus.Subscribe(eventbus.EvtIndexUpsertFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtIndexUpsertFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(160), 0, total)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtIndexUpsertFile, func(context map[string]interface{}, count int, total int) {
+ eventbus.Subscribe(eventbus.EvtIndexUpsertFile, func(context map[string]any, count int, total int) {
msg := fmt.Sprintf(Conf.Language(160), count, total)
if 0 == count%32 {
util.SetBootDetails(msg)
@@ -2083,13 +2083,13 @@ func subscribeRepoEvents() {
}
})
- eventbus.Subscribe(eventbus.EvtCheckoutBeforeWalkData, func(context map[string]interface{}, path string) {
+ eventbus.Subscribe(eventbus.EvtCheckoutBeforeWalkData, func(context map[string]any, path string) {
msg := fmt.Sprintf(Conf.Language(161), path)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
coWalkDataCount := 0
- eventbus.Subscribe(eventbus.EvtCheckoutWalkData, func(context map[string]interface{}, path string) {
+ eventbus.Subscribe(eventbus.EvtCheckoutWalkData, func(context map[string]any, path string) {
msg := fmt.Sprintf(Conf.Language(161), filepath.Base(path))
if 0 == coWalkDataCount%512 {
util.SetBootDetails(msg)
@@ -2098,14 +2098,14 @@ func subscribeRepoEvents() {
coWalkDataCount++
})
var bootProgressPart int32
- eventbus.Subscribe(eventbus.EvtCheckoutUpsertFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCheckoutUpsertFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(162), 0, total)
util.SetBootDetails(msg)
bootProgressPart = int32(10 / float64(total))
util.ContextPushMsg(context, msg)
})
coUpsertFileCount := 0
- eventbus.Subscribe(eventbus.EvtCheckoutUpsertFile, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCheckoutUpsertFile, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(162), count, total)
util.IncBootProgress(bootProgressPart, msg)
if 0 == coUpsertFileCount%32 {
@@ -2113,14 +2113,14 @@ func subscribeRepoEvents() {
}
coUpsertFileCount++
})
- eventbus.Subscribe(eventbus.EvtCheckoutRemoveFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCheckoutRemoveFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(163), 0, total)
util.SetBootDetails(msg)
bootProgressPart = int32(10 / float64(total))
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCheckoutRemoveFile, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCheckoutRemoveFile, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(163), count, total)
util.IncBootProgress(bootProgressPart, msg)
if 0 == count%64 {
@@ -2128,104 +2128,104 @@ func subscribeRepoEvents() {
}
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadIndex, func(context map[string]interface{}, id string) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadIndex, func(context map[string]any, id string) {
msg := fmt.Sprintf(Conf.Language(164), id[:7])
util.IncBootProgress(1, msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(165), 0, total)
util.SetBootDetails(msg)
bootProgressPart = int32(10 / float64(total))
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadFile, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadFile, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(165), count, total)
util.IncBootProgress(bootProgressPart, msg)
if 0 == count%8 {
util.ContextPushMsg(context, msg)
}
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunks, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunks, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(166), 0, total)
util.SetBootDetails(msg)
bootProgressPart = int32(10 / float64(total))
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunk, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunk, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(166), count, total)
util.IncBootProgress(bootProgressPart, msg)
if 0 == count%8 {
util.ContextPushMsg(context, msg)
}
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadRef, func(context map[string]interface{}, ref string) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadRef, func(context map[string]any, ref string) {
msg := fmt.Sprintf(Conf.Language(167), ref)
util.IncBootProgress(1, msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadIndex, func(context map[string]interface{}, id string) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadIndex, func(context map[string]any, id string) {
msg := fmt.Sprintf(Conf.Language(168), id[:7])
util.IncBootProgress(1, msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadFiles, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadFiles, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(169), 0, total)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadFile, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadFile, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(169), count, total)
if 0 == count%8 {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
}
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunks, func(context map[string]interface{}, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunks, func(context map[string]any, total int) {
msg := fmt.Sprintf(Conf.Language(170), 0, total)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunk, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunk, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(170), count, total)
if 0 == count%8 {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
}
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadRef, func(context map[string]interface{}, ref string) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadRef, func(context map[string]any, ref string) {
msg := fmt.Sprintf(Conf.Language(171), ref)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudLock, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudLock, func(context map[string]any) {
msg := fmt.Sprintf(Conf.Language(186))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudUnlock, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudUnlock, func(context map[string]any) {
msg := fmt.Sprintf(Conf.Language(187))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadIndexes, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadIndexes, func(context map[string]any) {
msg := fmt.Sprintf(Conf.Language(208))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeUploadCheckIndex, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeUploadCheckIndex, func(context map[string]any) {
msg := fmt.Sprintf(Conf.Language(209))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudBeforeFixObjects, func(context map[string]interface{}, count, total int) {
+ eventbus.Subscribe(eventbus.EvtCloudBeforeFixObjects, func(context map[string]any, count, total int) {
msg := fmt.Sprintf(Conf.Language(210), count, total)
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
- eventbus.Subscribe(eventbus.EvtCloudAfterFixObjects, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudAfterFixObjects, func(context map[string]any) {
msg := fmt.Sprintf(Conf.Language(211))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
@@ -2233,28 +2233,28 @@ func subscribeRepoEvents() {
eventbus.Subscribe(eventbus.EvtCloudCorrupted, func() {
util.PushErrMsg(Conf.language(220), 30000)
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeListObjects, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeListObjects, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(224))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeListIndexes, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeListIndexes, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(225))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeListRefs, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeListRefs, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(226))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadIndexes, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadIndexes, func(context map[string]any) {
util.ContextPushMsg(context, fmt.Sprintf(Conf.language(227)))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadFiles, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadFiles, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(228))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexes, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexes, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(229))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexesV2, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexesV2, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(230))
})
- eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveObjects, func(context map[string]interface{}) {
+ eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveObjects, func(context map[string]any) {
util.ContextPushMsg(context, Conf.language(231))
})
}
diff --git a/kernel/model/session.go b/kernel/model/session.go
index 39b4c2c25c..997093959e 100644
--- a/kernel/model/session.go
+++ b/kernel/model/session.go
@@ -47,7 +47,7 @@ func LogoutAuth(c *gin.Context) {
if "" == Conf.AccessAuthCode {
ret.Code = -1
ret.Msg = Conf.Language(86)
- ret.Data = map[string]interface{}{"closeTimeout": 5000}
+ ret.Data = map[string]any{"closeTimeout": 5000}
return
}
@@ -191,7 +191,7 @@ func CheckReadonly(c *gin.Context) {
result := util.NewResult()
result.Code = -1
result.Msg = Conf.Language(34)
- result.Data = map[string]interface{}{"closeTimeout": 5000}
+ result.Data = map[string]any{"closeTimeout": 5000}
c.JSON(http.StatusOK, result)
c.Abort()
return
@@ -229,7 +229,7 @@ func CheckAuth(c *gin.Context) {
return
}
- c.JSON(http.StatusUnauthorized, map[string]interface{}{"code": -1, "msg": "Auth failed [header: Authorization]"})
+ c.JSON(http.StatusUnauthorized, map[string]any{"code": -1, "msg": "Auth failed [header: Authorization]"})
c.Abort()
return
}
@@ -243,7 +243,7 @@ func CheckAuth(c *gin.Context) {
return
}
- c.JSON(http.StatusUnauthorized, map[string]interface{}{"code": -1, "msg": "Auth failed [query: token]"})
+ c.JSON(http.StatusUnauthorized, map[string]any{"code": -1, "msg": "Auth failed [query: token]"})
c.Abort()
return
}
@@ -270,7 +270,7 @@ func CheckAuth(c *gin.Context) {
("" != host && !util.IsLocalHost(host)) ||
("" != origin && !util.IsLocalOrigin(origin) && !strings.HasPrefix(origin, "chrome-extension://")) ||
("" != forwardedHost && !util.IsLocalHost(forwardedHost)) {
- c.JSON(http.StatusUnauthorized, map[string]interface{}{"code": -1, "msg": "Auth failed: for security reasons, please set [Access authorization code] when using non-127.0.0.1 access\n\n为安全起见,使用非 127.0.0.1 访问时请设置 [访问授权码]"})
+ c.JSON(http.StatusUnauthorized, map[string]any{"code": -1, "msg": "Auth failed: for security reasons, please set [Access authorization code] when using non-127.0.0.1 access\n\n为安全起见,使用非 127.0.0.1 访问时请设置 [访问授权码]"})
c.Abort()
return
}
@@ -352,7 +352,7 @@ func CheckAuth(c *gin.Context) {
userAgentHeader := c.GetHeader("User-Agent")
if strings.HasPrefix(userAgentHeader, "SiYuan/") || strings.HasPrefix(userAgentHeader, "Mozilla/") {
if "GET" != c.Request.Method || c.IsWebsocket() {
- c.JSON(http.StatusUnauthorized, map[string]interface{}{"code": -1, "msg": Conf.Language(156)})
+ c.JSON(http.StatusUnauthorized, map[string]any{"code": -1, "msg": Conf.Language(156)})
c.Abort()
return
}
@@ -368,7 +368,7 @@ func CheckAuth(c *gin.Context) {
return
}
- c.JSON(http.StatusUnauthorized, map[string]interface{}{"code": -1, "msg": "Auth failed [session]"})
+ c.JSON(http.StatusUnauthorized, map[string]any{"code": -1, "msg": "Auth failed [session]"})
c.Abort()
return
}
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index 96cb21f625..5daa9f7426 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -45,8 +45,8 @@ type RecentDoc struct {
}
type OutlineDoc struct {
- DocID string `json:"docID"`
- Data map[string]interface{} `json:"data"`
+ DocID string `json:"docID"`
+ Data map[string]any `json:"data"`
}
var recentDocLock = sync.Mutex{}
@@ -646,7 +646,7 @@ func RemoveLocalStorageVals(keys []string) (err error) {
return setLocalStorage(localStorage)
}
-func SetLocalStorageVal(key string, val interface{}) (err error) {
+func SetLocalStorageVal(key string, val any) (err error) {
localStorageLock.Lock()
defer localStorageLock.Unlock()
@@ -655,19 +655,19 @@ func SetLocalStorageVal(key string, val interface{}) (err error) {
return setLocalStorage(localStorage)
}
-func SetLocalStorage(val interface{}) (err error) {
+func SetLocalStorage(val any) (err error) {
localStorageLock.Lock()
defer localStorageLock.Unlock()
return setLocalStorage(val)
}
-func GetLocalStorage() (ret map[string]interface{}) {
+func GetLocalStorage() (ret map[string]any) {
localStorageLock.Lock()
defer localStorageLock.Unlock()
return getLocalStorage()
}
-func setLocalStorage(val interface{}) (err error) {
+func setLocalStorage(val any) (err error) {
dirPath := filepath.Join(util.DataDir, "storage")
if err = os.MkdirAll(dirPath, 0755); err != nil {
logging.LogErrorf("create storage [local] dir failed: %s", err)
@@ -689,9 +689,9 @@ func setLocalStorage(val interface{}) (err error) {
return
}
-func getLocalStorage() (ret map[string]interface{}) {
+func getLocalStorage() (ret map[string]any) {
// When local.json is corrupted, clear the file to avoid being unable to enter the main interface https://github.com/siyuan-note/siyuan/issues/7911
- ret = map[string]interface{}{}
+ ret = map[string]any{}
lsPath := filepath.Join(util.DataDir, "storage/local.json")
if !filelock.IsExist(lsPath) {
return
@@ -712,11 +712,11 @@ func getLocalStorage() (ret map[string]interface{}) {
var outlineStorageLock = sync.Mutex{}
-func GetOutlineStorage(docID string) (ret map[string]interface{}, err error) {
+func GetOutlineStorage(docID string) (ret map[string]any, err error) {
outlineStorageLock.Lock()
defer outlineStorageLock.Unlock()
- ret = map[string]interface{}{}
+ ret = map[string]any{}
outlineDocs, err := getOutlineDocs()
if err != nil {
return
@@ -731,16 +731,16 @@ func GetOutlineStorage(docID string) (ret map[string]interface{}, err error) {
return
}
-func SetOutlineStorage(docID string, val interface{}) (err error) {
+func SetOutlineStorage(docID string, val any) (err error) {
outlineStorageLock.Lock()
defer outlineStorageLock.Unlock()
outlineDoc := &OutlineDoc{
DocID: docID,
- Data: make(map[string]interface{}),
+ Data: make(map[string]any),
}
- if valMap, ok := val.(map[string]interface{}); ok {
+ if valMap, ok := val.(map[string]any); ok {
outlineDoc.Data = valMap
}
diff --git a/kernel/model/sync.go b/kernel/model/sync.go
index d5df2b6a17..ba1c75fabe 100644
--- a/kernel/model/sync.go
+++ b/kernel/model/sync.go
@@ -213,7 +213,7 @@ func syncData(exit, byHand bool) {
if 1 == Conf.Sync.Mode && nil != webSocketConn && Conf.Sync.Perception && dataChanged {
// 如果处于自动同步模式且不是由 WS 触发的同步,则通知其他设备上的内核进行同步
- request := map[string]interface{}{
+ request := map[string]any{
"cmd": "synced",
"synced": Conf.Sync.Synced,
}
@@ -872,7 +872,7 @@ func connectSyncWebSocket() {
}
logging.LogInfof("sync websocket message: %v", result)
- data := result.Data.(map[string]interface{})
+ data := result.Data.(map[string]any)
switch data["cmd"].(string) {
case "synced":
// Improve data synchronization perception https://github.com/siyuan-note/siyuan/issues/13000
@@ -881,8 +881,8 @@ func connectSyncWebSocket() {
onlineKernelsLock.Lock()
onlineKernels = []*OnlineKernel{}
- for _, kernel := range data["kernels"].([]interface{}) {
- kernelMap := kernel.(map[string]interface{})
+ for _, kernel := range data["kernels"].([]any) {
+ kernelMap := kernel.(map[string]any)
onlineKernels = append(onlineKernels, &OnlineKernel{
ID: kernelMap["id"].(string),
Hostname: kernelMap["hostname"].(string),
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 37ffec12f0..162c9013f5 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -1600,7 +1600,7 @@ func unfoldHeading(heading, currentNode *ast.Node) {
heading.RemoveIALAttr("fold")
heading.RemoveIALAttr("heading-fold")
- util.BroadcastByType("protyle", "unfoldHeading", 0, "", map[string]interface{}{"id": heading.ID, "currentNodeID": currentNode.ID})
+ util.BroadcastByType("protyle", "unfoldHeading", 0, "", map[string]any{"id": heading.ID, "currentNodeID": currentNode.ID})
}
func getRefDefIDs(node *ast.Node) (refDefIDs []string) {
@@ -1819,38 +1819,38 @@ func createdUpdated(node *ast.Node) {
}
type Operation struct {
- Action string `json:"action"`
- Data interface{} `json:"data"`
- ID string `json:"id"`
- RootID string `json:"rootID"` // 思源内部暂时没有用到 https://github.com/siyuan-note/siyuan/issues/17179#issuecomment-4051604916
- ParentID string `json:"parentID"`
- PreviousID string `json:"previousID"`
- NextID string `json:"nextID"`
- RetData interface{} `json:"retData"`
- BlockIDs []string `json:"blockIDs"`
- BlockID string `json:"blockID"`
+ Action string `json:"action"`
+ Data any `json:"data"`
+ ID string `json:"id"`
+ RootID string `json:"rootID"` // 思源内部暂时没有用到 https://github.com/siyuan-note/siyuan/issues/17179#issuecomment-4051604916
+ ParentID string `json:"parentID"`
+ PreviousID string `json:"previousID"`
+ NextID string `json:"nextID"`
+ RetData any `json:"retData"`
+ BlockIDs []string `json:"blockIDs"`
+ BlockID string `json:"blockID"`
DeckID string `json:"deckID"` // 用于添加/删除闪卡
- AvID string `json:"avID"` // 属性视图 ID
- SrcIDs []string `json:"srcIDs"` // 用于从属性视图中删除行
- Srcs []map[string]interface{} `json:"srcs"` // 用于添加属性视图行(包括绑定块){id, content, isDetached}
- IsDetached bool `json:"isDetached"` // 用于标识是否未绑定块,仅存在于属性视图中
- Name string `json:"name"` // 属性视图列名
- Typ string `json:"type"` // 属性视图列类型
- Format string `json:"format"` // 属性视图列格式化
- KeyID string `json:"keyID"` // 属性视图字段 ID
- RowID string `json:"rowID"` // 属性视图行 ID
- IsTwoWay bool `json:"isTwoWay"` // 属性视图关联列是否是双向关系
- BackRelationKeyID string `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID
- RemoveDest bool `json:"removeDest"` // 属性视图删除关联目标
- Layout av.LayoutType `json:"layout"` // 属性视图布局类型
- GroupID string `json:"groupID"` // 属性视图分组视图 ID
- TargetGroupID string `json:"targetGroupID"` // 属性视图目标分组视图 ID
- ViewID string `json:"viewID"` // 属性视图视图 ID
- IgnoreDefaultFill bool `json:"ignoreDefaultFill"` // 是否忽略默认填充
-
- Context map[string]interface{} `json:"context"` // 上下文信息
+ AvID string `json:"avID"` // 属性视图 ID
+ SrcIDs []string `json:"srcIDs"` // 用于从属性视图中删除行
+ Srcs []map[string]any `json:"srcs"` // 用于添加属性视图行(包括绑定块){id, content, isDetached}
+ IsDetached bool `json:"isDetached"` // 用于标识是否未绑定块,仅存在于属性视图中
+ Name string `json:"name"` // 属性视图列名
+ Typ string `json:"type"` // 属性视图列类型
+ Format string `json:"format"` // 属性视图列格式化
+ KeyID string `json:"keyID"` // 属性视图字段 ID
+ RowID string `json:"rowID"` // 属性视图行 ID
+ IsTwoWay bool `json:"isTwoWay"` // 属性视图关联列是否是双向关系
+ BackRelationKeyID string `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID
+ RemoveDest bool `json:"removeDest"` // 属性视图删除关联目标
+ Layout av.LayoutType `json:"layout"` // 属性视图布局类型
+ GroupID string `json:"groupID"` // 属性视图分组视图 ID
+ TargetGroupID string `json:"targetGroupID"` // 属性视图目标分组视图 ID
+ ViewID string `json:"viewID"` // 属性视图视图 ID
+ IgnoreDefaultFill bool `json:"ignoreDefaultFill"` // 是否忽略默认填充
+
+ Context map[string]any `json:"context"` // 上下文信息
}
type Transaction struct {
@@ -1909,7 +1909,7 @@ func (tx *Transaction) commit() (err error) {
return
}
- var sources []interface{}
+ var sources []any
sources = append(sources, tx)
util.PushSaveDoc(tree.ID, "tx", sources)
diff --git a/kernel/model/updater.go b/kernel/model/updater.go
index 4e4c327462..555d806076 100644
--- a/kernel/model/updater.go
+++ b/kernel/model/updater.go
@@ -164,7 +164,7 @@ func getUpdatePkg() (downloadPkgURLs []string, checksum string, err error) {
downloadPkgURLs = append(downloadPkgURLs, ghproxyURL)
}
- checksums := result["checksums"].(map[string]interface{})
+ checksums := result["checksums"].(map[string]any)
checksum = checksums[pkg].(string)
if "" == checksum {
@@ -257,9 +257,9 @@ func getAnnouncements() (ret []*Announcement) {
return
}
- announcements := result["announcement"].([]interface{})
+ announcements := result["announcement"].([]any)
for _, announcement := range announcements {
- ann := announcement.(map[string]interface{})
+ ann := announcement.(map[string]any)
ret = append(ret, &Announcement{
Id: ann["id"].(string),
Title: ann["title"].(string),
diff --git a/kernel/model/upload.go b/kernel/model/upload.go
index f59665b118..662ac0cb58 100644
--- a/kernel/model/upload.go
+++ b/kernel/model/upload.go
@@ -34,8 +34,8 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func InsertLocalAssets(id string, assetAbsPaths []string, isUpload bool) (succMap map[string]interface{}, err error) {
- succMap = map[string]interface{}{}
+func InsertLocalAssets(id string, assetAbsPaths []string, isUpload bool) (succMap map[string]any, err error) {
+ succMap = map[string]any{}
bt := treenode.GetBlockTree(id)
if nil == bt {
@@ -171,7 +171,7 @@ func Upload(c *gin.Context) {
}
var errFiles []string
- succMap := map[string]interface{}{}
+ succMap := map[string]any{}
files := form.File["file[]"]
skipIfDuplicated := false // 默认不跳过重复文件,但是有的场景需要跳过,比如上传 PDF 标注图片 https://github.com/siyuan-note/siyuan/issues/10666
if nil != form.Value["skipIfDuplicated"] {
@@ -344,7 +344,7 @@ func Upload(c *gin.Context) {
}
}
- ret.Data = map[string]interface{}{
+ ret.Data = map[string]any{
"errFiles": errFiles,
"succMap": succMap,
}
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index d281a4c330..7a2a5b1453 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -468,7 +468,7 @@ func serveAppearance(ginServer *gin.Engine) {
util.ReportFileSysFatalError(err)
return
}
- enUSMap := map[string]interface{}{}
+ enUSMap := map[string]any{}
if err = gulu.JSON.UnmarshalJSON(enUSData, &enUSMap); err != nil {
logging.LogErrorf("unmarshal en_US.json [%s] failed: %s", enUSFilePath, err)
util.ReportFileSysFatalError(err)
@@ -482,7 +482,7 @@ func serveAppearance(ginServer *gin.Engine) {
return
}
- langMap := map[string]interface{}{}
+ langMap := map[string]any{}
if err = gulu.JSON.UnmarshalJSON(data, &langMap); err != nil {
logging.LogErrorf("unmarshal json [%s] failed: %s", filePath, err)
c.JSON(200, enUSMap)
@@ -528,12 +528,12 @@ func serveAuthPage(c *gin.Context) {
keymapHideWindow := "⌥M"
if nil != (*model.Conf.Keymap)["general"] {
switch (*model.Conf.Keymap)["general"].(type) {
- case map[string]interface{}:
- keymapGeneral := (*model.Conf.Keymap)["general"].(map[string]interface{})
+ case map[string]any:
+ keymapGeneral := (*model.Conf.Keymap)["general"].(map[string]any)
if nil != keymapGeneral["toggleWin"] {
switch keymapGeneral["toggleWin"].(type) {
- case map[string]interface{}:
- toggleWin := keymapGeneral["toggleWin"].(map[string]interface{})
+ case map[string]any:
+ toggleWin := keymapGeneral["toggleWin"].(map[string]any)
if nil != toggleWin["custom"] {
keymapHideWindow = toggleWin["custom"].(string)
}
@@ -544,7 +544,7 @@ func serveAuthPage(c *gin.Context) {
keymapHideWindow = "⌥M"
}
}
- model := map[string]interface{}{
+ model := map[string]any{
"l0": model.Conf.Language(173),
"l1": model.Conf.Language(174),
"l2": template.HTML(model.Conf.Language(172)),
@@ -788,7 +788,7 @@ func serveWebSocket(ginServer *gin.Engine) {
return
}
- request := map[string]interface{}{}
+ request := map[string]any{}
if err := gulu.JSON.UnmarshalJSON(msg, &request); err != nil {
result := util.NewResult()
result.Code = -1
@@ -808,7 +808,7 @@ func serveWebSocket(ginServer *gin.Engine) {
cmdStr := request["cmd"].(string)
cmdId := request["reqId"].(float64)
- param := request["param"].(map[string]interface{})
+ param := request["param"].(map[string]any)
command := cmd.NewCommand(cmdStr, cmdId, param, s)
if nil == command {
result := util.NewResult()
diff --git a/kernel/sql/asset_content.go b/kernel/sql/asset_content.go
index d97d9b6ef5..691b049237 100644
--- a/kernel/sql/asset_content.go
+++ b/kernel/sql/asset_content.go
@@ -39,7 +39,7 @@ const (
AssetContentsPlaceholder = "(?, ?, ?, ?, ?, ?, ?)"
)
-func insertAssetContents(tx *sql.Tx, assetContents []*AssetContent, context map[string]interface{}) (err error) {
+func insertAssetContents(tx *sql.Tx, assetContents []*AssetContent, context map[string]any) (err error) {
if 1 > len(assetContents) {
return
}
@@ -64,9 +64,9 @@ func insertAssetContents(tx *sql.Tx, assetContents []*AssetContent, context map[
return
}
-func insertAssetContents0(tx *sql.Tx, bulk []*AssetContent, context map[string]interface{}) (err error) {
+func insertAssetContents0(tx *sql.Tx, bulk []*AssetContent, context map[string]any) (err error) {
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(AssetContentsPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(AssetContentsPlaceholder, "?"))
for _, b := range bulk {
valueStrings = append(valueStrings, AssetContentsPlaceholder)
valueArgs = append(valueArgs, b.ID)
diff --git a/kernel/sql/asset_content_query.go b/kernel/sql/asset_content_query.go
index 04d16a3512..da75e76f4d 100644
--- a/kernel/sql/asset_content_query.go
+++ b/kernel/sql/asset_content_query.go
@@ -27,11 +27,11 @@ import (
"github.com/siyuan-note/logging"
)
-func QueryAssetContentNoLimit(stmt string) (ret []map[string]interface{}, err error) {
+func QueryAssetContentNoLimit(stmt string) (ret []map[string]any, err error) {
return queryAssetContentRawStmt(stmt, math.MaxInt)
}
-func queryAssetContentRawStmt(stmt string, limit int) (ret []map[string]interface{}, err error) {
+func queryAssetContentRawStmt(stmt string, limit int) (ret []map[string]any, err error) {
rows, err := queryAssetContent(stmt)
if err != nil {
if strings.Contains(err.Error(), "syntax error") {
@@ -49,8 +49,8 @@ func queryAssetContentRawStmt(stmt string, limit int) (ret []map[string]interfac
noLimit := !containsLimitClause(stmt)
var count int
for rows.Next() {
- columns := make([]interface{}, len(cols))
- columnPointers := make([]interface{}, len(cols))
+ columns := make([]any, len(cols))
+ columnPointers := make([]any, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
@@ -59,9 +59,9 @@ func queryAssetContentRawStmt(stmt string, limit int) (ret []map[string]interfac
return
}
- m := make(map[string]interface{})
+ m := make(map[string]any)
for i, colName := range cols {
- val := columnPointers[i].(*interface{})
+ val := columnPointers[i].(*any)
m[colName] = *val
}
@@ -180,7 +180,7 @@ func scanAssetContentRows(rows *sql.Rows) (ret *AssetContent) {
return
}
-func queryAssetContent(query string, args ...interface{}) (*sql.Rows, error) {
+func queryAssetContent(query string, args ...any) (*sql.Rows, error) {
query = strings.TrimSpace(query)
if "" == query {
return nil, errors.New("statement is empty")
diff --git a/kernel/sql/av.go b/kernel/sql/av.go
index fa4402ce33..ac875b464a 100644
--- a/kernel/sql/av.go
+++ b/kernel/sql/av.go
@@ -141,7 +141,7 @@ func renderTemplateField(ial map[string]string, keyValues []*av.KeyValues, tplCo
}
buf := &bytes.Buffer{}
- dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据
+ dataModel := map[string]any{} // 复制一份 IAL 以避免修改原始数据
for k, v := range ial {
dataModel[k] = v
diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go
index c1ab498e0b..bf0ffe3815 100644
--- a/kernel/sql/block_query.go
+++ b/kernel/sql/block_query.go
@@ -359,11 +359,11 @@ func QueryBookmarkLabels() (ret []string) {
return
}
-func QueryNoLimit(stmt string) (ret []map[string]interface{}, err error) {
+func QueryNoLimit(stmt string) (ret []map[string]any, err error) {
return queryRawStmt(stmt, math.MaxInt)
}
-func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
+func Query(stmt string, limit int) (ret []map[string]any, err error) {
originalStmt := stmt
// Kernel API `/api/query/sql` support `||` operator https://github.com/siyuan-note/siyuan/issues/9662
// 这里为了支持 || 操作符,使用了另一个 sql 解析器,但是这个解析器无法处理 UNION https://github.com/siyuan-note/siyuan/issues/8226
@@ -409,7 +409,7 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
}
}
- ret = []map[string]interface{}{}
+ ret = []map[string]any{}
rows, err := query(stmt)
if err != nil {
rows, err = query(originalStmt + " LIMIT " + strconv.Itoa(limit))
@@ -426,8 +426,8 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
}
for rows.Next() {
- columns := make([]interface{}, len(cols))
- columnPointers := make([]interface{}, len(cols))
+ columns := make([]any, len(cols))
+ columnPointers := make([]any, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
@@ -436,9 +436,9 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
return
}
- m := make(map[string]interface{})
+ m := make(map[string]any)
for i, colName := range cols {
- val := columnPointers[i].(*interface{})
+ val := columnPointers[i].(*any)
m[colName] = *val
}
ret = append(ret, m)
@@ -446,7 +446,7 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
return
}
-func ToBlocks(result []map[string]interface{}) (ret []*Block) {
+func ToBlocks(result []map[string]any) (ret []*Block) {
for _, row := range result {
b := &Block{
ID: row["id"].(string),
@@ -501,7 +501,7 @@ func getLimitClause(parsedStmt sqlparser.Statement, limit int) (ret *sqlparser.L
return
}
-func queryRawStmt(stmt string, limit int) (ret []map[string]interface{}, err error) {
+func queryRawStmt(stmt string, limit int) (ret []map[string]any, err error) {
rows, err := query(stmt)
if err != nil {
if strings.Contains(err.Error(), "syntax error") {
@@ -519,8 +519,8 @@ func queryRawStmt(stmt string, limit int) (ret []map[string]interface{}, err err
noLimit := !containsLimitClause(stmt)
var count int
for rows.Next() {
- columns := make([]interface{}, len(cols))
- columnPointers := make([]interface{}, len(cols))
+ columns := make([]any, len(cols))
+ columnPointers := make([]any, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
@@ -529,9 +529,9 @@ func queryRawStmt(stmt string, limit int) (ret []map[string]interface{}, err err
return
}
- m := make(map[string]interface{})
+ m := make(map[string]any)
for i, colName := range cols {
- val := columnPointers[i].(*interface{})
+ val := columnPointers[i].(*any)
m[colName] = *val
}
@@ -881,7 +881,7 @@ func GetBlocks(ids []string) (ret []*Block) {
length := len(notHitIDs)
stmtBuilder := bytes.Buffer{}
stmtBuilder.WriteString("SELECT * FROM blocks WHERE id IN (")
- var args []interface{}
+ var args []any
for i, id := range notHitIDs {
args = append(args, id)
stmtBuilder.WriteByte('?')
diff --git a/kernel/sql/database.go b/kernel/sql/database.go
index 094dcd15a3..f960fc60c2 100644
--- a/kernel/sql/database.go
+++ b/kernel/sql/database.go
@@ -1116,7 +1116,7 @@ func deleteFileAnnotationRefsByBoxTx(tx *sql.Tx, box string) (err error) {
return
}
-func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (err error) {
+func deleteByRootID(tx *sql.Tx, rootID string, context map[string]any) (err error) {
stmt := "DELETE FROM blocks WHERE root_id = ?"
if err = execStmtTx(tx, stmt, rootID); err != nil {
return
@@ -1156,7 +1156,7 @@ func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (
return
}
-func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]interface{}) (err error) {
+func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]any) (err error) {
if 1 > len(rootIDs) {
return
}
@@ -1241,7 +1241,7 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
return
}
-func batchUpdatePath(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
+func batchUpdatePath(tx *sql.Tx, tree *parse.Tree, context map[string]any) (err error) {
ialContent := treenode.IALStr(tree.Root)
stmt := "UPDATE blocks SET box = ?, path = ?, hpath = ?, ial = ? WHERE root_id = ?"
if err = execStmtTx(tx, stmt, tree.Box, tree.Path, tree.HPath, ialContent, tree.ID); err != nil {
@@ -1263,7 +1263,7 @@ func batchUpdatePath(tx *sql.Tx, tree *parse.Tree, context map[string]interface{
return
}
-func batchUpdateHPath(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
+func batchUpdateHPath(tx *sql.Tx, tree *parse.Tree, context map[string]any) (err error) {
ialContent := treenode.IALStr(tree.Root)
stmt := "UPDATE blocks SET hpath = ?, ial = ? WHERE root_id = ?"
if err = execStmtTx(tx, stmt, tree.HPath, ialContent, tree.ID); err != nil {
@@ -1299,7 +1299,7 @@ func CloseDatabase() {
logging.LogInfof("closed database")
}
-func queryRow(query string, args ...interface{}) *sql.Row {
+func queryRow(query string, args ...any) *sql.Row {
query = strings.TrimSpace(query)
if "" == query {
logging.LogErrorf("statement is empty")
@@ -1312,7 +1312,7 @@ func queryRow(query string, args ...interface{}) *sql.Row {
return db.QueryRow(query, args...)
}
-func queryTx(tx *sql.Tx, query string, args ...interface{}) (*sql.Rows, error) {
+func queryTx(tx *sql.Tx, query string, args ...any) (*sql.Rows, error) {
query = strings.TrimSpace(query)
if "" == query {
return nil, errors.New("statement is empty")
@@ -1324,7 +1324,7 @@ func queryTx(tx *sql.Tx, query string, args ...interface{}) (*sql.Rows, error) {
return tx.Query(query, args...)
}
-func query(query string, args ...interface{}) (*sql.Rows, error) {
+func query(query string, args ...any) (*sql.Rows, error) {
query = strings.TrimSpace(query)
if "" == query {
return nil, errors.New("statement is empty")
@@ -1438,7 +1438,7 @@ func txCacheKey(tx *sql.Tx) string {
return fmt.Sprintf("%p", tx)
}
-func prepareExecInsertTx(tx *sql.Tx, stmtSQL string, args []interface{}) (err error) {
+func prepareExecInsertTx(tx *sql.Tx, stmtSQL string, args []any) (err error) {
if tx == nil {
return fmt.Errorf("tx is nil")
}
@@ -1483,7 +1483,7 @@ func prepareExecInsertTx(tx *sql.Tx, stmtSQL string, args []interface{}) (err er
return
}
-func execStmtTx(tx *sql.Tx, stmt string, args ...interface{}) (err error) {
+func execStmtTx(tx *sql.Tx, stmt string, args ...any) (err error) {
if _, err = tx.Exec(stmt, args...); err != nil {
tx.Rollback()
logging.LogErrorf("exec database stmt [%s] failed: %s\n %s", stmt, err, logging.ShortStack())
@@ -1568,7 +1568,7 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
switch v := arg.(type) {
case string:
retBlock = GetBlock(v)
- case map[string]interface{}:
+ case map[string]any:
if id, ok := v["id"]; ok {
retBlock = GetBlock(id.(string))
}
@@ -1582,7 +1582,7 @@ func SQLTemplateFuncs(templateFuncMap *template.FuncMap) {
retSpans = SelectSpansRawStmt(stmt, 512)
return
}
- (*templateFuncMap)["querySQL"] = func(stmt string) (ret []map[string]interface{}) {
+ (*templateFuncMap)["querySQL"] = func(stmt string) (ret []map[string]any) {
ret, _ = Query(stmt, 1024)
return
}
diff --git a/kernel/sql/history.go b/kernel/sql/history.go
index 321a881b0a..cd6a63e89f 100644
--- a/kernel/sql/history.go
+++ b/kernel/sql/history.go
@@ -36,8 +36,8 @@ type History struct {
Path string
}
-func QueryHistory(stmt string) (ret []map[string]interface{}, err error) {
- ret = []map[string]interface{}{}
+func QueryHistory(stmt string) (ret []map[string]any, err error) {
+ ret = []map[string]any{}
rows, err := queryHistory(stmt)
if err != nil {
logging.LogWarnf("sql query [%s] failed: %s", stmt, err)
@@ -51,8 +51,8 @@ func QueryHistory(stmt string) (ret []map[string]interface{}, err error) {
}
for rows.Next() {
- columns := make([]interface{}, len(cols))
- columnPointers := make([]interface{}, len(cols))
+ columns := make([]any, len(cols))
+ columnPointers := make([]any, len(cols))
for i := range columns {
columnPointers[i] = &columns[i]
}
@@ -61,9 +61,9 @@ func QueryHistory(stmt string) (ret []map[string]interface{}, err error) {
return
}
- m := make(map[string]interface{})
+ m := make(map[string]any)
for i, colName := range cols {
- val := columnPointers[i].(*interface{})
+ val := columnPointers[i].(*any)
m[colName] = *val
}
ret = append(ret, m)
@@ -99,7 +99,7 @@ func scanHistoryRows(rows *sql.Rows) (ret *History) {
return
}
-func queryHistory(query string, args ...interface{}) (*sql.Rows, error) {
+func queryHistory(query string, args ...any) (*sql.Rows, error) {
query = strings.TrimSpace(query)
if "" == query {
return nil, errors.New("statement is empty")
@@ -123,7 +123,7 @@ const (
HistoriesPlaceholder = "(?, ?, ?, ?, ?, ?, ?)"
)
-func insertHistories(tx *sql.Tx, histories []*History, context map[string]interface{}) (err error) {
+func insertHistories(tx *sql.Tx, histories []*History, context map[string]any) (err error) {
if 1 > len(histories) {
return
}
@@ -148,9 +148,9 @@ func insertHistories(tx *sql.Tx, histories []*History, context map[string]interf
return
}
-func insertHistories0(tx *sql.Tx, bulk []*History, context map[string]interface{}) (err error) {
+func insertHistories0(tx *sql.Tx, bulk []*History, context map[string]any) (err error) {
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(HistoriesPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(HistoriesPlaceholder, "?"))
for _, b := range bulk {
valueStrings = append(valueStrings, HistoriesPlaceholder)
valueArgs = append(valueArgs, b.ID)
diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go
index 54d3d9cd2c..d984c95ac3 100644
--- a/kernel/sql/queue.go
+++ b/kernel/sql/queue.go
@@ -148,7 +148,7 @@ func FlushQueue() {
}
}
- context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ context := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
if 512 < len(ops) {
disableCache()
defer enableCache()
@@ -205,7 +205,7 @@ func FlushQueue() {
eventbus.Publish(eventbus.EvtSQLIndexFlushed)
}
-func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (err error) {
+func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]any) (err error) {
switch op.action {
case "index":
err = indexTree(tx, op.indexTree, context)
diff --git a/kernel/sql/queue_asset_content.go b/kernel/sql/queue_asset_content.go
index 87675f93af..a3f5e1e270 100644
--- a/kernel/sql/queue_asset_content.go
+++ b/kernel/sql/queue_asset_content.go
@@ -64,7 +64,7 @@ func FlushAssetContentQueue() {
groupOpsTotal[op.action]++
}
- context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ context := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
groupOpsCurrent := map[string]int{}
for i, op := range ops {
if util.IsExiting.Load() {
@@ -107,7 +107,7 @@ func FlushAssetContentQueue() {
}
}
-func execAssetContentOp(op *assetContentDBQueueOperation, tx *sql.Tx, context map[string]interface{}) (err error) {
+func execAssetContentOp(op *assetContentDBQueueOperation, tx *sql.Tx, context map[string]any) (err error) {
switch op.action {
case "index":
err = insertAssetContents(tx, op.assetContents, context)
diff --git a/kernel/sql/queue_history.go b/kernel/sql/queue_history.go
index c1109c7fa5..ddc0b6819c 100644
--- a/kernel/sql/queue_history.go
+++ b/kernel/sql/queue_history.go
@@ -67,7 +67,7 @@ func FlushHistoryQueue() {
groupOpsTotal[op.action]++
}
- context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
+ context := map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
groupOpsCurrent := map[string]int{}
for i, op := range ops {
if util.IsExiting.Load() {
@@ -119,7 +119,7 @@ func FlushHistoryQueue() {
}
}
-func execHistoryOp(op *historyDBQueueOperation, tx *sql.Tx, context map[string]interface{}) (err error) {
+func execHistoryOp(op *historyDBQueueOperation, tx *sql.Tx, context map[string]any) (err error) {
switch op.action {
case "index":
err = insertHistories(tx, op.histories, context)
diff --git a/kernel/sql/upsert.go b/kernel/sql/upsert.go
index 75e1d5c107..2f2fcfc64a 100644
--- a/kernel/sql/upsert.go
+++ b/kernel/sql/upsert.go
@@ -57,7 +57,7 @@ const (
FileAnnotationRefsPlaceholder = "(?, ?, ?, ?, ?, ?, ?, ?, ?)"
)
-func insertBlocks(tx *sql.Tx, blocks []*Block, context map[string]interface{}) (err error) {
+func insertBlocks(tx *sql.Tx, blocks []*Block, context map[string]any) (err error) {
if 1 > len(blocks) {
return
}
@@ -82,9 +82,9 @@ func insertBlocks(tx *sql.Tx, blocks []*Block, context map[string]interface{}) (
return
}
-func insertBlocks0(tx *sql.Tx, bulk []*Block, context map[string]interface{}) (err error) {
+func insertBlocks0(tx *sql.Tx, bulk []*Block, context map[string]any) (err error) {
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(BlocksPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(BlocksPlaceholder, "?"))
hashBuf := bytes.Buffer{}
for _, b := range bulk {
valueStrings = append(valueStrings, BlocksPlaceholder)
@@ -171,7 +171,7 @@ func insertAttribute0(tx *sql.Tx, bulk []*Attribute) (err error) {
}
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(AttributesPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(AttributesPlaceholder, "?"))
for _, attr := range bulk {
valueStrings = append(valueStrings, AttributesPlaceholder)
valueArgs = append(valueArgs, attr.ID)
@@ -219,7 +219,7 @@ func insertAsset0(tx *sql.Tx, bulk []*Asset) (err error) {
}
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(AssetsPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(AssetsPlaceholder, "?"))
for _, asset := range bulk {
valueStrings = append(valueStrings, AssetsPlaceholder)
valueArgs = append(valueArgs, asset.ID)
@@ -268,7 +268,7 @@ func insertSpans0(tx *sql.Tx, bulk []*Span) (err error) {
}
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(SpansPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(SpansPlaceholder, "?"))
for _, span := range bulk {
valueStrings = append(valueStrings, SpansPlaceholder)
valueArgs = append(valueArgs, span.ID)
@@ -317,7 +317,7 @@ func insertRefs0(tx *sql.Tx, bulk []*Ref) (err error) {
}
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(RefsPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(RefsPlaceholder, "?"))
for _, ref := range bulk {
valueStrings = append(valueStrings, RefsPlaceholder)
valueArgs = append(valueArgs, ref.ID)
@@ -371,7 +371,7 @@ func insertFileAnnotationRefs0(tx *sql.Tx, bulk []*FileAnnotationRef) (err error
}
valueStrings := make([]string, 0, len(bulk))
- valueArgs := make([]interface{}, 0, len(bulk)*strings.Count(FileAnnotationRefsPlaceholder, "?"))
+ valueArgs := make([]any, 0, len(bulk)*strings.Count(FileAnnotationRefsPlaceholder, "?"))
for _, ref := range bulk {
valueStrings = append(valueStrings, FileAnnotationRefsPlaceholder)
valueArgs = append(valueArgs, ref.ID)
@@ -389,14 +389,14 @@ func insertFileAnnotationRefs0(tx *sql.Tx, bulk []*FileAnnotationRef) (err error
return
}
-func indexTree(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
+func indexTree(tx *sql.Tx, tree *parse.Tree, context map[string]any) (err error) {
blocks, spans, assets, attributes := fromTree(tree.Root, tree)
refs, fileAnnotationRefs := refsFromTree(tree)
err = insertTree0(tx, tree, context, blocks, spans, assets, attributes, refs, fileAnnotationRefs)
return
}
-func upsertTree(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
+func upsertTree(tx *sql.Tx, tree *parse.Tree, context map[string]any) (err error) {
oldBlockHashes := queryBlockHashes(tx, tree.ID)
blocks, spans, assets, attributes := fromTree(tree.Root, tree)
newBlockHashes := map[string]string{}
@@ -452,7 +452,7 @@ func upsertTree(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (e
return err
}
-func insertTree0(tx *sql.Tx, tree *parse.Tree, context map[string]interface{},
+func insertTree0(tx *sql.Tx, tree *parse.Tree, context map[string]any,
blocks []*Block, spans []*Span, assets []*Asset, attributes []*Attribute,
refs []*Ref, fileAnnotationRefs []*FileAnnotationRef) (err error) {
if ignoreLines := getIndexIgnoreLines(); 0 < len(ignoreLines) {
diff --git a/kernel/task/queue.go b/kernel/task/queue.go
index 30076974a0..c92f916093 100644
--- a/kernel/task/queue.go
+++ b/kernel/task/queue.go
@@ -35,26 +35,26 @@ var (
type Task struct {
Action string
Handler reflect.Value
- Args []interface{}
+ Args []any
Created time.Time
Async bool // 为 true 说明是异步任务,不会阻塞任务队列,满足 Delay 条件后立即执行
Delay time.Duration
Timeout time.Duration
}
-func AppendTask(action string, handler interface{}, args ...interface{}) {
+func AppendTask(action string, handler any, args ...any) {
appendTaskWithDelayTimeout(action, false, 0, 24*time.Hour, handler, args...)
}
-func AppendAsyncTaskWithDelay(action string, delay time.Duration, handler interface{}, args ...interface{}) {
+func AppendAsyncTaskWithDelay(action string, delay time.Duration, handler any, args ...any) {
appendTaskWithDelayTimeout(action, true, delay, 24*time.Hour, handler, args...)
}
-func AppendTaskWithTimeout(action string, timeout time.Duration, handler interface{}, args ...interface{}) {
+func AppendTaskWithTimeout(action string, timeout time.Duration, handler any, args ...any) {
appendTaskWithDelayTimeout(action, false, 0, timeout, handler, args...)
}
-func appendTaskWithDelayTimeout(action string, async bool, delay, timeout time.Duration, handler interface{}, args ...interface{}) {
+func appendTaskWithDelayTimeout(action string, async bool, delay, timeout time.Duration, handler any, args ...any) {
if util.IsExiting.Load() {
//logging.LogWarnf("task queue is paused, action [%s] will be ignored", action)
return
@@ -101,7 +101,7 @@ func containTask(task *Task, tasks []*Task) bool {
}
// areArgsEqual 比较两个参数是否相等
-func areArgsEqual(a, b interface{}) bool {
+func areArgsEqual(a, b any) bool {
// 如果两个参数都为 nil
if a == nil && b == nil {
@@ -258,7 +258,7 @@ func ContainIndexTask() bool {
}
func StatusJob() {
- var items []map[string]interface{}
+ var items []map[string]any
count := map[string]int{}
actionLangs := util.TaskActionLangs[util.Lang]
@@ -283,7 +283,7 @@ func StatusJob() {
}
}
- item := map[string]interface{}{"action": action}
+ item := map[string]any{"action": action}
items = append(items, item)
}
defer queueLock.Unlock()
@@ -291,15 +291,15 @@ func StatusJob() {
currentTaskLock.Lock()
if nil != currentTask && nil != actionLangs && !skipPushTaskAction(currentTask.Action) {
if label := actionLangs[currentTask.Action]; nil != label {
- items = append([]map[string]interface{}{{"action": label.(string)}}, items...)
+ items = append([]map[string]any{{"action": label.(string)}}, items...)
}
}
currentTaskLock.Unlock()
if 1 > len(items) {
- items = []map[string]interface{}{}
+ items = []map[string]any{}
}
- data := map[string]interface{}{}
+ data := map[string]any{}
data["tasks"] = items
util.PushBackgroundTask(data)
}
diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.go
index 3354ed3283..4b31314518 100644
--- a/kernel/treenode/blocktree.go
+++ b/kernel/treenode/blocktree.go
@@ -678,7 +678,7 @@ func CeilBlockCount(count int) int {
return 10000*100 + 1
}
-func queryRow(query string, args ...interface{}) *sql.Row {
+func queryRow(query string, args ...any) *sql.Row {
query = strings.TrimSpace(query)
if "" == query {
logging.LogErrorf("statement is empty")
@@ -691,7 +691,7 @@ func queryRow(query string, args ...interface{}) *sql.Row {
return db.QueryRow(query, args...)
}
-func query(query string, args ...interface{}) (*sql.Rows, error) {
+func query(query string, args ...any) (*sql.Rows, error) {
query = strings.TrimSpace(query)
if "" == query {
return nil, errors.New("statement is empty")
@@ -703,7 +703,7 @@ func query(query string, args ...interface{}) (*sql.Rows, error) {
return db.Query(query, args...)
}
-func exec(stmt string, args ...interface{}) (sql.Result, error) {
+func exec(stmt string, args ...any) (sql.Result, error) {
stmt = strings.TrimSpace(stmt)
if "" == stmt {
return nil, errors.New("statement is empty")
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go
index 103d0adebd..ef278a2b56 100644
--- a/kernel/util/ocr.go
+++ b/kernel/util/ocr.go
@@ -157,7 +157,7 @@ func ExistsAssetText(asset string) (ret bool) {
return
}
-func OcrAsset(asset string) (ret []map[string]interface{}, err error) {
+func OcrAsset(asset string) (ret []map[string]any, err error) {
if !TesseractEnabled {
err = fmt.Errorf(Langs[Lang][266])
return
@@ -219,7 +219,7 @@ func IsTesseractExtractable(p string) bool {
// tesseractOCRLock 用于 Tesseract OCR 加锁串行执行提升稳定性 https://github.com/siyuan-note/siyuan/issues/7265
var tesseractOCRLock = sync.Mutex{}
-func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
+func Tesseract(imgAbsPath string) (ret []map[string]any) {
if ContainerStd != Container || !TesseractEnabled {
return
}
@@ -283,7 +283,7 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
// 分割每列数据
fields := strings.Split(line, "\t")
// 将字段名和字段值映射到一个 map 中
- dataMap := make(map[string]interface{})
+ dataMap := make(map[string]any)
headers := strings.Split(lines[0], "\t")
for i, header := range headers {
if i < len(fields) {
@@ -303,7 +303,7 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
}
// GetOcrJsonText 提取并连接所有 text 字段的函数
-func GetOcrJsonText(jsonData []map[string]interface{}) (ret string) {
+func GetOcrJsonText(jsonData []map[string]any) (ret string) {
for _, dataMap := range jsonData {
// 检查 text 字段是否存在
if text, ok := dataMap["text"]; ok {
diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.go
index 2b1bb41bf3..a231d02a98 100644
--- a/kernel/util/pandoc.go
+++ b/kernel/util/pandoc.go
@@ -135,9 +135,9 @@ func InitPandoc() {
if confPath := filepath.Join(ConfDir, "conf.json"); gulu.File.IsExist(confPath) {
// Workspace built-in Pandoc is no longer initialized after customizing Pandoc path https://github.com/siyuan-note/siyuan/issues/8377
if data, err := os.ReadFile(confPath); err == nil {
- conf := map[string]interface{}{}
+ conf := map[string]any{}
if err = gulu.JSON.UnmarshalJSON(data, &conf); err == nil && nil != conf["export"] {
- export := conf["export"].(map[string]interface{})
+ export := conf["export"].(map[string]any)
if customPandocBinPath := export["pandocBin"].(string); !strings.HasPrefix(customPandocBinPath, tempPandocDir) {
if pandocVer := getPandocVer(customPandocBinPath); "" != pandocVer {
PandocBinPath = customPandocBinPath
diff --git a/kernel/util/result.go b/kernel/util/result.go
index 7789a1f7d0..77eb2ecfdb 100644
--- a/kernel/util/result.go
+++ b/kernel/util/result.go
@@ -38,10 +38,10 @@ type Result struct {
AppId string `json:"app"`
SessionId string `json:"sid"`
PushMode PushMode `json:"pushMode"`
- Callback interface{} `json:"callback"`
+ Callback any `json:"callback"`
Code int `json:"code"`
Msg string `json:"msg"`
- Data interface{} `json:"data"`
+ Data any `json:"data"`
Context map[string]any `json:"context,omitempty"`
}
diff --git a/kernel/util/rune.go b/kernel/util/rune.go
index 1617a3b390..de733ec590 100644
--- a/kernel/util/rune.go
+++ b/kernel/util/rune.go
@@ -95,16 +95,16 @@ func InitEmojiChars() {
return
}
- var conf []map[string]interface{}
+ var conf []map[string]any
if err = gulu.JSON.UnmarshalJSON(data, &conf); err != nil {
logging.LogErrorf("unmarshal emojis conf.json failed: %s", err)
return
}
for _, emoji := range conf {
- items := emoji["items"].([]interface{})
+ items := emoji["items"].([]any)
for _, item := range items {
- e := item.(map[string]interface{})
+ e := item.(map[string]any)
NativeEmojiChars[e["unicode"].(string)] = true
}
}
diff --git a/kernel/util/runtime.go b/kernel/util/runtime.go
index d0e51b6231..247a5c4a51 100644
--- a/kernel/util/runtime.go
+++ b/kernel/util/runtime.go
@@ -225,10 +225,10 @@ const (
var (
Langs = map[string]map[int]string{}
- TimeLangs = map[string]map[string]interface{}{}
- TaskActionLangs = map[string]map[string]interface{}{}
- TrayMenuLangs = map[string]map[string]interface{}{}
- AttrViewLangs = map[string]map[string]interface{}{}
+ TimeLangs = map[string]map[string]any{}
+ TaskActionLangs = map[string]map[string]any{}
+ TrayMenuLangs = map[string]map[string]any{}
+ AttrViewLangs = map[string]map[string]any{}
)
var (
diff --git a/kernel/util/time.go b/kernel/util/time.go
index 6646da3d7f..e196bae553 100644
--- a/kernel/util/time.go
+++ b/kernel/util/time.go
@@ -221,7 +221,7 @@ func HumanizeTime(then time.Time, lang string) string {
return strings.TrimSpace(humanize.CustomRelTime(then, time.Now(), labels["albl"].(string), labels["blbl"].(string), magnitudes))
}
-func humanizeTimeMagnitudes(lang string) (labels map[string]interface{}, magnitudes []humanize.RelTimeMagnitude) {
+func humanizeTimeMagnitudes(lang string) (labels map[string]any, magnitudes []humanize.RelTimeMagnitude) {
labels = TimeLangs[lang]
magnitudes = []humanize.RelTimeMagnitude{
{time.Second, labels["now"].(string), time.Second},
diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go
index 0663c6101c..321a83e151 100644
--- a/kernel/util/websocket.go
+++ b/kernel/util/websocket.go
@@ -33,14 +33,14 @@ var (
authSessions = sync.Map{}
)
-func BroadcastByTypeAndExcludeApp(excludeApp, typ, cmd string, code int, msg string, data interface{}) {
- sessions.Range(func(key, value interface{}) bool {
+func BroadcastByTypeAndExcludeApp(excludeApp, typ, cmd string, code int, msg string, data any) {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
if key == excludeApp {
return true
}
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if t, ok := session.Get("type"); ok && typ == t {
event := NewResult()
@@ -56,13 +56,13 @@ func BroadcastByTypeAndExcludeApp(excludeApp, typ, cmd string, code int, msg str
})
}
-func BroadcastByTypeAndApp(typ, app, cmd string, code int, msg string, data interface{}) {
+func BroadcastByTypeAndApp(typ, app, cmd string, code int, msg string, data any) {
appSessions, ok := sessions.Load(app)
if !ok {
return
}
- appSessions.(*sync.Map).Range(func(key, value interface{}) bool {
+ appSessions.(*sync.Map).Range(func(key, value any) bool {
session := value.(*melody.Session)
if t, ok := session.Get("type"); ok && typ == t {
event := NewResult()
@@ -77,7 +77,7 @@ func BroadcastByTypeAndApp(typ, app, cmd string, code int, msg string, data inte
}
// BroadcastByType 广播所有实例上 typ 类型的会话。
-func BroadcastByType(typ, cmd string, code int, msg string, data interface{}) {
+func BroadcastByType(typ, cmd string, code int, msg string, data any) {
typeSessions := SessionsByType(typ)
for _, sess := range typeSessions {
event := NewResult()
@@ -92,9 +92,9 @@ func BroadcastByType(typ, cmd string, code int, msg string, data interface{}) {
func SessionsByType(typ string) (ret []*melody.Session) {
ret = []*melody.Session{}
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if t, ok := session.Get("type"); ok && typ == t {
ret = append(ret, session)
@@ -173,7 +173,7 @@ func RemovePushChan(session *melody.Session) {
}
func lenOfSyncMap(m *sync.Map) (ret int) {
- m.Range(func(key, value interface{}) bool {
+ m.Range(func(key, value any) bool {
ret++
return true
})
@@ -181,9 +181,9 @@ func lenOfSyncMap(m *sync.Map) (ret int) {
}
func ClosePushChan(id string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if sid, _ := session.Get("id"); sid == id {
session.CloseWithMsg([]byte(" close websocket"))
@@ -196,40 +196,40 @@ func ClosePushChan(id string) {
}
func ReloadUIResetScroll() {
- BroadcastByType("main", "reloadui", 0, "", map[string]interface{}{"resetScroll": true})
+ BroadcastByType("main", "reloadui", 0, "", map[string]any{"resetScroll": true})
}
func ReloadUI() {
BroadcastByType("main", "reloadui", 0, "", nil)
}
-func PushTxErr(msg string, code int, data interface{}) {
+func PushTxErr(msg string, code int, data any) {
BroadcastByType("main", "txerr", code, msg, data)
}
func PushUpdateMsg(msgId string, msg string, timeout int) {
- BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
+ BroadcastByType("main", "msg", 0, msg, map[string]any{"id": msgId, "closeTimeout": timeout})
}
func PushMsg(msg string, timeout int) (msgId string) {
msgId = gulu.Rand.String(7)
- BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
+ BroadcastByType("main", "msg", 0, msg, map[string]any{"id": msgId, "closeTimeout": timeout})
return
}
func PushMsgWithApp(app, msg string, timeout int) (msgId string) {
msgId = gulu.Rand.String(7)
if "" == app {
- BroadcastByType("main", "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
+ BroadcastByType("main", "msg", 0, msg, map[string]any{"id": msgId, "closeTimeout": timeout})
return
}
- BroadcastByTypeAndApp("main", app, "msg", 0, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
+ BroadcastByTypeAndApp("main", app, "msg", 0, msg, map[string]any{"id": msgId, "closeTimeout": timeout})
return
}
func PushErrMsg(msg string, timeout int) (msgId string) {
msgId = gulu.Rand.String(7)
- BroadcastByType("main", "msg", -1, msg, map[string]interface{}{"id": msgId, "closeTimeout": timeout})
+ BroadcastByType("main", "msg", -1, msg, map[string]any{"id": msgId, "closeTimeout": timeout})
return
}
@@ -238,7 +238,7 @@ func PushStatusBar(msg string) {
BroadcastByType("main", "statusbar", 0, msg, nil)
}
-func PushBackgroundTask(data map[string]interface{}) {
+func PushBackgroundTask(data map[string]any) {
BroadcastByType("main", "backgroundtask", 0, "", data)
}
@@ -259,7 +259,7 @@ type BlockStatResult struct {
BlockCount int `json:"blockCount"`
}
-func ContextPushMsg(context map[string]interface{}, msg string) {
+func ContextPushMsg(context map[string]any, msg string) {
switch context[eventbus.CtxPushMsg].(int) {
case eventbus.CtxPushMsgToNone:
break
@@ -293,7 +293,7 @@ func PushEndlessProgress(msg string) {
}
func PushProgress(code, current, total int, msg string) {
- BroadcastByType("main", "progress", code, msg, map[string]interface{}{
+ BroadcastByType("main", "progress", code, msg, map[string]any{
"current": current,
"total": total,
})
@@ -301,7 +301,7 @@ func PushProgress(code, current, total int, msg string) {
// PushClearMsg 会清空指定消息。
func PushClearMsg(msgId string) {
- BroadcastByType("main", "cmsg", 0, "", map[string]interface{}{"id": msgId})
+ BroadcastByType("main", "cmsg", 0, "", map[string]any{"id": msgId})
}
// PushClearProgress 取消进度遮罩。
@@ -317,9 +317,9 @@ func PushReloadDoc(rootID string) {
BroadcastByType("main", "reloaddoc", 0, "", rootID)
}
-func PushSaveDoc(rootID, typ string, sources interface{}) {
+func PushSaveDoc(rootID, typ string, sources any) {
evt := NewCmdResult("savedoc", 0, PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"rootID": rootID,
"type": typ,
"sources": sources,
@@ -336,15 +336,15 @@ func PushReloadProtyle(rootID string) {
}
func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string) {
- BroadcastByType("main", "setRefDynamicText", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText})
+ BroadcastByType("main", "setRefDynamicText", 0, "", map[string]any{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText})
}
func PushSetDefRefCount(rootID, blockID string, defIDs []string, refCount, rootRefCount int) {
- BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "defIDs": defIDs})
+ BroadcastByType("main", "setDefRefCount", 0, "", map[string]any{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "defIDs": defIDs})
}
func PushLocalShorthandCount(count int) {
- BroadcastByType("main", "setLocalShorthandCount", 0, "", map[string]interface{}{"count": count})
+ BroadcastByType("main", "setLocalShorthandCount", 0, "", map[string]any{"count": count})
}
func PushProtyleLoading(rootID, msg string) {
@@ -357,7 +357,7 @@ func PushReloadEmojiConf() {
func PushDownloadProgress(id string, percent float32) {
evt := NewCmdResult("downloadProgress", 0, PushModeBroadcast)
- evt.Data = map[string]interface{}{
+ evt.Data = map[string]any{
"id": id,
"percent": percent,
}
@@ -384,13 +384,13 @@ func PushEvent(event *Result) {
}
func single(msg []byte, appId, sid string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
if key != appId {
return true
}
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if id, _ := session.Get("id"); id == sid {
session.Write(msg)
@@ -402,9 +402,9 @@ func single(msg []byte, appId, sid string) {
}
func Broadcast(msg []byte) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
session.Write(msg)
return true
@@ -414,9 +414,9 @@ func Broadcast(msg []byte) {
}
func broadcastOtherApps(msg []byte, excludeApp string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if app, _ := session.Get("app"); app == excludeApp {
return true
@@ -429,9 +429,9 @@ func broadcastOtherApps(msg []byte, excludeApp string) {
}
func broadcastOtherAppMains(msg []byte, excludeApp string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if app, _ := session.Get("app"); app == excludeApp {
return true
@@ -449,9 +449,9 @@ func broadcastOtherAppMains(msg []byte, excludeApp string) {
}
func broadcastApp(msg []byte, app string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if sessionApp, _ := session.Get("app"); sessionApp != app {
return true
@@ -464,9 +464,9 @@ func broadcastApp(msg []byte, app string) {
}
func broadcastOthers(msg []byte, excludeSID string) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if id, _ := session.Get("id"); id == excludeSID {
return true
@@ -479,11 +479,11 @@ func broadcastOthers(msg []byte, excludeSID string) {
}
func CountSessions() (ret int) {
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
ret++
return true
})
- authSessions.Range(func(key, value interface{}) bool {
+ authSessions.Range(func(key, value any) bool {
ret++
return true
})
@@ -498,9 +498,9 @@ func ClosePublishServiceSessions() {
// 收集所有发布服务的会话
var publishSessions []*melody.Session
- sessions.Range(func(key, value interface{}) bool {
+ sessions.Range(func(key, value any) bool {
appSessions := value.(*sync.Map)
- appSessions.Range(func(key, value interface{}) bool {
+ appSessions.Range(func(key, value any) bool {
session := value.(*melody.Session)
if isPublish, ok := session.Get("isPublish"); ok && isPublish == true {
publishSessions = append(publishSessions, session)
@@ -516,7 +516,7 @@ func ClosePublishServiceSessions() {
event.Cmd = "closepublishpage"
event.Code = 0
event.Msg = "SiYuan publish service closed"
- event.Data = map[string]interface{}{
+ event.Data = map[string]any{
"reason": "publish service closed",
}
session.Write(event.Bytes())