diff --git a/README.md b/README.md index 3e33fe0..c64a967 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,13 @@ pnpm tauri build - [x] md - [x] markdown - 文档: - - [ ] xlsx - - [ ] xls + - [x] xlsx + - [x] xls + - [x] xlsm + - [x] xlsb + - [x] xla + - [x] xlam + - [x] ods - [ ] csv - 代码文件(utf8): - [x] html diff --git a/package.json b/package.json index 0cb3d38..9ead168 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quicklook", - "version": "0.4.0", + "version": "0.5.0", "description": "Windows 平台的文件预览工具", "private": true, "type": "module", @@ -17,6 +17,7 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", + "@handsontable/vue3": "^14.6.1", "@shikijs/markdown-it": "^1.22.2", "@tauri-apps/api": "^2.0.3", "@tauri-apps/plugin-autostart": "~2", @@ -27,6 +28,7 @@ "@vicons/fluent": "^0.12.0", "@vueuse/core": "^11.1.0", "element-plus": "^2.8.7", + "handsontable": "^14.6.1", "leafer-ui": "^1.0.7", "markdown-it": "^14.1.0", "naive-ui": "^2.40.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2dadc5..d6ba559 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@element-plus/icons-vue': specifier: ^2.3.1 version: 2.3.1(vue@3.5.12(typescript@5.5.4)) + '@handsontable/vue3': + specifier: ^14.6.1 + version: 14.6.1(handsontable@14.6.1)(vue@3.5.12(typescript@5.5.4)) '@shikijs/markdown-it': specifier: ^1.22.2 version: 1.22.2 @@ -41,6 +44,9 @@ importers: element-plus: specifier: ^2.8.7 version: 2.8.7(vue@3.5.12(typescript@5.5.4)) + handsontable: + specifier: ^14.6.1 + version: 14.6.1 leafer-ui: specifier: ^1.0.7 version: 1.0.7 @@ -498,6 +504,15 @@ packages: '@floating-ui/utils@0.2.8': resolution: {integrity: sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==} + '@handsontable/pikaday@1.0.0': + resolution: {integrity: sha512-1VN6N38t5/DcjJ7y7XUYrDx1LuzvvzlrFdBdMG90Qo1xc8+LXHqbWbsTEm5Ec5gXTEbDEO53vUT35R+2COmOyg==} + + '@handsontable/vue3@14.6.1': + resolution: {integrity: sha512-Mxt7eM4Q3aGK2qidf3oBLVrdBWtdYgO1+3p+bdt2Pf9TFN8HiS/nv7m8eHYpBBQ9xfaYsCKv0wRI6nCN0vFEHw==} + peerDependencies: + handsontable: '>=14.0.0' + vue: ^3.2.22 + '@humanfs/core@0.19.0': resolution: {integrity: sha512-2cbWIHbZVEweE853g8jymffCA+NCMiuqeECeBBLm8dg2oFdjuGJhgN4UAbI+6v0CKbbhvtXA4qV8YR5Ji86nmw==} engines: {node: '>=18.18.0'} @@ -1042,6 +1057,9 @@ packages: resolution: {integrity: sha512-TRdIPqdsvKmPla44kVy4jv5Nt5vjMfVjbIEke1CRULIrwKNRC4lIiZvNYDJvbUMNCFPNIUcOKhXTyMJrX18IMA==} deprecated: This is a stub types definition. pdfjs-dist provides its own type definitions, so you do not need this installed. + '@types/pikaday@1.7.4': + resolution: {integrity: sha512-0KsHVyw5pTG829nqG4IRu7m+BFQlFEBdbE/1i3S5182HeKUKv1uEW0gyEmkJVp5i4IV+9pyh23O83+KpRkSQbw==} + '@types/tough-cookie@4.0.5': resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==} @@ -1354,6 +1372,9 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + bignumber.js@8.1.1: + resolution: {integrity: sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==} + birpc@0.2.19: resolution: {integrity: sha512-5WeXXAvTmitV1RqJFppT5QtUiz2p1mRSYU000Jkft5ZUCLJIk4uQriYNO50HknxKwM6jd8utNc66K1qGIwwWBQ==} @@ -1425,6 +1446,9 @@ packages: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} + chevrotain@6.5.0: + resolution: {integrity: sha512-BwqQ/AgmKJ8jcMEjaSnfMybnKMgGTrtDKowfTP3pX4jwVy0kNjRsT/AP6h+wC3+3NC+X8X15VWBnTCQlX+wQFg==} + chokidar@4.0.1: resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==} engines: {node: '>= 14.16.0'} @@ -1588,6 +1612,9 @@ packages: devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + dompurify@2.5.7: + resolution: {integrity: sha512-2q4bEI+coQM8f5ez7kt2xclg1XsecaV9ASJk/54vwlfRRNQfDqJz2pzQ8t0Ix/ToBpXlVjrRIx7pFC/o8itG2Q==} + downloadjs@1.4.7: resolution: {integrity: sha512-LN1gO7+u9xjU5oEScGFKvXhYf7Y/empUIIEAGBs1LzUq/rg5duiDrkuH5A2lQGd5jfMOb9X9usDa2oVXwJ0U/Q==} @@ -1859,6 +1886,9 @@ packages: graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + handsontable@14.6.1: + resolution: {integrity: sha512-uPvGTkV9dgndwRhSjlJpBzSLW7o7LX18GE70HbaBlcaNKUCEEXhzJ7WGlaw6X8rQZqShIB1HAC+h/t98odqVQQ==} + has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} @@ -1907,6 +1937,9 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} + hyperformula@2.7.1: + resolution: {integrity: sha512-mpVF5zOyNpksZzgTaCQyRAzdC/X43+taz5x1n7zNbs/PUUv0AuLmsy2yfihCr+vihUzN/pk+gXBbOfNpXKOpgA==} + iconv-lite@0.6.3: resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} @@ -2168,6 +2201,9 @@ packages: mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + moment@2.30.1: + resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} + mrmime@2.0.0: resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} engines: {node: '>=10'} @@ -2231,6 +2267,9 @@ packages: nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} + numbro@2.1.2: + resolution: {integrity: sha512-7w833BxZmKGLE9HI0aREtNVRVH6WTYUUlWf4qgA5gKNhPQ4F/MRZ14sc0v8eoLORprk9ZTVwYaLwj8N3Zgxwiw==} + nwsapi@2.2.13: resolution: {integrity: sha512-cTGB9ptp9dY9A5VbMSe7fQBcl/tt22Vcqdq8+eN93rblOuE0aCFu4aZ2vMwct/2t+lFnosm8RkQW1I0Omb1UtQ==} @@ -2319,6 +2358,9 @@ packages: engines: {node: '>=0.10'} hasBin: true + pikaday@1.8.2: + resolution: {integrity: sha512-TNtsE+34BIax3WtkB/qqu5uepV1McKYEgvL3kWzU7aqPCpMEN6rBF3AOwu4WCwAealWlBGobXny/9kJb49C1ew==} + pinia@2.2.4: resolution: {integrity: sha512-K7ZhpMY9iJ9ShTC0cR2+PnxdQRuwVIsXDO/WIEV/RnMC/vmSoKDTKW/exNQYPI+4ij10UjXqdNiEHwn47McANQ==} peerDependencies: @@ -2396,6 +2438,9 @@ packages: regex@4.4.0: resolution: {integrity: sha512-uCUSuobNVeqUupowbdZub6ggI5/JZkYyJdDogddJr60L764oxC2pMZov1fQ3wM9bdyzUILDG+Sqx6NAKAz9rKQ==} + regexp-to-ast@0.4.0: + resolution: {integrity: sha512-4qf/7IsIKfSNHQXSwial1IFmfM1Cc/whNBQqRwe0V2stPe7KmN1U0tWQiIx6JiirgSrisjE0eECdNf7Tav1Ntw==} + resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -2566,6 +2611,9 @@ packages: text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} + tiny-emitter@2.1.0: + resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==} + tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} @@ -3281,6 +3329,13 @@ snapshots: '@floating-ui/utils@0.2.8': {} + '@handsontable/pikaday@1.0.0': {} + + '@handsontable/vue3@14.6.1(handsontable@14.6.1)(vue@3.5.12(typescript@5.5.4))': + dependencies: + handsontable: 14.6.1 + vue: 3.5.12(typescript@5.5.4) + '@humanfs/core@0.19.0': {} '@humanfs/node@0.16.5': @@ -3875,6 +3930,10 @@ snapshots: dependencies: pdfjs-dist: 4.8.69 + '@types/pikaday@1.7.4': + dependencies: + moment: 2.30.1 + '@types/tough-cookie@4.0.5': {} '@types/unist@3.0.3': {} @@ -4289,6 +4348,8 @@ snapshots: base64-js@1.5.1: optional: true + bignumber.js@8.1.1: {} + birpc@0.2.19: {} bl@4.1.0: @@ -4370,6 +4431,11 @@ snapshots: check-error@2.1.1: {} + chevrotain@6.5.0: + dependencies: + regexp-to-ast: 0.4.0 + optional: true + chokidar@4.0.1: dependencies: readdirp: 4.0.2 @@ -4506,6 +4572,8 @@ snapshots: dependencies: dequal: 2.0.3 + dompurify@2.5.7: {} + downloadjs@1.4.7: {} eastasianwidth@0.2.0: {} @@ -4850,6 +4918,18 @@ snapshots: graphemer@1.4.0: {} + handsontable@14.6.1: + dependencies: + '@handsontable/pikaday': 1.0.0 + '@types/pikaday': 1.7.4 + core-js: 3.38.1 + dompurify: 2.5.7 + moment: 2.30.1 + numbro: 2.1.2 + pikaday: 1.8.2 + optionalDependencies: + hyperformula: 2.7.1 + has-flag@3.0.0: {} has-flag@4.0.0: {} @@ -4902,6 +4982,12 @@ snapshots: human-signals@5.0.0: {} + hyperformula@2.7.1: + dependencies: + chevrotain: 6.5.0 + tiny-emitter: 2.1.0 + optional: true + iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2 @@ -5166,6 +5252,8 @@ snapshots: mkdirp-classic@0.5.3: optional: true + moment@2.30.1: {} + mrmime@2.0.0: {} ms@2.1.3: {} @@ -5240,6 +5328,10 @@ snapshots: dependencies: boolbase: 1.0.0 + numbro@2.1.2: + dependencies: + bignumber.js: 8.1.1 + nwsapi@2.2.13: {} once@1.4.0: @@ -5322,6 +5414,8 @@ snapshots: pidtree@0.6.0: {} + pikaday@1.8.2: {} + pinia@2.2.4(typescript@5.5.4)(vue@3.5.12(typescript@5.5.4)): dependencies: '@vue/devtools-api': 6.6.4 @@ -5405,6 +5499,9 @@ snapshots: regex@4.4.0: {} + regexp-to-ast@0.4.0: + optional: true + resolve-from@4.0.0: {} reusify@1.0.4: {} @@ -5594,6 +5691,9 @@ snapshots: text-table@0.2.0: {} + tiny-emitter@2.1.0: + optional: true + tinybench@2.9.0: {} tinyexec@0.3.1: {} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 773905d..5ed9388 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -103,9 +103,11 @@ checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "app" -version = "0.4.0" +version = "0.5.0" dependencies = [ + "calamine", "chrono", + "csv", "infer", "log", "serde", @@ -577,6 +579,21 @@ dependencies = [ "system-deps", ] +[[package]] +name = "calamine" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138646b9af2c5d7f1804ea4bf93afc597737d2bd4f7341d67c48b03316976eb1" +dependencies = [ + "byteorder", + "codepage", + "encoding_rs", + "log", + "quick-xml 0.31.0", + "serde", + "zip", +] + [[package]] name = "camino" version = "1.1.9" @@ -730,6 +747,15 @@ dependencies = [ "objc", ] +[[package]] +name = "codepage" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48f68d061bc2828ae826206326e61251aca94c1e4a5305cf52d9138639c918b4" +dependencies = [ + "encoding_rs", +] + [[package]] name = "combine" version = "4.6.7" @@ -886,6 +912,27 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "csv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +dependencies = [ + "csv-core", + "itoa 1.0.11", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +dependencies = [ + "memchr", +] + [[package]] name = "ctor" version = "0.2.8" @@ -3116,6 +3163,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "encoding_rs", + "memchr", +] + [[package]] name = "quick-xml" version = "0.32.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e218572..1335254 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "0.4.0" +version = "0.5.0" description = "Windows 平台的文件预览工具" authors = ["GuoJikun "] license = "" @@ -42,6 +42,8 @@ urlencoding = "2.1.3" tauri-plugin-shell = "2" zip = { version = "2.2.1", features = [] } chrono = { version = "0.4.38", features = ["serde"] } +calamine = "0.26.1" +csv = "1.3.1" [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-autostart = "2" diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png index 77e7d23..7b85181 100644 Binary files a/src-tauri/icons/128x128.png and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png index 0f7976f..1f12879 100644 Binary files a/src-tauri/icons/128x128@2x.png and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png index 98fda06..cee0963 100644 Binary files a/src-tauri/icons/32x32.png and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png index f35d84f..a81c1e7 100644 Binary files a/src-tauri/icons/Square107x107Logo.png and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png index 1823bb2..7f51123 100644 Binary files a/src-tauri/icons/Square142x142Logo.png and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png index dc2b22c..bd7ac82 100644 Binary files a/src-tauri/icons/Square150x150Logo.png and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png index 0ed3984..b79b097 100644 Binary files a/src-tauri/icons/Square284x284Logo.png and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png index 60bf0ea..87c85fe 100644 Binary files a/src-tauri/icons/Square30x30Logo.png and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png index c8ca0ad..1be29c3 100644 Binary files a/src-tauri/icons/Square310x310Logo.png and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png index 8756459..7719ac6 100644 Binary files a/src-tauri/icons/Square44x44Logo.png and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png index 2c8023c..ae29665 100644 Binary files a/src-tauri/icons/Square71x71Logo.png and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png index 2c5e603..98ef7b2 100644 Binary files a/src-tauri/icons/Square89x89Logo.png and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png index 17d142c..f066348 100644 Binary files a/src-tauri/icons/StoreLogo.png and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns index a2993ad..0ad60f9 100644 Binary files a/src-tauri/icons/icon.icns and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico index 06c23c8..43889e3 100644 Binary files a/src-tauri/icons/icon.ico and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png index d1756ce..8e62ff4 100644 Binary files a/src-tauri/icons/icon.png and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/command.rs b/src-tauri/src/command.rs index c982f13..04f2804 100644 --- a/src-tauri/src/command.rs +++ b/src-tauri/src/command.rs @@ -25,3 +25,14 @@ pub fn archive(path: &str, mode: &str) -> Result, String> { } } + +#[command] +pub fn document(path: &str, mode: &str) -> Result, String> { + match mode { + "csv" => helper::Document::csv(path).map_err(|e| e.to_string()), + "xlsx" | "xls" | "xlsm" | "xlsb" | "xla" | "xlam" | "ods" => helper::Document::excel(path).map_err(|e| e.to_string()), + _ => { + Err("Not Support".to_string()) + } + } +} diff --git a/src-tauri/src/helper.rs b/src-tauri/src/helper.rs index 1cee7c1..35820d5 100644 --- a/src-tauri/src/helper.rs +++ b/src-tauri/src/helper.rs @@ -1,3 +1,4 @@ +use calamine::Reader; use serde::Serialize; use tauri::{ webview::WebviewWindow, AppHandle, Error as TError, Manager, WebviewUrl, WebviewWindowBuilder, @@ -117,4 +118,61 @@ impl Extract { Ok(target) } +} + +#[allow(unused)] +#[derive(Debug, Clone, Serialize)] +pub struct DSheet { + name: String, + rows: Vec> +} + +#[allow(unused)] +pub struct Document; + +#[allow(unused)] +impl Document { + pub fn excel(file_path: &str) -> Result, Box> { + let mut workbook = calamine::open_workbook_auto(file_path)?; + let sheets = workbook.sheet_names().to_owned(); + let mut target: Vec = Vec::new(); + + for sheet in sheets { + let range = workbook.worksheet_range(&sheet)?; + let mut rows = Vec::new(); + for row in range.rows() { + let mut cell_list: Vec = Vec::new(); + for cell in row.iter() { + cell_list.push(cell.to_string()); + } + rows.push(cell_list); + } + let map = DSheet { + name: sheet, + rows + }; + + target.push(map); + } + Ok(target) + } + pub fn csv(file_path: &str) -> Result, Box> { + let file = File::open(file_path)?; + let mut rdr = csv::ReaderBuilder::new().has_headers(true).from_reader(file); + + let mut rows : Vec> = vec![]; + for result in rdr.records() { + let record = result?; + let mut cols: Vec = Vec::new(); + for i in 0..record.len() { + cols.push(record[i].to_string()); + } + rows.push(cols); + } + let target: Vec = vec![DSheet { + name: "sheet1".to_string(), + rows + }]; + Ok(target) + } } \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 0af2612..154c678 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -19,8 +19,14 @@ pub fn run() { .setup(|app| { if cfg!(debug_assertions) { app.handle().plugin( - tauri_plugin_log::Builder::default() + tauri_plugin_log::Builder::new() + .target(tauri_plugin_log::Target::new( + tauri_plugin_log::TargetKind::LogDir { file_name: Some("logs".to_string()) } + )) .level(log::LevelFilter::Info) + .max_file_size(50000) + .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll) + .timezone_strategy(tauri_plugin_log::TimezoneStrategy::UseLocal) .build(), )?; } @@ -35,7 +41,7 @@ pub fn run() { Ok(()) }) - .invoke_handler(tauri::generate_handler![command::show_open_with_dialog, command::archive]) + .invoke_handler(tauri::generate_handler![command::show_open_with_dialog, command::archive, command::document]) .build(tauri::generate_context!()) .expect("error while running tauri application") .run(|_handle, event| { diff --git a/src-tauri/src/preview.rs b/src-tauri/src/preview.rs index 696b68e..34fde9f 100644 --- a/src-tauri/src/preview.rs +++ b/src-tauri/src/preview.rs @@ -328,6 +328,7 @@ impl PreviewFile { "Code" => WebRoute::new("/preview/code".to_string(), file_info.clone()), "Book" => WebRoute::new("/preview/book".to_string(), file_info.clone()), "Archive" => WebRoute::new("/preview/archive".to_string(), file_info.clone()), + "Doc" => WebRoute::new("/preview/document".to_string(), file_info.clone()), _ => WebRoute::new("/preview/not-support".to_string(), file_info.clone()), }; @@ -362,6 +363,7 @@ impl PreviewFile { "Code" => WebRoute::new("/preview/code".to_string(), file_info.clone()), "Book" => WebRoute::new("/preview/book".to_string(), file_info.clone()), "Archive" => WebRoute::new("/preview/archive".to_string(), file_info.clone()), + "Doc" => WebRoute::new("/preview/document".to_string(), file_info.clone()), _ => WebRoute::new( "/preview/not-support".to_string(), file_info.clone(), diff --git a/src-tauri/src/utils/mod.rs b/src-tauri/src/utils/mod.rs index 545fe5d..2deb460 100644 --- a/src-tauri/src/utils/mod.rs +++ b/src-tauri/src/utils/mod.rs @@ -95,8 +95,9 @@ fn file_type_mapping() -> HashMap<&'static str, &'static str> { // DOC 文件 // map.insert("doc", "Doc"); // map.insert("docx", "Doc"); - // map.insert("xls", "Doc"); - // map.insert("xlsx", "Doc"); + map.insert("xls", "Doc"); + map.insert("xlsx", "Doc"); + map.insert("csv", "Doc"); // map.insert("ppt", "Doc"); // map.insert("pptx", "Doc"); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5900671..8d195ee 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "quicklook", - "version": "0.4.0", + "version": "0.5.0", "identifier": "dev.jikun.quicklook", "build": { "frontendDist": "../dist", diff --git a/src/assets/logo.svg b/src/assets/logo.svg index 7565660..37d8b95 100644 --- a/src/assets/logo.svg +++ b/src/assets/logo.svg @@ -1 +1,5 @@ - + + + \ No newline at end of file diff --git a/src/components/document/excel.vue b/src/components/document/excel.vue new file mode 100644 index 0000000..59a99c4 --- /dev/null +++ b/src/components/document/excel.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index 5f92b2b..ff6ce39 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -65,6 +65,11 @@ const router = createRouter({ name: 'previewArchive', component: () => import('@/views/preview/archive.vue'), }, + { + path: '/preview/document', + name: 'previewDocument', + component: () => import('@/views/preview/document.vue'), + }, ], }, { diff --git a/src/views/preview/code.vue b/src/views/preview/code.vue index e2a1804..a1dca5c 100644 --- a/src/views/preview/code.vue +++ b/src/views/preview/code.vue @@ -17,7 +17,7 @@ const content = ref() const loading = ref(false) onMounted(async () => { - loading.value = false + loading.value = true fileInfo.value = route.query as unknown as FileInfo const code = await readTextFile(fileInfo.value.path) const html = await codeToHtml(code, { @@ -28,7 +28,7 @@ onMounted(async () => { }, }) content.value = html - loading.value = true + loading.value = false }) diff --git a/src/views/preview/document.vue b/src/views/preview/document.vue new file mode 100644 index 0000000..9782682 --- /dev/null +++ b/src/views/preview/document.vue @@ -0,0 +1,58 @@ + + + + +