Skip to content

Commit

Permalink
[update] 最前面表示を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
pasta04 committed Jul 11, 2020
1 parent 650a3c9 commit 6f7e3c3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
26 changes: 26 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unacast",
"version": "0.6.1",
"version": "0.6.2",
"description": "掲示板のレスをYoutubeコメント風に表示したいという思想の元に開発されるツール",
"main": "dist/index.js",
"scripts": {
Expand Down
35 changes: 34 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Electronのモジュール
import path from 'path';
import electron, { Tray, Menu, dialog } from 'electron';
import electron, { Tray, Menu, dialog, MenuItem } from 'electron';
import log from 'electron-log';
import { sleep } from './util';
import windowStateKeeper from 'electron-window-state';
Expand Down Expand Up @@ -54,6 +54,31 @@ if (!app.requestSingleInstanceLock()) {
// }
// });

// 右クリックメニュー
const mainContextMenu = new Menu();
mainContextMenu.append(
new MenuItem({
label: '最前面表示',
type: 'checkbox',
checked: false,
click: (e) => {
globalThis.electron.mainWindow.setAlwaysOnTop(e.checked);
},
}),
);

const chatContextMenu = new Menu();
chatContextMenu.append(
new MenuItem({
label: '最前面表示',
type: 'checkbox',
checked: false,
click: (e) => {
globalThis.electron.chatWindow.setAlwaysOnTop(e.checked);
},
}),
);

// Electronの初期化完了後に実行
app.on('ready', () => {
const windowState = windowStateKeeper({
Expand Down Expand Up @@ -152,6 +177,14 @@ if (!app.requestSingleInstanceLock()) {
});

createChatWindow();

// 右クリックメニュー開く
globalThis.electron.mainWindow.webContents.on('context-menu', (e, params) => {
mainContextMenu.popup({ window: globalThis.electron.mainWindow, x: params.x, y: params.y });
});
globalThis.electron.chatWindow.webContents.on('context-menu', (e, params) => {
chatContextMenu.popup({ window: globalThis.electron.chatWindow, x: params.x, y: params.y });
});
});

// 音声再生できるようにする
Expand Down

0 comments on commit 6f7e3c3

Please sign in to comment.