feat: integrate hostinfo into ui
This commit is contained in:
parent
7d4da73141
commit
e33504016b
9 changed files with 564 additions and 56 deletions
36
app/utils/host-info.ts
Normal file
36
app/utils/host-info.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import type { HostInfo } from '~/utils/types';
|
||||
|
||||
export function getTSVersion(host: HostInfo) {
|
||||
const { IPNVersion } = host;
|
||||
if (!IPNVersion) {
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
// IPNVersion is <Semver>-<something>-<something>
|
||||
return IPNVersion.split('-')[0];
|
||||
}
|
||||
|
||||
export function getOSInfo(host: HostInfo) {
|
||||
const { OS, OSVersion } = host;
|
||||
// OS follows runtime.GOOS but uses iOS and macOS instead of darwin
|
||||
const formattedOS = formatOS(OS);
|
||||
|
||||
// Trim in case OSVersion is empty
|
||||
return `${formattedOS} ${OSVersion}`.trim();
|
||||
}
|
||||
|
||||
function formatOS(os?: string) {
|
||||
switch (os) {
|
||||
case 'macOS':
|
||||
case 'iOS':
|
||||
return os;
|
||||
case 'windows':
|
||||
return 'Windows';
|
||||
case 'linux':
|
||||
return 'Linux';
|
||||
case undefined:
|
||||
return 'Unknown';
|
||||
default:
|
||||
return os;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue