-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.ts
49 lines (37 loc) · 1.04 KB
/
store.ts
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
48
import { Storage } from "@plasmohq/storage"
import { AUTO_CLOSE_TAB_RULES, AUTO_CLOSE_TAB_RULES_HISTORY } from "~const"
import { create } from 'zustand'
export const storageConfig = {
key: AUTO_CLOSE_TAB_RULES,
instance: new Storage({
area: "local",
copiedKeyList: [AUTO_CLOSE_TAB_RULES]
})
}
export const storageHistoryConfig = {
key: AUTO_CLOSE_TAB_RULES_HISTORY,
instance: new Storage({
area: "local",
copiedKeyList: [AUTO_CLOSE_TAB_RULES_HISTORY]
})
}
interface OpenType {
openPage: string
setOpenPage: (openPage: string) => void
}
interface IdType {
id: string
setId: (id: string) => void
}
export const usePageVisibleStore = create<OpenType>((set) => ({
openPage: 'ruleList',
setOpenPage: (openPage: string) => set({ openPage }),
}))
export const useCurrentIdStore = create<IdType>((set) => ({
id: "",
setId: (id: string) => set({ id }),
}))
export const defaultValueFunction = (v: RuleType[]) => v ?? []
export const useVersionStore = create(() => ({
version: chrome.runtime.getManifest().version
}))