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

This commit is contained in:
Vanessa 2023-12-22 10:26:05 +08:00
commit 55f02dde40
9 changed files with 66 additions and 47 deletions

View file

@ -16,10 +16,10 @@ Install pnpm: `npm install -g pnpm`
Set the Electron mirror environment variable and install Electron:
* macOS/Linux: `ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ pnpm install electron@27.1.3 -D`
* macOS/Linux: `ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ pnpm install electron@27.2.0 -D`
* Windows:
* `SET ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/`
* `pnpm install electron@27.1.3 -D`
* `pnpm install electron@27.2.0 -D`
NPM mirror:
@ -30,7 +30,7 @@ NPM mirror:
On the desktop, go to the app folder to run:
* `pnpm install electron@27.1.3 -D`
* `pnpm install electron@27.2.0 -D`
* `pnpm run dev`
* `pnpm run start`

View file

@ -18,11 +18,11 @@
* macOS/Linux:
```
ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ pnpm install electron@27.1.3 -D
ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/ pnpm install electron@27.2.0 -D
```
* Windows:
* `SET ELECTRON_MIRROR=https://cnpmjs.org/mirrors/electron/`
* `pnpm install electron@27.1.3 -D`
* `pnpm install electron@27.2.0 -D`
NPM 镜像:
@ -32,7 +32,7 @@ NPM 镜像:
桌面端进入 app 文件夹运行:
* `pnpm install electron@27.1.3 -D`
* `pnpm install electron@27.2.0 -D`
* `pnpm run dev`
* `pnpm run start`

View file

@ -53,7 +53,7 @@
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.7.1",
"dayjs": "^1.11.5",
"electron": "27.1.3",
"electron": "27.2.0",
"electron-builder": "^24.9.1",
"encoding": "^0.1.13",
"esbuild-loader": "^3.0.1",

14
app/pnpm-lock.yaml generated
View file

@ -7,7 +7,7 @@ settings:
dependencies:
'@electron/remote':
specifier: ^2.0.12
version: 2.0.12(electron@27.1.3)
version: 2.0.12(electron@27.2.0)
devDependencies:
'@types/node':
@ -32,8 +32,8 @@ devDependencies:
specifier: ^1.11.5
version: 1.11.5
electron:
specifier: 27.1.3
version: 27.1.3
specifier: 27.2.0
version: 27.2.0
electron-builder:
specifier: ^24.9.1
version: 24.9.1
@ -161,12 +161,12 @@ packages:
- supports-color
dev: true
/@electron/remote@2.0.12(electron@27.1.3):
/@electron/remote@2.0.12(electron@27.2.0):
resolution: {integrity: sha512-IJN6xLAxptq5MCvXNCU6+pdQyz0DjpPtX6g2TPJftu3Z9pU6BTdnos9ZMN8nK471LkASqiA6C+Hzjv5SS8PAQw==}
peerDependencies:
electron: '>= 13.0.0'
dependencies:
electron: 27.1.3
electron: 27.2.0
dev: false
/@electron/universal@1.4.1:
@ -1670,8 +1670,8 @@ packages:
resolution: {integrity: sha512-YoVeFrGd/7ROjz4R9uPoND1K/hSRC/xADy9639ZmIZeJSaBnKdYx3I6LMPsY7CXLpK7JFgKQVzeZ/dk2br6Eaw==}
dev: true
/electron@27.1.3:
resolution: {integrity: sha512-7eD8VMhhlL5J531OOawn00eMthUkX1e3qN5Nqd7eMK8bg5HxQBrn8bdPlvUEnCano9KhrVwaDnGeuzWoDOGpjQ==}
/electron@27.2.0:
resolution: {integrity: sha512-no/iMICVLI/5G0IqgKFbB89HDN88DWwKeRO+dPfJPkpJISdEX8Cx/sMEOFuuRa4VNInNe5CKCqRWExK5z3AdcQ==}
engines: {node: '>= 12.20.55'}
hasBin: true
requiresBuild: true

View file

