From 11b4b329fe34ffc0f6737d32f1baf7358f280e0d Mon Sep 17 00:00:00 2001 From: Bamboooz Date: Mon, 11 Nov 2024 14:35:27 +0100 Subject: [PATCH] New theme, better context menus, code improvements --- package.json | 12 +- pnpm-lock.yaml | 266 +++++++++--------- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/main.rs | 3 +- src-tauri/src/module/steam.rs | 4 +- src-tauri/src/util/mod.rs | 1 - src-tauri/src/util/string.rs | 8 - src-tauri/tauri.conf.json | 37 +-- src/App.tsx | 30 +- src/components/Apps/AppItemContext.tsx | 22 +- src/components/Apps/index.tsx | 36 ++- .../Commands/CommandItemContext.tsx | 16 +- src/components/Commands/index.tsx | 15 +- src/components/Games/GameItem.tsx | 8 +- src/components/Games/GameItemContext.tsx | 12 +- src/components/Games/index.tsx | 17 +- src/components/Home/HomeUpdatePanel.tsx | 29 +- src/components/Home/index.tsx | 6 +- src/components/Settings/index.tsx | 4 +- src/components/common/Context.tsx | 2 +- src/components/common/ContextButton.tsx | 20 +- src/components/common/Item.tsx | 6 +- src/components/common/Page.tsx | 13 +- src/hooks/useMount.ts | 11 - src/hooks/useStickyState.ts | 20 ++ src/utils/storage.ts | 33 --- tailwind.config.js | 6 +- 28 files changed, 286 insertions(+), 355 deletions(-) delete mode 100644 src-tauri/src/util/string.rs delete mode 100644 src/hooks/useMount.ts create mode 100644 src/hooks/useStickyState.ts delete mode 100644 src/utils/storage.ts diff --git a/package.json b/package.json index e0b12ff..fb18a7b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "magnetar", "private": true, - "version": "0.0.8", + "version": "0.0.9", "type": "module", "scripts": { "pretty": "pnpm exec prettier . --write", @@ -13,26 +13,26 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "^2.0.3", + "@tauri-apps/api": "^2.1.0", "@tauri-apps/plugin-dialog": "~2.0.1", "@tauri-apps/plugin-global-shortcut": "~2.0.0", "@tauri-apps/plugin-shell": "~2.0.1", + "clsx": "^2.1.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-icons": "^5.3.0", - "clsx": "^2.1.1", "tailwind-merge": "^2.5.4" }, "devDependencies": { - "@tauri-apps/cli": "^2.0.4", + "@tauri-apps/cli": "^2.1.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.3.3", "autoprefixer": "^10.4.20", - "postcss": "^8.4.47", + "postcss": "^8.4.48", "prettier": "3.3.3", "tailwindcss": "^3.4.14", "typescript": "^5.6.3", - "vite": "^5.4.10" + "vite": "^5.4.11" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e15bb15..bdfc0df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: "@tauri-apps/api": - specifier: ^2.0.3 - version: 2.0.3 + specifier: ^2.1.0 + version: 2.1.0 "@tauri-apps/plugin-dialog": specifier: ~2.0.1 version: 2.0.1 @@ -35,8 +35,8 @@ dependencies: devDependencies: "@tauri-apps/cli": - specifier: ^2.0.4 - version: 2.0.4 + specifier: ^2.1.0 + version: 2.1.0 "@types/react": specifier: ^18.3.12 version: 18.3.12 @@ -45,13 +45,13 @@ devDependencies: version: 18.3.1 "@vitejs/plugin-react": specifier: ^4.3.3 - version: 4.3.3(vite@5.4.10) + version: 4.3.3(vite@5.4.11) autoprefixer: specifier: ^10.4.20 - version: 10.4.20(postcss@8.4.47) + version: 10.4.20(postcss@8.4.48) postcss: - specifier: ^8.4.47 - version: 8.4.47 + specifier: ^8.4.48 + version: 8.4.48 prettier: specifier: 3.3.3 version: 3.3.3 @@ -62,8 +62,8 @@ devDependencies: specifier: ^5.6.3 version: 5.6.3 vite: - specifier: ^5.4.10 - version: 5.4.10 + specifier: ^5.4.11 + version: 5.4.11 packages: /@alloc/quick-lru@5.2.0: @@ -686,10 +686,10 @@ packages: dev: true optional: true - /@rollup/rollup-android-arm-eabi@4.24.4: + /@rollup/rollup-android-arm-eabi@4.25.0: resolution: { - integrity: sha512-jfUJrFct/hTA0XDM5p/htWKoNNTbDLY0KRwEt6pyOA6k2fmk0WVwl65PdUdJZgzGEHWx+49LilkcSaumQRyNQw==, + integrity: sha512-CC/ZqFZwlAIbU1wUPisHyV/XRc5RydFrNLtgl3dGYskdwPZdt4HERtKm50a/+DtTlKeCq9IXFEWR+P6blwjqBA==, } cpu: [arm] os: [android] @@ -697,10 +697,10 @@ packages: dev: true optional: true - /@rollup/rollup-android-arm64@4.24.4: + /@rollup/rollup-android-arm64@4.25.0: resolution: { - integrity: sha512-j4nrEO6nHU1nZUuCfRKoCcvh7PIywQPUCBa2UsootTHvTHIoIu2BzueInGJhhvQO/2FTRdNYpf63xsgEqH9IhA==, + integrity: sha512-/Y76tmLGUJqVBXXCfVS8Q8FJqYGhgH4wl4qTA24E9v/IJM0XvJCGQVSW1QZ4J+VURO9h8YCa28sTFacZXwK7Rg==, } cpu: [arm64] os: [android] @@ -708,10 +708,10 @@ packages: dev: true optional: true - /@rollup/rollup-darwin-arm64@4.24.4: + /@rollup/rollup-darwin-arm64@4.25.0: resolution: { - integrity: sha512-GmU/QgGtBTeraKyldC7cDVVvAJEOr3dFLKneez/n7BvX57UdhOqDsVwzU7UOnYA7AAOt+Xb26lk79PldDHgMIQ==, + integrity: sha512-YVT6L3UrKTlC0FpCZd0MGA7NVdp7YNaEqkENbWQ7AOVOqd/7VzyHpgIpc1mIaxRAo1ZsJRH45fq8j4N63I/vvg==, } cpu: [arm64] os: [darwin] @@ -719,10 +719,10 @@ packages: dev: true optional: true - /@rollup/rollup-darwin-x64@4.24.4: + /@rollup/rollup-darwin-x64@4.25.0: resolution: { - integrity: sha512-N6oDBiZCBKlwYcsEPXGDE4g9RoxZLK6vT98M8111cW7VsVJFpNEqvJeIPfsCzbf0XEakPslh72X0gnlMi4Ddgg==, + integrity: sha512-ZRL+gexs3+ZmmWmGKEU43Bdn67kWnMeWXLFhcVv5Un8FQcx38yulHBA7XR2+KQdYIOtD0yZDWBCudmfj6lQJoA==, } cpu: [x64] os: [darwin] @@ -730,10 +730,10 @@ packages: dev: true optional: true - /@rollup/rollup-freebsd-arm64@4.24.4: + /@rollup/rollup-freebsd-arm64@4.25.0: resolution: { - integrity: sha512-py5oNShCCjCyjWXCZNrRGRpjWsF0ic8f4ieBNra5buQz0O/U6mMXCpC1LvrHuhJsNPgRt36tSYMidGzZiJF6mw==, + integrity: sha512-xpEIXhiP27EAylEpreCozozsxWQ2TJbOLSivGfXhU4G1TBVEYtUPi2pOZBnvGXHyOdLAUUhPnJzH3ah5cqF01g==, } cpu: [arm64] os: [freebsd] @@ -741,10 +741,10 @@ packages: dev: true optional: true - /@rollup/rollup-freebsd-x64@4.24.4: + /@rollup/rollup-freebsd-x64@4.25.0: resolution: { - integrity: sha512-L7VVVW9FCnTTp4i7KrmHeDsDvjB4++KOBENYtNYAiYl96jeBThFfhP6HVxL74v4SiZEVDH/1ILscR5U9S4ms4g==, + integrity: sha512-sC5FsmZGlJv5dOcURrsnIK7ngc3Kirnx3as2XU9uER+zjfyqIjdcMVgzy4cOawhsssqzoAX19qmxgJ8a14Qrqw==, } cpu: [x64] os: [freebsd] @@ -752,10 +752,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.24.4: + /@rollup/rollup-linux-arm-gnueabihf@4.25.0: resolution: { - integrity: sha512-10ICosOwYChROdQoQo589N5idQIisxjaFE/PAnX2i0Zr84mY0k9zul1ArH0rnJ/fpgiqfu13TFZR5A5YJLOYZA==, + integrity: sha512-uD/dbLSs1BEPzg564TpRAQ/YvTnCds2XxyOndAO8nJhaQcqQGFgv/DAVko/ZHap3boCvxnzYMa3mTkV/B/3SWA==, } cpu: [arm] os: [linux] @@ -763,10 +763,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm-musleabihf@4.24.4: + /@rollup/rollup-linux-arm-musleabihf@4.25.0: resolution: { - integrity: sha512-ySAfWs69LYC7QhRDZNKqNhz2UKN8LDfbKSMAEtoEI0jitwfAG2iZwVqGACJT+kfYvvz3/JgsLlcBP+WWoKCLcw==, + integrity: sha512-ZVt/XkrDlQWegDWrwyC3l0OfAF7yeJUF4fq5RMS07YM72BlSfn2fQQ6lPyBNjt+YbczMguPiJoCfaQC2dnflpQ==, } cpu: [arm] os: [linux] @@ -774,10 +774,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.24.4: + /@rollup/rollup-linux-arm64-gnu@4.25.0: resolution: { - integrity: sha512-uHYJ0HNOI6pGEeZ/5mgm5arNVTI0nLlmrbdph+pGXpC9tFHFDQmDMOEqkmUObRfosJqpU8RliYoGz06qSdtcjg==, + integrity: sha512-qboZ+T0gHAW2kkSDPHxu7quaFaaBlynODXpBVnPxUgvWYaE84xgCKAPEYE+fSMd3Zv5PyFZR+L0tCdYCMAtG0A==, } cpu: [arm64] os: [linux] @@ -785,10 +785,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-musl@4.24.4: + /@rollup/rollup-linux-arm64-musl@4.25.0: resolution: { - integrity: sha512-38yiWLemQf7aLHDgTg85fh3hW9stJ0Muk7+s6tIkSUOMmi4Xbv5pH/5Bofnsb6spIwD5FJiR+jg71f0CH5OzoA==, + integrity: sha512-ndWTSEmAaKr88dBuogGH2NZaxe7u2rDoArsejNslugHZ+r44NfWiwjzizVS1nUOHo+n1Z6qV3X60rqE/HlISgw==, } cpu: [arm64] os: [linux] @@ -796,10 +796,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-powerpc64le-gnu@4.24.4: + /@rollup/rollup-linux-powerpc64le-gnu@4.25.0: resolution: { - integrity: sha512-q73XUPnkwt9ZNF2xRS4fvneSuaHw2BXuV5rI4cw0fWYVIWIBeDZX7c7FWhFQPNTnE24172K30I+dViWRVD9TwA==, + integrity: sha512-BVSQvVa2v5hKwJSy6X7W1fjDex6yZnNKy3Kx1JGimccHft6HV0THTwNtC2zawtNXKUu+S5CjXslilYdKBAadzA==, } cpu: [ppc64] os: [linux] @@ -807,10 +807,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.24.4: + /@rollup/rollup-linux-riscv64-gnu@4.25.0: resolution: { - integrity: sha512-Aie/TbmQi6UXokJqDZdmTJuZBCU3QBDA8oTKRGtd4ABi/nHgXICulfg1KI6n9/koDsiDbvHAiQO3YAUNa/7BCw==, + integrity: sha512-G4hTREQrIdeV0PE2JruzI+vXdRnaK1pg64hemHq2v5fhv8C7WjVaeXc9P5i4Q5UC06d/L+zA0mszYIKl+wY8oA==, } cpu: [riscv64] os: [linux] @@ -818,10 +818,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-s390x-gnu@4.24.4: + /@rollup/rollup-linux-s390x-gnu@4.25.0: resolution: { - integrity: sha512-P8MPErVO/y8ohWSP9JY7lLQ8+YMHfTI4bAdtCi3pC2hTeqFJco2jYspzOzTUB8hwUWIIu1xwOrJE11nP+0JFAQ==, + integrity: sha512-9T/w0kQ+upxdkFL9zPVB6zy9vWW1deA3g8IauJxojN4bnz5FwSsUAD034KpXIVX5j5p/rn6XqumBMxfRkcHapQ==, } cpu: [s390x] os: [linux] @@ -829,10 +829,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-gnu@4.24.4: + /@rollup/rollup-linux-x64-gnu@4.25.0: resolution: { - integrity: sha512-K03TljaaoPK5FOyNMZAAEmhlyO49LaE4qCsr0lYHUKyb6QacTNF9pnfPpXnFlFD3TXuFbFbz7tJ51FujUXkXYA==, + integrity: sha512-ThcnU0EcMDn+J4B9LD++OgBYxZusuA7iemIIiz5yzEcFg04VZFzdFjuwPdlURmYPZw+fgVrFzj4CA64jSTG4Ig==, } cpu: [x64] os: [linux] @@ -840,10 +840,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-musl@4.24.4: + /@rollup/rollup-linux-x64-musl@4.25.0: resolution: { - integrity: sha512-VJYl4xSl/wqG2D5xTYncVWW+26ICV4wubwN9Gs5NrqhJtayikwCXzPL8GDsLnaLU3WwhQ8W02IinYSFJfyo34Q==, + integrity: sha512-zx71aY2oQxGxAT1JShfhNG79PnjYhMC6voAjzpu/xmMjDnKNf6Nl/xv7YaB/9SIa9jDYf8RBPWEnjcdlhlv1rQ==, } cpu: [x64] os: [linux] @@ -851,10 +851,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.24.4: + /@rollup/rollup-win32-arm64-msvc@4.25.0: resolution: { - integrity: sha512-ku2GvtPwQfCqoPFIJCqZ8o7bJcj+Y54cZSr43hHca6jLwAiCbZdBUOrqE6y29QFajNAzzpIOwsckaTFmN6/8TA==, + integrity: sha512-JT8tcjNocMs4CylWY/CxVLnv8e1lE7ff1fi6kbGocWwxDq9pj30IJ28Peb+Y8yiPNSF28oad42ApJB8oUkwGww==, } cpu: [arm64] os: [win32] @@ -862,10 +862,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.24.4: + /@rollup/rollup-win32-ia32-msvc@4.25.0: resolution: { - integrity: sha512-V3nCe+eTt/W6UYNr/wGvO1fLpHUrnlirlypZfKCT1fG6hWfqhPgQV/K/mRBXBpxc0eKLIF18pIOFVPh0mqHjlg==, + integrity: sha512-dRLjLsO3dNOfSN6tjyVlG+Msm4IiZnGkuZ7G5NmpzwF9oOc582FZG05+UdfTbz5Jd4buK/wMb6UeHFhG18+OEg==, } cpu: [ia32] os: [win32] @@ -873,10 +873,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-x64-msvc@4.24.4: + /@rollup/rollup-win32-x64-msvc@4.25.0: resolution: { - integrity: sha512-LTw1Dfd0mBIEqUVCxbvTE/LLo+9ZxVC9k99v1v4ahg9Aak6FpqOfNu5kRkeTAn0wphoC4JU7No1/rL+bBCEwhg==, + integrity: sha512-/RqrIFtLB926frMhZD0a5oDa4eFIbyNEwLLloMTEjmqfwZWXywwVVOVmwTsuyhC9HKkVEZcOOi+KV4U9wmOdlg==, } cpu: [x64] os: [win32] @@ -884,17 +884,17 @@ packages: dev: true optional: true - /@tauri-apps/api@2.0.3: + /@tauri-apps/api@2.1.0: resolution: { - integrity: sha512-840qk6n8rbXBXMA5/aAgTYsg5JAubKO0nXw5wf7IzGnUuYKGbB4oFBIZtXOIWy+E0kNTDI3qhq5iqsoMJfwp8g==, + integrity: sha512-1w/JygZOiUtdOU7qart78MaB4/qayZ2heB793KhbZRS7I9q4sxXcXaB7He6uFlprD8w5TI9P8HCuEByCvWRtfw==, } dev: false - /@tauri-apps/cli-darwin-arm64@2.0.4: + /@tauri-apps/cli-darwin-arm64@2.1.0: resolution: { - integrity: sha512-siH7rOHobb16rPbc11k64p1mxIpiRCkWmzs2qmL5IX21Gx9K5onI3Tk67Oqpf2uNupbYzItrOttaDT4NHFC7tw==, + integrity: sha512-ESc6J6CE8hl1yKH2vJ+ALF+thq4Be+DM1mvmTyUCQObvezNCNhzfS6abIUd3ou4x5RGH51ouiANeT3wekU6dCw==, } engines: { node: ">= 10" } cpu: [arm64] @@ -903,10 +903,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-darwin-x64@2.0.4: + /@tauri-apps/cli-darwin-x64@2.1.0: resolution: { - integrity: sha512-zIccfbCoZMfmUpnk6PFCV0keFyfVj1A9XV3Oiiitj/dkTZ9CQvzjhX3XC0XcK4rsTWegfr2PjSrK06aiPAROAw==, + integrity: sha512-TasHS442DFs8cSH2eUQzuDBXUST4ECjCd0yyP+zZzvAruiB0Bg+c8A+I/EnqCvBQ2G2yvWLYG8q/LI7c87A5UA==, } engines: { node: ">= 10" } cpu: [x64] @@ -915,10 +915,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm-gnueabihf@2.0.4: + /@tauri-apps/cli-linux-arm-gnueabihf@2.1.0: resolution: { - integrity: sha512-fgQqJzefOGWCBNg4yrVA82Rg4s1XQr5K0dc2rCxBhJfa696e8dQ1LDrnWq/AiO5r+uHfVaoQTIUvxxpFicYRSA==, + integrity: sha512-aP7ZBGNL4ny07Cbb6kKpUOSrmhcIK2KhjviTzYlh+pPhAptxnC78xQGD3zKQkTi2WliJLPmBYbOHWWQa57lQ9w==, } engines: { node: ">= 10" } cpu: [arm] @@ -927,10 +927,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-gnu@2.0.4: + /@tauri-apps/cli-linux-arm64-gnu@2.1.0: resolution: { - integrity: sha512-u8wbt5tPA9pI6j+d7jGrfOz9UVCiTp+IYzKNiIqlrDsAjqAUFaNXYHKqOUboeFWEmI4zoCWj6LgpS2OJTQ5FKg==, + integrity: sha512-ZTdgD5gLeMCzndMT2f358EkoYkZ5T+Qy6zPzU+l5vv5M7dHVN9ZmblNAYYXmoOuw7y+BY4X/rZvHV9pcGrcanQ==, } engines: { node: ">= 10" } cpu: [arm64] @@ -939,10 +939,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-arm64-musl@2.0.4: + /@tauri-apps/cli-linux-arm64-musl@2.1.0: resolution: { - integrity: sha512-hntF1V8e3V1hlrESm93PsghDhf3lA5pbvFrRfYxU1c+fVD/jRXGVw8BH3O1lW8MWwhEg1YdhKk01oAgsuHLuig==, + integrity: sha512-NzwqjUCilhnhJzusz3d/0i0F1GFrwCQbkwR6yAHUxItESbsGYkZRJk0yMEWkg3PzFnyK4cWTlQJMEU52TjhEzA==, } engines: { node: ">= 10" } cpu: [arm64] @@ -951,10 +951,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-gnu@2.0.4: + /@tauri-apps/cli-linux-x64-gnu@2.1.0: resolution: { - integrity: sha512-Iq1GGJb+oT1T0ZV8izrgf0cBtlzPCJaWcNueRbf1ZXquMf+FSTyQv+/Lo8rq5T6buOIJOH7cAOTuEWWqiCZteg==, + integrity: sha512-TyiIpMEtZxNOQmuFyfJwaaYbg3movSthpBJLIdPlKxSAB2BW0VWLY3/ZfIxm/G2YGHyREkjJvimzYE0i37PnMA==, } engines: { node: ">= 10" } cpu: [x64] @@ -963,10 +963,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-linux-x64-musl@2.0.4: + /@tauri-apps/cli-linux-x64-musl@2.1.0: resolution: { - integrity: sha512-9NTk6Pf0bSwXqCBdAA+PDYts9HeHebZzIo8mbRzRyUbER6QngG5HZb9Ka36Z1QWtJjdRy6uxSb4zb/9NuTeHfA==, + integrity: sha512-/dQd0TlaxBdJACrR72DhynWftzHDaX32eBtS5WBrNJ+nnNb+znM3gON6nJ9tSE9jgDa6n1v2BkI/oIDtypfUXw==, } engines: { node: ">= 10" } cpu: [x64] @@ -975,10 +975,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-arm64-msvc@2.0.4: + /@tauri-apps/cli-win32-arm64-msvc@2.1.0: resolution: { - integrity: sha512-OF2e9oxiBFR8A8wVMOhUx9QGN/I1ZkquWC7gVQBnA56nx9PabJlDT08QBy5UD8USqZFVznnfNr2ehlheQahb3g==, + integrity: sha512-NdQJO7SmdYqOcE+JPU7bwg7+odfZMWO6g8xF9SXYCMdUzvM2Gv/AQfikNXz5yS7ralRhNFuW32i5dcHlxh4pDg==, } engines: { node: ">= 10" } cpu: [arm64] @@ -987,10 +987,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-ia32-msvc@2.0.4: + /@tauri-apps/cli-win32-ia32-msvc@2.1.0: resolution: { - integrity: sha512-T+hCKB3rFP6q0saHHtR02hm6wr1ZPJ0Mkii3oRTxjPG6BBXoVzHNCYzvdgEGJPTA2sFuAQtJH764NRtNlDMifw==, + integrity: sha512-f5h8gKT/cB8s1ticFRUpNmHqkmaLutT62oFDB7N//2YTXnxst7EpMIn1w+QimxTvTk2gcx6EcW6bEk/y2hZGzg==, } engines: { node: ">= 10" } cpu: [ia32] @@ -999,10 +999,10 @@ packages: dev: true optional: true - /@tauri-apps/cli-win32-x64-msvc@2.0.4: + /@tauri-apps/cli-win32-x64-msvc@2.1.0: resolution: { - integrity: sha512-GVaiI3KWRFLomjJmApHqihhYlkJ+7FqhumhVfBO6Z2tWzZjQyVQgTdNp0kYEuW2WoAYEj0dKY6qd4YM33xYcUA==, + integrity: sha512-P/+LrdSSb5Xbho1LRP4haBjFHdyPdjWvGgeopL96OVtrFpYnfC+RctB45z2V2XxqFk3HweDDxk266btjttfjGw==, } engines: { node: ">= 10" } cpu: [x64] @@ -1011,24 +1011,24 @@ packages: dev: true optional: true - /@tauri-apps/cli@2.0.4: + /@tauri-apps/cli@2.1.0: resolution: { - integrity: sha512-Hl9eFXz+O366+6su9PfaSzu2EJdFe1p8K8ghkWmi40dz8VmSE7vsMTaOStD0I71ckSOkh2ICDX7FQTBgjlpjWw==, + integrity: sha512-K2VhcKqBhAeS5pNOVdnR/xQRU6jwpgmkSL2ejHXcl0m+kaTggT0WRDQnFtPq6NljA7aE03cvwsbCAoFG7vtkJw==, } engines: { node: ">= 10" } hasBin: true optionalDependencies: - "@tauri-apps/cli-darwin-arm64": 2.0.4 - "@tauri-apps/cli-darwin-x64": 2.0.4 - "@tauri-apps/cli-linux-arm-gnueabihf": 2.0.4 - "@tauri-apps/cli-linux-arm64-gnu": 2.0.4 - "@tauri-apps/cli-linux-arm64-musl": 2.0.4 - "@tauri-apps/cli-linux-x64-gnu": 2.0.4 - "@tauri-apps/cli-linux-x64-musl": 2.0.4 - "@tauri-apps/cli-win32-arm64-msvc": 2.0.4 - "@tauri-apps/cli-win32-ia32-msvc": 2.0.4 - "@tauri-apps/cli-win32-x64-msvc": 2.0.4 + "@tauri-apps/cli-darwin-arm64": 2.1.0 + "@tauri-apps/cli-darwin-x64": 2.1.0 + "@tauri-apps/cli-linux-arm-gnueabihf": 2.1.0 + "@tauri-apps/cli-linux-arm64-gnu": 2.1.0 + "@tauri-apps/cli-linux-arm64-musl": 2.1.0 + "@tauri-apps/cli-linux-x64-gnu": 2.1.0 + "@tauri-apps/cli-linux-x64-musl": 2.1.0 + "@tauri-apps/cli-win32-arm64-msvc": 2.1.0 + "@tauri-apps/cli-win32-ia32-msvc": 2.1.0 + "@tauri-apps/cli-win32-x64-msvc": 2.1.0 dev: true /@tauri-apps/plugin-dialog@2.0.1: @@ -1037,7 +1037,7 @@ packages: integrity: sha512-fnUrNr6EfvTqdls/ufusU7h6UbNFzLKvHk/zTuOiBq01R3dTODqwctZlzakdbfSp/7pNwTKvgKTAgl/NAP/Z0Q==, } dependencies: - "@tauri-apps/api": 2.0.3 + "@tauri-apps/api": 2.1.0 dev: false /@tauri-apps/plugin-global-shortcut@2.0.0: @@ -1046,7 +1046,7 @@ packages: integrity: sha512-pnB4CUwFVjg4twtBSxoLJ4uLFTYxsvOdC1zIbG581pYzhYatOl6mjB+ijD5SSXgiS/jNoqMcfkOF9PWAisurew==, } dependencies: - "@tauri-apps/api": 2.0.3 + "@tauri-apps/api": 2.1.0 dev: false /@tauri-apps/plugin-shell@2.0.1: @@ -1055,7 +1055,7 @@ packages: integrity: sha512-akU1b77sw3qHiynrK0s930y8zKmcdrSD60htjH+mFZqv5WaakZA/XxHR3/sF1nNv9Mgmt/Shls37HwnOr00aSw==, } dependencies: - "@tauri-apps/api": 2.0.3 + "@tauri-apps/api": 2.1.0 dev: false /@types/babel__core@7.20.5: @@ -1132,7 +1132,7 @@ packages: csstype: 3.1.3 dev: true - /@vitejs/plugin-react@4.3.3(vite@5.4.10): + /@vitejs/plugin-react@4.3.3(vite@5.4.11): resolution: { integrity: sha512-NooDe9GpHGqNns1i8XDERg0Vsg5SSYRhRxxyTGogUdkdNt47jal+fbuYi+Yfq6pzRCKXyoPcWisfxE6RIM3GKA==, @@ -1146,7 +1146,7 @@ packages: "@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 + vite: 5.4.11 transitivePeerDependencies: - supports-color dev: true @@ -1210,7 +1210,7 @@ packages: } dev: true - /autoprefixer@10.4.20(postcss@8.4.47): + /autoprefixer@10.4.20(postcss@8.4.48): resolution: { integrity: sha512-XY25y5xSv/wEoqzDyXXME4AFfkZI0P23z6Fs3YgymDnKJkCGOnkL0iTxCa85UTqaSgfcqyf3UA6+c7wUvx/16g==, @@ -1221,11 +1221,11 @@ packages: postcss: ^8.1.0 dependencies: browserslist: 4.24.2 - caniuse-lite: 1.0.30001678 + caniuse-lite: 1.0.30001680 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.1.1 - postcss: 8.4.47 + postcss: 8.4.48 postcss-value-parser: 4.2.0 dev: true @@ -1271,8 +1271,8 @@ packages: engines: { node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7 } hasBin: true dependencies: - caniuse-lite: 1.0.30001678 - electron-to-chromium: 1.5.52 + caniuse-lite: 1.0.30001680 + electron-to-chromium: 1.5.55 node-releases: 2.0.18 update-browserslist-db: 1.1.1(browserslist@4.24.2) dev: true @@ -1285,10 +1285,10 @@ packages: engines: { node: ">= 6" } dev: true - /caniuse-lite@1.0.30001678: + /caniuse-lite@1.0.30001680: resolution: { - integrity: sha512-RR+4U/05gNtps58PEBDZcPWTgEO2MBeoPZ96aQcjmfkBWRIDfN451fW2qyDA9/+HohLLIL5GqiMwA+IB1pWarw==, + integrity: sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==, } dev: true @@ -1414,10 +1414,10 @@ packages: } dev: true - /electron-to-chromium@1.5.52: + /electron-to-chromium@1.5.55: resolution: { - integrity: sha512-xtoijJTZ+qeucLBDNztDOuQBE1ksqjvNjvqFoST3nGC7fSpqJ+X6BdTBaY5BHG+IhWWmpc6b/KfpeuEDupEPOQ==, + integrity: sha512-6maZ2ASDOTBtjt9FhqYPRnbvKU5tjG0IN9SztUOWYw2AzNDNpKJYLJmlK0/En4Hs/aiWnB+JZ+gW19PIGszgKg==, } dev: true @@ -1927,7 +1927,7 @@ packages: engines: { node: ">= 6" } dev: true - /postcss-import@15.1.0(postcss@8.4.47): + /postcss-import@15.1.0(postcss@8.4.48): resolution: { integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==, @@ -1936,13 +1936,13 @@ packages: peerDependencies: postcss: ^8.0.0 dependencies: - postcss: 8.4.47 + postcss: 8.4.48 postcss-value-parser: 4.2.0 read-cache: 1.0.0 resolve: 1.22.8 dev: true - /postcss-js@4.0.1(postcss@8.4.47): + /postcss-js@4.0.1(postcss@8.4.48): resolution: { integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==, @@ -1952,10 +1952,10 @@ packages: postcss: ^8.4.21 dependencies: camelcase-css: 2.0.1 - postcss: 8.4.47 + postcss: 8.4.48 dev: true - /postcss-load-config@4.0.2(postcss@8.4.47): + /postcss-load-config@4.0.2(postcss@8.4.48): resolution: { integrity: sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==, @@ -1971,11 +1971,11 @@ packages: optional: true dependencies: lilconfig: 3.1.2 - postcss: 8.4.47 + postcss: 8.4.48 yaml: 2.6.0 dev: true - /postcss-nested@6.2.0(postcss@8.4.47): + /postcss-nested@6.2.0(postcss@8.4.48): resolution: { integrity: sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==, @@ -1984,7 +1984,7 @@ packages: peerDependencies: postcss: ^8.2.14 dependencies: - postcss: 8.4.47 + postcss: 8.4.48 postcss-selector-parser: 6.1.2 dev: true @@ -2006,10 +2006,10 @@ packages: } dev: true - /postcss@8.4.47: + /postcss@8.4.48: resolution: { - integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==, + integrity: sha512-GCRK8F6+Dl7xYniR5a4FYbpBzU8XnZVeowqsQFYdcXuSbChgiks7qybSkbvnaeqv0G0B+dd9/jJgH8kkLDQeEA==, } engines: { node: ^10 || ^12 || >=14 } dependencies: @@ -2115,34 +2115,34 @@ packages: engines: { iojs: ">=1.0.0", node: ">=0.10.0" } dev: true - /rollup@4.24.4: + /rollup@4.25.0: resolution: { - integrity: sha512-vGorVWIsWfX3xbcyAS+I047kFKapHYivmkaT63Smj77XwvLSJos6M1xGqZnBPFQFBRZDOcG1QnYEIxAvTr/HjA==, + integrity: sha512-uVbClXmR6wvx5R1M3Od4utyLUxrmOcEm3pAtMphn73Apq19PDtHpgZoEvqH2YnnaNUuvKmg2DgRd2Sqv+odyqg==, } engines: { node: ">=18.0.0", npm: ">=8.0.0" } hasBin: true dependencies: "@types/estree": 1.0.6 optionalDependencies: - "@rollup/rollup-android-arm-eabi": 4.24.4 - "@rollup/rollup-android-arm64": 4.24.4 - "@rollup/rollup-darwin-arm64": 4.24.4 - "@rollup/rollup-darwin-x64": 4.24.4 - "@rollup/rollup-freebsd-arm64": 4.24.4 - "@rollup/rollup-freebsd-x64": 4.24.4 - "@rollup/rollup-linux-arm-gnueabihf": 4.24.4 - "@rollup/rollup-linux-arm-musleabihf": 4.24.4 - "@rollup/rollup-linux-arm64-gnu": 4.24.4 - "@rollup/rollup-linux-arm64-musl": 4.24.4 - "@rollup/rollup-linux-powerpc64le-gnu": 4.24.4 - "@rollup/rollup-linux-riscv64-gnu": 4.24.4 - "@rollup/rollup-linux-s390x-gnu": 4.24.4 - "@rollup/rollup-linux-x64-gnu": 4.24.4 - "@rollup/rollup-linux-x64-musl": 4.24.4 - "@rollup/rollup-win32-arm64-msvc": 4.24.4 - "@rollup/rollup-win32-ia32-msvc": 4.24.4 - "@rollup/rollup-win32-x64-msvc": 4.24.4 + "@rollup/rollup-android-arm-eabi": 4.25.0 + "@rollup/rollup-android-arm64": 4.25.0 + "@rollup/rollup-darwin-arm64": 4.25.0 + "@rollup/rollup-darwin-x64": 4.25.0 + "@rollup/rollup-freebsd-arm64": 4.25.0 + "@rollup/rollup-freebsd-x64": 4.25.0 + "@rollup/rollup-linux-arm-gnueabihf": 4.25.0 + "@rollup/rollup-linux-arm-musleabihf": 4.25.0 + "@rollup/rollup-linux-arm64-gnu": 4.25.0 + "@rollup/rollup-linux-arm64-musl": 4.25.0 + "@rollup/rollup-linux-powerpc64le-gnu": 4.25.0 + "@rollup/rollup-linux-riscv64-gnu": 4.25.0 + "@rollup/rollup-linux-s390x-gnu": 4.25.0 + "@rollup/rollup-linux-x64-gnu": 4.25.0 + "@rollup/rollup-linux-x64-musl": 4.25.0 + "@rollup/rollup-win32-arm64-msvc": 4.25.0 + "@rollup/rollup-win32-ia32-msvc": 4.25.0 + "@rollup/rollup-win32-x64-msvc": 4.25.0 fsevents: 2.3.3 dev: true @@ -2304,11 +2304,11 @@ packages: normalize-path: 3.0.0 object-hash: 3.0.0 picocolors: 1.1.1 - postcss: 8.4.47 - postcss-import: 15.1.0(postcss@8.4.47) - postcss-js: 4.0.1(postcss@8.4.47) - postcss-load-config: 4.0.2(postcss@8.4.47) - postcss-nested: 6.2.0(postcss@8.4.47) + postcss: 8.4.48 + postcss-import: 15.1.0(postcss@8.4.48) + postcss-js: 4.0.1(postcss@8.4.48) + postcss-load-config: 4.0.2(postcss@8.4.48) + postcss-nested: 6.2.0(postcss@8.4.48) postcss-selector-parser: 6.1.2 resolve: 1.22.8 sucrase: 3.35.0 @@ -2382,10 +2382,10 @@ packages: } dev: true - /vite@5.4.10: + /vite@5.4.11: resolution: { - integrity: sha512-1hvaPshuPUtxeQ0hsVH3Mud0ZanOLwVTneA1EgbAM5LhaZEqyPWGRQ7BtaMvUrTDeEaC8pxtj6a6jku3x4z6SQ==, + integrity: sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==, } engines: { node: ^18.0.0 || >=20.0.0 } hasBin: true @@ -2417,8 +2417,8 @@ packages: optional: true dependencies: esbuild: 0.21.5 - postcss: 8.4.47 - rollup: 4.24.4 + postcss: 8.4.48 + rollup: 4.25.0 optionalDependencies: fsevents: 2.3.3 dev: true diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e87df61..a77e6fd 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1976,7 +1976,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "magnetar" -version = "0.0.8" +version = "0.0.9" dependencies = [ "reqwest", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2026c31..5e6b459 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "magnetar" -version = "0.0.8" +version = "0.0.9" description = "magnetar" authors = ["Bamboooz"] edition = "2021" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d5ff8dc..666572d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -27,10 +27,9 @@ fn main() { .plugin(tauri_plugin_dialog::init()) .setup(initialize) .invoke_handler(tauri::generate_handler![ - module::steam::fetch_steam_games, + module::steam::fetch_games, module::commands::fetch_commands, module::commands::execute_command, - util::string::file_name, util::update::latest_update, ]) .run(tauri::generate_context!()) diff --git a/src-tauri/src/module/steam.rs b/src-tauri/src/module/steam.rs index 2879749..63d545b 100644 --- a/src-tauri/src/module/steam.rs +++ b/src-tauri/src/module/steam.rs @@ -1,7 +1,7 @@ use std::error::Error; use winreg::{ + enums::{HKEY_CURRENT_USER, KEY_READ}, RegKey, - enums::{HKEY_CURRENT_USER, KEY_READ} }; #[derive(Debug, serde::Serialize)] @@ -41,7 +41,7 @@ fn fetch_steam_game(id: String) -> Option { } #[tauri::command] -pub async fn fetch_steam_games() -> Vec { +pub async fn fetch_games() -> Vec { let app_ids = match fetch_steam_app_ids() { Ok(ids) => ids, Err(_) => return Vec::new(), diff --git a/src-tauri/src/util/mod.rs b/src-tauri/src/util/mod.rs index 61120b9..d00bb5e 100644 --- a/src-tauri/src/util/mod.rs +++ b/src-tauri/src/util/mod.rs @@ -1,3 +1,2 @@ pub mod config; -pub mod string; pub mod update; diff --git a/src-tauri/src/util/string.rs b/src-tauri/src/util/string.rs deleted file mode 100644 index f22e086..0000000 --- a/src-tauri/src/util/string.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::path::Path; - -#[tauri::command] -pub fn file_name(path: &str) -> String { - let file_with_extension = Path::new(path).file_name().unwrap().to_str().unwrap(); - - file_with_extension.split('.').next().unwrap().to_string() -} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f875eac..6443695 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,26 +1,14 @@ { + "$schema": "https://schema.tauri.app/config/2", + "productName": "magnetar", + "version": "0.0.9", + "identifier": "net.bamboooz.magnetar", "build": { "beforeDevCommand": "pnpm dev", "beforeBuildCommand": "pnpm build", "frontendDist": "../dist", "devUrl": "http://localhost:1420" }, - "bundle": { - "active": true, - "targets": "all", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ] - }, - "productName": "magnetar", - "mainBinaryName": "magnetar", - "version": "0.0.8", - "identifier": "com.magnetar.dev", - "plugins": {}, "app": { "windows": [ { @@ -32,11 +20,24 @@ "decorations": false, "visible": false, "skipTaskbar": true, - "alwaysOnTop": true + "alwaysOnTop": true, + "transparent": true, + "shadow": false } ], "security": { "csp": "img-src 'self' asset: https://asset.localhost https://cdn.akamai.steamstatic.com; connect-src ipc: http://ipc.localhost" } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] } -} +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 8717c05..aa24773 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,14 +1,13 @@ -import React, { useState, lazy, Suspense } from "react"; +import React, { useState } from "react"; import Header from "./components/Header"; import Navigation from "./components/Navigation"; +import Home from "./components/Home"; +import Apps from "./components/Apps"; +import Games from "./components/Games"; +import Commands from "./components/Commands"; +import Settings from "./components/Settings"; import { PageType } from "./types"; -const Home = lazy(() => import("./components/Home")); -const Apps = lazy(() => import("./components/Apps")); -const Games = lazy(() => import("./components/Games")); -const Commands = lazy(() => import("./components/Commands")); -const Settings = lazy(() => import("./components/Settings")); - const App: React.FC = () => { const [page, setPage] = useState(PageType.HOME); const [search, setSearch] = useState(""); @@ -22,13 +21,16 @@ const App: React.FC = () => { search={search} setSearch={setSearch} /> - - - - - - - + + + + + + + + + + ); }; diff --git a/src/components/Apps/AppItemContext.tsx b/src/components/Apps/AppItemContext.tsx index d6b2262..e01a283 100644 --- a/src/components/Apps/AppItemContext.tsx +++ b/src/components/Apps/AppItemContext.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { LuFolder, LuPlay, LuTrash } from "react-icons/lu"; import Context from "../common/Context"; import ContextButton from "../common/ContextButton"; @@ -22,24 +21,9 @@ const AppItemContext: React.FC = ({ }) => { return ( - } - className="text-neutral-400 hover:text-neutral-300" - onClick={openApp} - /> - } - className="text-neutral-400 hover:text-neutral-300" - onClick={openInExplorer} - /> - } - className="text-red-500 hover:text-red-400" - onClick={removeApp} - /> + + + ); }; diff --git a/src/components/Apps/index.tsx b/src/components/Apps/index.tsx index 27d6c9a..a58c8e1 100644 --- a/src/components/Apps/index.tsx +++ b/src/components/Apps/index.tsx @@ -1,13 +1,13 @@ -import React, { useState } from "react"; +import React from "react"; import { open } from "@tauri-apps/plugin-dialog"; import { getCurrentWindow } from "@tauri-apps/api/window"; -import { invoke } from "@tauri-apps/api/core"; import { LuPlus } from "react-icons/lu"; -import Page from "../common/Page"; -import { PageType, App } from "../../types"; +import { App, PageType } from "../../types"; import Expander from "../common/Expander"; import AppItem from "./AppItem"; import Item from "../common/Item"; +import { useStickyState } from "../../hooks/useStickyState"; +import Page from "../common/Page"; interface AppsProps { page: PageType; @@ -15,8 +15,7 @@ interface AppsProps { } const Apps: React.FC = ({ page, search }) => { - const foundApps = localStorage.getItem("apps") || "[]"; - const [apps, setApps] = useState(JSON.parse(foundApps)); + const [apps, setApps] = useStickyState("apps", []); const appWindow = getCurrentWindow(); @@ -37,19 +36,16 @@ const Apps: React.FC = ({ page, search }) => { if (!paths) return; - const addedApps = await Promise.all( - paths.map(async (path) => { - const label = (await invoke("file_name", { - path, - })) as string; - return { label, path }; - }) - ); - setApps((prev) => { - const newApps = [...prev, ...addedApps]; - localStorage.setItem("apps", JSON.stringify(newApps)); - return newApps; + const newApps = paths + .filter((path) => !prev.some((app) => app.path === path)) + .map((path) => { + const file = path.split(/(\\|\/)/g).pop()!; + const label = file.replace(/\.[^/.]+$/, ""); + return { label, path }; + }); + + return [...prev, ...newApps]; }); appWindow.show(); @@ -57,7 +53,7 @@ const Apps: React.FC = ({ page, search }) => { }; return ( - + } title="Add a new app" @@ -68,7 +64,7 @@ const Apps: React.FC = ({ page, search }) => { {filteredApps.length !== 0 ? ( {filteredApps.map((app) => ( - + ))} ) : ( diff --git a/src/components/Commands/CommandItemContext.tsx b/src/components/Commands/CommandItemContext.tsx index 46872ed..4d1adda 100644 --- a/src/components/Commands/CommandItemContext.tsx +++ b/src/components/Commands/CommandItemContext.tsx @@ -1,6 +1,4 @@ import React from "react"; -import { LuPlay } from "react-icons/lu"; -import { MdOutlineAdminPanelSettings } from "react-icons/md"; import Context from "../common/Context"; import ContextButton from "../common/ContextButton"; @@ -19,18 +17,8 @@ const CommandItemContext: React.FC = ({ }) => { return ( - } - className="text-neutral-400 hover:text-neutral-300" - onClick={() => execute(false)} - /> - } - className="text-neutral-400 hover:text-neutral-300" - onClick={() => execute(true)} - /> + execute(false)} /> + execute(true)} /> ); }; diff --git a/src/components/Commands/index.tsx b/src/components/Commands/index.tsx index 07b1623..b7c4265 100644 --- a/src/components/Commands/index.tsx +++ b/src/components/Commands/index.tsx @@ -1,10 +1,9 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { invoke } from "@tauri-apps/api/core"; -import Page from "../common/Page"; import Expander from "../common/Expander"; import CommandItem from "./CommandItem"; -import { PageType, CommandList } from "../../types"; -import { useMount } from "../../hooks/useMount"; +import { CommandList, PageType } from "../../types"; +import Page from "../common/Page"; interface HomeProps { page: PageType; @@ -23,15 +22,15 @@ const Commands: React.FC = ({ page, search }) => { })) .filter((group) => group.commands.length > 0); - useMount(async () => { - await invoke("fetch_commands").then((commands) => { + useEffect(() => { + invoke("fetch_commands").then((commands) => { const commandsJson = JSON.parse(commands as string) as CommandList; setCommands(commandsJson); }); - }); + }, []); return ( - + {filteredCommandGroups.length !== 0 ? ( filteredCommandGroups.map((group) => ( diff --git a/src/components/Games/GameItem.tsx b/src/components/Games/GameItem.tsx index d52f888..176da2d 100644 --- a/src/components/Games/GameItem.tsx +++ b/src/components/Games/GameItem.tsx @@ -44,7 +44,13 @@ const GameItem: React.FC = ({ game }) => { {valid && ( <> setValid(false)} className="h-[44px] rounded-sm" />} + icon={ + setValid(false)} + className="h-[44px] rounded-sm" + /> + } title={game.name} description={`steam://rungameid/${game.id}`} onClick={openGame} diff --git a/src/components/Games/GameItemContext.tsx b/src/components/Games/GameItemContext.tsx index dc66cde..eefc0e5 100644 --- a/src/components/Games/GameItemContext.tsx +++ b/src/components/Games/GameItemContext.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { LuExternalLink, LuPlay } from "react-icons/lu"; import Context from "../common/Context"; import ContextButton from "../common/ContextButton"; @@ -23,17 +22,10 @@ const GameItemContext: React.FC = ({ return ( } - className="text-neutral-400 hover:text-neutral-300" + label={installed ? "Play" : "Install"} onClick={playGame} /> - } - className="text-neutral-400 hover:text-neutral-300" - onClick={openGamePage} - /> + ); }; diff --git a/src/components/Games/index.tsx b/src/components/Games/index.tsx index 6e105a9..85c92fd 100644 --- a/src/components/Games/index.tsx +++ b/src/components/Games/index.tsx @@ -1,13 +1,12 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { invoke } from "@tauri-apps/api/core"; import { FaSteam } from "react-icons/fa"; -import Page from "../common/Page"; import Expander from "../common/Expander"; -import { PageType, Game } from "../../types"; -import { useMount } from "../../hooks/useMount"; +import { Game, PageType } from "../../types"; import GameItem from "./GameItem"; import { executeCommand } from "../../utils/cmd"; import Item from "../common/Item"; +import Page from "../common/Page"; interface GamesProps { page: PageType; @@ -29,14 +28,12 @@ const Games: React.FC = ({ page, search }) => { const closeSteam = async () => await executeCommand("start steam://exit", false); - useMount(async () => { - await invoke("fetch_steam_games").then((games) => - setGames(games as Game[]) - ); - }); + useEffect(() => { + invoke("fetch_games").then((games) => setGames(games as Game[])); + }, []); return ( - + } diff --git a/src/components/Home/HomeUpdatePanel.tsx b/src/components/Home/HomeUpdatePanel.tsx index cc6671b..a520e98 100644 --- a/src/components/Home/HomeUpdatePanel.tsx +++ b/src/components/Home/HomeUpdatePanel.tsx @@ -1,25 +1,28 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { open } from "@tauri-apps/plugin-shell"; import { invoke } from "@tauri-apps/api/core"; import { getVersion } from "@tauri-apps/api/app"; -import { useMount } from "../../hooks/useMount"; const HomeUpdatePanel: React.FC = () => { const [latestUpdate, setLatestUpdate] = useState(""); const [updateAvailable, setUpdateAvailable] = useState(false); - useMount(async () => { - try { - const update = (await invoke("latest_update")) as string; - const currentVersion = await getVersion(); - const available = currentVersion !== update; + useEffect(() => { + const fetchUpdate = async () => { + try { + const update = (await invoke("latest_update")) as string; + const currentVersion = await getVersion(); + const available = currentVersion !== update; - setLatestUpdate(update); - setUpdateAvailable(available); - } catch (error) { - console.error(error); - } - }); + setLatestUpdate(update); + setUpdateAvailable(available); + } catch (error) { + console.error(error); + } + }; + + fetchUpdate(); + }, []); return ( <> diff --git a/src/components/Home/index.tsx b/src/components/Home/index.tsx index ca32b94..4e6579f 100644 --- a/src/components/Home/index.tsx +++ b/src/components/Home/index.tsx @@ -13,7 +13,11 @@ interface HomeProps { const Home: React.FC = ({ page }) => { return ( - +
logo diff --git a/src/components/Settings/index.tsx b/src/components/Settings/index.tsx index 76e4acc..fd90ab4 100644 --- a/src/components/Settings/index.tsx +++ b/src/components/Settings/index.tsx @@ -1,9 +1,9 @@ import React from "react"; import { LuLanguages, LuPaintbrush, LuPlay } from "react-icons/lu"; -import Page from "../common/Page"; import Expander from "../common/Expander"; import SettingsItem from "./SettingsItem"; import { PageType } from "../../types"; +import Page from "../common/Page"; interface SettingsProps { page: PageType; @@ -11,7 +11,7 @@ interface SettingsProps { const Settings: React.FC = ({ page }) => { return ( - + } diff --git a/src/components/common/Context.tsx b/src/components/common/Context.tsx index 1f2e178..ef82fa1 100644 --- a/src/components/common/Context.tsx +++ b/src/components/common/Context.tsx @@ -52,7 +52,7 @@ const Context: React.FC = ({
diff --git a/src/components/common/ContextButton.tsx b/src/components/common/ContextButton.tsx index 6f8822f..4af61cb 100644 --- a/src/components/common/ContextButton.tsx +++ b/src/components/common/ContextButton.tsx @@ -1,29 +1,17 @@ import React from "react"; -import { cn } from "../../utils/cn"; interface ContextButtonProps { - title: string; - icon: React.ReactNode; + label: string; onClick: () => void; - className: string; } -const ContextButton: React.FC = ({ - title, - icon, - onClick, - className, -}) => { +const ContextButton: React.FC = ({ label, onClick }) => { return ( ); }; diff --git a/src/components/common/Item.tsx b/src/components/common/Item.tsx index 11ed643..bbac392 100644 --- a/src/components/common/Item.tsx +++ b/src/components/common/Item.tsx @@ -23,10 +23,10 @@ const Item: React.FC = ({ onContextMenu={onContextMenu} className="w-full h-14 flex justify-between items-center px-6 hover:bg-secondary" > -
-
{icon}
+
+
{icon}
-
+

{title}

{description}

diff --git a/src/components/common/Page.tsx b/src/components/common/Page.tsx index f9dffff..4277653 100644 --- a/src/components/common/Page.tsx +++ b/src/components/common/Page.tsx @@ -3,18 +3,23 @@ import { PageType } from "../../types"; import { cn } from "../../utils/cn"; interface PageProps { - id: PageType; - page: PageType; + target: PageType; + current: PageType; className?: string; children?: React.ReactNode; } -const Page: React.FC = ({ id, page, className, children }) => { +const Page: React.FC = ({ + target, + current, + className, + children, +}) => { return (
{children} diff --git a/src/hooks/useMount.ts b/src/hooks/useMount.ts deleted file mode 100644 index 206e2bd..0000000 --- a/src/hooks/useMount.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { useEffect } from "react"; - -type Callback = () => void | Promise; - -const useMount = (callback: Callback) => { - useEffect(() => { - callback(); - }, []); -}; - -export { useMount }; diff --git a/src/hooks/useStickyState.ts b/src/hooks/useStickyState.ts new file mode 100644 index 0000000..6882355 --- /dev/null +++ b/src/hooks/useStickyState.ts @@ -0,0 +1,20 @@ +import { useState, useEffect } from "react"; + +const useStickyState = ( + key: string, + defaultValue: T +): [T, React.Dispatch>] => { + const [value, setValue] = useState(() => { + const stickyValue = window.localStorage.getItem(key); + + return stickyValue !== null ? JSON.parse(stickyValue) : defaultValue; + }); + + useEffect(() => { + window.localStorage.setItem(key, JSON.stringify(value)); + }, [key, value]); + + return [value, setValue]; +}; + +export { useStickyState }; diff --git a/src/utils/storage.ts b/src/utils/storage.ts deleted file mode 100644 index 9e0897d..0000000 --- a/src/utils/storage.ts +++ /dev/null @@ -1,33 +0,0 @@ -const APPS_KEY = "apps"; -const THEME_KEY = "theme"; -const LANGUAGE_KEY = "language"; - -const getStorage = (key: string) => { - return window.localStorage.getItem(key); -}; - -const setStorage = (key: string, value: any) => { - window.localStorage.setItem(key, value); -}; - -const getStorageJson = (key: string) => { - try { - return JSON.parse(window.localStorage.getItem(key)!); - } catch (_) { - return null; - } -}; - -const setStorageJson = (key: string, value: Object) => { - window.localStorage.setItem(key, JSON.stringify(value)); -}; - -export { - APPS_KEY, - THEME_KEY, - LANGUAGE_KEY, - getStorage, - setStorage, - getStorageJson, - setStorageJson, -}; diff --git a/tailwind.config.js b/tailwind.config.js index 076acaa..5ae7d10 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,9 +4,9 @@ export default { theme: { extend: { colors: { - primary: "#161a1f", - secondary: "#20252b", - tertiary: "#394147", + primary: "#0d0f12", + secondary: "#171a1e", + tertiary: "#30363a", accent: "#5066ef", }, fontSize: {