mirror of
https://github.com/yang991178/fluent-reader.git
synced 2025-03-25 07:50:09 +01:00
add macos fullscreen
This commit is contained in:
parent
ae37b2ed36
commit
f4dd5c9984
2
dist/styles/global.css
vendored
2
dist/styles/global.css
vendored
@ -207,7 +207,7 @@ body.darwin .btn-group .seperator {
|
|||||||
height: var(--navHeight);
|
height: var(--navHeight);
|
||||||
line-height: var(--navHeight);
|
line-height: var(--navHeight);
|
||||||
}
|
}
|
||||||
body.darwin #root > nav .btn-group .btn:first-of-type {
|
body.darwin.not-fullscreen #root > nav .btn-group .btn:first-of-type {
|
||||||
margin-left: 72px;
|
margin-left: 72px;
|
||||||
}
|
}
|
||||||
#root > nav .btn-group .btn.system {
|
#root > nav .btn-group .btn.system {
|
||||||
|
2
dist/styles/main.css
vendored
2
dist/styles/main.css
vendored
@ -222,7 +222,7 @@ img.favicon.dropdown {
|
|||||||
height: calc(var(--navHeight) - 4px);
|
height: calc(var(--navHeight) - 4px);
|
||||||
box-shadow: 0 1.6px 3.6px 0 rgba(0,0,0,.132), 0 0.3px 0.9px 0 rgba(0,0,0,.108);
|
box-shadow: 0 1.6px 3.6px 0 rgba(0,0,0,.132), 0 0.3px 0.9px 0 rgba(0,0,0,.108);
|
||||||
}
|
}
|
||||||
body.darwin .article-search {
|
body.darwin.not-fullscreen .article-search {
|
||||||
left: 108px;
|
left: 108px;
|
||||||
max-width: calc(100% - 384px);
|
max-width: calc(100% - 384px);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,9 @@ const utilsBridge = {
|
|||||||
isMaximized: () => {
|
isMaximized: () => {
|
||||||
return ipcRenderer.sendSync("is-maximized") as boolean
|
return ipcRenderer.sendSync("is-maximized") as boolean
|
||||||
},
|
},
|
||||||
|
isFullscreen: () => {
|
||||||
|
return ipcRenderer.sendSync("is-fullscreen") as boolean
|
||||||
|
},
|
||||||
isFocused: () => {
|
isFocused: () => {
|
||||||
return ipcRenderer.sendSync("is-focused") as boolean
|
return ipcRenderer.sendSync("is-focused") as boolean
|
||||||
},
|
},
|
||||||
@ -108,6 +111,14 @@ const utilsBridge = {
|
|||||||
ipcRenderer.on("unmaximized", () => {
|
ipcRenderer.on("unmaximized", () => {
|
||||||
callback(WindowStateListenerType.Maximized, false)
|
callback(WindowStateListenerType.Maximized, false)
|
||||||
})
|
})
|
||||||
|
ipcRenderer.removeAllListeners("enter-fullscreen")
|
||||||
|
ipcRenderer.on("enter-fullscreen", () => {
|
||||||
|
callback(WindowStateListenerType.Fullscreen, true)
|
||||||
|
})
|
||||||
|
ipcRenderer.removeAllListeners("leave-fullscreen")
|
||||||
|
ipcRenderer.on("leave-fullscreen", () => {
|
||||||
|
callback(WindowStateListenerType.Fullscreen, false)
|
||||||
|
})
|
||||||
ipcRenderer.removeAllListeners("window-focus")
|
ipcRenderer.removeAllListeners("window-focus")
|
||||||
ipcRenderer.on("window-focus", () => {
|
ipcRenderer.on("window-focus", () => {
|
||||||
callback(WindowStateListenerType.Focused, true)
|
callback(WindowStateListenerType.Focused, true)
|
||||||
|
@ -26,6 +26,7 @@ class Nav extends React.Component<NavProps, NavState> {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.setBodyFocusState(window.utils.isFocused())
|
this.setBodyFocusState(window.utils.isFocused())
|
||||||
|
this.setBodyFullscreenState(window.utils.isFullscreen())
|
||||||
window.utils.addWindowStateListener(this.windowStateListener)
|
window.utils.addWindowStateListener(this.windowStateListener)
|
||||||
this.state = {
|
this.state = {
|
||||||
maximized: window.utils.isMaximized()
|
maximized: window.utils.isMaximized()
|
||||||
@ -37,11 +38,19 @@ class Nav extends React.Component<NavProps, NavState> {
|
|||||||
else document.body.classList.add("blur")
|
else document.body.classList.add("blur")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBodyFullscreenState = (fullscreen: boolean) => {
|
||||||
|
if (fullscreen) document.body.classList.remove("not-fullscreen")
|
||||||
|
else document.body.classList.add("not-fullscreen")
|
||||||
|
}
|
||||||
|
|
||||||
windowStateListener = (type: WindowStateListenerType, state: boolean) => {
|
windowStateListener = (type: WindowStateListenerType, state: boolean) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WindowStateListenerType.Maximized:
|
case WindowStateListenerType.Maximized:
|
||||||
this.setState({ maximized: state })
|
this.setState({ maximized: state })
|
||||||
break
|
break
|
||||||
|
case WindowStateListenerType.Fullscreen:
|
||||||
|
this.setBodyFullscreenState(state)
|
||||||
|
break
|
||||||
case WindowStateListenerType.Focused:
|
case WindowStateListenerType.Focused:
|
||||||
this.setBodyFocusState(state)
|
this.setBodyFocusState(state)
|
||||||
break
|
break
|
||||||
|
@ -184,6 +184,10 @@ export function setUtilsListeners(manager: WindowManager) {
|
|||||||
event.returnValue = manager.hasWindow() && manager.mainWindow.isFocused()
|
event.returnValue = manager.hasWindow() && manager.mainWindow.isFocused()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on("is-fullscreen", (event) => {
|
||||||
|
event.returnValue = manager.hasWindow() && manager.mainWindow.isFullScreen()
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.handle("request-focus", () => {
|
ipcMain.handle("request-focus", () => {
|
||||||
if (manager.hasWindow()) {
|
if (manager.hasWindow()) {
|
||||||
const win = manager.mainWindow
|
const win = manager.mainWindow
|
||||||
|
@ -54,7 +54,7 @@ export class WindowManager {
|
|||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
frame: process.platform === "darwin",
|
frame: process.platform === "darwin",
|
||||||
titleBarStyle: "hiddenInset",
|
titleBarStyle: "hiddenInset",
|
||||||
fullscreenable: false,
|
fullscreenable: process.platform === "darwin",
|
||||||
show: false,
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
@ -79,6 +79,12 @@ export class WindowManager {
|
|||||||
this.mainWindow.on("unmaximize", () => {
|
this.mainWindow.on("unmaximize", () => {
|
||||||
this.mainWindow.webContents.send("unmaximized")
|
this.mainWindow.webContents.send("unmaximized")
|
||||||
})
|
})
|
||||||
|
this.mainWindow.on("enter-full-screen", () => {
|
||||||
|
this.mainWindow.webContents.send("enter-fullscreen")
|
||||||
|
})
|
||||||
|
this.mainWindow.on("leave-full-screen", () => {
|
||||||
|
this.mainWindow.webContents.send("leave-fullscreen")
|
||||||
|
})
|
||||||
this.mainWindow.on("focus", () => {
|
this.mainWindow.on("focus", () => {
|
||||||
this.mainWindow.webContents.send("window-focus")
|
this.mainWindow.webContents.send("window-focus")
|
||||||
})
|
})
|
||||||
|
@ -51,7 +51,7 @@ export interface ServiceConfigs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const enum WindowStateListenerType {
|
export const enum WindowStateListenerType {
|
||||||
Maximized, Focused
|
Maximized, Focused, Fullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TouchBarTexts {
|
export interface TouchBarTexts {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user