-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main.ts を移動 * なんか一杯かえた * なんか一杯かえた * OptionWindowを開くようにした * Debug.vue をちょっと修正 * tsのエラーをちょっと解消 * refactor * フィルター処理の条件をoptionに移動 * めちゃくちゃリファクタした * めちゃくちゃリファクタした * bump 1.4.0 * fix build target
- Loading branch information
Showing
25 changed files
with
902 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ dist | |
out | ||
.gitignore | ||
.env | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// レンダラープロセスからのメッセージを受信する | ||
import { createOptionWindow, mainWindow, windowPosition } from './windows' | ||
import { activateWindow, grantPermission } from './helper' | ||
import { ipcMain, screen } from 'electron' | ||
import { store } from './store' | ||
|
||
type LayoutType = 'right' | 'left' | 'bottom' | ||
|
||
export function setEventHandlers() { | ||
ipcMain.on('activeWindow', (_event, windowId) => { | ||
activateWindow(windowId) | ||
}) | ||
ipcMain.on('openOption', () => { | ||
createOptionWindow() | ||
}) | ||
|
||
ipcMain.on('setLayout', (_event, layout: LayoutType) => { | ||
store.set('layout', layout) | ||
const primaryDisplay = screen.getPrimaryDisplay() | ||
const position = windowPosition(primaryDisplay, layout) | ||
mainWindow.setBounds(position) | ||
mainWindow.webContents.send('setLayout', layout) | ||
}) | ||
|
||
ipcMain.on('grantPermission', () => { | ||
grantPermission() | ||
store.set('granted', true) | ||
}) | ||
ipcMain.on('clearSetting', () => { | ||
store.clear() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Store from 'electron-store' | ||
|
||
export const store = new Store({ | ||
defaults: { | ||
layout: 'bottom', | ||
filters: [ | ||
[{ property: 'kCGWindowIsOnscreen', is: false }], | ||
[{ property: 'kCGWindowOwnerName', is: 'Dock' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'DockHelper' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'screencapture' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'スクリーンショット' }], | ||
[{ property: 'kCGWindowName', is: 'Notification Center' }], | ||
[{ property: 'kCGWindowName', is: 'Item-0' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'Window Server' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'コントロールセンター' }], | ||
[ | ||
{ property: 'kCGWindowOwnerName', is: 'Finder' }, | ||
{ property: 'kCGWindowName', is: '' } | ||
], | ||
[{ property: 'kCGWindowName', is: 'Spotlight' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'GoogleJapaneseInputRenderer' }], | ||
[{ property: 'kCGWindowOwnerName', is: 'taskbar.fm' }], | ||
[{ property: 'kCGWindowName', is: 'taskbar.fm' }] | ||
] | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { join } from 'path' | ||
import { is } from '@electron-toolkit/utils' | ||
import { BrowserWindow, screen } from 'electron' | ||
import { getAndSubmitProcesses } from './helper' | ||
import { store } from './store' | ||
|
||
type LayoutType = 'right' | 'left' | 'bottom' | ||
|
||
export let mainWindow: BrowserWindow | ||
export function createWindow() { | ||
// Create the browser window. | ||
|
||
const primaryDisplay = screen.getPrimaryDisplay() | ||
|
||
mainWindow = new BrowserWindow({ | ||
webPreferences: { | ||
preload: join(__dirname, '../preload/index.js'), | ||
sandbox: false | ||
}, | ||
titleBarStyle: 'hiddenInset', | ||
autoHideMenuBar: true, | ||
// resizable: false, | ||
movable: false, | ||
maximizable: false, | ||
minimizable: false, | ||
alwaysOnTop: true, | ||
skipTaskbar: true, | ||
show: false, | ||
...windowPosition(primaryDisplay, store.get('layout') as LayoutType) | ||
}) | ||
|
||
// 準備ができたら表示 | ||
mainWindow.on('ready-to-show', () => { | ||
mainWindow.show() | ||
}) | ||
// 閉じるボタンなどを消す | ||
mainWindow.setWindowButtonVisibility(false) | ||
|
||
// HMR for renderer base on electron-vite cli. | ||
// Load the remote URL for development or the local html file for production. | ||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { | ||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) | ||
} else { | ||
mainWindow.loadFile(join(__dirname, '../renderer/index.html')) | ||
} | ||
|
||
// 1秒ごとにプロセスのリストを取得 | ||
setInterval(() => { | ||
getAndSubmitProcesses(mainWindow) | ||
}, 1000) | ||
} | ||
|
||
export let optionWindow: BrowserWindow | ||
export function createOptionWindow() { | ||
// すでにウィンドウを開いているならそれをアクティブにする | ||
if (optionWindow && !optionWindow.isDestroyed()) { | ||
optionWindow.show() | ||
return | ||
} | ||
optionWindow = new BrowserWindow({ | ||
webPreferences: { | ||
preload: join(__dirname, '../preload/index.js'), | ||
sandbox: false | ||
} | ||
}) | ||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { | ||
optionWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] + '#option') | ||
} else { | ||
optionWindow.loadFile(join(__dirname, '../renderer/index.html#option')) | ||
} | ||
optionWindow.on('ready-to-show', () => { | ||
optionWindow.show() | ||
}) | ||
} | ||
|
||
export function windowPosition( | ||
display: Electron.Display, | ||
type: LayoutType | ||
): { width: number; height: number; x: number; y: number } { | ||
return { | ||
width: type === 'bottom' ? display.workArea.width : 210, | ||
height: type !== 'bottom' ? display.workArea.height : 60, | ||
x: type === 'right' ? display.workArea.width - 210 : 0, | ||
y: type === 'bottom' ? display.workArea.height - 30 : 0 | ||
} | ||
} |
Oops, something went wrong.