diff --git a/Cargo.lock b/Cargo.lock index 9453ff6..c08a811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,7 +20,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -47,9 +47,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" +checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" dependencies = [ "smallvec", "target-lexicon", @@ -578,12 +578,12 @@ dependencies = [ [[package]] name = "cssparser-macros" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -695,15 +695,15 @@ checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "dtoa" -version = "0.4.8" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" [[package]] name = "dtoa-short" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde03329ae10e79ede66c9ce4dc930aa8599043b0743008548680f25b91502d6" +checksum = "dbaceec3c6e4211c79e7b1800fb9680527106beb2f9c51904a3210c03a448c74" dependencies = [ "dtoa", ] @@ -782,9 +782,9 @@ dependencies = [ [[package]] name = "field-offset" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf3a800ff6e860c863ca6d4b16fd999db8b752819c1606884047b73e468535" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ "memoffset", "rustc_version", @@ -847,9 +847,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -1094,9 +1094,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -1478,9 +1478,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1517,9 +1517,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1733,9 +1733,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" [[package]] name = "libgit2-sys" @@ -1789,9 +1789,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -1870,9 +1870,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -2099,9 +2099,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "open" @@ -2115,9 +2115,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.53" +version = "0.10.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12df40a956736488b7b44fe79fe12d4f245bb5b3f5a1f6095e499760015be392" +checksum = "69b3f656a17a6cbc115b5c7a40c616947d213ba182135b014d6051b73ab6f019" dependencies = [ "bitflags", "cfg-if", @@ -2239,7 +2239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.8", ] [[package]] @@ -2258,15 +2258,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -2283,9 +2283,9 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "phf" @@ -2504,9 +2504,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -2589,7 +2589,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -2643,18 +2643,18 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "regex" -version = "1.8.3" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-syntax 0.7.2", ] @@ -2957,18 +2957,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", @@ -3396,7 +3396,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5fa6fb9ee296c0dc2df41a656ca7948546d061958115ddb0bcaae43ad0d17d2" dependencies = [ - "cfg-expr 0.15.1", + "cfg-expr 0.15.2", "heck 0.4.1", "pkg-config", "toml 0.7.4", @@ -3655,15 +3655,16 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -4014,9 +4015,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -4036,7 +4037,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -4339,7 +4340,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] @@ -4383,37 +4384,13 @@ dependencies = [ "windows_x86_64_msvc 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] diff --git a/README.md b/README.md index c8b5546..823e5a1 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,6 @@ ## 功能 -### 🚧 正在开发和重构中... 🚧 - -**开发者测试版:[releases](https://github.com/lgou2w/HoYo.Gacha/releases)** - - [x] 支持 **`原神`** 和 **`崩坏:星穹铁道`** 游戏抽卡记录。 - [x] 管理游戏的多个账号。 - [x] 获取游戏的抽卡链接。 diff --git a/package.json b/package.json index 8b9c130..c2cf9d9 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,10 @@ "lint:fix": "prettier --write src/**/*.{ts,tsx} && eslint --fix --ext .ts,.tsx --ignore-path .gitignore ." }, "dependencies": { - "@emotion/react": "^11.11.0", + "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.11.16", - "@mui/material": "^5.13.3", + "@mui/material": "^5.13.4", "@mui/system": "^5.13.2", "@nivo/calendar": "^0.83.0", "@nivo/core": "^0.83.0", @@ -31,25 +31,25 @@ "@tanstack/react-query": "^4.29.12", "@tanstack/react-query-devtools": "^4.29.12", "@tauri-apps/api": "^1.3.0", - "dayjs": "^1.11.7", + "dayjs": "^1.11.8", "immer": "^10.0.2", "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-hook-form": "^7.44.2", - "react-router-dom": "^6.11.2", + "react-hook-form": "^7.44.3", + "react-router-dom": "^6.12.1", "use-immer": "^0.9.0" }, "devDependencies": { "@tauri-apps/cli": "^1.3.1", "@types/node": "^18.16.16", - "@types/react": "^18.2.7", + "@types/react": "^18.2.9", "@types/react-dom": "^18.2.4", - "@typescript-eslint/eslint-plugin": "^5.59.8", - "@typescript-eslint/parser": "^5.59.8", + "@typescript-eslint/eslint-plugin": "^5.59.9", + "@typescript-eslint/parser": "^5.59.9", "@vitejs/plugin-react": "^4.0.0", "cross-env": "^7.0.3", - "eslint": "^8.41.0", + "eslint": "^8.42.0", "eslint-config-prettier": "^8.8.0", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.27.5", @@ -57,7 +57,7 @@ "eslint-plugin-promise": "^6.1.1", "eslint-plugin-react": "^7.32.2", "prettier": "^2.8.8", - "typescript": "^5.0.4", + "typescript": "^5.1.3", "vite": "^4.3.9" }, "packageManager": "yarn@3.5.1" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 0b25474..b080ea2 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -20,13 +20,13 @@ tauri-build = { version = "1", features = [] } anyhow = "1.0.71" async-trait = "0.1.68" byteorder = "1.4.3" -form_urlencoded = "1.1.0" +form_urlencoded = "1.2.0" futures = { version = "0.3.28", default-features = false, features = ["std", "async-await"] } lazy_static = "1.4.0" paste = "1.0.12" reqwest = { version = "0.11.18", features = ["json", "stream"] } sea-orm = { version = "0.11.3", features = ["sqlx-sqlite", "runtime-tokio", "macros", "runtime-tokio-native-tls"], default-features = false } -serde = { version = "1.0.163", features = ["derive"] } +serde = { version = "1.0.164", features = ["derive"] } serde_json = "1.0.96" shadow-rs = "0.21.0" sqlx-core = "0.6.3" @@ -36,7 +36,7 @@ time = { version = "=0.3.15", features = ["formatting", "serde", "macros", "serd tokio = { version = "1.28.2", features = ["full"] } tracing = "0.1.37" tracing-subscriber = "0.3.17" -url = "2.3.1" +url = "2.4.0" [features] default = ["custom-protocol"] diff --git a/src-tauri/src/storage/impl_storage.rs b/src-tauri/src/storage/impl_storage.rs index 95f153a..27980e0 100644 --- a/src-tauri/src/storage/impl_storage.rs +++ b/src-tauri/src/storage/impl_storage.rs @@ -64,7 +64,16 @@ pub struct Storage { impl Storage { pub async fn new() -> Result { - let database_file = PathBuf::from(DATABASE); + // HACK: See -> https://github.com/lgou2w/HoYo.Gacha/issues/8 + // - In debug mode : the database file is in the src-tauri directory + // - In release mode: the database file is in the same directory as the executable + let database_file = if cfg!(debug_assertions) { + // Avoid clearing the database file with the 'cargo clean' command in debug mode + PathBuf::from(DATABASE) + } else { + std::env::current_exe()?.parent().unwrap().join(DATABASE) + }; + Self::new_with_database_file(database_file).await } diff --git a/src/components/common/VersionChecker.tsx b/src/components/common/VersionChecker.tsx index a5de4eb..83f0c2c 100644 --- a/src/components/common/VersionChecker.tsx +++ b/src/components/common/VersionChecker.tsx @@ -1,6 +1,6 @@ import React from 'react' import { dialog, process } from '@tauri-apps/api' -import { useVersion, useLatestVersion } from '@/components/common/useVersion' +import { useVersion, useLatestVersion, CurrentVersion, LatestVersion } from '@/components/common/useVersion' import Button from '@mui/material/Button' import Typography from '@mui/material/Typography' import DownloadIcon from '@mui/icons-material/Download' @@ -53,8 +53,7 @@ export default function VersionChecker () { if (latestVersion.isLoading) return 加载中... if (latestVersion.isError) return 检查最新版本失败 - // TODO: semver - const needUpdate = dayjs(version.data.date).isBefore(latestVersion.data.created_at) + const needUpdate = isNeedUpdate(version.data, latestVersion.data) if (!needUpdate) return 已是最新版本 return ( @@ -67,3 +66,21 @@ export default function VersionChecker () { ) } + +function isNeedUpdate ( + version: CurrentVersion, + latestVersion: LatestVersion | null +): boolean { + if (!latestVersion) return false + + // TODO: Strictly compare semver + const current = version.version + const latest = latestVersion.tag_name + const currentSemver = current.split('.').map(v => parseInt(v)) + const latestSemver = latest.split('.').map(v => parseInt(v)) + for (let i = 0; i < 3; i++) { + if (currentSemver[i] < latestSemver[i]) return true + if (currentSemver[i] > latestSemver[i]) return false + } + return false +} diff --git a/src/components/gacha/toolbar/GachaActionExport.tsx b/src/components/gacha/toolbar/GachaActionExport.tsx index 4fcdaf5..a1a0921 100644 --- a/src/components/gacha/toolbar/GachaActionExport.tsx +++ b/src/components/gacha/toolbar/GachaActionExport.tsx @@ -71,7 +71,7 @@ export default function GachaActionExport() { open={open} onClose={handleClose} MenuListProps={{ disablePadding: false }} - slotProps={{ backdrop: { invisible: false } }} + slotProps={{ root: { slotProps: { backdrop: { invisible: false } } } }} > {`export ${action} is documented as:`}