forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal-file-initializer.ts
More file actions
47 lines (44 loc) · 1.38 KB
/
local-file-initializer.ts
File metadata and controls
47 lines (44 loc) · 1.38 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Copyright (c) 2022 Hengyang Zhang
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
import mergeRuleDatabase from "@db/merge-rule-database"
import { t2Chrome } from "@i18n/chrome/t"
import { saveAlias } from '@service/site-service'
import { JSON_HOST, LOCAL_HOST_PATTERN, MERGED_HOST, PDF_HOST, PIC_HOST, TXT_HOST } from "@util/constant/remain-host"
import { type Migrator } from "./common"
/**
* Process the host of local files
*
* @since 0.7.0
*/
export default class LocalFileInitializer implements Migrator {
onUpdate(_version: string): void {
}
onInstall(): void {
// Add merged rules
mergeRuleDatabase.add({
origin: LOCAL_HOST_PATTERN,
merged: MERGED_HOST,
}).then(() => console.log('Local file merge rules initialized'))
// Add site name
saveAlias(
{ host: PDF_HOST, type: 'normal' },
t2Chrome(msg => msg.initial.localFile.pdf),
)
saveAlias(
{ host: JSON_HOST, type: 'normal' },
t2Chrome(msg => msg.initial.localFile.json),
)
saveAlias(
{ host: PIC_HOST, type: 'normal' },
t2Chrome(msg => msg.initial.localFile.pic),
)
saveAlias(
{ host: TXT_HOST, type: 'normal' },
t2Chrome(msg => msg.initial.localFile.txt),
)
}
}