-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
70 lines (65 loc) · 1.62 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { listen } from "./module/static.ts";
import { loadWebview } from "./module/webview.ts";
import { blue, red } from "std/fmt/colors.ts";
import {
getAllfield,
getLanguagesKey,
Lang,
languages,
setLanguageId,
} from "./lang/index.ts";
let lang: Lang = "en";
class Menu {
id;
callBack;
sort = "";
constructor(id: number, name: string, callBack: () => void) {
const sort = languages[lang]["sort"];
const description = languages[lang]["description"];
Reflect.set(this, sort, id);
Reflect.set(this, description, name);
this.id = id;
this.callBack = callBack;
}
}
function welcome() {
console.clear();
const SelectLangText = blue(languages[lang]["SelectLang"]);
console.table(getLanguagesKey(lang));
const text = prompt(SelectLangText);
if (text) {
const l = setLanguageId(parseInt(text));
if (l) lang = l;
}
console.clear();
showMenu();
}
welcome();
function showMenu() {
const menus = [
new Menu(0, languages[lang]["openWsServerPort"], () => {
}),
new Menu(1, languages[lang]["selectMenuLang"], welcome),
];
// const sort = languages[lang]["sort"];
const description = languages[lang]["description"];
console.clear();
console.table(
menus,
[description],
);
const SelectMenuText = blue(languages[lang]["SelectMenu"]);
let text1 = prompt(SelectMenuText);
function passMenuText() {
const item = menus.find((e) => text1 && e.id === parseInt(text1));
item?.callBack();
if (!item) {
text1 = prompt(SelectMenuText);
passMenuText();
}
}
passMenuText();
}
// console.log(text);
// listen();
// setTimeout(loadWebview);