mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-13 18:08:15 +08:00
add default arg for read registry method
This commit is contained in:
12
appcenter.js
12
appcenter.js
@@ -8,7 +8,8 @@ const getTimestamp = (d = new Date()) => {
|
|||||||
return `${d.getUTCFullYear()}-${p(d.getUTCMonth() + 1)}-${p(d.getUTCDate())}T${p(d.getUTCHours())}:${p(d.getUTCMinutes())}:${p(d.getUTCSeconds())}.${p(d.getUTCMilliseconds())}Z`
|
return `${d.getUTCFullYear()}-${p(d.getUTCMonth() + 1)}-${p(d.getUTCDate())}T${p(d.getUTCHours())}:${p(d.getUTCMinutes())}:${p(d.getUTCSeconds())}.${p(d.getUTCMilliseconds())}Z`
|
||||||
}
|
}
|
||||||
|
|
||||||
const readRegistry = (path, key) => {
|
const readRegistry = (path, key, def) => {
|
||||||
|
try {
|
||||||
const i = cp.execSync(`reg query "${path}" /v ${key}`, {
|
const i = cp.execSync(`reg query "${path}" /v ${key}`, {
|
||||||
encoding: "utf-8"
|
encoding: "utf-8"
|
||||||
}).split("\n")[2].split(" ").filter(s => s.length > 0).map(s => s.trim())
|
}).split("\n")[2].split(" ").filter(s => s.length > 0).map(s => s.trim())
|
||||||
@@ -18,7 +19,10 @@ const readRegistry = (path, key) => {
|
|||||||
case "REG_DWORD":
|
case "REG_DWORD":
|
||||||
return parseInt(i[2])
|
return parseInt(i[2])
|
||||||
default:
|
default:
|
||||||
throw "Unsupported"
|
return def
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return def
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +48,8 @@ const device = (() => {
|
|||||||
timeZoneOffset: parseInt(osi[1]),
|
timeZoneOffset: parseInt(osi[1]),
|
||||||
osBuild: `${osi[2]}.${readRegistry("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR")}`,
|
osBuild: `${osi[2]}.${readRegistry("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR")}`,
|
||||||
osVersion: osi[2],
|
osVersion: osi[2],
|
||||||
locale: readRegistry("HKCU\\Control Panel\\International", "LocaleName"),
|
locale: readRegistry("HKCU\\Control Panel\\International", "LocaleName", "zh-CN"),
|
||||||
carrierCountry: readRegistry("HKCU\\Control Panel\\International\\Geo", "Name"),
|
carrierCountry: readRegistry("HKCU\\Control Panel\\International\\Geo", "Name", "CN"),
|
||||||
sdkName: "appcenter.wpf.netcore",
|
sdkName: "appcenter.wpf.netcore",
|
||||||
sdkVersion: "4.5.0",
|
sdkVersion: "4.5.0",
|
||||||
osName: "WINDOWS",
|
osName: "WINDOWS",
|
||||||
|
|||||||
Reference in New Issue
Block a user