Compare commits

...

3 Commits

Author SHA1 Message Date
BTMuli
69cede4274 🚀 v0.7.5 2025-05-09 12:07:00 +08:00
BTMuli
20e942b8a8 🐛 添加时区处理功能
close #155
2025-05-09 12:03:53 +08:00
BTMuli
82c06c3727 ⬆️ 更新依赖项版本 2025-05-09 11:37:12 +08:00
8 changed files with 465 additions and 420 deletions

View File

@@ -2,12 +2,16 @@
Author: 目棃 Author: 目棃
Description: CHANGELOG Description: CHANGELOG
Date: 2024-10-09 Date: 2024-10-09
Update: 2025-05-06 Update: 2025-05-09
--- ---
> 本文档 [`Frontmatter`](https://github.com/BTMuli/MuCli#Frontmatter) 由 [MuCli](https://github.com/BTMuli/Mucli) 自动生成于 `2024-10-09 15:51:43` > 本文档 [`Frontmatter`](https://github.com/BTMuli/MuCli#Frontmatter) 由 [MuCli](https://github.com/BTMuli/Mucli) 自动生成于 `2024-10-09 15:51:43`
> >
> 更新于 `2025-05-06 13:52:36` > 更新于 `2025-05-09 12:06:20`
## [0.7.5](https://github.com/BTMuli/TeyvatGuide/releases/v0.7.5) (2025-05-09)
- 🐛 处理UIGF时区异常 [`#155`](https://github.com/BTMuli/TeyvatGuide/issues/155)
## [0.7.4](https://github.com/BTMuli/TeyvatGuide/releases/v0.7.4) (2025-05-06) ## [0.7.4](https://github.com/BTMuli/TeyvatGuide/releases/v0.7.4) (2025-05-06)

View File

@@ -1,6 +1,6 @@
{ {
"name": "teyvatguide", "name": "teyvatguide",
"version": "0.7.4", "version": "0.7.5",
"description": "Game Tool for GenshinImpact player", "description": "Game Tool for GenshinImpact player",
"private": true, "private": true,
"packageManager": "pnpm@10.10.0", "packageManager": "pnpm@10.10.0",
@@ -109,9 +109,9 @@
"@types/color-convert": "^2.0.4", "@types/color-convert": "^2.0.4",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/js-md5": "^0.7.2", "@types/js-md5": "^0.7.2",
"@types/node": "^22.15.3", "@types/node": "^22.15.14",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"@typescript-eslint/parser": "^8.31.1", "@typescript-eslint/parser": "^8.32.0",
"@vitejs/plugin-vue": "^5.2.3", "@vitejs/plugin-vue": "^5.2.3",
"concurrently": "^9.1.2", "concurrently": "^9.1.2",
"eslint": "^9.26.0", "eslint": "^9.26.0",
@@ -124,7 +124,7 @@
"globals": "^16.0.0", "globals": "^16.0.0",
"husky": "^9.1.7", "husky": "^9.1.7",
"jsonc-eslint-parser": "^2.4.0", "jsonc-eslint-parser": "^2.4.0",
"lint-staged": "^15.5.1", "lint-staged": "^15.5.2",
"oxlint": "^0.16.9", "oxlint": "^0.16.9",
"prettier": "3.5.3", "prettier": "3.5.3",
"stylelint": "^16.19.1", "stylelint": "^16.19.1",
@@ -134,10 +134,10 @@
"stylelint-high-performance-animation": "^1.11.0", "stylelint-high-performance-animation": "^1.11.0",
"stylelint-order": "^7.0.0", "stylelint-order": "^7.0.0",
"stylelint-prettier": "^5.0.3", "stylelint-prettier": "^5.0.3",
"stylelint-scss": "^6.11.1", "stylelint-scss": "^6.12.0",
"tsx": "^4.19.4", "tsx": "^4.19.4",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"typescript-eslint": "^8.31.1", "typescript-eslint": "^8.32.0",
"vite": "^6.3.5", "vite": "^6.3.5",
"vite-plugin-vue-devtools": "^7.7.6", "vite-plugin-vue-devtools": "^7.7.6",
"vite-plugin-vuetify": "^2.1.1", "vite-plugin-vuetify": "^2.1.1",

709
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

75
src-tauri/Cargo.lock generated
View File

@@ -4,7 +4,7 @@ version = 4
[[package]] [[package]]
name = "TeyvatGuide" name = "TeyvatGuide"
version = "0.7.4" version = "0.7.5"
dependencies = [ dependencies = [
"chrono", "chrono",
"log", "log",
@@ -325,9 +325,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.74" version = "0.3.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cfg-if", "cfg-if",
@@ -1990,7 +1990,7 @@ dependencies = [
"tokio", "tokio",
"tokio-rustls", "tokio-rustls",
"tower-service", "tower-service",
"webpki-roots", "webpki-roots 0.26.11",
] ]
[[package]] [[package]]
@@ -2412,9 +2412,9 @@ dependencies = [
[[package]] [[package]]
name = "libm" name = "libm"
version = "0.2.14" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a25169bd5913a4b437588a7e3d127cd6e90127b60e0ffbd834a38f1599e016b8" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
[[package]] [[package]]
name = "libredox" name = "libredox"
@@ -3733,7 +3733,7 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots", "webpki-roots 0.26.11",
"windows-registry 0.4.0", "windows-registry 0.4.0",
] ]
@@ -3901,9 +3901,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.26" version = "0.23.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"ring", "ring",
@@ -3933,9 +3933,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
version = "0.103.1" version = "0.103.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" checksum = "7149975849f1abb3832b246010ef62ccc80d3a76169517ada7188252b9cfb437"
dependencies = [ dependencies = [
"ring", "ring",
"rustls-pki-types", "rustls-pki-types",
@@ -4900,7 +4900,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-deep-link" name = "tauri-plugin-deep-link"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"dunce", "dunce",
"rust-ini", "rust-ini",
@@ -4919,7 +4919,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-dialog" name = "tauri-plugin-dialog"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"log", "log",
"raw-window-handle", "raw-window-handle",
@@ -4936,7 +4936,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-fs" name = "tauri-plugin-fs"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"dunce", "dunce",
@@ -4957,7 +4957,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-http" name = "tauri-plugin-http"
version = "2.4.3" version = "2.4.3"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"bytes", "bytes",
"cookie_store", "cookie_store",
@@ -4980,7 +4980,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-log" name = "tauri-plugin-log"
version = "2.4.0" version = "2.4.0"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"android_logger", "android_logger",
"byte-unit", "byte-unit",
@@ -5001,7 +5001,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-opener" name = "tauri-plugin-opener"
version = "2.2.6" version = "2.2.6"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"dunce", "dunce",
"glob", "glob",
@@ -5022,7 +5022,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-os" name = "tauri-plugin-os"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"gethostname", "gethostname",
"log", "log",
@@ -5039,7 +5039,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-process" name = "tauri-plugin-process"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"tauri", "tauri",
"tauri-plugin", "tauri-plugin",
@@ -5048,7 +5048,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-shell" name = "tauri-plugin-shell"
version = "2.2.1" version = "2.2.1"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"encoding_rs", "encoding_rs",
"log", "log",
@@ -5068,7 +5068,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-single-instance" name = "tauri-plugin-single-instance"
version = "2.2.3" version = "2.2.3"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
@@ -5082,7 +5082,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-sql" name = "tauri-plugin-sql"
version = "2.2.0" version = "2.2.0"
source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#98e268a98fd31f8f57c2611826478b76a43cfe0b" source = "git+ssh://git@github.com/tauri-apps/plugins-workspace.git?branch=v2#323afd1b6d03a101375aa47f820f85b96ec210da"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"indexmap 2.9.0", "indexmap 2.9.0",
@@ -5334,9 +5334,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.44.2" version = "1.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@@ -5449,7 +5449,7 @@ dependencies = [
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"toml_write", "toml_write",
"winnow 0.7.9", "winnow 0.7.10",
] ]
[[package]] [[package]]
@@ -5952,9 +5952,18 @@ dependencies = [
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.26.10" version = "0.26.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37493cadf42a2a939ed404698ded7fb378bf301b5011f973361779a3a74f8c93" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
dependencies = [
"webpki-roots 1.0.0",
]
[[package]]
name = "webpki-roots"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb"
dependencies = [ dependencies = [
"rustls-pki-types", "rustls-pki-types",
] ]
@@ -6481,9 +6490,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.7.9" version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9fb597c990f03753e08d3c29efbfcf2019a003b4bf4ba19225c158e1549f0f3" checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -6645,7 +6654,7 @@ dependencies = [
"tracing", "tracing",
"uds_windows", "uds_windows",
"windows-sys 0.59.0", "windows-sys 0.59.0",
"winnow 0.7.9", "winnow 0.7.10",
"zbus_macros", "zbus_macros",
"zbus_names", "zbus_names",
"zvariant", "zvariant",
@@ -6674,7 +6683,7 @@ checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97"
dependencies = [ dependencies = [
"serde", "serde",
"static_assertions", "static_assertions",
"winnow 0.7.9", "winnow 0.7.10",
"zvariant", "zvariant",
] ]
@@ -6757,7 +6766,7 @@ dependencies = [
"enumflags2", "enumflags2",
"serde", "serde",
"url", "url",
"winnow 0.7.9", "winnow 0.7.10",
"zvariant_derive", "zvariant_derive",
"zvariant_utils", "zvariant_utils",
] ]
@@ -6786,5 +6795,5 @@ dependencies = [
"serde", "serde",
"static_assertions", "static_assertions",
"syn 2.0.101", "syn 2.0.101",
"winnow 0.7.9", "winnow 0.7.10",
] ]

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "TeyvatGuide" name = "TeyvatGuide"
version = "0.7.4" version = "0.7.5"
description = "Game Tool for Genshin Impact player" description = "Game Tool for Genshin Impact player"
authors = ["BTMuli <bt-muli@outlook.com>"] authors = ["BTMuli <bt-muli@outlook.com>"]
license = "MIT" license = "MIT"
@@ -20,7 +20,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2.2.0", features = [] } tauri-build = { version = "2.2.0", features = [] }
[dependencies] [dependencies]
chrono = "0.4.40" chrono = "0.4.41"
log = "0.4.27" log = "0.4.27"
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140" serde_json = "1.0.140"

View File

@@ -2,7 +2,7 @@
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "TeyvatGuide", "productName": "TeyvatGuide",
"identifier": "TeyvatGuide", "identifier": "TeyvatGuide",
"version": "0.7.4", "version": "0.7.5",
"build": { "build": {
"beforeDevCommand": "pnpm vite:dev", "beforeDevCommand": "pnpm vite:dev",
"beforeBuildCommand": "pnpm vite:build", "beforeBuildCommand": "pnpm vite:build",

View File

@@ -1,7 +1,7 @@
/** /**
* @file plugins/Sqlite/modules/userGacha.ts * @file plugins/Sqlite/modules/userGacha.ts
* @description 用户祈愿模块 * @description 用户祈愿模块
* @since Beta v0.6.8 * @since Beta v0.7.5
*/ */
import showSnackbar from "@comp/func/snackbar.js"; import showSnackbar from "@comp/func/snackbar.js";
@@ -10,7 +10,7 @@ import { path } from "@tauri-apps/api";
import { exists, mkdir, readDir } from "@tauri-apps/plugin-fs"; import { exists, mkdir, readDir } from "@tauri-apps/plugin-fs";
import TGLogger from "@/utils/TGLogger.js"; import TGLogger from "@/utils/TGLogger.js";
import { getWikiBrief } from "@/utils/toolFunc.js"; import { getWikiBrief, timestampToDate } from "@/utils/toolFunc.js";
import { exportUigfData, readUigfData, verifyUigfData } from "@/utils/UIGF.js"; import { exportUigfData, readUigfData, verifyUigfData } from "@/utils/UIGF.js";
/** /**
@@ -41,20 +41,38 @@ function getInsertSql(uid: string, gacha: TGApp.Plugins.UIGF.GachaItem): string
`; `;
} }
/**
* @description 传入时间字符串跟对应时区转成utc8时间字符串
* @since Beta v0.7.5
* @param {string} time - 时间字符串
* @param {number} timezone - 时区
* @return {string} 转换后的时间戳
*/
function getUtc8Time(time: string, timezone: number): string {
const date = new Date(time);
const diffTimezone = -timezone + 8;
const realDate = new Date(date.getTime() + diffTimezone * 60 * 60 * 1000);
return timestampToDate(realDate.getTime());
}
/** /**
* @description 转换祈愿数据,防止多语言 * @description 转换祈愿数据,防止多语言
* @since Beta v0.6.8 * @since Beta v0.7.5
* @param {TGApp.Plugins.UIGF.GachaItem} gacha - UIGF数据 * @param {TGApp.Plugins.UIGF.GachaItem} gacha - UIGF数据
* @param {number} timezone - 时区
* @return {TGApp.Plugins.UIGF.GachaItem} 转换后的数据 * @return {TGApp.Plugins.UIGF.GachaItem} 转换后的数据
*/ */
function transGacha(gacha: TGApp.Plugins.UIGF.GachaItem): TGApp.Plugins.UIGF.GachaItem { function transGacha(
gacha: TGApp.Plugins.UIGF.GachaItem,
timezone: number = 8,
): TGApp.Plugins.UIGF.GachaItem {
const find = getWikiBrief(gacha.item_id); const find = getWikiBrief(gacha.item_id);
if (!find) return gacha; if (!find) return gacha;
return { return {
gacha_type: gacha.gacha_type, gacha_type: gacha.gacha_type,
item_id: gacha.item_id, item_id: gacha.item_id,
count: gacha.count ?? "1", count: gacha.count ?? "1",
time: gacha.time, time: getUtc8Time(gacha.time, timezone),
name: find.name, name: find.name,
item_type: "element" in find ? "角色" : "武器", item_type: "element" in find ? "角色" : "武器",
rank_type: find.star.toString(), rank_type: find.star.toString(),
@@ -204,7 +222,7 @@ async function mergeUIGF(uid: string, data: TGApp.Plugins.UIGF.GachaItem[]): Pro
async function mergeUIGF4(data: TGApp.Plugins.UIGF.GachaHk4e): Promise<void> { async function mergeUIGF4(data: TGApp.Plugins.UIGF.GachaHk4e): Promise<void> {
const db = await TGSqlite.getDB(); const db = await TGSqlite.getDB();
for (const gacha of data.list) { for (const gacha of data.list) {
const trans = transGacha(gacha); const trans = transGacha(gacha, data.timezone);
const sql = getInsertSql(data.uid.toString(), trans); const sql = getInsertSql(data.uid.toString(), trans);
await db.execute(sql); await db.execute(sql);
} }

View File

@@ -1,7 +1,7 @@
/** /**
* @file utils/UIGF.ts * @file utils/UIGF.ts
* @description UIGF工具类 * @description UIGF工具类
* @since Beta v0.6.5 * @since Beta v0.7.5
*/ */
import showSnackbar from "@comp/func/snackbar.js"; import showSnackbar from "@comp/func/snackbar.js";
@@ -28,13 +28,28 @@ function getUigfTimeZone(uid: string): number {
return 8; return 8;
} }
/**
* @description 传入utc8时间字符串跟目标时区转成目标时区时间字符串
* @since Beta v0.7.5
* @param {string} time - 时间字符串
* @param {number} timezone - 时区
* @return {string} 转换后的时间字符串
*/
function getExportTime(time: string, timezone: number): string {
const date = new Date(time);
const diffTimezone = -8 + timezone;
const realDate = new Date(date.getTime() + diffTimezone * 60 * 60 * 1000);
return timestampToDate(realDate.getTime());
}
/** /**
* @description 获取 UIGF 头部信息 * @description 获取 UIGF 头部信息
* @since Beta v0.4.4 * @since Beta v0.7.5
* @param {string} uid - UID * @param {string} uid - UID
* @param {number} timezone - 时区
* @returns {Promise<TGApp.Plugins.UIGF.Info>} * @returns {Promise<TGApp.Plugins.UIGF.Info>}
*/ */
async function getUigfHeader(uid: string): Promise<TGApp.Plugins.UIGF.Info> { async function getUigfHeader(uid: string, timezone: number): Promise<TGApp.Plugins.UIGF.Info> {
const stamp = Date.now(); const stamp = Date.now();
return { return {
uid, uid,
@@ -44,7 +59,7 @@ async function getUigfHeader(uid: string): Promise<TGApp.Plugins.UIGF.Info> {
export_time: timestampToDate(stamp), export_time: timestampToDate(stamp),
export_app: "TeyvatGuide", export_app: "TeyvatGuide",
export_app_version: await app.getVersion(), export_app_version: await app.getVersion(),
region_time_zone: getUigfTimeZone(uid), region_time_zone: timezone,
}; };
} }
@@ -66,19 +81,21 @@ export async function getUigf4Header(): Promise<TGApp.Plugins.UIGF.Info4> {
/** /**
* @description 数据转换-数据库到 UIGF * @description 数据转换-数据库到 UIGF
* @since Alpha v0.2.3 * @since Beta v0.7.5
* @param {TGApp.Sqlite.GachaRecords.SingleTable[]} data - 数据库数据 * @param {TGApp.Sqlite.GachaRecords.SingleTable[]} data - 数据库数据
* @param {number} timezone - 时区
* @returns {TGApp.Plugins.UIGF.GachaItem[]} UIGF 数据 * @returns {TGApp.Plugins.UIGF.GachaItem[]} UIGF 数据
*/ */
function convertDataToUigf( function convertDataToUigf(
data: TGApp.Sqlite.GachaRecords.SingleTable[], data: TGApp.Sqlite.GachaRecords.SingleTable[],
timezone: number,
): TGApp.Plugins.UIGF.GachaItem[] { ): TGApp.Plugins.UIGF.GachaItem[] {
return data.map((gacha) => { return data.map((gacha) => {
return { return {
gacha_type: gacha.gachaType, gacha_type: gacha.gachaType,
item_id: gacha.itemId, item_id: gacha.itemId,
count: gacha.count, count: gacha.count,
time: gacha.time, time: getExportTime(gacha.time, timezone),
name: gacha.name, name: gacha.name,
item_type: gacha.type, item_type: gacha.type,
rank_type: gacha.rank, rank_type: gacha.rank,
@@ -172,7 +189,7 @@ export async function readUigf4Data(userPath: string): Promise<TGApp.Plugins.UIG
/** /**
* @description 导出 UIGF 数据 * @description 导出 UIGF 数据
* @since Beta v0.5.0 * @since Beta v0.7.5
* @param {string} uid - UID * @param {string} uid - UID
* @param {TGApp.Sqlite.GachaRecords.SingleTable[]} gachaList - 祈愿列表 * @param {TGApp.Sqlite.GachaRecords.SingleTable[]} gachaList - 祈愿列表
* @param {string} savePath - 保存路径 * @param {string} savePath - 保存路径
@@ -183,21 +200,23 @@ export async function exportUigfData(
gachaList: TGApp.Sqlite.GachaRecords.SingleTable[], gachaList: TGApp.Sqlite.GachaRecords.SingleTable[],
savePath?: string, savePath?: string,
): Promise<void> { ): Promise<void> {
const UigfData = { info: await getUigfHeader(uid), list: convertDataToUigf(gachaList) }; const timezone = getUigfTimeZone(uid);
const UigfData = {
info: await getUigfHeader(uid, timezone),
list: convertDataToUigf(gachaList, timezone),
};
const filePath = savePath ?? `${await path.appLocalDataDir()}userData\\UIGF_${uid}.json`; const filePath = savePath ?? `${await path.appLocalDataDir()}userData\\UIGF_${uid}.json`;
await writeTextFile(filePath, JSON.stringify(UigfData)); await writeTextFile(filePath, JSON.stringify(UigfData));
} }
/** /**
* @description 获取单项UID的UIGF4.0数据 * @description 获取单项UID的UIGF4.0数据
* @since Beta v0.7.5
* @param {string} uid - UID * @param {string} uid - UID
* @returns {Promise<TGApp.Plugins.UIGF.GachaHk4e>} * @returns {Promise<TGApp.Plugins.UIGF.GachaHk4e>}
*/ */
export async function getUigf4Item(uid: string): Promise<TGApp.Plugins.UIGF.GachaHk4e> { export async function getUigf4Item(uid: string): Promise<TGApp.Plugins.UIGF.GachaHk4e> {
const gachaList = await TSUserGacha.getGachaRecords(uid); const gachaList = await TSUserGacha.getGachaRecords(uid);
return { const timezone = getUigfTimeZone(uid);
uid: uid, return { uid: uid, timezone: timezone, list: convertDataToUigf(gachaList, timezone) };
timezone: getUigfTimeZone(uid),
list: convertDataToUigf(gachaList),
};
} }