2019-03-07 14:21:27 +11:00
|
|
|
// Create the Application's main menu
|
2020-09-18 22:49:55 +10:00
|
|
|
function templete(lang, mainWindow, packaged, dir, dirname) {
|
2020-03-19 15:17:02 +11:00
|
|
|
//フレーム
|
2021-04-18 05:24:52 +10:00
|
|
|
if (lang != "ja" && lang != "en") {
|
2019-08-07 10:24:52 +10:00
|
|
|
lang = "en"
|
|
|
|
}
|
2021-04-18 05:24:52 +10:00
|
|
|
const electron = require("electron")
|
|
|
|
const { Menu, MenuItem, ipcMain, BrowserWindow, app } = electron
|
2019-08-26 22:06:07 +10:00
|
|
|
const join = require('path').join;
|
2019-05-19 17:39:30 +10:00
|
|
|
const dict = {
|
|
|
|
"application": {
|
|
|
|
"ja": "アプリケーション",
|
|
|
|
"en": "Application"
|
|
|
|
},
|
|
|
|
"about": {
|
|
|
|
"ja": "TheDeskについて",
|
|
|
|
"en": "About TheDesk"
|
|
|
|
},
|
|
|
|
"quit": {
|
|
|
|
"ja": "終了",
|
|
|
|
"en": "Quit"
|
|
|
|
},
|
|
|
|
"edit": {
|
|
|
|
"ja": "編集",
|
|
|
|
"en": "Edit"
|
|
|
|
},
|
|
|
|
"undo": {
|
|
|
|
"ja": "元に戻す",
|
|
|
|
"en": "Undo"
|
|
|
|
},
|
|
|
|
"redo": {
|
|
|
|
"ja": "やり直す",
|
|
|
|
"en": "Redo"
|
|
|
|
},
|
|
|
|
"cut": {
|
|
|
|
"ja": "切り取り",
|
|
|
|
"en": "Cut"
|
|
|
|
},
|
|
|
|
"copy": {
|
|
|
|
"ja": "コピー",
|
|
|
|
"en": "Copy"
|
|
|
|
},
|
|
|
|
"paste": {
|
|
|
|
"ja": "貼り付け",
|
|
|
|
"en": "Paste"
|
|
|
|
},
|
|
|
|
"selall": {
|
|
|
|
"ja": "すべて選択",
|
|
|
|
"en": "Select All"
|
|
|
|
},
|
|
|
|
"view": {
|
|
|
|
"ja": "表示",
|
|
|
|
"en": "View"
|
|
|
|
},
|
|
|
|
"reload": {
|
|
|
|
"ja": "再読み込み",
|
|
|
|
"en": "Reload"
|
|
|
|
},
|
|
|
|
"window": {
|
|
|
|
"ja": "ウィンドウ",
|
|
|
|
"en": "Window"
|
|
|
|
},
|
|
|
|
"minimun": {
|
|
|
|
"ja": "最小化",
|
|
|
|
"en": "Minimarize"
|
|
|
|
},
|
|
|
|
"close": {
|
|
|
|
"ja": "閉じる",
|
|
|
|
"en": "Close"
|
2019-03-07 14:21:27 +11:00
|
|
|
}
|
|
|
|
}
|
2021-04-18 05:24:52 +10:00
|
|
|
if (packaged) {
|
2019-06-16 02:08:10 +10:00
|
|
|
var ifDev = [
|
|
|
|
{
|
|
|
|
label: dict.reload[lang],
|
|
|
|
accelerator: 'CmdOrCtrl+R',
|
|
|
|
click: function () { mainWindow.reload(); }
|
|
|
|
}
|
|
|
|
]
|
2021-04-18 05:24:52 +10:00
|
|
|
} else {
|
2019-06-16 02:08:10 +10:00
|
|
|
var ifDev = [
|
|
|
|
{
|
|
|
|
label: 'Toggle Developer Tools',
|
|
|
|
accelerator: 'Alt+Command+I',
|
2021-04-18 05:24:52 +10:00
|
|
|
click: function () { mainWindow.toggleDevTools(); }
|
2019-06-16 02:08:10 +10:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: dict.reload[lang],
|
|
|
|
accelerator: 'CmdOrCtrl+R',
|
|
|
|
click: function () { mainWindow.reload(); }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2019-03-07 14:21:27 +11:00
|
|
|
const menu = [{
|
|
|
|
label: dict.application[lang],
|
|
|
|
submenu: [
|
2019-05-19 17:39:30 +10:00
|
|
|
{
|
|
|
|
label: dict.about[lang], click: function () {
|
|
|
|
var ver = app.getVersion()
|
|
|
|
var window = new BrowserWindow({
|
2019-05-19 20:24:27 +10:00
|
|
|
webPreferences: {
|
2019-06-15 19:52:28 +10:00
|
|
|
webviewTag: false,
|
|
|
|
nodeIntegration: false,
|
|
|
|
contextIsolation: true,
|
2021-04-18 05:24:52 +10:00
|
|
|
preload: join(dirname, "js", "platform", "preload.js")
|
2019-05-19 20:24:27 +10:00
|
|
|
},
|
2019-08-26 22:06:07 +10:00
|
|
|
width: 300, height: 500,
|
2019-05-19 17:39:30 +10:00
|
|
|
"transparent": false, // ウィンドウの背景を透過
|
|
|
|
"frame": false, // 枠の無いウィンドウ
|
|
|
|
"resizable": false
|
|
|
|
});
|
|
|
|
window.loadURL(dir + '/about.html?ver=' + ver);
|
|
|
|
}
|
|
|
|
},
|
2019-03-07 14:21:27 +11:00
|
|
|
{ type: "separator" },
|
2019-05-19 17:39:30 +10:00
|
|
|
{ label: dict.quit[lang], accelerator: "Command+Q", click: function () { app.quit(); } }
|
|
|
|
|
|
|
|
]
|
|
|
|
}, {
|
2019-03-07 14:21:27 +11:00
|
|
|
label: dict.edit[lang],
|
|
|
|
submenu: [
|
|
|
|
{ label: dict.undo[lang], accelerator: "CmdOrCtrl+Z", selector: "undo:" },
|
|
|
|
{ label: dict.redo[lang], accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
|
|
|
|
{ type: "separator" },
|
|
|
|
{ label: dict.cut[lang], accelerator: "CmdOrCtrl+X", selector: "cut:" },
|
|
|
|
{ label: dict.copy[lang], accelerator: "CmdOrCtrl+C", selector: "copy:" },
|
|
|
|
{ label: dict.paste[lang], accelerator: "CmdOrCtrl+V", selector: "paste:" },
|
|
|
|
{ label: dict.selall[lang], accelerator: "CmdOrCtrl+A", selector: "selectAll:" }
|
2019-05-19 17:39:30 +10:00
|
|
|
]
|
|
|
|
}, {
|
2019-03-07 14:21:27 +11:00
|
|
|
label: dict.view[lang],
|
2019-06-16 02:08:10 +10:00
|
|
|
submenu: ifDev
|
2019-05-19 17:39:30 +10:00
|
|
|
},
|
|
|
|
{
|
2019-03-07 14:21:27 +11:00
|
|
|
label: dict.window[lang],
|
|
|
|
role: 'window',
|
|
|
|
submenu: [
|
2019-05-19 17:39:30 +10:00
|
|
|
{
|
2019-03-07 14:21:27 +11:00
|
|
|
label: dict.minimun[lang],
|
|
|
|
accelerator: 'CmdOrCtrl+M',
|
|
|
|
role: 'minimize'
|
2019-05-19 17:39:30 +10:00
|
|
|
},
|
|
|
|
{
|
2019-03-07 14:21:27 +11:00
|
|
|
label: dict.close[lang],
|
|
|
|
accelerator: 'CmdOrCtrl+W',
|
|
|
|
role: 'close'
|
2019-05-19 17:39:30 +10:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
2019-03-07 14:21:27 +11:00
|
|
|
];
|
2021-04-18 05:24:52 +10:00
|
|
|
// コピペメニュー
|
|
|
|
const ctxMenu = new Menu()
|
|
|
|
ctxMenu.append(new MenuItem({
|
|
|
|
label: dict.cut[lang],
|
|
|
|
role: 'cut',
|
|
|
|
click: () => { console.log('Cut clicked!') }
|
|
|
|
}))
|
|
|
|
ctxMenu.append(new MenuItem({
|
|
|
|
label: dict.copy[lang],
|
|
|
|
role: 'copy',
|
|
|
|
click: () => { console.log('Copy clicked!') }
|
|
|
|
}))
|
|
|
|
ctxMenu.append(new MenuItem({
|
|
|
|
label: dict.paste[lang],
|
|
|
|
role: 'paste',
|
|
|
|
click: () => { console.log('Paste clicked!') }
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
ipcMain.on('textareaContextMenu', function (e, params) {
|
|
|
|
ctxMenu.popup(mainWindow, params.x, params.y)
|
|
|
|
})
|
2019-03-07 14:21:27 +11:00
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
2019-06-26 01:52:15 +10:00
|
|
|
exports.template = templete;
|