修复 Linux 端 hostnamectl 命令不可用时无法与手机端同步的问题 (#1784)
* Don't fail to sync without hostnamectl * update --------- Co-authored-by: lyswhut <lyswhut@qq.com>pull/1460/merge
parent
79d8d79b9d
commit
15c9207542
|
@ -31,11 +31,15 @@ export const getComputerName = () => {
|
|||
name = process.env.COMPUTERNAME
|
||||
break
|
||||
case 'darwin':
|
||||
name = cp.execSync('scutil --get ComputerName').toString().trim()
|
||||
try {
|
||||
name = cp.execSync('scutil --get ComputerName').toString().trim()
|
||||
} catch {}
|
||||
break
|
||||
case 'linux':
|
||||
name = cp.execSync('hostnamectl --pretty').toString().trim()
|
||||
break
|
||||
// Don't fail even if hostnamectl is unavailable
|
||||
try {
|
||||
name = cp.execSync('hostnamectl --pretty').toString().trim()
|
||||
} catch {}
|
||||
}
|
||||
if (!name) name = os.hostname()
|
||||
return name
|
||||
|
|
Loading…
Reference in New Issue