19
19
</n-gi >
20
20
<n-gi >
21
21
<n-card bordered shadow =" always" >
22
- <n-popconfirm @positive-click =" checkAll" >
22
+ <n-popconfirm @positive-click =" checkAll(false) " positive-text = " 开始检查 " negative-text = " 强制完成 " @negative-click = " checkAll(true) " >
23
23
<template #trigger >
24
24
<n-button type =" primary" style =" width : 100% ;" >完成设备检查</n-button >
25
25
</template >
26
- 确认完成设备检查?
26
+ 确认完成设备检查?<br />
27
+ 设备座位号:{{ nowSeat || '未设置' }}<br />
28
+ 设备IP地址:{{ getIp() || '未获取' }}
27
29
</n-popconfirm >
28
30
</n-card >
29
31
<n-card bordered shadow =" always" class =" text-center" >
@@ -53,7 +55,7 @@ const saveSeat = async () => {
53
55
nowSeat .value = editSeat .value ;
54
56
} catch (error ) {
55
57
console .error (error );
56
- window .$notification .error ({ title: ' 保存座位号失败' , content: (error as any ).message });
58
+ window .$notification .error ({ title: ' 保存座位号失败' , content: (error as any ).message , duration: 3000 });
57
59
}
58
60
};
59
61
@@ -64,14 +66,34 @@ const showSeat = async () => {
64
66
if (res .stdErr ) throw new Error (res .stdErr );
65
67
} catch (error ) {
66
68
console .error (error );
67
- window .$notification .error ({ title: ' 放大显示座位号失败' , content: (error as any ).message });
69
+ window .$notification .error ({ title: ' 放大显示座位号失败' , content: (error as any ).message , duration: 3000 });
68
70
}
69
71
};
70
72
71
- const checkAll = () => {
72
- console .log (' check all' );
73
+ const checkAll = async (force = false ) => {
74
+ if (force ) {
75
+ if (! nowSeat .value ) {
76
+ window .$notification .error ({ title: ' 未设置座位号' , content: ' 请先设置座位号' , duration: 3000 });
77
+ return ;
78
+ }
79
+ const res = await filesystem .readFile (' /etc/hostname' );
80
+ if (res !== nowSeat .value ) {
81
+ window .$notification .error ({ title: ' 主机名不匹配' , content: ' 请保存一次座位号以同步主机名' , duration: 3000 });
82
+ return ;
83
+ }
84
+ if (! getIp ()) {
85
+ window .$notification .error ({ title: ' 未获取到IP地址' , content: ' 请检查网络连接或重启' , duration: 3000 });
86
+ return ;
87
+ }
88
+ window .$notification .success ({ title: ' 设备检查完成' , content: ` seat: ${nowSeat .value }\n ip: ${window .ip } ` , duration: 3000 });
89
+ }
90
+ await os .execCommand (` systemctl enable heartbeat.timer ` );
91
+ await os .execCommand (` zenity --info --text "<span font='256'>${nowSeat .value }</span><br><span font='128'>${window .ip }</span>" ` );
92
+ console .log (' check all' );
73
93
};
74
94
95
+ const getIp = () => window .ip ;
96
+
75
97
onMounted (async () => {
76
98
try {
77
99
const res = await filesystem .readFile (' /var/lib/icpc/config.json' );
0 commit comments