generated from vivid-lapin/ts
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.tsx
102 lines (100 loc) · 2.73 KB
/
index.tsx
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import fs from "fs"
import os from "os"
import path from "path"
import { SAMPLE_META, SAMPLE_WINDOW_ID } from "./constants"
import { InitPlugin } from "../@types/plugin"
const main: InitPlugin = {
renderer:
typeof window !== "undefined"
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require("./SampleRenderer").SampleRenderer
: undefined,
main: ({ appInfo, packages, functions }) => {
const homedir = os.homedir()
console.info("homedir:", homedir)
return {
...SAMPLE_META,
setup: () => {
return
},
destroy: () => {
return
},
appMenu: {
label: SAMPLE_META.name,
submenu: [
{
label: "アプリバージョン",
click: () => {
packages.Electron.dialog.showMessageBox({
message: `AppVersion: ${appInfo.version}`,
})
},
},
{
label: "ウィンドウを開く",
click: () => {
functions.openWindow({
name: SAMPLE_WINDOW_ID,
isSingletone: true,
})
},
},
{
label: "/tmp/mirakにファイルを書き込んでみる",
click: () => {
fs.promises.writeFile("/tmp/mirak", "Hello, world!")
},
},
{
label: "/tmp/.mirakにファイルを書き込んでみる",
click: () => {
fs.promises.writeFile("/tmp/.mirak", "Hello, world!")
},
},
{
label: "~/mirakにファイルを書き込んでみる",
click: () => {
fs.promises.writeFile(
path.join(homedir, "mirak"),
"Hello, world!"
)
},
},
{
label: "~/.mirakにファイルを書き込んでみる",
click: () => {
fs.promises.writeFile(
path.join(homedir, ".mirak"),
"Hello, world!"
)
},
},
{
label: "evalで/tmp/mirakevalにファイルを書き込んでみる",
click() {
eval(
`require('fs').promises.writeFile('/tmp/mirakeval', 'Hello, world!')`
)
},
},
],
},
contextMenu: {
label: SAMPLE_META.name,
submenu: [
{
label: "ウィンドウを開く",
click: () => {
functions.openWindow({
name: SAMPLE_WINDOW_ID,
isSingletone: true,
})
},
},
],
},
}
},
}
export default main