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

View File

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