-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23c1754
commit 6ff62d4
Showing
19 changed files
with
348 additions
and
25 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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
### Breaking Changes | ||
|
||
- 此版本修改了应用的显示名称,macOS用户可能无法自动更新,需要手动删除 `/Applications/mihomo-party.app` | ||
|
||
### New Features | ||
|
||
- 允许切换订阅卡片显示过期时间还是更新时间 | ||
- 添加悬浮窗功能,可以在设置中开启 |
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,75 @@ | ||
import { is } from '@electron-toolkit/utils' | ||
import { BrowserWindow, ipcMain } from 'electron' | ||
import windowStateKeeper from 'electron-window-state' | ||
import { join } from 'path' | ||
import { getAppConfig } from '../config' | ||
import { applyTheme } from './theme' | ||
import { buildContextMenu } from './tray' | ||
|
||
export let floatingWindow: BrowserWindow | null = null | ||
|
||
async function createFloatingWindow(): Promise<void> { | ||
const floatingWindowState = windowStateKeeper({ | ||
file: 'floating-window-state.json' | ||
}) | ||
const { customTheme = 'default.css' } = await getAppConfig() | ||
floatingWindow = new BrowserWindow({ | ||
width: 126, | ||
height: 50, | ||
x: floatingWindowState.x, | ||
y: floatingWindowState.y, | ||
show: false, | ||
frame: false, | ||
alwaysOnTop: true, | ||
resizable: false, | ||
transparent: true, | ||
skipTaskbar: true, | ||
minimizable: false, | ||
maximizable: false, | ||
closable: false, | ||
webPreferences: { | ||
preload: join(__dirname, '../preload/index.js'), | ||
spellcheck: false, | ||
sandbox: false | ||
} | ||
}) | ||
floatingWindowState.manage(floatingWindow) | ||
floatingWindow.on('ready-to-show', () => { | ||
applyTheme(customTheme) | ||
floatingWindow?.show() | ||
}) | ||
floatingWindow.on('moved', () => { | ||
if (floatingWindow) floatingWindowState.saveState(floatingWindow) | ||
}) | ||
ipcMain.on('updateFloatingWindow', () => { | ||
if (floatingWindow) { | ||
floatingWindow?.webContents.send('controledMihomoConfigUpdated') | ||
floatingWindow?.webContents.send('appConfigUpdated') | ||
} | ||
}) | ||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { | ||
floatingWindow.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/floating.html`) | ||
} else { | ||
floatingWindow.loadFile(join(__dirname, '../renderer/floating.html')) | ||
} | ||
} | ||
export function showFloatingWindow(): void { | ||
if (floatingWindow) { | ||
floatingWindow.show() | ||
} else { | ||
createFloatingWindow() | ||
} | ||
} | ||
|
||
export function closeFloatingWindow(): void { | ||
if (floatingWindow) { | ||
floatingWindow.close() | ||
floatingWindow.destroy() | ||
floatingWindow = null | ||
} | ||
} | ||
|
||
export async function showContextMenu(): Promise<void> { | ||
const menu = await buildContextMenu() | ||
menu.popup() | ||
} |
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
Oops, something went wrong.