forked from oldj/SwitchHosts
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
16 changed files
with
173 additions
and
9 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
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,15 @@ | ||
/** | ||
* @author: oldj | ||
* @homepage: https://oldj.net | ||
*/ | ||
|
||
import { makeWindow } from '@main/ui/find' | ||
|
||
export default async () => { | ||
if (!global.find_win) { | ||
global.find_win = await makeWindow() | ||
} | ||
|
||
global.find_win?.show() | ||
global.find_win?.focus() | ||
} |
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
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,67 @@ | ||
/** | ||
* @author: oldj | ||
* @homepage: https://oldj.net | ||
*/ | ||
|
||
import getIndex from '@main/libs/getIndex' | ||
import isDev from '@main/libs/isDev' | ||
import { BrowserWindow } from 'electron' | ||
import path from 'path' | ||
|
||
const makeWindow = () => { | ||
let win: BrowserWindow | null | ||
win = new BrowserWindow({ | ||
// frame: false, | ||
// titleBarStyle: 'hidden', | ||
hasShadow: true, | ||
// resizable: false, | ||
// transparent: true, | ||
width: 480, | ||
height: 400, | ||
minWidth: 300, | ||
minHeight: 200, | ||
maximizable: false, | ||
minimizable: false, | ||
skipTaskbar: true, | ||
// show: false, | ||
webPreferences: { | ||
contextIsolation: true, | ||
preload: path.join(__dirname, 'preload.js'), | ||
spellcheck: true, | ||
}, | ||
}) | ||
|
||
win.setVisibleOnAllWorkspaces(true, { | ||
visibleOnFullScreen: true, | ||
}) | ||
|
||
win.loadURL(`${getIndex()}#/find`) | ||
.catch(e => console.error(e)) | ||
|
||
// win.on('blur', () => win?.hide()) | ||
|
||
win.on('close', (e: Electron.Event) => { | ||
if (global.is_will_quit) { | ||
win = null | ||
global.find_win = null | ||
} else { | ||
e.preventDefault() | ||
win?.hide() | ||
} | ||
}) | ||
|
||
if (isDev()) { | ||
// Open DevTools, see https://github.com/electron/electron/issues/12438 for why we wait for dom-ready | ||
win.webContents.once('dom-ready', () => { | ||
win!.webContents.openDevTools() | ||
}) | ||
} | ||
|
||
global.find_win = win | ||
|
||
return win | ||
} | ||
|
||
export { | ||
makeWindow, | ||
} |
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
File renamed without changes.
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,5 @@ | ||
@import "../styles/common"; | ||
|
||
.root { | ||
|
||
} |
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,47 @@ | ||
/** | ||
* @author: oldj | ||
* @homepage: https://oldj.net | ||
*/ | ||
|
||
import { useModel } from '@@/plugin-model/useModel' | ||
import { agent } from '@renderer/core/agent' | ||
import React, { useEffect } from 'react' | ||
import styles from './find.less' | ||
|
||
interface Props { | ||
|
||
} | ||
|
||
const find = (props: Props) => { | ||
const { lang, setLocale } = useModel('useI18n') | ||
const { configs } = useModel('useConfigs') | ||
|
||
const init = async () => { | ||
if (!configs) return | ||
|
||
setLocale(configs.locale) | ||
|
||
let theme = configs.theme | ||
let cls = document.body.className | ||
document.body.className = cls.replace(/\btheme-\w+/ig, '') | ||
document.body.classList.add(`platform-${agent.platform}`, `theme-${theme}`) | ||
} | ||
|
||
useEffect(() => { | ||
if (!configs) return | ||
init().catch(e => console.error(e)) | ||
}, [configs]) | ||
|
||
useEffect(() => { | ||
console.log(lang.find_and_replace) | ||
document.title = lang.find_and_replace | ||
}, [lang]) | ||
|
||
return ( | ||
<div className={styles.root}> | ||
find | ||
</div> | ||
) | ||
} | ||
|
||
export default find |
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 +1 @@ | ||
[4, 0, 0, 6029] | ||
[4, 0, 1, 6030] |