@ -50,7 +50,7 @@ require (
github.com/rqlite/sql v0.0.0-20221103124402-8f9ff0ceb8f0
github.com/sashabaranov/go-openai v1.17.9
github.com/shirou/gopsutil/v3 v3.23.11
github.com/siyuan-note/dejavu v0.0.0-20231221144323-86aba7fc891e
github.com/siyuan-note/dejavu v0.0.0-20231222001002-f9ee1c8562bf
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

View file

@ -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-20231221144323-86aba7fc891e h1:vto8rhxvaM5umJlM7kIikiDJ3y1HsX0EMRf+CsM2BP4=
github.com/siyuan-note/dejavu v0.0.0-20231221144323-86aba7fc891e/go.mod h1:Zpo0p/Z5dSebzbxMiGJKp0X4OeJ4kBrLOJO6a0txDQs=
github.com/siyuan-note/dejavu v0.0.0-20231222001002-f9ee1c8562bf h1:ou1qYDJkVuDGPf7x6rD/7Z5KE1Seaqf884A+POh1WwA=
github.com/siyuan-note/dejavu v0.0.0-20231222001002-f9ee1c8562bf/go.mod h1:Zpo0p/Z5dSebzbxMiGJKp0X4OeJ4kBrLOJO6a0txDQs=
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=

View file

@ -626,8 +626,8 @@ func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard, unreviewed
for _, deck := range Decks {
cards, unreviewedCnt, unreviewedNewCardCnt, unreviewedOldCardCnt := getDeckDueCards(deck, reviewedCardIDs, nil, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit)
unreviewedCount += unreviewedCnt
unreviewedNewCardCnt += unreviewedNewCardCnt
unreviewedOldCardCnt += unreviewedOldCardCnt
unreviewedNewCardCount += unreviewedNewCardCnt
unreviewedOldCardCount += unreviewedOldCardCnt
for _, card := range cards {
ret = append(ret, newFlashcard(card, card.BlockID(), deck.ID, now))
}
@ -994,38 +994,16 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar
dues := deck.Dues()
var tmp []riff.Card
for _, c := range dues {
if nil == treenode.GetBlockTree(c.BlockID()) {
continue
}
tmp = append(tmp, c)
}
dues = tmp
tmp = nil
for _, c := range dues {
if 0 < len(blockIDs) && !gulu.Str.Contains(c.BlockID(), blockIDs) {
continue
}
tmp = append(tmp, c)
if 0 < len(reviewedCardIDs) {
if !gulu.Str.Contains(c.ID(), reviewedCardIDs) {
unreviewedCount++
if riff.New == c.GetState() {
unreviewedNewCardCount++
} else {
unreviewedOldCardCount++
}
}
} else {
unreviewedCount++
if riff.New == c.GetState() {
unreviewedNewCardCount++
} else {
unreviewedOldCardCount++
}
if nil == treenode.GetBlockTree(c.BlockID()) {
continue
}
tmp = append(tmp, c)
}
dues = tmp
@ -1055,8 +1033,22 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar
}
}
if 0 < len(reviewedCardIDs) && !gulu.Str.Contains(c.ID(), reviewedCardIDs) {
continue
if 0 < len(reviewedCardIDs) {
if !gulu.Str.Contains(c.ID(), reviewedCardIDs) {
unreviewedCount++
if riff.New == c.GetState() {
unreviewedNewCardCount++
} else {
unreviewedOldCardCount++
}
}
} else {
unreviewedCount++
if riff.New == c.GetState() {
unreviewedNewCardCount++
} else {
unreviewedOldCardCount++
}
}
ret = append(ret, c)

View file

@ -23,10 +23,12 @@ import (
"os"
"strconv"
"strings"
"sync"
"time"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/steambap/captcha"
@ -317,3 +319,27 @@ func Recover(c *gin.Context) {
c.Next()
}
var (
requestingLock = sync.Mutex{}
requesting = map[string]*sync.Mutex{}
)
func ControlConcurrency(c *gin.Context) {
if websocket.IsWebSocketUpgrade(c.Request) {
c.Next()
return
}
requestingLock.Lock()
mutex := requesting[c.Request.URL.Path]
if nil == mutex {
mutex = &sync.Mutex{}
requesting[c.Request.URL.Path] = mutex
}
requestingLock.Unlock()
mutex.Lock()
c.Next()
mutex.Unlock()
}

View file

@ -52,6 +52,7 @@ func Serve(fastMode bool) {
ginServer := gin.New()
ginServer.MaxMultipartMemory = 1024 * 1024 * 32 // 插入较大的资源文件时内存占用较大 https://github.com/siyuan-note/siyuan/issues/5023
ginServer.Use(
model.ControlConcurrency, // 请求串行化 Concurrency control when requesting the kernel API https://github.com/siyuan-note/siyuan/issues/9939
model.Timing,
model.Recover,
corsMiddleware(), // 后端服务支持 CORS 预检请求验证 https://github.com/siyuan-note/siyuan/pull/5593