优化缩放倍率
This commit is contained in:
parent
1c5a7aa4a9
commit
6f882d030c
12
main.js
12
main.js
|
|
@ -142,9 +142,9 @@ app.on('ready', () => {
|
|||
// 监听f12打开控制台
|
||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||
// if (env === 'development') {
|
||||
if (input.key === 'F12') {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
if (input.key === 'F12') {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
// }
|
||||
});
|
||||
// 监听移动
|
||||
|
|
@ -242,6 +242,12 @@ app.on('ready', () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
// 获取桌面大小
|
||||
ipcMain.handle('getWindowSize', (event, config) => {
|
||||
const primaryDisplay = screen.getPrimaryDisplay()
|
||||
const { width, height } = primaryDisplay.workAreaSize
|
||||
return { width, height }
|
||||
});
|
||||
// 设置桌面应用基础属性
|
||||
ipcMain.handle('setMainWindowSize', (event, config) => {
|
||||
// 设置最小窗口尺寸
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ window.electron = {
|
|||
setMainWindowSize: (config) => {
|
||||
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
||||
},
|
||||
// 获取窗口大小
|
||||
getWindowSize: (config) => {
|
||||
return ipcRenderer.invoke('getWindowSize')
|
||||
},
|
||||
// 设置窗口状态
|
||||
setViewStatus: (status) => {
|
||||
ipcRenderer.invoke('setViewStatus', status)
|
||||
|
|
|
|||
31
src/App.tsx
31
src/App.tsx
|
|
@ -197,21 +197,22 @@ const App: React.FC = () => {
|
|||
})
|
||||
}
|
||||
const toSrc = (path: string): void => {
|
||||
switch (path) {
|
||||
case '/login':
|
||||
storage.removeItem('user')
|
||||
storage.setItem('userLogin', false)
|
||||
navigate('/login')
|
||||
break;
|
||||
case '/home':
|
||||
window.electron.setMainWindowSize({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
})
|
||||
navigate('/home')
|
||||
break;
|
||||
|
||||
}
|
||||
window.electron.getWindowSize().then((res: any) => {
|
||||
switch (path) {
|
||||
case '/login':
|
||||
storage.removeItem('user')
|
||||
storage.setItem('userLogin', false)
|
||||
navigate('/login')
|
||||
break;
|
||||
case '/home':
|
||||
window.electron.setMainWindowSize({
|
||||
width: Math.ceil(res.width / 1.5),
|
||||
height: Math.ceil(res.height / 1.3),
|
||||
})
|
||||
navigate('/home')
|
||||
break;
|
||||
}
|
||||
})
|
||||
};
|
||||
const leaveChannel = async (bool?: boolean): Promise<void> => {
|
||||
if (location.hash.indexOf('/meeting') === 1) {
|
||||
|
|
|
|||
|
|
@ -142,9 +142,11 @@ const Login: React.FC = () => {
|
|||
storage.setItem('user', JSON.stringify(res.data))
|
||||
storage.setItem('userLogin', true)
|
||||
try {
|
||||
window.electron.setMainWindowSize({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
window.electron.getWindowSize().then((res: any) => {
|
||||
window.electron.setMainWindowSize({
|
||||
width: Math.ceil(res.width / 1.5),
|
||||
height: Math.ceil(res.height / 1.3),
|
||||
})
|
||||
})
|
||||
} catch {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// electron-env.d.ts
|
||||
export interface IElectronAPI {
|
||||
setMainWindowSize: (config: any) => void;
|
||||
getWindowSize: () => any;
|
||||
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize' | 'hide') => void;
|
||||
getIsMaximized: () => Promise<boolean>;
|
||||
setWriteText: (text: string) => void;
|
||||
|
|
|
|||
Loading…
Reference in New Issue