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

This commit is contained in:
Vanessa 2023-01-27 16:35:52 +08:00
commit 258acc1142
7 changed files with 53 additions and 41 deletions

View file

@ -131,8 +131,8 @@ const boot = () => {
let defaultHeight
let workArea
try {
defaultWidth = screen.getPrimaryDisplay().size.width * 4 / 5
defaultHeight = screen.getPrimaryDisplay().workAreaSize.height * 4 / 5
defaultWidth = screen.getPrimaryDisplay().size.width
defaultHeight = screen.getPrimaryDisplay().workAreaSize.height
workArea = screen.getPrimaryDisplay().workArea
} catch (e) {
console.error(e)
@ -807,8 +807,8 @@ app.whenReady().then(() => {
if (firstOpen) {
const firstOpenWindow = new BrowserWindow({
width: screen.getPrimaryDisplay().size.width / 2,
height: screen.getPrimaryDisplay().workAreaSize.height / 2,
width: screen.getPrimaryDisplay().size.width * 0.6,
height: screen.getPrimaryDisplay().workAreaSize.height * 0.8,
frame: false,
icon: path.join(appDir, 'stage', 'icon-large.png'),
transparent: 'linux' !== process.platform,

View file

@ -45,6 +45,7 @@ func StartCron() {
}
func every(interval time.Duration, f func()) {
util.RandomSleep(50, 200)
for {
func() {
defer logging.Recover()

View file

@ -32,34 +32,37 @@ func autoOCRAssets() {
assetsPath := util.GetDataAssetsAbsPath()
assets := getUnOCRAssetsAbsPaths()
poolSize := runtime.NumCPU()
if 4 < poolSize {
poolSize = 4
}
waitGroup := &sync.WaitGroup{}
p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
defer waitGroup.Done()
assetAbsPath := arg.(string)
text := util.Tesseract(assetAbsPath)
p := strings.TrimPrefix(assetAbsPath, assetsPath)
p = "assets" + filepath.ToSlash(p)
util.AssetsTextsLock.Lock()
util.AssetsTexts[p] = text
util.AssetsTextsLock.Unlock()
util.AssetsTextsChanged = true
})
for i, assetAbsPath := range assets {
waitGroup.Add(1)
p.Invoke(assetAbsPath)
if 63 <= i { // 一次任务中最多处理 64 张图片,防止卡顿
break
if 0 < len(assets) {
poolSize := runtime.NumCPU()
if 4 < poolSize {
poolSize = 4
}
waitGroup := &sync.WaitGroup{}
p, _ := ants.NewPoolWithFunc(poolSize, func(arg interface{}) {
defer waitGroup.Done()
assetAbsPath := arg.(string)
text := util.Tesseract(assetAbsPath)
p := strings.TrimPrefix(assetAbsPath, assetsPath)
p = "assets" + filepath.ToSlash(p)
util.AssetsTextsLock.Lock()
util.AssetsTexts[p] = text
util.AssetsTextsLock.Unlock()
util.AssetsTextsChanged = true
})
for i, assetAbsPath := range assets {
waitGroup.Add(1)
p.Invoke(assetAbsPath)
if 63 <= i { // 一次任务中最多处理 64 张图片,防止卡顿
break
}
}
waitGroup.Wait()
p.Release()
}
waitGroup.Wait()
p.Release()
cleanNotExistAssetsTexts()
}

View file

@ -51,6 +51,10 @@ func HookDesktopUIProcJob() {
return
}
if 0 < util.CountSessions() {
return
}
uiProcNames := []string{"siyuan", "electron"}
existUIProc := false
util.UIProcessIDs.Range(func(uiProcIDArg, _ interface{}) bool {

View file

@ -47,9 +47,11 @@ var (
)
func SyncDataJob() {
if time.Now().After(syncPlanTime) {
SyncData(false, false, false)
if time.Now().Before(syncPlanTime) {
return
}
SyncData(false, false, false)
}
func BootSyncData() {

View file

@ -135,8 +135,8 @@ func FlushQueue() {
}
elapsed := time.Now().Sub(start).Milliseconds()
if 5000 < elapsed {
logging.LogInfof("op tx [%dms]", elapsed)
if 7000 < elapsed {
logging.LogInfof("database op tx [%dms]", elapsed)
}
}

View file

@ -97,21 +97,23 @@ func StatusJob() {
tasks := taskQueue
data := map[string]interface{}{}
var items []map[string]interface{}
count := map[string]int{}
for _, task := range tasks {
if OCRImage == task.Action || DatabaseIndexEmbedBlock == task.Action {
continue
}
actionLangs := util.TaskActionLangs[util.Lang]
action := task.Action
if c := count[action]; 3 < c {
logging.LogWarnf("too many tasks [%s], ignore show its status", action)
continue
}
count[action]++
if nil != actionLangs {
if label := actionLangs[task.Action]; nil != label {
action = label.(string)
}
}
item := map[string]interface{}{
"action": action,
}
item := map[string]interface{}{"action": action}
items = append(items, item)
}
if 1 > len(items) {