Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 178841e

Browse files
committed
feature: 增加任务缓存配置(暂未开放, 存储存在一定问题);
1 parent 73e1a10 commit 178841e

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

adapter/gui_windows/gui_windows.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ type GuiWindows struct {
5656
ptrNumThreads *walk.LineEdit
5757
ptrNumProcessors *walk.LineEdit
5858

59-
ptrBtnCmdFile *walk.PushButton
60-
ptrEchoCmdFile *walk.TextLabel
59+
ptrBtnCmdFile *walk.PushButton
60+
ptrEchoCmdFile *walk.TextLabel
61+
ptrFlagCacheWhisperData *walk.CheckBox
6162

6263
chanMsg chan string
6364
ptrOutput *walk.ListBox

adapter/gui_windows/panel_fly.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ func (customGW *GuiWindows) panelFlyBuilder() Widget {
129129
HSpacer{},
130130
},
131131
},
132+
/*Composite{
133+
Layout: HBox{MarginsZero: true},
134+
Children: []Widget{
135+
CheckBox{AssignTo: &customGW.ptrFlagCacheWhisperData, Text: "是否缓存未处理完的任务[临时]", Checked: repository.ApiCfg().ActionGetFlagCacheWhisperData(), OnCheckedChanged: func() {
136+
repository.ApiCfg().ActionSetFlagCacheWhisperData(customGW.ptrFlagCacheWhisperData.Checked())
137+
}},
138+
HSpacer{},
139+
},
140+
},*/
132141
VSeparator{MinSize: Size{Height: 10}, MaxSize: Size{Height: 10}},
133142
Composite{
134143
Layout: HBox{MarginsZero: true},

cfg/cfg.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ func Api() *Cfg {
1414
onceCfg.Do(func() {
1515
apiCfg = new(Cfg)
1616
apiCfg.WhisperCfg = new(whisper.Cfg).Default()
17+
apiCfg.FlagCacheWhisperData = true
1718
})
1819
return apiCfg
1920
}
2021

2122
type Cfg struct {
22-
FlagInstalled bool
23-
WhisperCfg *whisper.Cfg
23+
FlagInstalled bool
24+
FlagCacheWhisperData bool
25+
WhisperCfg *whisper.Cfg
2426
}

cron/whisper_cron.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"titmouse/lib/processor/whisper"
1616
"titmouse/lib/storage/single_file"
1717
"titmouse/model"
18+
"titmouse/repository"
1819
)
1920

2021
var (
@@ -199,6 +200,9 @@ func (customWC *WhisperCron) init() {
199200
}
200201

201202
func (customWC *WhisperCron) recoverListInMemory() {
203+
if repository.ApiCfg().ActionGetFlagCacheWhisperData() == false {
204+
return
205+
}
202206
waitList := new(WhisperDataList).GetLastData()
203207
for _, data := range waitList {
204208
customWC.chanMsg <- fmt.Sprintf("恢复上次任务(%s)", data.Data.PathAudioFile)
@@ -207,6 +211,9 @@ func (customWC *WhisperCron) recoverListInMemory() {
207211
}
208212

209213
func (customWC *WhisperCron) storeListInMemory() {
214+
if repository.ApiCfg().ActionGetFlagCacheWhisperData() == false {
215+
return
216+
}
210217
waitList := new(WhisperDataList)
211218
customWC.listInMemory.Range(func(idx, val any) bool {
212219
tmpWhisperData := val.(*WhisperData)

repository/cfg.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ func (customCR CfgRepository) ActionSetWhisperCfg(whisperCfg *whisper.Cfg) error
4747
return customCR.whisperClient.SetCfg(whisperCfg)
4848
}
4949

50+
func (customCR CfgRepository) ActionGetFlagCacheWhisperData() bool {
51+
return cfg.Api().FlagCacheWhisperData
52+
}
53+
54+
func (customCR CfgRepository) ActionSetFlagCacheWhisperData(flag bool) {
55+
defer func() {
56+
_ = customCR.ActionSync()
57+
}()
58+
cfg.Api().FlagCacheWhisperData = flag
59+
}
60+
5061
// ActionSync 同步配置
5162
func (customCR CfgRepository) ActionSync() error {
5263
return cfg.Api().Store()

0 commit comments

Comments
 (0)