modify and add some message, optimize

This commit is contained in:
HolographicHat
2022-04-06 00:11:21 +08:00
parent f7c48472f1
commit d5e290e866
2 changed files with 22 additions and 21 deletions

View File

@@ -18,7 +18,6 @@ const install = (() => {
})()
const device = (() => {
console.time("Initialize device info")
const info = getDeviceInfo()
info.appBuild = version.code
info.appVersion = version.name
@@ -26,7 +25,6 @@ const device = (() => {
info.sdkVersion = "4.5.0"
info.osName = "WINDOWS"
info.appNamespace = "default"
console.timeEnd("Initialize device info")
return info
})()
@@ -81,7 +79,7 @@ const uploadError = (err, fatal) => {
upload()
}
const init = () => {
const startup = () => {
queue.push({
type: "startService",
services: [ "Analytics","Crashes" ],
@@ -99,5 +97,5 @@ const init = () => {
}
module.exports = {
init, upload, uploadError
startup, upload, uploadError
}

View File

@@ -1,7 +1,7 @@
const fs = require("fs")
const readline = require("readline")
const { spawnSync } = require("child_process")
const { loadCache } = require("./utils")
const { loadCache, log } = require("./utils")
const { copyToClipboard } = require("./native")
const exportToSeelie = proto => {
const out = { achievements: {} }
@@ -10,7 +10,7 @@ const exportToSeelie = proto => {
})
const fp = `./export-${Date.now()}-seelie.json`
fs.writeFileSync(fp, JSON.stringify(out))
console.log(`导出为文件: ${fp}`)
log(`导出为文件: ${fp}`)
}
const exportToPaimon = async proto => {
@@ -29,7 +29,7 @@ const exportToPaimon = async proto => {
})
const fp = `./export-${Date.now()}-paimon.json`
fs.writeFileSync(fp, JSON.stringify(out))
console.log(`导出为文件: ${fp}`)
log(`导出为文件: ${fp}`)
}
const exportToCocogoat = async proto => {
@@ -62,10 +62,10 @@ const exportToCocogoat = async proto => {
})
const ts = Date.now()
const json = JSON.stringify(out,null,2)
spawnSync("clip", { input: json })
copyToClipboard(json)
const fp = `./export-${ts}-cocogoat.json`
fs.writeFileSync(fp, json)
console.log(`导出内容已复制到剪贴板,若拷贝失败请手动复制 export-${ts}-cocogoat.json 文件内容`)
log(`导出内容已复制到剪贴板`)
}
const exportToCsv = async proto => {
@@ -88,7 +88,9 @@ const exportToCsv = async proto => {
const p = i => i.toString().padStart(2, "0")
return `${d.getFullYear()}/${p(d.getMonth() + 1)}/${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
}
const bl = [84517]
proto.list.forEach(({current, finishTimestamp, id, status, require}) => {
if (!bl.includes(id)) {
const desc = achievementMap.get(id) === undefined ? (() => {
console.log(`Error get id ${id} in excel`)
return {
@@ -98,10 +100,11 @@ const exportToCsv = async proto => {
}
})() : achievementMap.get(id)
outputLines.push(`${id},${getStatusText(status)},${excel.goal[desc.goal]},${desc.name},${desc.desc},${status !== 1 ? current === 0 ? require : current : current},${require},${status === 1 ? "" : getTime(finishTimestamp)}`)
}
})
const fp = `./export-${Date.now()}.csv`
fs.writeFileSync(fp, `\uFEFF${outputLines.join("\n")}`)
console.log(`导出为文件: ${fp}`)
log(`导出为文件: ${fp}`)
}
const exportData = async proto => {
@@ -126,7 +129,7 @@ const exportData = async proto => {
break
case "raw":
fs.writeFileSync(`./export-${Date.now()}-raw.json`, JSON.stringify(proto,null,2))
console.log("OK")
log("OK")
break
default:
await exportToCsv(proto)