Test.js
1.18 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
48
49
50
51
52
53
54
55
56
57
import localforage from "localforage";
const initTempSubjects = async () => {
let tcolors = [
"red",
"green",
"blue",
"orange",
"gold",
"aqua",
"chartreuse",
];
const subCodeLst = ["1", "2"];
const subObj = {
1: {
name: "과목A",
color: tcolors[0],
selected: true,
schedule: [
{ type: "zoom", category: "과목A", label: "", start: [9, 30] },
],
},
2: {
name: "과목B",
color: tcolors[1],
selected: true,
schedule: [
{
date: new Date(2022, 5, 3),
type: "ecampus",
category: "과목B",
label: "과제",
end: [23, 59],
},
],
},
};
await localforage.setItem("1", subObj["1"]);
await localforage.setItem("2", subObj["2"]);
for (let i = 2; i < 7; i++) {
let code = (i + 1).toString();
let tsub = {
date: new Date(2022, 5, 3),
name: "과목" + code,
color: tcolors[i],
selected: true,
schedule: [],
};
subCodeLst.push(code);
await localforage.setItem(code, tsub);
}
localStorage.setItem("Subjects", JSON.stringify(subCodeLst));
};
export { initTempSubjects };