forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprinter.ts
More file actions
32 lines (28 loc) · 993 Bytes
/
printer.ts
File metadata and controls
32 lines (28 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Copyright (c) 2021 Hengyang Zhang
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
import { t } from "./locale"
import { formatPeriod } from "@util/time"
import { sendMsg2Runtime } from "@api/chrome/runtime"
/**
* Print info of today
*/
export default async function printInfo(host: string) {
const waste: timer.stat.Result = await sendMsg2Runtime('cs.getTodayInfo', host)
const hourMsg = t(msg => msg.console.timeWithHour)
const minuteMsg = t(msg => msg.console.timeWithMinute)
const secondMsg = t(msg => msg.console.timeWithSecond)
const msg = { hourMsg, minuteMsg, secondMsg }
const param = {
time: waste.time ? '' + waste.time : '-',
focus: formatPeriod(waste.focus, msg),
host,
}
const info0 = t(msg => msg.console.consoleLog, param)
const info1 = t(msg => msg.console.closeAlert, { appName: t(msg => msg.meta.name) })
console.log(info0)
console.log(info1)
}