Оптимизация ядра, исправление гонки потоков при получении версии
This commit is contained in:
62
app/hooks/useCore.ts
Normal file
62
app/hooks/useCore.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
export function useCore() {
|
||||
const openExternal = (url: string) => {
|
||||
window.shell.openExternal(url);
|
||||
};
|
||||
|
||||
const showItemInFolder = (fullPath: string) => {
|
||||
window.shell.showItemInFolder(fullPath);
|
||||
};
|
||||
|
||||
const getCoreVersion = async () => {
|
||||
const version = await window.electron.ipcRenderer.invoke('ipcCore:getCoreVersion');
|
||||
return version;
|
||||
}
|
||||
|
||||
const getArch = async () => {
|
||||
const arch = await window.electron.ipcRenderer.invoke('ipcCore:getArch');
|
||||
return arch;
|
||||
}
|
||||
|
||||
const getUserDir = async () => {
|
||||
const userDir = await window.electron.ipcRenderer.invoke('ipcCore:getUserDir');
|
||||
return userDir;
|
||||
}
|
||||
|
||||
const getAppPath = async () => {
|
||||
const appPath = await window.electron.ipcRenderer.invoke('ipcCore:getAppPath');
|
||||
return appPath;
|
||||
}
|
||||
|
||||
const getDownloadsPath = async () => {
|
||||
const downloadsPath = await window.electron.ipcRenderer.invoke('ipcCore:getDownloadsPath');
|
||||
return downloadsPath;
|
||||
}
|
||||
|
||||
const getPlatform = async () => {
|
||||
const platform = await window.electron.ipcRenderer.invoke('ipcCore:getPlatform');
|
||||
return platform;
|
||||
}
|
||||
|
||||
const getDeviceName = async () => {
|
||||
const deviceName = await window.electron.ipcRenderer.invoke('device:name');
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
const getDeviceId = async () => {
|
||||
const deviceId = await window.electron.ipcRenderer.invoke('device:id');
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
return {
|
||||
openExternal,
|
||||
showItemInFolder,
|
||||
getCoreVersion,
|
||||
getArch,
|
||||
getUserDir,
|
||||
getAppPath,
|
||||
getDownloadsPath,
|
||||
getPlatform,
|
||||
getDeviceName,
|
||||
getDeviceId
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user