优化缩放倍率
This commit is contained in:
parent
1c5a7aa4a9
commit
6f882d030c
6
main.js
6
main.js
|
|
@ -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) => {
|
ipcMain.handle('setMainWindowSize', (event, config) => {
|
||||||
// 设置最小窗口尺寸
|
// 设置最小窗口尺寸
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ window.electron = {
|
||||||
setMainWindowSize: (config) => {
|
setMainWindowSize: (config) => {
|
||||||
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
ipcRenderer.invoke('setMainWindowSize', { ...config })
|
||||||
},
|
},
|
||||||
|
// 获取窗口大小
|
||||||
|
getWindowSize: (config) => {
|
||||||
|
return ipcRenderer.invoke('getWindowSize')
|
||||||
|
},
|
||||||
// 设置窗口状态
|
// 设置窗口状态
|
||||||
setViewStatus: (status) => {
|
setViewStatus: (status) => {
|
||||||
ipcRenderer.invoke('setViewStatus', status)
|
ipcRenderer.invoke('setViewStatus', status)
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@ const App: React.FC = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const toSrc = (path: string): void => {
|
const toSrc = (path: string): void => {
|
||||||
|
window.electron.getWindowSize().then((res: any) => {
|
||||||
switch (path) {
|
switch (path) {
|
||||||
case '/login':
|
case '/login':
|
||||||
storage.removeItem('user')
|
storage.removeItem('user')
|
||||||
|
|
@ -205,13 +206,13 @@ const App: React.FC = () => {
|
||||||
break;
|
break;
|
||||||
case '/home':
|
case '/home':
|
||||||
window.electron.setMainWindowSize({
|
window.electron.setMainWindowSize({
|
||||||
width: 1200,
|
width: Math.ceil(res.width / 1.5),
|
||||||
height: 800,
|
height: Math.ceil(res.height / 1.3),
|
||||||
})
|
})
|
||||||
navigate('/home')
|
navigate('/home')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
const leaveChannel = async (bool?: boolean): Promise<void> => {
|
const leaveChannel = async (bool?: boolean): Promise<void> => {
|
||||||
if (location.hash.indexOf('/meeting') === 1) {
|
if (location.hash.indexOf('/meeting') === 1) {
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,11 @@ const Login: React.FC = () => {
|
||||||
storage.setItem('user', JSON.stringify(res.data))
|
storage.setItem('user', JSON.stringify(res.data))
|
||||||
storage.setItem('userLogin', true)
|
storage.setItem('userLogin', true)
|
||||||
try {
|
try {
|
||||||
|
window.electron.getWindowSize().then((res: any) => {
|
||||||
window.electron.setMainWindowSize({
|
window.electron.setMainWindowSize({
|
||||||
width: 1200,
|
width: Math.ceil(res.width / 1.5),
|
||||||
height: 800,
|
height: Math.ceil(res.height / 1.3),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// electron-env.d.ts
|
// electron-env.d.ts
|
||||||
export interface IElectronAPI {
|
export interface IElectronAPI {
|
||||||
setMainWindowSize: (config: any) => void;
|
setMainWindowSize: (config: any) => void;
|
||||||
|
getWindowSize: () => any;
|
||||||
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize' | 'hide') => void;
|
setViewStatus: (status: 'quit' | 'maximize' | 'minimize' | 'unmaximize' | 'hide') => void;
|
||||||
getIsMaximized: () => Promise<boolean>;
|
getIsMaximized: () => Promise<boolean>;
|
||||||
setWriteText: (text: string) => void;
|
setWriteText: (text: string) => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue