30 lines
782 B
TypeScript
30 lines
782 B
TypeScript
import { useContext } from "react";
|
||
import { SystemProviderContext } from "./SystemProvider";
|
||
|
||
/**
|
||
* Информация о системе и устройстве
|
||
*/
|
||
export interface SystemInformation {
|
||
/**
|
||
* Уникальный обезличенный идентификатор устройства
|
||
*/
|
||
id: string;
|
||
/**
|
||
* Имя устройства
|
||
*/
|
||
name: string;
|
||
/**
|
||
* Операционная система устройства
|
||
*/
|
||
os: string;
|
||
}
|
||
|
||
export function useSystemInformation() : SystemInformation {
|
||
const context = useContext(SystemProviderContext);
|
||
|
||
if(!context) {
|
||
throw new Error("useSystemInformation must be used within a SystemProvider");
|
||
}
|
||
|
||
return context as SystemInformation;
|
||
} |