1
+ <template >
2
+ <n-card bordered title =" Machine Info" shadow =" always" >
3
+ <n-grid x-gap =" 12" :cols =" 2" >
4
+ <n-gi >
5
+ <p >CPU: {{ cpuInfo }}</p >
6
+ <p >Mem: {{ memoryInfo }}</p >
7
+ <p >OS: {{ osInfo }}</p >
8
+ <p >Image Version: {{ imageVer }}</p >
9
+ <p >Displays: {{ displaysInfo }}</p >
10
+ </n-gi >
11
+ <n-gi >
12
+ <p >gcc: {{ gccVer }}</p >
13
+ <p >g++: {{ gppVer }}</p >
14
+ <p >java: {{ javaVer }}</p >
15
+ <p >kotlin: {{ kotlinVer }}</p >
16
+ <p >python3: {{ python3Ver }}</p >
17
+ <p >pypy3: {{ pypy3Ver }}</p >
18
+ </n-gi >
19
+ </n-grid >
20
+ </n-card >
21
+ </template >
22
+
23
+ <script setup lang="ts">
24
+ import { computer , filesystem , os } from ' @neutralinojs/lib' ;
25
+ import { onMounted , ref } from ' vue' ;
26
+
27
+ const osInfo = ref <string >(' Loading...' );
28
+ const cpuInfo = ref <string >(' Loading...' );
29
+ const memoryInfo = ref <string >(' Loading...' );
30
+ const displaysInfo = ref <string >(' Loading...' );
31
+ const imageVer = ref <string >(' Loading...' );
32
+
33
+ const gccVer = ref <string >(' Loading...' );
34
+ const gppVer = ref <string >(' Loading...' );
35
+ const javaVer = ref <string >(' Loading...' );
36
+ const kotlinVer = ref <string >(' Loading...' );
37
+ const python3Ver = ref <string >(' Loading...' );
38
+ const pypy3Ver = ref <string >(' Loading...' );
39
+
40
+ const getVer = async (cmd : string , regexp ? : string ) => {
41
+ try {
42
+ const exec = await os .execCommand (` ${cmd } ` );
43
+ if (regexp ) {
44
+ let match = exec .stdOut .match (new RegExp (regexp ));
45
+ if (! exec .stdOut || ! match || ! match .length ) {
46
+ match = exec .stdErr .match (new RegExp (regexp ));
47
+ }
48
+ console .log (cmd , exec , match );
49
+ return match ? match [0 ] : ' Not found' ;
50
+ }
51
+ return exec .stdOut ;
52
+ } catch (e ) {
53
+ return ' Not found' ;
54
+ }
55
+ }
56
+
57
+ onMounted (async () => {
58
+ const [arch, kernel, os, cpu, memory, displays] = await Promise .all ([
59
+ computer .getArch (),
60
+ computer .getKernelInfo (),
61
+ computer .getOSInfo (),
62
+ computer .getCPUInfo (),
63
+ computer .getMemoryInfo (),
64
+ computer .getDisplays (),
65
+ ]);
66
+ osInfo .value = ` ${os .name } ${os .version } ${arch } - ${os .description }(${kernel .variant } ${kernel .version }) ` ;
67
+ cpuInfo .value = ` ${cpu .physicalCores }C${cpu .logicalThreads }T ${cpu .architecture } ${cpu .model } ${(cpu .frequency / 1024 / 1024 / 1024 ).toFixed (2 )}GHz ` ;
68
+ memoryInfo .value = ` P: ${(memory .physical .available / 1024 / 1024 / 1024 ).toFixed (2 )}GB/${(memory .physical .total / 1024 / 1024 / 1024 ).toFixed (2 )}GB
69
+ S: ${(memory .virtual .available / 1024 / 1024 / 1024 ).toFixed (2 )}GB/${(memory .virtual .total / 1024 / 1024 / 1024 ).toFixed (2 )}GB ` ;
70
+ displaysInfo .value = displays .map (d => ` ${d .resolution .width }x${d .resolution .height }@${d .refreshRate }Hz ` ).join (' , ' );
71
+ try {
72
+ const imageversion = await filesystem .readFile (' /etc/icpcimage-version' )
73
+ imageVer .value = imageversion ;
74
+ } catch (e ) {
75
+ imageVer .value = ' Unknown' ;
76
+ }
77
+ gccVer .value = await getVer (' gcc --version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?([_-p][0-9]+)?' );
78
+ gppVer .value = await getVer (' g++ --version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?([_-p][0-9]+)?' );
79
+ javaVer .value = await getVer (' java -version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?' );
80
+ kotlinVer .value = await getVer (' kotlin -version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?' );
81
+ python3Ver .value = await getVer (' python3 --version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?' );
82
+ pypy3Ver .value = await getVer (' pypy3 --version' , ' [0-9.]+\. [0-9.]+(\. [0-9]+)?' );
83
+ });
84
+ </script >
0 commit comments