瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 年之前
父節點
當前提交
cc0c7fc1b5
共有 8 個文件被更改,包括 42 次插入16 次删除
  1. 1 1
      .github/workflows/dockerimage.yml
  2. 1 1
      API.md
  3. 1 1
      API_zh_CN.md
  4. 1 1
      app/appx/AppxManifest.xml
  5. 1 1
      app/package.json
  6. 4 10
      kernel/model/export.go
  7. 32 0
      kernel/model/template.go
  8. 1 1
      kernel/util/working.go

+ 1 - 1
.github/workflows/dockerimage.yml

@@ -49,4 +49,4 @@ jobs:
 
 
       - name: Build the Docker image
       - name: Build the Docker image
         run: |
         run: |
-          docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v2.10.11 .
+          docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v2.10.12 .

+ 1 - 1
API.md

@@ -1149,7 +1149,7 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
       "/conf/appearance/boot",
       "/conf/appearance/boot",
       "/conf/appearance/langs",
       "/conf/appearance/langs",
       "/conf/appearance/emojis/conf.json",
       "/conf/appearance/emojis/conf.json",
-      "/conf/appearance/icons/index.html",
+      "/conf/appearance/icons/index.html"
     ],
     ],
     "name": "zip-file-name"
     "name": "zip-file-name"
   }
   }

+ 1 - 1
API_zh_CN.md

@@ -1141,7 +1141,7 @@
       "/conf/appearance/boot",
       "/conf/appearance/boot",
       "/conf/appearance/langs",
       "/conf/appearance/langs",
       "/conf/appearance/emojis/conf.json",
       "/conf/appearance/emojis/conf.json",
-      "/conf/appearance/icons/index.html",
+      "/conf/appearance/icons/index.html"
     ],
     ],
     "name": "zip-file-name"
     "name": "zip-file-name"
   }
   }

+ 1 - 1
app/appx/AppxManifest.xml

@@ -9,7 +9,7 @@
     <Identity Name="89C2A984.SiYuan"
     <Identity Name="89C2A984.SiYuan"
               ProcessorArchitecture="x64"
               ProcessorArchitecture="x64"
               Publisher="CN=087C656E-C1D9-42D8-8807-CED45A74FC0F"
               Publisher="CN=087C656E-C1D9-42D8-8807-CED45A74FC0F"
-              Version="2.10.11.0"/>
+              Version="2.10.12.0"/>
     <Properties>
     <Properties>
         <DisplayName>SiYuan</DisplayName>
         <DisplayName>SiYuan</DisplayName>
         <PublisherDisplayName>云南链滴科技有限公司</PublisherDisplayName>
         <PublisherDisplayName>云南链滴科技有限公司</PublisherDisplayName>

+ 1 - 1
app/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "SiYuan",
   "name": "SiYuan",
-  "version": "2.10.11",
+  "version": "2.10.12",
   "description": "Refactor your thinking",
   "description": "Refactor your thinking",
   "homepage": "https://b3log.org/siyuan",
   "homepage": "https://b3log.org/siyuan",
   "main": "./electron/main.js",
   "main": "./electron/main.js",

+ 4 - 10
kernel/model/export.go

@@ -1890,16 +1890,10 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
 			return ast.WalkContinue
 			return ast.WalkContinue
 		}
 		}
 
 
-		var view *av.View
-		if "" != attrView.ViewID {
-			for _, v := range attrView.Views {
-				if v.ID == attrView.ViewID {
-					view = v
-					break
-				}
-			}
-		} else {
-			view = attrView.Views[0]
+		view, err := attrView.GetView()
+		if nil != err {
+			logging.LogErrorf("get attribute view [%s] failed: %s", avID, err)
+			return ast.WalkContinue
 		}
 		}
 
 
 		table, err := renderAttributeViewTable(attrView, view)
 		table, err := renderAttributeViewTable(attrView, view)

+ 32 - 0
kernel/model/template.go

@@ -290,9 +290,41 @@ func renderTemplate(p, id string, preview bool) (string, error) {
 				if nil != cloned {
 				if nil != cloned {
 					n.AttributeViewID = cloned.ID
 					n.AttributeViewID = cloned.ID
 					if !preview {
 					if !preview {
+						// 非预览时持久化数据库
 						if saveErr := av.SaveAttributeView(cloned); nil != saveErr {
 						if saveErr := av.SaveAttributeView(cloned); nil != saveErr {
 							logging.LogErrorf("save attribute view [%s] failed: %s", cloned.ID, saveErr)
 							logging.LogErrorf("save attribute view [%s] failed: %s", cloned.ID, saveErr)
 						}
 						}
+					} else {
+						// 预览时使用简单表格渲染
+						view, getErr := attrView.GetView()
+						if nil != getErr {
+							logging.LogErrorf("get attribute view [%s] failed: %s", n.AttributeViewID, getErr)
+							return ast.WalkContinue
+						}
+
+						table, renderErr := renderAttributeViewTable(attrView, view)
+						if nil != renderErr {
+							logging.LogErrorf("render attribute view [%s] table failed: %s", n.AttributeViewID, renderErr)
+							return ast.WalkContinue
+						}
+
+						var aligns []int
+						for range table.Columns {
+							aligns = append(aligns, 0)
+						}
+						mdTable := &ast.Node{Type: ast.NodeTable, TableAligns: aligns}
+						mdTableHead := &ast.Node{Type: ast.NodeTableHead}
+						mdTable.AppendChild(mdTableHead)
+						mdTableHeadRow := &ast.Node{Type: ast.NodeTableRow, TableAligns: aligns}
+						mdTableHead.AppendChild(mdTableHeadRow)
+						for _, col := range table.Columns {
+							cell := &ast.Node{Type: ast.NodeTableCell}
+							cell.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(col.Name)})
+							mdTableHeadRow.AppendChild(cell)
+						}
+
+						n.InsertBefore(mdTable)
+						unlinks = append(unlinks, n)
 					}
 					}
 				}
 				}
 			}
 			}

+ 1 - 1
kernel/util/working.go

@@ -42,7 +42,7 @@ import (
 var Mode = "prod"
 var Mode = "prod"
 
 
 const (
 const (
-	Ver       = "2.10.11"
+	Ver       = "2.10.12"
 	IsInsider = false
 	IsInsider = false
 )
 )