From 69217094616e6abb0c1f2f02b4adbbcd42909597 Mon Sep 17 00:00:00 2001 From: ayang <75017711+ayangweb@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:18:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=8F=8C=E5=87=BB=E5=A4=87=E4=BB=BD=E6=96=87=E4=BB=B6=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=20(#751)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 124 ++++++++++++++++-- package.json | 5 +- pnpm-lock.yaml | 111 +++++++++------- src-tauri/Cargo.toml | 1 + src-tauri/capabilities/default.json | 1 + src-tauri/src/lib.rs | 2 + src-tauri/tauri.conf.json | 9 +- src/pages/Backup/components/Manual/index.tsx | 41 +++++- .../components/List/components/Item/index.tsx | 2 +- .../Clipboard/Panel/components/List/index.tsx | 3 +- src/plugins/backup.ts | 27 +--- 11 files changed, 232 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e02063f0d8..a3894c7697 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -899,6 +899,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -1366,6 +1386,15 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -1424,6 +1453,7 @@ dependencies = [ "tauri-build", "tauri-nspanel", "tauri-plugin-autostart", + "tauri-plugin-deep-link", "tauri-plugin-dialog", "tauri-plugin-eco-autostart", "tauri-plugin-eco-backup", @@ -1820,9 +1850,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210" dependencies = [ "fastrand", "futures-core", @@ -2134,9 +2164,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "global-hotkey" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b75248f33c73df1ed69673f6cb36d2e048ae84d29aa1d3e53199d138ebb1df" +checksum = "b00d88f1be7bf4cd2e61623ce08e84be2dfa4eab458e5d632d3dab95f16c1f64" dependencies = [ "crossbeam-channel", "keyboard-types", @@ -3059,9 +3089,9 @@ dependencies = [ [[package]] name = "muda" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8123dfd4996055ac9b15a60ad263b44b01e539007523ad7a4a533a3d93b0591" +checksum = "b18047edf23933de40835403d4b9211ffd1dcc65c0eec569df38a1fb8aebd719" dependencies = [ "crossbeam-channel", "dpi", @@ -3555,6 +3585,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-multimap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" +dependencies = [ + "dlv-list", + "hashbrown 0.14.5", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -4379,7 +4419,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "windows-registry", + "windows-registry 0.2.0", ] [[package]] @@ -4475,6 +4515,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rust-ini" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f" +dependencies = [ + "cfg-if", + "ordered-multimap", + "trim-in-place", +] + [[package]] name = "rust_decimal" version = "1.36.0" @@ -5596,6 +5647,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "tauri-plugin-deep-link" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31a9b5725027c6e9e075b06cb2d5c2cd3b5c29daa8012b404e1ff755cc56082f" +dependencies = [ + "dunce", + "log", + "rust-ini", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-utils", + "thiserror", + "url", + "windows-registry 0.3.0", + "windows-result 0.2.0", +] + [[package]] name = "tauri-plugin-dialog" version = "2.0.3" @@ -6092,6 +6163,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -6277,6 +6357,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "trim-in-place" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" + [[package]] name = "try-lock" version = "0.2.5" @@ -6896,7 +6982,7 @@ dependencies = [ "windows-implement 0.58.0", "windows-interface 0.58.0", "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] @@ -6951,7 +7037,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafa604f2104cf5ae2cc2db1dee84b7e6a5d11b05f737b60def0ffdc398cbc0a" +dependencies = [ + "windows-result 0.2.0", + "windows-strings 0.2.0", "windows-targets 0.52.6", ] @@ -6983,6 +7080,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978d65aedf914c664c510d9de43c8fd85ca745eaff1ed53edf409b479e441663" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.45.0" diff --git a/package.json b/package.json index 438d6cf73e..366ecf8195 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@tanstack/react-virtual": "^3.10.8", "@tauri-apps/api": "^2.0.3", "@tauri-apps/plugin-autostart": "^2.0.0", + "@tauri-apps/plugin-deep-link": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.0.1", "@tauri-apps/plugin-fs": "^2.0.1", "@tauri-apps/plugin-global-shortcut": "^2.0.0", @@ -68,7 +69,7 @@ "@iconify-json/skill-icons": "^1.2.0", "@tauri-apps/cli": "^2.0.4", "@types/lodash-es": "^4.17.12", - "@types/node": "^22.8.2", + "@types/node": "^22.8.4", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@unocss/preset-rem-to-px": "^0.63.6", @@ -76,7 +77,7 @@ "lint-staged": "^15.2.10", "npm-run-all": "^4.1.5", "release-it": "^17.10.0", - "sass": "^1.80.4", + "sass": "^1.80.5", "simple-git-hooks": "^2.11.1", "tsx": "^4.19.2", "typescript": "^5.6.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d3750274a..483c0913cd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: '@tauri-apps/plugin-autostart': specifier: ^2.0.0 version: 2.0.0 + '@tauri-apps/plugin-deep-link': + specifier: ^2.0.0 + version: 2.0.0 '@tauri-apps/plugin-dialog': specifier: ^2.0.1 version: 2.0.1 @@ -110,7 +113,7 @@ importers: version: 1.9.3 '@commitlint/cli': specifier: ^19.5.0 - version: 19.5.0(@types/node@22.8.2)(typescript@5.6.3) + version: 19.5.0(@types/node@22.8.4)(typescript@5.6.3) '@commitlint/config-conventional': specifier: ^19.5.0 version: 19.5.0 @@ -142,8 +145,8 @@ importers: specifier: ^4.17.12 version: 4.17.12 '@types/node': - specifier: ^22.8.2 - version: 22.8.2 + specifier: ^22.8.4 + version: 22.8.4 '@types/react': specifier: ^18.3.12 version: 18.3.12 @@ -155,7 +158,7 @@ importers: version: 0.63.6 '@vitejs/plugin-react': specifier: ^4.3.3 - version: 4.3.3(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)) + version: 4.3.3(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)) lint-staged: specifier: ^15.2.10 version: 15.2.10 @@ -166,8 +169,8 @@ importers: specifier: ^17.10.0 version: 17.10.0(typescript@5.6.3) sass: - specifier: ^1.80.4 - version: 1.80.4 + specifier: ^1.80.5 + version: 1.80.5 simple-git-hooks: specifier: ^2.11.1 version: 2.11.1 @@ -182,13 +185,13 @@ importers: version: 5.1.0(typescript@5.6.3) unocss: specifier: ^0.63.6 - version: 0.63.6(postcss@8.4.47)(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)) + version: 0.63.6(postcss@8.4.47)(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)) unplugin-auto-import: specifier: ^0.18.3 version: 0.18.3(rollup@4.24.3)(webpack-sources@3.2.3) vite: specifier: ^5.4.10 - version: 5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0) + version: 5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0) packages: @@ -1215,6 +1218,9 @@ packages: '@tauri-apps/plugin-autostart@2.0.0': resolution: {integrity: sha512-NEwOQWVasZ8RczXkMLNJokRDujneuMH/UFA5t84DLkbNZUmiD3G7HZWhgSd1YQ0BFU9h9w+h2B/py3y6bzWg4Q==} + '@tauri-apps/plugin-deep-link@2.0.0': + resolution: {integrity: sha512-cDa2k1OrRU5DoKc0IXl1Y8RlFOU107u2phdZfT7FkApsC6TL/VAPs3YOUTT8p9/PZ50EjOKP104HFMqVqnQ0bw==} + '@tauri-apps/plugin-dialog@2.0.1': resolution: {integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==} @@ -1275,8 +1281,8 @@ packages: '@types/lodash-es@4.17.12': resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} - '@types/lodash@4.17.12': - resolution: {integrity: sha512-sviUmCE8AYdaF/KIHLDJBQgeYzPBI0vf/17NaYehBJfYD1j6/L95Slh07NlyK2iNyBNaEkb3En2jRt+a8y3xZQ==} + '@types/lodash@4.17.13': + resolution: {integrity: sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==} '@types/mdast@4.0.4': resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} @@ -1284,8 +1290,8 @@ packages: '@types/ms@0.7.34': resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} - '@types/node@22.8.2': - resolution: {integrity: sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw==} + '@types/node@22.8.4': + resolution: {integrity: sha512-SpNNxkftTJOPk0oN+y2bIqurEXHTA2AOZ3EJDDKeJ5VzkvvORSvmQXGQarcOzWV1ac7DCaPBEdMDxBsM+d8jWw==} '@types/postcss-modules-local-by-default@4.0.2': resolution: {integrity: sha512-CtYCcD+L+trB3reJPny+bKWKMzPfxEyQpKIwit7kErnOexf5/faaGpkFy4I5AwbV4hp1sk7/aTg0tt0B67VkLQ==} @@ -1594,8 +1600,8 @@ packages: resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} engines: {node: '>=16'} - caniuse-lite@1.0.30001674: - resolution: {integrity: sha512-jOsKlZVRnzfhLojb+Ykb+gyUSp9Xb57So+fAiFlLzzTKpqg8xxSav0e40c8/4F/v9N8QSvrRRaLeVzQbLqomYw==} + caniuse-lite@1.0.30001675: + resolution: {integrity: sha512-/wV1bQwPrkLiQMjaJF5yUMVM/VdRPOCU8QZ+PmG6uW6DvYSrNY1bpwHI/3mOcUosLaJCzYDi5o91IQB51ft6cg==} ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -2711,8 +2717,8 @@ packages: mdast-util-to-hast@13.2.0: resolution: {integrity: sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==} - mdast-util-to-markdown@2.1.0: - resolution: {integrity: sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==} + mdast-util-to-markdown@2.1.1: + resolution: {integrity: sha512-OrkcCoqAkEg9b1ykXBrA0ehRc8H4fGU/03cACmW2xXzau1+dIdS+qJugh1Cqex3hMumSBgSE/5pc7uqP12nLAw==} mdast-util-to-string@4.0.0: resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==} @@ -3566,8 +3572,8 @@ packages: safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - sass@1.80.4: - resolution: {integrity: sha512-rhMQ2tSF5CsuuspvC94nPM9rToiAFw2h3JTrLlgmNw1MH79v8Cr3DH6KF6o6r+8oofY3iYVPUf66KzC8yuVN1w==} + sass@1.80.5: + resolution: {integrity: sha512-TQd2aoQl/+zsxRMEDSxVdpPIqeq9UFc6pr7PzkugiTx3VYCFPUaa3P4RrBQsqok4PO200Vkz0vXQBNlg7W907g==} engines: {node: '>=14.0.0'} hasBin: true @@ -4380,11 +4386,11 @@ snapshots: '@biomejs/cli-win32-x64@1.9.3': optional: true - '@commitlint/cli@19.5.0(@types/node@22.8.2)(typescript@5.6.3)': + '@commitlint/cli@19.5.0(@types/node@22.8.4)(typescript@5.6.3)': dependencies: '@commitlint/format': 19.5.0 '@commitlint/lint': 19.5.0 - '@commitlint/load': 19.5.0(@types/node@22.8.2)(typescript@5.6.3) + '@commitlint/load': 19.5.0(@types/node@22.8.4)(typescript@5.6.3) '@commitlint/read': 19.5.0 '@commitlint/types': 19.5.0 tinyexec: 0.3.1 @@ -4431,7 +4437,7 @@ snapshots: '@commitlint/rules': 19.5.0 '@commitlint/types': 19.5.0 - '@commitlint/load@19.5.0(@types/node@22.8.2)(typescript@5.6.3)': + '@commitlint/load@19.5.0(@types/node@22.8.4)(typescript@5.6.3)': dependencies: '@commitlint/config-validator': 19.5.0 '@commitlint/execute-rule': 19.5.0 @@ -4439,7 +4445,7 @@ snapshots: '@commitlint/types': 19.5.0 chalk: 5.3.0 cosmiconfig: 9.0.0(typescript@5.6.3) - cosmiconfig-typescript-loader: 5.1.0(@types/node@22.8.2)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3) + cosmiconfig-typescript-loader: 5.1.0(@types/node@22.8.4)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -5037,6 +5043,10 @@ snapshots: dependencies: '@tauri-apps/api': 2.0.3 + '@tauri-apps/plugin-deep-link@2.0.0': + dependencies: + '@tauri-apps/api': 2.0.3 + '@tauri-apps/plugin-dialog@2.0.1': dependencies: '@tauri-apps/api': 2.0.3 @@ -5098,7 +5108,7 @@ snapshots: '@types/conventional-commits-parser@5.0.0': dependencies: - '@types/node': 22.8.2 + '@types/node': 22.8.4 '@types/debug@4.1.12': dependencies: @@ -5116,9 +5126,9 @@ snapshots: '@types/lodash-es@4.17.12': dependencies: - '@types/lodash': 4.17.12 + '@types/lodash': 4.17.13 - '@types/lodash@4.17.12': {} + '@types/lodash@4.17.13': {} '@types/mdast@4.0.4': dependencies: @@ -5126,7 +5136,7 @@ snapshots: '@types/ms@0.7.34': {} - '@types/node@22.8.2': + '@types/node@22.8.4': dependencies: undici-types: 6.19.8 @@ -5155,13 +5165,13 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@unocss/astro@0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0))': + '@unocss/astro@0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0))': dependencies: '@unocss/core': 0.63.6 '@unocss/reset': 0.63.6 - '@unocss/vite': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)) + '@unocss/vite': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)) optionalDependencies: - vite: 5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0) + vite: 5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0) transitivePeerDependencies: - rollup - supports-color @@ -5294,7 +5304,7 @@ snapshots: dependencies: '@unocss/core': 0.63.6 - '@unocss/vite@0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0))': + '@unocss/vite@0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0))': dependencies: '@ampproject/remapping': 2.3.0 '@rollup/pluginutils': 5.1.3(rollup@4.24.3) @@ -5304,20 +5314,20 @@ snapshots: chokidar: 3.6.0 magic-string: 0.30.12 tinyglobby: 0.2.10 - vite: 5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0) + vite: 5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0) transitivePeerDependencies: - rollup - supports-color - typescript - '@vitejs/plugin-react@4.3.3(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0))': + '@vitejs/plugin-react@4.3.3(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0))': dependencies: '@babel/core': 7.26.0 '@babel/plugin-transform-react-jsx-self': 7.25.9(@babel/core@7.26.0) '@babel/plugin-transform-react-jsx-source': 7.25.9(@babel/core@7.26.0) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0) + vite: 5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0) transitivePeerDependencies: - supports-color @@ -5580,7 +5590,7 @@ snapshots: browserslist@4.24.2: dependencies: - caniuse-lite: 1.0.30001674 + caniuse-lite: 1.0.30001675 electron-to-chromium: 1.5.49 node-releases: 2.0.18 update-browserslist-db: 1.1.1(browserslist@4.24.2) @@ -5613,7 +5623,7 @@ snapshots: camelcase@8.0.0: {} - caniuse-lite@1.0.30001674: {} + caniuse-lite@1.0.30001675: {} ccount@2.0.1: {} @@ -5759,9 +5769,9 @@ snapshots: dependencies: toggle-selection: 1.0.6 - cosmiconfig-typescript-loader@5.1.0(@types/node@22.8.2)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3): + cosmiconfig-typescript-loader@5.1.0(@types/node@22.8.4)(cosmiconfig@9.0.0(typescript@5.6.3))(typescript@5.6.3): dependencies: - '@types/node': 22.8.2 + '@types/node': 22.8.4 cosmiconfig: 9.0.0(typescript@5.6.3) jiti: 1.21.6 typescript: 5.6.3 @@ -6835,7 +6845,7 @@ snapshots: '@types/mdast': 4.0.4 devlop: 1.1.0 mdast-util-from-markdown: 2.0.2 - mdast-util-to-markdown: 2.1.0 + mdast-util-to-markdown: 2.1.1 transitivePeerDependencies: - supports-color @@ -6848,7 +6858,7 @@ snapshots: ccount: 2.0.1 devlop: 1.1.0 mdast-util-from-markdown: 2.0.2 - mdast-util-to-markdown: 2.1.0 + mdast-util-to-markdown: 2.1.1 parse-entities: 4.0.1 stringify-entities: 4.0.4 unist-util-stringify-position: 4.0.0 @@ -6863,7 +6873,7 @@ snapshots: '@types/mdast': 4.0.4 devlop: 1.1.0 mdast-util-from-markdown: 2.0.2 - mdast-util-to-markdown: 2.1.0 + mdast-util-to-markdown: 2.1.1 transitivePeerDependencies: - supports-color @@ -6884,13 +6894,14 @@ snapshots: unist-util-visit: 5.0.0 vfile: 6.0.3 - mdast-util-to-markdown@2.1.0: + mdast-util-to-markdown@2.1.1: dependencies: '@types/mdast': 4.0.4 '@types/unist': 3.0.3 longest-streak: 3.1.0 mdast-util-phrasing: 4.1.0 mdast-util-to-string: 4.0.0 + micromark-util-classify-character: 2.0.0 micromark-util-decode-string: 2.0.0 unist-util-visit: 5.0.0 zwitch: 2.0.4 @@ -7963,7 +7974,7 @@ snapshots: safer-buffer@2.1.2: {} - sass@1.80.4: + sass@1.80.5: dependencies: '@parcel/watcher': 2.4.1 chokidar: 4.0.1 @@ -8299,7 +8310,7 @@ snapshots: postcss-modules-local-by-default: 4.0.5(postcss@8.4.47) postcss-modules-scope: 3.2.0(postcss@8.4.47) reserved-words: 0.1.2 - sass: 1.80.4 + sass: 1.80.5 source-map-js: 1.2.1 stylus: 0.62.0 tsconfig-paths: 4.2.0 @@ -8387,9 +8398,9 @@ snapshots: universalify@2.0.1: {} - unocss@0.63.6(postcss@8.4.47)(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)): + unocss@0.63.6(postcss@8.4.47)(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)): dependencies: - '@unocss/astro': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)) + '@unocss/astro': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)) '@unocss/cli': 0.63.6(rollup@4.24.3) '@unocss/core': 0.63.6 '@unocss/postcss': 0.63.6(postcss@8.4.47) @@ -8405,9 +8416,9 @@ snapshots: '@unocss/transformer-compile-class': 0.63.6 '@unocss/transformer-directives': 0.63.6 '@unocss/transformer-variant-group': 0.63.6 - '@unocss/vite': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0)) + '@unocss/vite': 0.63.6(rollup@4.24.3)(typescript@5.6.3)(vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0)) optionalDependencies: - vite: 5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0) + vite: 5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0) transitivePeerDependencies: - postcss - rollup @@ -8485,16 +8496,16 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.2 - vite@5.4.10(@types/node@22.8.2)(less@4.2.0)(sass@1.80.4)(stylus@0.62.0): + vite@5.4.10(@types/node@22.8.4)(less@4.2.0)(sass@1.80.5)(stylus@0.62.0): dependencies: esbuild: 0.21.5 postcss: 8.4.47 rollup: 4.24.3 optionalDependencies: - '@types/node': 22.8.2 + '@types/node': 22.8.4 fsevents: 2.3.3 less: 4.2.0 - sass: 1.80.4 + sass: 1.80.5 stylus: 0.62.0 void-elements@3.1.0: {} diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 4360c54532..a968b34d25 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -32,6 +32,7 @@ tauri-plugin-dialog = "2" tauri-plugin-fs = "2" tauri-plugin-updater = "2" tauri-plugin-process = "2" +tauri-plugin-deep-link = "2" tauri-plugin-eco-window.workspace = true tauri-plugin-eco-macos-permissions.workspace = true tauri-plugin-eco-mouse.workspace = true diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 7de622a531..f56acb625a 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -46,6 +46,7 @@ "dialog:default", "updater:default", "process:default", + "deep-link:default", "eco-window:default", "eco-macos-permissions:default", "eco-mouse:default", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 9ac26e89ee..d255fd2090 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -55,6 +55,8 @@ pub fn run() { .plugin(tauri_plugin_updater::Builder::new().build()) // 进程相关插件:https://github.com/tauri-apps/tauri-plugin-process .plugin(tauri_plugin_process::init()) + // 将 EcoPaste 设置为特殊的 URL 或者文件的默认处理程序:https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/deep-link + .plugin(tauri_plugin_deep_link::init()) // 自定义的窗口管理插件 .plugin(tauri_plugin_eco_window::init()) // 自定义的 fs_extra 插件 diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index d23b919a0d..85f1229066 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -73,7 +73,14 @@ "icons/icon.icns", "icons/icon.ico" ], - "resources": ["assets/tray.ico", "assets/tray-mac.ico"] + "resources": ["assets/tray.ico", "assets/tray-mac.ico"], + "fileAssociations": [ + { + "ext": ["EcoPaste-backup"], + "mimeType": "text/plain", + "description": "EcoPaste Backup File" + } + ] }, "plugins": { "updater": { diff --git a/src/pages/Backup/components/Manual/index.tsx b/src/pages/Backup/components/Manual/index.tsx index 6c46ef45ef..bbb70c4950 100644 --- a/src/pages/Backup/components/Manual/index.tsx +++ b/src/pages/Backup/components/Manual/index.tsx @@ -1,6 +1,9 @@ import Icon from "@/components/Icon"; import ProList from "@/components/ProList"; import { emit } from "@tauri-apps/api/event"; +import { downloadDir } from "@tauri-apps/api/path"; +import { onOpenUrl } from "@tauri-apps/plugin-deep-link"; +import { open } from "@tauri-apps/plugin-dialog"; import { Flex, List, message } from "antd"; import type { FC } from "react"; import type { State } from "../.."; @@ -9,11 +12,35 @@ const Manual: FC<{ state: State }> = (props) => { const { state } = props; const { t } = useTranslation(); - const handleImport = async () => { + useMount(() => { + onOpenUrl((urls) => { + const url = urls.find((item) => item.endsWith(extname())); + + if (!url) return; + + handleImport(url.replace("file://", "")); + }); + }); + + const extname = () => { + return `${globalStore.env.appName}-backup`; + }; + + const handleImport = async (path?: string | null) => { try { + let srcPath = path; + + srcPath ??= await open({ + filters: [{ name: "", extensions: [extname()] }], + }); + + showWindow(); + + if (!srcPath) return; + state.spinning = true; - const result = await importData(); + const result = await importData(srcPath); state.spinning = false; @@ -37,7 +64,13 @@ const Manual: FC<{ state: State }> = (props) => { try { state.spinning = true; - await exportData(); + await saveStore(true); + + const filename = formatDate(dayjs(), "YYYY_MM_DD_HH_mm_ss"); + + const path = joinPath(await downloadDir(), `${filename}.${extname()}`); + + await exportData(path); state.spinning = false; @@ -79,7 +112,7 @@ const Manual: FC<{ state: State }> = (props) => { justify="center" gap="small" className="b b-color-2 hover:b-primary h-102 flex-1 cursor-pointer rounded-8 bg-3 px-8 text-center transition hover:text-primary" - onClick={event} + onClick={() => event()} > {label} diff --git a/src/pages/Clipboard/Panel/components/List/components/Item/index.tsx b/src/pages/Clipboard/Panel/components/List/components/Item/index.tsx index 8d71dcc176..efbeea8042 100644 --- a/src/pages/Clipboard/Panel/components/List/components/Item/index.tsx +++ b/src/pages/Clipboard/Panel/components/List/components/Item/index.tsx @@ -114,7 +114,7 @@ const Item: FC = (props) => { // 打开文件至访达 const openFinder = () => { if (subtype === "path") { - openPath(value, false); + openPath(value); } else { const [file] = JSON.parse(value); diff --git a/src/pages/Clipboard/Panel/components/List/index.tsx b/src/pages/Clipboard/Panel/components/List/index.tsx index 7482114657..ab8ef68236 100644 --- a/src/pages/Clipboard/Panel/components/List/index.tsx +++ b/src/pages/Clipboard/Panel/components/List/index.tsx @@ -110,8 +110,7 @@ const List = () => { - {/* @ts-ignore */} - outerRef.current} /> + outerRef.current!} /> diff --git a/src/plugins/backup.ts b/src/plugins/backup.ts index 1b76a05b8e..19a9c4f930 100644 --- a/src/plugins/backup.ts +++ b/src/plugins/backup.ts @@ -1,27 +1,10 @@ import { invoke } from "@tauri-apps/api/core"; import { emit } from "@tauri-apps/api/event"; -import { downloadDir } from "@tauri-apps/api/path"; -import { open } from "@tauri-apps/plugin-dialog"; - -/** - * 备份数据的扩展名 - */ -const extname = () => { - const { appName } = globalStore.env; - - return `${appName}-backup`; -}; /** * 导出数据 */ -export const exportData = async () => { - await saveStore(true); - - const filename = formatDate(dayjs(), "YYYY_MM_DD_HH_mm_ss"); - - const dstPath = joinPath(await downloadDir(), `${filename}.${extname()}`); - +export const exportData = async (dstPath: string) => { return invoke(BACKUP_PLUGIN.EXPORT_DATA, { dstPath, srcDir: getSaveDataDir(), @@ -31,13 +14,7 @@ export const exportData = async () => { /** * 导入数据 */ -export const importData = async () => { - const srcPath = await open({ - filters: [{ name: "", extensions: [extname()] }], - }); - - if (!srcPath) return; - +export const importData = async (srcPath: string) => { await emit(LISTEN_KEY.CLOSE_DATABASE); return invoke(BACKUP_PLUGIN.IMPORT_DATA, {