-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
87 lines (80 loc) · 2.57 KB
/
index.js
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
const electron = require('electron');
const {app,dialog,BrowserWindow,Menu,shell} = electron;
const {ipcMain} = require('electron');
let win;
app.on('ready', function () {
win = new BrowserWindow({width: 800, height: 600});
win.loadURL(`file://${__dirname}/index.html`);
win.setTitle('this is my first app for testing electron');
var app_menu=[
{
label:'پرونده',
submenu:[
{
label:'باز کردن',
accelerator:'CmdOrCtrl+O',
click:()=>{
dialog.showOpenDialog({
title:'باز کردن فایل متنی',
properties: [ 'openFile']//[ 'openFile', 'openDirectory', 'multiSelections' ]
,filters:[
{name:'فایل های نوشتاری' , extensions:['txt','text']},
{name:'جهت تست' , extensions:['doc','docx']}
]
},
(filename)=>{
if(filename===undefined)
return;
win.webContents.send('openFile',filename);
// dialog.showMessageBox({title:'پیام اطلاعاتی',type:"info",buttons:['تایید'],message:`the name of file is [${filename}]`});
});
}
},
{
label:'ذخیره',
accelerator:'CmdOrCtrl+S',
click:()=>{
dialog.showSaveDialog({
title:'باز کردن فایل متنی',
properties: [ 'openFile']//[ 'openFile', 'openDirectory', 'multiSelections' ]
,filters:[
{name:'فایل های نوشتاری' , extensions:['txt','text']}
]
},
(filename)=>{
if(filename===undefined)
return;
win.webContents.send('saveFile',filename);
});
}
}
]
},
{
label:'سیستم',
submenu:[
{
label:'درباره ما',
click:()=>
{
shell.openExternal('http://www.dotnettips.info');
}
},
{
label:'خروج',
accelerator:'CmdOrCtrl+X',
role:'close'
}
]
}
];
if(process.platform=="darwin")
{
const app_name=app.getName();
app_menu.unshift({
label:app_name
})
}
var menu=Menu.buildFromTemplate(app_menu);
Menu.setApplicationMenu(menu);
});