temp: 适配mac桌面

This commit is contained in:
2024-10-23 20:02:59 +08:00
parent 4e0e149f54
commit a6a47be45f
7 changed files with 107 additions and 11 deletions

20
src/electron/utils.ts Normal file
View File

@@ -0,0 +1,20 @@
export const getIsMac = async () => {
// @ts-ignore
const userAgentData = navigator.userAgentData;
if (userAgentData) {
const ua = await userAgentData.getHighEntropyValues(['platform']);
console.log('ua', ua);
if (ua.platform === 'macOS') {
return true;
}
}
return false;
};
export const getIsElectron = () => {
// 检查 window.process 和 navigator.userAgent 中是否包含 Electron 信息
return (
// @ts-ignore
(typeof window !== 'undefined' && typeof window.process !== 'undefined' && window.process.type === 'renderer') ||
(typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0)
);
};