Skip to content

Commit 0174e3b

Browse files
committed
feat: semi
1 parent 32ff483 commit 0174e3b

41 files changed

Lines changed: 611 additions & 273 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"license": "MIT",
3030
"devDependencies": {
3131
"@commitlint/types": "^21.0.1",
32-
"@crowdin/crowdin-api-client": "^1.55.1",
32+
"@crowdin/crowdin-api-client": "^1.55.2",
3333
"@emotion/babel-plugin": "^11.13.5",
3434
"@rsdoctor/rspack-plugin": "^1.5.11",
3535
"@rspack/cli": "^2.0.3",
@@ -39,7 +39,7 @@
3939
"@types/chrome": "0.1.42",
4040
"@types/decompress": "^4.2.7",
4141
"@types/firefox-webext-browser": "^143.0.0",
42-
"@types/node": "^25.8.0",
42+
"@types/node": "^25.9.1",
4343
"@vue/babel-plugin-jsx": "^2.0.1",
4444
"babel-loader": "^10.1.1",
4545
"commitlint": "^21.0.1",
@@ -51,10 +51,10 @@
5151
"jsdom": "^29.1.1",
5252
"jszip": "^3.10.1",
5353
"knip": "^6.14.1",
54-
"postcss": "^8.5.14",
54+
"postcss": "^8.5.15",
5555
"postcss-loader": "^8.2.1",
5656
"postcss-rtlcss": "^6.0.0",
57-
"puppeteer": "^25.0.2",
57+
"puppeteer": "^25.0.4",
5858
"ts-node": "^10.9.2",
5959
"tsconfig-paths": "^4.2.0",
6060
"typescript": "6.0.3",
@@ -63,7 +63,7 @@
6363
"dependencies": {
6464
"@element-plus/icons-vue": "^2.3.2",
6565
"@emotion/css": "^11.13.5",
66-
"echarts": "^6.0.0",
66+
"echarts": "^6.1.0",
6767
"element-plus": "2.14.0",
6868
"hash.js": "^1.1.7",
6969
"qrcode-generator": "^2.0.4",

src/api/sw/focus.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { sendMsg2Runtime } from './common'
2+
3+
export const listFocusPresets = () => sendMsg2Runtime('focus.allPresets')
4+
5+
export const getCurrentSession = () => sendMsg2Runtime('focus.current')
6+
7+
export const focusAction = (request: tt4b.focus.ActionRequest) => sendMsg2Runtime('focus.action', request)

src/background/message-dispatcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { exportData, importData, migrateStorage } from "./service/components/imm
1919
import { importOther, previewBackup } from "./service/components/import-processor"
2020
import optionHolder from "./service/components/option-holder"
2121
import { getWeekStartDay, getWeekStartTime } from "./service/components/week-helper"
22-
import { handleAction } from "./service/focus-service"
22+
import { getCurrentSession, handleAction } from "./service/focus-service"
2323
import { getTodayResult } from './service/item-service'
2424
import { getInstallTime, getLastBackUp } from "./service/meta-service"
2525
import notificationProcessor from './service/notification/processor'
@@ -136,6 +136,7 @@ class MessageDispatcher {
136136
.register('focus.addPreset', data => focusPresetDatabase.add(data))
137137
.register('focus.savePreset', data => focusPresetDatabase.update(data))
138138
.register('focus.action', handleAction)
139+
.register('focus.current', getCurrentSession)
139140
// Data immigration
140141
.register('immigration.import', importData)
141142
.register('immigration.export', exportData)

src/background/service/focus-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FocusHolder {
6666
if (this.#session.state !== 'running') return
6767

6868
const now = Date.now()
69-
increaseTime(this.#session, now)
69+
await increaseTime(this.#session, now)
7070
this.#session.end = now
7171
this.#session.state = 'paused'
7272
this.#session.logs.push({ action: 'pause', ts: now })
@@ -98,10 +98,16 @@ class FocusHolder {
9898
this.#session.duration += MILL_PER_MINUTE * 5
9999
await db.save(this.#session)
100100
}
101+
102+
get current(): tt4b.focus.Record | undefined {
103+
return this.#session
104+
}
101105
}
102106

103107
const focusHolder = new FocusHolder()
104108

109+
export const getCurrentSession = () => focusHolder.current
110+
105111
export async function handleAction(request: tt4b.focus.ActionRequest): Promise<void> {
106112
if (typeof request === 'object') {
107113
return focusHolder.start(request.config, request.presetId)

src/i18n/message/app/limit-resource.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"enabled": "启用",
1414
"locked": "锁定",
1515
"effectiveDay": "生效日期",
16-
"allowDelay": "可延时",
1716
"or": "或者",
1817
"notEffective": "未生效"
1918
},
@@ -62,7 +61,6 @@
6261
"enabled": "是否啟用",
6362
"locked": "已鎖定",
6463
"effectiveDay": "生效日期",
65-
"allowDelay": "允許延遲",
6664
"or": "",
6765
"notEffective": "未生效"
6866
},
@@ -110,7 +108,6 @@
110108
"enabled": "Enabled",
111109
"locked": "Locked",
112110
"effectiveDay": "Effective On",
113-
"allowDelay": "Allow Delay",
114111
"or": "or",
115112
"notEffective": "Not effective"
116113
},
@@ -204,7 +201,6 @@
204201
"enabled": "Ativo",
205202
"locked": "Bloqueado",
206203
"effectiveDay": "Dias de aplicação",
207-
"allowDelay": "Permitir atraso",
208204
"or": "ou",
209205
"notEffective": "Não aplicável"
210206
},
@@ -252,7 +248,6 @@
252248
"enabled": "Увімкнено",
253249
"locked": "Заблоковано",
254250
"effectiveDay": "Діє",
255-
"allowDelay": "Дозволити затримку",
256251
"or": "або",
257252
"notEffective": "Не діє"
258253
},
@@ -347,7 +342,6 @@
347342
"enabled": "Aktiviert",
348343
"locked": "Gesperrt",
349344
"effectiveDay": "Wirksam auf",
350-
"allowDelay": "Verzögerung zulassen",
351345
"or": "oder",
352346
"notEffective": "Nicht wirksam"
353347
},
@@ -397,7 +391,6 @@
397391
"enabled": "Activé",
398392
"locked": "Verrouillé",
399393
"effectiveDay": "Effectif le",
400-
"allowDelay": "Retardable",
401394
"or": "ou",
402395
"notEffective": "Non efficace"
403396
},
@@ -447,7 +440,6 @@
447440
"enabled": "Включено",
448441
"locked": "Заблокировано",
449442
"effectiveDay": "Эффективный",
450-
"allowDelay": "Разрешить задержку",
451443
"or": "или",
452444
"notEffective": "Не активировано"
453445
},
@@ -541,7 +533,6 @@
541533
"enabled": "Etkinleştirildi",
542534
"locked": "Kilitli",
543535
"effectiveDay": "Geçerli Olduğu Gün(ler)",
544-
"allowDelay": "Ertelenebilir",
545536
"or": "yada",
546537
"notEffective": "Geçerli değil"
547538
},
@@ -588,7 +579,6 @@
588579
"enabled": "Aktywne",
589580
"locked": "Zablokowany",
590581
"effectiveDay": "Aktywna w",
591-
"allowDelay": "Możliwe do przedłużenia",
592582
"or": "lub",
593583
"notEffective": "Nieskuteczny"
594584
},
@@ -636,7 +626,6 @@
636626
"enabled": "Attivata",
637627
"locked": "Bloccato",
638628
"effectiveDay": "Effettivo On",
639-
"allowDelay": "Ritardabile",
640629
"or": "o",
641630
"notEffective": "Non valido"
642631
},

src/i18n/message/app/limit.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export type LimitMessage = {
2424
enabled: string
2525
locked: string
2626
effectiveDay: string
27-
allowDelay: string
2827
delayCount: string
2928
detail: string
3029
or: string

src/i18n/message/app/menu-resource.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"analysis": "Site Analysis",
2929
"productivity": "Productivity & Focus",
3030
"habit": "Habits",
31-
"focus": "Focus Mode",
3231
"siteRule": "Sites & Rules",
3332
"sites": "Site Management",
3433
"whitelist": "Whitelist",

src/i18n/message/app/menu.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ export type MenuMessage = {
1212
dashboard: string
1313
record: string
1414
analysis: string
15-
1615
productivity: string
1716
habit: string
18-
focus: string
19-
2017
siteRule: string
2118
sites: string
2219
whitelist: string
2320
mergeRule: string
24-
2521
other: string
2622
migration: string
2723
about: string

src/i18n/message/common/shared-resource.json

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@
1818
"daily": "Daily limit",
1919
"weekly": "Weekly limit",
2020
"period": "Blocked periods",
21-
"visits": "{n} visits"
21+
"visits": "{n} visits",
22+
"allowDelay": "Allow Delay",
23+
"unlimited": "Unlimited"
24+
},
25+
"focus": {
26+
"menu": "Focus Mode",
27+
"mode": {
28+
"allow": "Allow only",
29+
"block": "Block"
30+
},
31+
"duration": "Focus Time"
2232
}
2333
},
2434
"zh_CN": {
@@ -40,7 +50,8 @@
4050
"daily": "每日上限",
4151
"weekly": "每周上限",
4252
"period": "不可访问的时间段",
43-
"visits": "{n}次访问"
53+
"visits": "{n}次访问",
54+
"allowDelay": "可延时"
4455
}
4556
},
4657
"ja": {
@@ -83,7 +94,8 @@
8394
"daily": "每日上限",
8495
"weekly": "每週上限",
8596
"period": "限制時段",
86-
"visits": "{n}次造訪"
97+
"visits": "{n}次造訪",
98+
"allowDelay": "允許延遲"
8799
}
88100
},
89101
"pt_PT": {
@@ -104,7 +116,8 @@
104116
"daily": "Limite diário",
105117
"weekly": "Limite semanal",
106118
"period": "Períodos bloqueados",
107-
"visits": "{n} visitas"
119+
"visits": "{n} visitas",
120+
"allowDelay": "Permitir atraso"
108121
}
109122
},
110123
"uk": {
@@ -125,7 +138,8 @@
125138
"daily": "Денний ліміт",
126139
"weekly": "Тижневий ліміт",
127140
"period": "Недозволені періоди",
128-
"visits": "{n} відвідування"
141+
"visits": "{n} відвідування",
142+
"allowDelay": "Дозволити затримку"
129143
}
130144
},
131145
"it": {
@@ -147,7 +161,8 @@
147161
"daily": "Limite giornaliero",
148162
"weekly": "Limite settimanale",
149163
"period": "Periodi bloccati",
150-
"visits": "{n} visite"
164+
"visits": "{n} visite",
165+
"allowDelay": "Ritardabile"
151166
}
152167
},
153168
"es": {
@@ -190,7 +205,8 @@
190205
"daily": "Tägliches Limit",
191206
"weekly": "Wöchentliches Limit",
192207
"period": "Unzulässiger Zeitraum",
193-
"visits": "{n} Besuche"
208+
"visits": "{n} Besuche",
209+
"allowDelay": "Verzögerung zulassen"
194210
}
195211
},
196212
"fr": {
@@ -212,7 +228,8 @@
212228
"daily": "Limite quotidienne",
213229
"weekly": "Limite hebdomadaire",
214230
"period": "Périodes bloquées",
215-
"visits": "{n} visites"
231+
"visits": "{n} visites",
232+
"allowDelay": "Retardable"
216233
}
217234
},
218235
"ru": {
@@ -233,7 +250,8 @@
233250
"daily": "Дневной лимит",
234251
"weekly": "Недельный лимит",
235252
"period": "Заблокированное время",
236-
"visits": "{n} посещения"
253+
"visits": "{n} посещения",
254+
"allowDelay": "Разрешить задержку"
237255
}
238256
},
239257
"ar": {
@@ -275,7 +293,8 @@
275293
"daily": "Günlük limit",
276294
"weekly": "Haftalık limit",
277295
"period": "Engellenen periyotlar",
278-
"visits": "{n} ziyaretler"
296+
"visits": "{n} ziyaretler",
297+
"allowDelay": "Ertelenebilir"
279298
}
280299
},
281300
"pl": {
@@ -296,7 +315,8 @@
296315
"daily": "Dzienny limit",
297316
"weekly": "Limit tygodniowy",
298317
"period": "Godziny blokowania",
299-
"visits": "{n} wizyt"
318+
"visits": "{n} wizyt",
319+
"allowDelay": "Możliwe do przedłużenia"
300320
}
301321
}
302322
}

src/i18n/message/common/shared.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export type SharedMessage = {
1414
weekly: string
1515
period: string
1616
visits: string
17+
allowDelay: string
18+
unlimited: string
19+
}
20+
focus: {
21+
menu: string
22+
mode: Record<tt4b.focus.Mode, string>
23+
duration: string
1724
}
1825
}
1926

0 commit comments

Comments
 (0)