diff --git a/app/changelogs/v2.12.1/v2.12.1.md b/app/changelogs/v2.12.1/v2.12.1.md new file mode 100644 index 000000000..6547aa8df --- /dev/null +++ b/app/changelogs/v2.12.1/v2.12.1.md @@ -0,0 +1,58 @@ +## Overview + +This version supports configuration to ignore data indexing and improves the stability of cloud data synchronization. + +## Changelogs + +Below are the detailed changes in this version. + +### Enhancement + +* [Reset the dialog interface size when the dialog box exceeds the window](https://github.com/siyuan-note/siyuan/issues/10000) +* [Double-click the doc title image to preview](https://github.com/siyuan-note/siyuan/issues/10041) +* [Hide menu when click document title image](https://github.com/siyuan-note/siyuan/issues/10046) +* [Keep tabs visible when window shrinks](https://github.com/siyuan-note/siyuan/issues/10048) +* [`Go back` keep scroll position](https://github.com/siyuan-note/siyuan/issues/10050) +* [Add tips for database table view rollup column configuration](https://github.com/siyuan-note/siyuan/issues/10055) +* [Only block marked as flashcards are hidden based on configuration](https://github.com/siyuan-note/siyuan/issues/10058) +* [Snapshot comparison interface supports key selection of files](https://github.com/siyuan-note/siyuan/issues/10078) +* [Add `Home` and `End` support to the list item selected by `↑` and `↓`](https://github.com/siyuan-note/siyuan/issues/10083) +* [Hotkeys not working after switching applications](https://github.com/siyuan-note/siyuan/issues/10085) +* [Cards expired no longer appear in the same review round](https://github.com/siyuan-note/siyuan/issues/10087) +* [Improve `New document save location`](https://github.com/siyuan-note/siyuan/issues/10094) +* [Remove image icon menu in embed block](https://github.com/siyuan-note/siyuan/issues/10097) +* [Improve continuous soft newline split block parsing](https://github.com/siyuan-note/siyuan/issues/10098) +* [Improve the stability of cloud data synchronization](https://github.com/siyuan-note/siyuan/issues/10111) + +### Bugfix + +* [Emoji not rendering as expected](https://github.com/siyuan-note/siyuan/issues/8910) +* [The parent block field of the blocks under the heading block is calculated incorrectly](https://github.com/siyuan-note/siyuan/issues/9869) +* [Open external application protocol invalid](https://github.com/siyuan-note/siyuan/issues/10075) +* [Alt+X cannot record the font color](https://github.com/siyuan-note/siyuan/issues/10088) +* [Unable to preview first template directly](https://github.com/siyuan-note/siyuan/issues/10103) +* [Positioning may be reset after opening a document and scrolling quickly](https://github.com/siyuan-note/siyuan/issues/10108) + +### Development + +* [Improve database table view `Select` cell value input](https://github.com/siyuan-note/siyuan/issues/10052) +* [Database select, multiple select, and asset column cannot be operated in batches](https://github.com/siyuan-note/siyuan/issues/10054) +* [Filter conditions cannot be added to database table view check column](https://github.com/siyuan-note/siyuan/issues/10056) +* [Add plugin function `lockScreen`](https://github.com/siyuan-note/siyuan/issues/10063) +* [Add plugin event bus `updateCards`](https://github.com/siyuan-note/siyuan/issues/10065) +* [`Untitled` is displayed when the original record primary key value of the related column is empty](https://github.com/siyuan-note/siyuan/issues/10067) +* [Fix `name` attribute could not be visited in the plugin constructor](https://github.com/siyuan-note/siyuan/pull/10071) +* [Database block supports export as CSV](https://github.com/siyuan-note/siyuan/issues/10072) +* [Database table view no longer scrolls to the beginning after pasting values](https://github.com/siyuan-note/siyuan/issues/10073) +* [The database template column supports `queryBlocks` function](https://github.com/siyuan-note/siyuan/issues/10077) +* [Add internal kernel API `/api/filetree/upsertIndexes` and `/api/filetree/removeIndexes`](https://github.com/siyuan-note/siyuan/issues/10079) +* [Reduce the delay in adding rows in database table view](https://github.com/siyuan-note/siyuan/issues/10082) +* [Add plugin API `uninstall`](https://github.com/siyuan-note/siyuan/issues/10086) +* [Add plugin field `protyleOptions`](https://github.com/siyuan-note/siyuan/issues/10090) +* [Improve adding rows of the sorted database table view](https://github.com/siyuan-note/siyuan/issues/10099) +* [Add internal kernel API `/api/repo/getRepoFile`](https://github.com/siyuan-note/siyuan/issues/10101) + +## Download + +* [B3log](https://b3log.org/siyuan/en/download.html) +* [GitHub](https://github.com/siyuan-note/siyuan/releases) diff --git a/app/changelogs/v2.12.1/v2.12.1_zh_CHT.md b/app/changelogs/v2.12.1/v2.12.1_zh_CHT.md new file mode 100644 index 000000000..80bed222d --- /dev/null +++ b/app/changelogs/v2.12.1/v2.12.1_zh_CHT.md @@ -0,0 +1,58 @@ +## 概述 + +此版本支援配置忽略資料索引,並提升了雲端資料同步穩定性。 + +## 變更記錄 + +以下是此版本中的詳細變更。 + +### 改進功能 + +* [當對話方塊超出視窗時重置對話方塊介面大小](https://github.com/siyuan-note/siyuan/issues/10000) +* [題頭圖支援雙擊預覽](https://github.com/siyuan-note/siyuan/issues/10041) +* [點選題頭圖時隱藏選單](https://github.com/siyuan-note/siyuan/issues/10046) +* [視窗縮小時保持頁籤可見](https://github.com/siyuan-note/siyuan/issues/10048) +* [`後退` 保持滾動位置](https://github.com/siyuan-note/siyuan/issues/10050) +* [新增資料庫表格視圖總列設定提示](https://github.com/siyuan-note/siyuan/issues/10055) +* [根據閃卡配置顯示高亮標記](https://github.com/siyuan-note/siyuan/issues/10058) +* [資料快照比較介面支援鍵盤選擇檔](https://github.com/siyuan-note/siyuan/issues/10078) +* [為支援 `↑` 和 `↓` 的候選清單新增 `Home` 和 `End` 支援](https://github.com/siyuan-note/siyuan/issues/10083) +* [切換應用程式後可能導致快速鍵失效](https://github.com/siyuan-note/siyuan/issues/10085) +* [同一輪閃卡複習中不再顯示再次到期的卡片](https://github.com/siyuan-note/siyuan/issues/10087) +* [改進 `新建文件存放位置`](https://github.com/siyuan-note/siyuan/issues/10094) +* [移除嵌入區塊中的圖片圖示選單](https://github.com/siyuan-note/siyuan/issues/10097) +* [改良連續軟換行分塊解析](https://github.com/siyuan-note/siyuan/issues/10098) +* [提升雲端資料同步穩定性](https://github.com/siyuan-note/siyuan/issues/10111) + +### 修復缺陷 + +* [某些 Emoji 圖示無法正常顯示](https://github.com/siyuan-note/siyuan/issues/8910) +* [標題區塊下方區塊的父區塊欄位計算不正確](https://github.com/siyuan-note/siyuan/issues/9869) +* [開啟外部應用程式協議失效](https://github.com/siyuan-note/siyuan/issues/10075) +* [Alt+X 無法記錄字體顏色](https://github.com/siyuan-note/siyuan/issues/10088) +* [無法直接預覽第一個範本](https://github.com/siyuan-note/siyuan/issues/10103) +* [開啟文件後快速捲動導致定位重置](https://github.com/siyuan-note/siyuan/issues/10108) + +### 開發者 + +* [改進資料庫表格視圖 `單選` 值輸入](https://github.com/siyuan-note/siyuan/issues/10052) +* [解決資料庫單選列、多選列和資源列無法批次操作](https://github.com/siyuan-note/siyuan/issues/10054) +* [資料庫表格視圖單選框無法新增篩選條件](https://github.com/siyuan-note/siyuan/issues/10056) +* [新增外掛程式 `lockScreen`](https://github.com/siyuan-note/siyuan/issues/10063) +* [新增插件事件匯流排 `updateCards`](https://github.com/siyuan-note/siyuan/issues/10065) +* [如果關聯列原記錄主鍵值為空則關聯列顯示 `Untitled`](https://github.com/siyuan-note/siyuan/issues/10067) +* [修正插件建構子中無法存取 `name` 屬性的問題](https://github.com/siyuan-note/siyuan/pull/10071) +* [資料庫區塊支援匯出 CSV](https://github.com/siyuan-note/siyuan/issues/10072) +* [資料庫表格視圖貼上值後不再重置滾動位置](https://github.com/siyuan-note/siyuan/issues/10073) +* [資料庫範本列支援 `queryBlocks` 函數](https://github.com/siyuan-note/siyuan/issues/10077) +* [新增內部核心 API `/api/filetree/upsertIndexes` 和 `/api/filetree/removeIndexes`](https://github.com/siyuan-note/siyuan/issues/10079) +* [降低資料庫表格視圖新增行延遲](https://github.com/siyuan-note/siyuan/issues/10082) +* [新增外掛程式 API `uninstall`](https://github.com/siyuan-note/siyuan/issues/10086) +* [新增插件欄位 `protyleOptions`](https://github.com/siyuan-note/siyuan/issues/10090) +* [改進排序的資料庫表格視圖新增行時的行為](https://github.com/siyuan-note/siyuan/issues/10099) +* [新增內部核心 API `/api/repo/getRepoFile`](https://github.com/siyuan-note/siyuan/issues/10101) + +## 下載 + +* [B3log](https://b3log.org/siyuan/download.html) +* [GitHub](https://github.com/siyuan-note/siyuan/releases) \ No newline at end of file diff --git a/app/changelogs/v2.12.1/v2.12.1_zh_CN.md b/app/changelogs/v2.12.1/v2.12.1_zh_CN.md new file mode 100644 index 000000000..6187f6460 --- /dev/null +++ b/app/changelogs/v2.12.1/v2.12.1_zh_CN.md @@ -0,0 +1,58 @@ +## 概述 + +该版本支持配置忽略数据索引,并提升了云端数据同步稳定性。 + +## 变更记录 + +以下是此版本中的详细变更。 + +### 改进功能 + +* [当对话框超出窗口时重置对话框界面大小](https://github.com/siyuan-note/siyuan/issues/10000) +* [题头图支持双击预览](https://github.com/siyuan-note/siyuan/issues/10041) +* [点击题头图时隐藏菜单](https://github.com/siyuan-note/siyuan/issues/10046) +* [窗口缩小时保持页签可见](https://github.com/siyuan-note/siyuan/issues/10048) +* [`后退` 保持滚动位置](https://github.com/siyuan-note/siyuan/issues/10050) +* [添加数据库表格视图汇总列配置提示](https://github.com/siyuan-note/siyuan/issues/10055) +* [根据闪卡配置显示高亮标记](https://github.com/siyuan-note/siyuan/issues/10058) +* [数据快照对比界面支持键盘选择文件](https://github.com/siyuan-note/siyuan/issues/10078) +* [为支持 `↑` 和 `↓` 的候选列表添加 `Home` 和 `End` 支持](https://github.com/siyuan-note/siyuan/issues/10083) +* [切换应用后可能导致快捷键失效](https://github.com/siyuan-note/siyuan/issues/10085) +* [同一轮闪卡复习中不再显示再次到期的卡](https://github.com/siyuan-note/siyuan/issues/10087) +* [改进 `新建文档存放位置`](https://github.com/siyuan-note/siyuan/issues/10094) +* [移除嵌入块中的图片图标菜单](https://github.com/siyuan-note/siyuan/issues/10097) +* [改进连续软换行分块解析](https://github.com/siyuan-note/siyuan/issues/10098) +* [提升云端数据同步稳定性](https://github.com/siyuan-note/siyuan/issues/10111) + +### 修复缺陷 + +* [某些 Emoji 图标无法正常显示](https://github.com/siyuan-note/siyuan/issues/8910) +* [标题块下方块的父块字段计算不正确](https://github.com/siyuan-note/siyuan/issues/9869) +* [打开外部应用协议失效](https://github.com/siyuan-note/siyuan/issues/10075) +* [Alt+X 无法记录字体颜色](https://github.com/siyuan-note/siyuan/issues/10088) +* [无法直接预览第一个模板](https://github.com/siyuan-note/siyuan/issues/10103) +* [打开文档后快速滚动导致定位重置](https://github.com/siyuan-note/siyuan/issues/10108) + +### 开发者 + +* [改进数据库表格视图 `单选` 值输入](https://github.com/siyuan-note/siyuan/issues/10052) +* [解决数据库单选列、多选列和资源列无法批量操作](https://github.com/siyuan-note/siyuan/issues/10054) +* [数据库表格视图单选框无法添加过滤条件](https://github.com/siyuan-note/siyuan/issues/10056) +* [添加插件函数 `lockScreen`](https://github.com/siyuan-note/siyuan/issues/10063) +* [添加插件事件总线 `updateCards`](https://github.com/siyuan-note/siyuan/issues/10065) +* [如果关联列原记录主键值为空则关联列显示 `Untitled`](https://github.com/siyuan-note/siyuan/issues/10067) +* [修复插件构造函数中无法访问 `name` 属性的问题](https://github.com/siyuan-note/siyuan/pull/10071) +* [数据库块支持导出 CSV](https://github.com/siyuan-note/siyuan/issues/10072) +* [数据库表格视图粘贴值后不再重置滚动位置](https://github.com/siyuan-note/siyuan/issues/10073) +* [数据库模板列支持 `queryBlocks` 函数](https://github.com/siyuan-note/siyuan/issues/10077) +* [添加内部内核 API `/api/filetree/upsertIndexes` 和 `/api/filetree/removeIndexes`](https://github.com/siyuan-note/siyuan/issues/10079) +* [降低数据库表格视图添加行延迟](https://github.com/siyuan-note/siyuan/issues/10082) +* [添加插件 API `uninstall`](https://github.com/siyuan-note/siyuan/issues/10086) +* [添加插件字段 `protyleOptions`](https://github.com/siyuan-note/siyuan/issues/10090) +* [改进排序的数据库表格视图添加行时的行为](https://github.com/siyuan-note/siyuan/issues/10099) +* [添加内部内核 API `/api/repo/getRepoFile`](https://github.com/siyuan-note/siyuan/issues/10101) + +## 下载 + +* [B3log](https://b3log.org/siyuan/download.html) +* [GitHub](https://github.com/siyuan-note/siyuan/releases) diff --git a/kernel/api/repo.go b/kernel/api/repo.go index f8f20c62a..0b59fe32b 100644 --- a/kernel/api/repo.go +++ b/kernel/api/repo.go @@ -18,14 +18,48 @@ package api import ( "fmt" + "mime" "net/http" + "path/filepath" "github.com/88250/gulu" + "github.com/gabriel-vasile/mimetype" "github.com/gin-gonic/gin" "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/util" ) +func getRepoFile(c *gin.Context) { + // Add internal kernel API `/api/repo/getRepoFile` https://github.com/siyuan-note/siyuan/issues/10101 + + ret := gulu.Ret.NewResult() + defer c.JSON(http.StatusOK, ret) + + arg, ok := util.JsonArg(c, ret) + if !ok { + return + } + + id := arg["id"].(string) + data, p, err := model.GetRepoFile(id) + if nil != err { + ret.Code = -1 + ret.Msg = err.Error() + return + } + + contentType := mime.TypeByExtension(filepath.Ext(p)) + if "" == contentType { + if m := mimetype.Detect(data); nil != m { + contentType = m.String() + } + } + if "" == contentType { + contentType = "application/octet-stream" + } + c.Data(http.StatusOK, contentType, data) +} + func openRepoSnapshotDoc(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) diff --git a/kernel/api/router.go b/kernel/api/router.go index 54bcdff7c..8e2f410cc 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -363,6 +363,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/repo/downloadCloudSnapshot", model.CheckAuth, model.CheckReadonly, downloadCloudSnapshot) ginServer.Handle("POST", "/api/repo/diffRepoSnapshots", model.CheckAuth, diffRepoSnapshots) ginServer.Handle("POST", "/api/repo/openRepoSnapshotDoc", model.CheckAuth, openRepoSnapshotDoc) + ginServer.Handle("POST", "/api/repo/getRepoFile", model.CheckAuth, getRepoFile) ginServer.Handle("POST", "/api/riff/createRiffDeck", model.CheckAuth, model.CheckReadonly, createRiffDeck) ginServer.Handle("POST", "/api/riff/renameRiffDeck", model.CheckAuth, model.CheckReadonly, renameRiffDeck) diff --git a/kernel/go.mod b/kernel/go.mod index 822df43c5..88cfbbe2e 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -51,7 +51,7 @@ require ( github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 github.com/sashabaranov/go-openai v1.17.10 github.com/shirou/gopsutil/v3 v3.23.12 - github.com/siyuan-note/dejavu v0.0.0-20240106123310-d41af94d3e67 + github.com/siyuan-note/dejavu v0.0.0-20240108131531-9a38601f4e0b github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 github.com/siyuan-note/eventbus v0.0.0-20231210025112-82fdedd8e374 github.com/siyuan-note/filelock v0.0.0-20231211015131-3b3dfabdce9c diff --git a/kernel/go.sum b/kernel/go.sum index d0a425e95..daa2c9b2f 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -354,8 +354,8 @@ github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA= github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8= -github.com/siyuan-note/dejavu v0.0.0-20240106123310-d41af94d3e67 h1:foJRxYDhG81UHzLmE+4oIHON918n+yi/xff7dIqru7Y= -github.com/siyuan-note/dejavu v0.0.0-20240106123310-d41af94d3e67/go.mod h1:3uStV30HTpFN1Zvyaf/thqheOh4RJ7WIVeTqUpBzNhc= +github.com/siyuan-note/dejavu v0.0.0-20240108131531-9a38601f4e0b h1:7Z4VzKrJY3snTJtVFxQ+J3BIl/bR3UV8PpOo4+xaRF0= +github.com/siyuan-note/dejavu v0.0.0-20240108131531-9a38601f4e0b/go.mod h1:3uStV30HTpFN1Zvyaf/thqheOh4RJ7WIVeTqUpBzNhc= github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 h1:kJaw5L/evyW6LcB9IQT8PR4ppx8JVqOFP9Ix3rfwSrc= github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4/go.mod h1:UYcCCY+0wh+GmUoDOaO63j1sV5lgy7laLAk1XhEiUis= github.com/siyuan-note/eventbus v0.0.0-20231210025112-82fdedd8e374 h1:haPIOZBOAEQaXsUPUpyZeOeMgw6g/9O7RBbS3d39Ta8= diff --git a/kernel/model/repository.go b/kernel/model/repository.go index 7b579ec0d..0c54bbc86 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -57,18 +57,25 @@ import ( "github.com/studio-b12/gowebdav" ) -func init() { - subscribeRepoEvents() -} +func GetRepoFile(fileID string) (ret []byte, p string, err error) { + if 1 > len(Conf.Repo.Key) { + err = errors.New(Conf.Language(26)) + return + } -type Snapshot struct { - *dejavu.Log - TypesCount []*TypeCount `json:"typesCount"` -} + repo, err := newRepository() + if nil != err { + return + } -type TypeCount struct { - Type string `json:"type"` - Count int `json:"count"` + file, err := repo.GetFile(fileID) + if nil != err { + return + } + + ret, err = repo.OpenFile(file) + p = file.Path + return } func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) { @@ -327,6 +334,16 @@ func parseTreeInSnapshot(data []byte, luteEngine *lute.Lute) (isProtyleDoc bool, return } +type Snapshot struct { + *dejavu.Log + TypesCount []*TypeCount `json:"typesCount"` +} + +type TypeCount struct { + Type string `json:"type"` + Count int `json:"count"` +} + func GetRepoSnapshots(page int) (ret []*Snapshot, pageCount, totalCount int, err error) { ret = []*Snapshot{} if 1 > len(Conf.Repo.Key) { @@ -1570,6 +1587,10 @@ func newRepository() (ret *dejavu.Repo, err error) { return } +func init() { + subscribeRepoEvents() +} + func subscribeRepoEvents() { eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]interface{}, path string) { msg := fmt.Sprintf(Conf.Language(158), path)