mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 17:00:14 +08:00
feat: Improve devtools font on Windows
This commit is contained in:
parent
a1ae55b29d
commit
fa32cd13cf
@ -1,4 +1,5 @@
|
|||||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||||
|
import { replaceDevtoolsFont } from '@main/utils/windowUtil'
|
||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ if (!app.requestSingleInstanceLock()) {
|
|||||||
|
|
||||||
registerIpc(mainWindow, app)
|
registerIpc(mainWindow, app)
|
||||||
|
|
||||||
|
replaceDevtoolsFont(mainWindow)
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
installExtension(REDUX_DEVTOOLS)
|
installExtension(REDUX_DEVTOOLS)
|
||||||
.then((name) => console.log(`Added Extension: ${name}`))
|
.then((name) => console.log(`Added Extension: ${name}`))
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { BrowserWindow } from 'electron'
|
||||||
|
|
||||||
function isTilingWindowManager() {
|
function isTilingWindowManager() {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
return false
|
return false
|
||||||
@ -13,4 +15,33 @@ function isTilingWindowManager() {
|
|||||||
return tilingSystems.some((system) => desktopEnv?.includes(system))
|
return tilingSystems.some((system) => desktopEnv?.includes(system))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const replaceDevtoolsFont = (browserWindow: BrowserWindow) => {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
browserWindow.webContents.on('devtools-opened', () => {
|
||||||
|
const css = `
|
||||||
|
:root {
|
||||||
|
--sys-color-base: var(--ref-palette-neutral100);
|
||||||
|
--source-code-font-family: consolas;
|
||||||
|
--source-code-font-size: 12px;
|
||||||
|
--monospace-font-family: consolas;
|
||||||
|
--monospace-font-size: 12px;
|
||||||
|
--default-font-family: system-ui, sans-serif;
|
||||||
|
--default-font-size: 12px;
|
||||||
|
}
|
||||||
|
.-theme-with-dark-background {
|
||||||
|
--sys-color-base: var(--ref-palette-secondary25);
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
--default-font-family: system-ui,sans-serif;
|
||||||
|
}`
|
||||||
|
|
||||||
|
browserWindow.webContents.devToolsWebContents?.executeJavaScript(`
|
||||||
|
const overriddenStyle = document.createElement('style');
|
||||||
|
overriddenStyle.innerHTML = '${css.replaceAll('\n', ' ')}';
|
||||||
|
document.body.append(overriddenStyle);
|
||||||
|
document.body.classList.remove('platform-windows');`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export { isTilingWindowManager }
|
export { isTilingWindowManager }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user