kingToolbox / kingToolbox/WindTerm
Sysmon正则匹配问题-uptimeInfo函数正则
- Dominant language
- C
- Stars
- 32.3k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
原函数中:
```javascript
function uptimeInfo(output) {
let pattern = /((\d+:\d+):\d+) up (.*?),\s+(\d+) users,\s+load average: (.*)/;
let matched = pattern.exec(output);
let text = '-';
let tooltip = '';
if (matched) {
let timeWithSeconds = matched[1];
let time = matched[2];
let uptime = matched[3];
let users = matched[4]
let loadAverage = matched[5];
text = time;
tooltip = `time${timeWithSeconds}`
+ `Uptime${uptime}, ${users} users`
+ `Load average${loadAverage}`;
}
return [`🆃 ${text}`, tooltip];
}
```
的正则项```let pattern = /((\d+:\d+):\d+) up (.*?),\s+(\d+) users,\s+load average: (.*)/;```在单用户登录时会出现不匹配的情况。
单用户```top - 04:03:13 up 37 min, 1 user, load average: 0.17, 0.12, 0.07```
多用户```top - 04:03:37 up 37 min, 2 users, load average: 0.11, 0.11, 0.07```
因此建议修改为```let pattern = /((\d+:\d+):\d+) up (.*?),\s+((?:\d+) user(?:s|)),\s+load average: (.*)/;```。
该问题还会导致时间无法正常显示:

同时希望能对该组件的配色做出修改。
感谢。
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the uptimeInfo function and inspect the current regular expression and its callers. Verify the parser with the single-user and multi-user top outputs given in the issue, then confirm that the displayed time and tooltip are restored for both forms; the requested component color change is separate and underspecified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100