diff --git a/electron-builder.yml b/electron-builder.yml index 495b57b..7ec547c 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -25,7 +25,7 @@ win: extraFiles: - from: "./resources/iconTemplate.png" to: "Resources" - - from: "./resources/index.html" + - from: "./resources/dist" to: "Resources" - from: "./resources/frpc/win/${arch}/frpc.exe" to: "Resources" @@ -53,10 +53,11 @@ mac: extraFiles: - from: "./resources/iconTemplate.png" to: "Resources" - - from: "./resources/index.html" - to: "Resources" - from: "./resources/frpc/mac/${arch}/frpc" to: "Resources" + extraResources: + - from: "./resources/dist" + to: "dist" dmg: artifactName: ${name}-${version}-${arch}.${ext} npmRebuild: false diff --git a/package-lock.json b/package-lock.json index 9581def..83f2952 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "dependencies": { "@electron-toolkit/preload": "^3.0.0", "@electron-toolkit/utils": "^3.0.0", + "@fastify/compress": "^8.0.1", + "@fastify/static": "^8.0.2", "@hookform/resolvers": "^3.4.2", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.1.1", @@ -1349,6 +1351,11 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fastify/accept-negotiator": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/@fastify/accept-negotiator/-/accept-negotiator-2.0.0.tgz", + "integrity": "sha512-/Sce/kBzuTxIq5tJh85nVNOq9wKD8s+viIgX0fFMDBdw95gnpf53qmF1oBgJym3cPFliWUuSloVg/1w/rH0FcQ==" + }, "node_modules/@fastify/ajv-compiler": { "version": "4.0.1", "resolved": "https://registry.npmmirror.com/@fastify/ajv-compiler/-/ajv-compiler-4.0.1.tgz", @@ -1379,6 +1386,75 @@ "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, + "node_modules/@fastify/compress": { + "version": "8.0.1", + "resolved": "https://registry.npmmirror.com/@fastify/compress/-/compress-8.0.1.tgz", + "integrity": "sha512-yWNfKhvL4orfN45LKCHCo8Fcsbj1kdNgwyShw2xpdHfzPf4A3MESmgSfUm3TCKQwgqDdrPnLfy1E+3I/DVP+BQ==", + "dependencies": { + "@fastify/accept-negotiator": "^2.0.0", + "fastify-plugin": "^5.0.0", + "mime-db": "^1.52.0", + "minipass": "^7.0.4", + "peek-stream": "^1.1.3", + "pump": "^3.0.0", + "pumpify": "^2.0.1", + "readable-stream": "^4.5.2" + } + }, + "node_modules/@fastify/compress/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@fastify/compress/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmmirror.com/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/@fastify/compress/node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@fastify/compress/node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, "node_modules/@fastify/error": { "version": "4.0.0", "resolved": "https://registry.npmmirror.com/@fastify/error/-/error-4.0.0.tgz", @@ -1400,6 +1476,123 @@ "fast-deep-equal": "^3.1.3" } }, + "node_modules/@fastify/send": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/@fastify/send/-/send-3.1.1.tgz", + "integrity": "sha512-LdiV2mle/2tH8vh6GwGl0ubfUAgvY+9yF9oGI1iiwVyNUVOQamvw5n+OFu6iCNNoyuCY80FFURBn4TZCbTe8LA==", + "dependencies": { + "@lukeed/ms": "^2.0.2", + "escape-html": "~1.0.3", + "fast-decode-uri-component": "^1.0.1", + "http-errors": "^2.0.0", + "mime": "^3" + } + }, + "node_modules/@fastify/send/node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@fastify/static": { + "version": "8.0.2", + "resolved": "https://registry.npmmirror.com/@fastify/static/-/static-8.0.2.tgz", + "integrity": "sha512-xJ+XaZVl4Y+lKztx8jGi+BE73aByhOmjMgaTx98E4XtVZxUpiaYQIMBlwACsJz+xohm0kvzV34BZoiZ+bsJtBQ==", + "dependencies": { + "@fastify/accept-negotiator": "^2.0.0", + "@fastify/send": "^3.1.0", + "content-disposition": "^0.5.4", + "fastify-plugin": "^5.0.0", + "fastq": "^1.17.1", + "glob": "^11.0.0" + } + }, + "node_modules/@fastify/static/node_modules/glob": { + "version": "11.0.0", + "resolved": "https://registry.npmmirror.com/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@fastify/static/node_modules/jackspeak": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@fastify/static/node_modules/lru-cache": { + "version": "11.0.2", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-11.0.2.tgz", + "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@fastify/static/node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@fastify/static/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmmirror.com/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/@fastify/static/node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@floating-ui/core": { "version": "1.6.8", "resolved": "https://registry.npmmirror.com/@floating-ui/core/-/core-1.6.8.tgz", @@ -1656,6 +1849,14 @@ "node": ">=10" } }, + "node_modules/@lukeed/ms": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/@lukeed/ms/-/ms-2.0.2.tgz", + "integrity": "sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==", + "engines": { + "node": ">=8" + } + }, "node_modules/@malept/cross-spawn-promise": { "version": "1.1.1", "resolved": "https://registry.npmmirror.com/@malept/cross-spawn-promise/-/cross-spawn-promise-1.1.1.tgz", @@ -3325,6 +3526,17 @@ "integrity": "sha512-ukTPVhqG4jNzMro2qA9HSCSSVJN3aN7tlb+hfqYCt3ER0yWroeA2VR38MNrOHLQ/cVj+DaIMad0kFCtWWowh/A==", "dev": true }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/abstract-logging": { "version": "2.0.1", "resolved": "https://registry.npmmirror.com/abstract-logging/-/abstract-logging-2.0.1.tgz", @@ -4075,8 +4287,7 @@ "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, "node_modules/builder-util": { "version": "24.8.1", @@ -4994,6 +5205,14 @@ "node": ">=0.4.0" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/destr": { "version": "2.0.3", "resolved": "https://registry.npmmirror.com/destr/-/destr-2.0.3.tgz", @@ -5199,6 +5418,17 @@ "resolved": "https://registry.npmmirror.com/duplexer3/-/duplexer3-0.1.5.tgz", "integrity": "sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA==" }, + "node_modules/duplexify": { + "version": "3.7.1", + "resolved": "https://registry.npmmirror.com/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", + "dependencies": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmmirror.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -5700,6 +5930,11 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -6033,6 +6268,22 @@ "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmmirror.com/execa/-/execa-5.1.1.tgz", @@ -6293,6 +6544,11 @@ "toad-cache": "^3.7.0" } }, + "node_modules/fastify-plugin": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/fastify-plugin/-/fastify-plugin-5.0.1.tgz", + "integrity": "sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==" + }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmmirror.com/fastq/-/fastq-1.17.1.tgz", @@ -7071,6 +7327,21 @@ "resolved": "https://registry.npmmirror.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==" }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/http-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmmirror.com/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", @@ -8886,6 +9157,16 @@ "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", "dev": true }, + "node_modules/peek-stream": { + "version": "1.1.3", + "resolved": "https://registry.npmmirror.com/peek-stream/-/peek-stream-1.1.3.tgz", + "integrity": "sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==", + "dependencies": { + "buffer-from": "^1.0.0", + "duplexify": "^3.5.0", + "through2": "^2.0.3" + } + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmmirror.com/pend/-/pend-1.2.0.tgz", @@ -9240,6 +9521,14 @@ "node": ">=6.0.0" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmmirror.com/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmmirror.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -9321,6 +9610,40 @@ "once": "^1.3.1" } }, + "node_modules/pumpify": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/pumpify/-/pumpify-2.0.1.tgz", + "integrity": "sha512-m7KOje7jZxrmutanlkS1daj1dS6z6BgslzOXmcSEpIlCxM3VJH7lG5QLeck/6hgF6F4crFf01UtQmNsJfweTAw==", + "dependencies": { + "duplexify": "^4.1.1", + "inherits": "^2.0.3", + "pump": "^3.0.0" + } + }, + "node_modules/pumpify/node_modules/duplexify": { + "version": "4.1.3", + "resolved": "https://registry.npmmirror.com/duplexify/-/duplexify-4.1.3.tgz", + "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", + "dependencies": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.2" + } + }, + "node_modules/pumpify/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmmirror.com/punycode/-/punycode-2.3.1.tgz", @@ -10107,6 +10430,11 @@ "node": ">=6.9" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", @@ -10332,6 +10660,19 @@ "node": ">= 6" } }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/stream-shift": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==" + }, "node_modules/strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmmirror.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -10904,6 +11245,15 @@ "resolved": "https://registry.npmmirror.com/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, + "node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, "node_modules/timed-out": { "version": "4.0.1", "resolved": "https://registry.npmmirror.com/timed-out/-/timed-out-4.0.1.tgz", @@ -11003,6 +11353,14 @@ "resolved": "https://registry.npmmirror.com/toggle-selection/-/toggle-selection-1.0.6.tgz", "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/trim-repeated": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/trim-repeated/-/trim-repeated-1.0.0.tgz", diff --git a/package.json b/package.json index c36bf40..3ee3992 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "dependencies": { "@electron-toolkit/preload": "^3.0.0", "@electron-toolkit/utils": "^3.0.0", + "@fastify/compress": "^8.0.1", + "@fastify/static": "^8.0.2", "@hookform/resolvers": "^3.4.2", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.1.1", diff --git a/resources/index.html b/resources/index.html deleted file mode 100644 index d7cb5c3..0000000 --- a/resources/index.html +++ /dev/null @@ -1,815 +0,0 @@ - - - - - - - - - - - - Fideo Web Control - - - - - - - - -
- - -
-
-
-

{{ streamConfig.title }}

-
- - - - - -
-
- {{ streamConfig.roomUrl }} - -
- -
-
-
{{ ffmpegProgressInfo[streamConfig.id].timemark }}
-
- {{ ffmpegProgressInfo[streamConfig.id].targetSize / 1024 + 'M' }} -
-
-
-
- - - -
-
-
×
-

- {{ activeStreamConfig.type === 'create' ? '创建' : '编辑' }} -

- -
-
-
- - -
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
-
- - -
-
- -
-
-
-
-
- -
-
-
×
-
{{ dialogObj.title }}
-
{{ dialogObj.description }}
- -
-
-
- - - - diff --git a/src/main/frpc/index.ts b/src/main/frpc/index.ts index 4308c1b..94d20b7 100644 --- a/src/main/frpc/index.ts +++ b/src/main/frpc/index.ts @@ -6,6 +6,9 @@ import type { ChildProcess } from 'node:child_process' import { app, BrowserWindow } from 'electron' import { is } from '@electron-toolkit/utils' import Fastify from 'fastify' +import fastifyStatic from '@fastify/static' +import fastifyCompress from '@fastify/compress' + import WebSocket from 'ws' import spawn from 'cross-spawn' import { FRP_DOMAIN, FRPC_PROCESS_ERROR, WEBSOCKET_MESSAGE_TYPE } from '../../const' @@ -41,18 +44,36 @@ async function startFrpcLocalServer( const fastify = Fastify() + fastify.register(fastifyCompress, { + global: true + }) + + fastify.register(fastifyStatic, { + root: is.dev ? join(__dirname, '../../resources/dist') : join(process.resourcesPath, 'dist'), + prefix: `/${code}/`, + // serve: false, + setHeaders: (res, path) => { + console.log('path: ', path) + if (path.endsWith('.js') || path.endsWith('.css')) { + res.setHeader('Cache-Control', 'public, max-age=31536000, immutable') + } + } + }) + fastify.get(`/${code}`, async (_, reply) => { const filePath = is.dev - ? join(__dirname, '../../resources/index.html') - : join(process.resourcesPath, 'index.html') + ? join(__dirname, '../../resources/dist/index.html') + : join(process.resourcesPath, 'dist/index.html') try { const htmlContent = (await fsp.readFile(filePath, 'utf-8')) .toString() .replace( - '$$WEBSOCKET_URL$$', - !is.dev ? `ws://localhost:${port}` : `wss://${FRP_DOMAIN}/${code}` + '__WEBSOCKET_URL__', + // is.dev ? `ws://localhost:${port}` : `wss://${FRP_DOMAIN}/${code}` + `"wss://${FRP_DOMAIN}/${code}"` ) + .replaceAll('__WEB_CONTROL_CODE__', code) reply.code(200).header('Content-Type', 'text/html').send(htmlContent) } catch (err) { @@ -109,6 +130,9 @@ async function startFrpcLocalServer( ) break case WEBSOCKET_MESSAGE_TYPE.ADD_STREAM_CONFIG: + if (!data.directory) { + data.directory = app.getPath('desktop') + } streamConfigList.unshift(data as IStreamConfig) break } @@ -194,7 +218,11 @@ export async function startFrpcProcess( writeLog('frpc', 'frpcConfigPath: ' + frpcConfigPath) - const frpcPath = isMac ? join(process.resourcesPath, 'frpc') : join(process.resourcesPath, 'frpc.exe') + const frpcPath = is.dev + ? join(__dirname, '../../resources/frpc/mac/arm64/frpc') + : isMac + ? join(process.resourcesPath, 'frpc') + : join(process.resourcesPath, 'frpc.exe') const frpcProcess = spawn(frpcPath, ['-c', frpcConfigPath]) @@ -232,7 +260,7 @@ export async function startFrpcProcess( stopFrpcLocalServer() clearInterval(frpcProcessTimer) } - }, 3000) + }, 5000) frpcObj = { frpcProcess, diff --git a/src/main/index.ts b/src/main/index.ts index cf15851..bd057b2 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -264,7 +264,6 @@ app.whenReady().then(async () => { app.on('browser-window-created', (_, window) => { optimizer.watchWindowShortcuts(window) }) - ipcMain.handle(SELECT_DIR, async () => { const dir = await dialog.showOpenDialog({ properties: ['openDirectory'] diff --git a/src/renderer/src/components/NavBar/components/WebControlSettingSheet.tsx b/src/renderer/src/components/NavBar/components/WebControlSettingSheet.tsx index 229c326..efce192 100644 --- a/src/renderer/src/components/NavBar/components/WebControlSettingSheet.tsx +++ b/src/renderer/src/components/NavBar/components/WebControlSettingSheet.tsx @@ -70,21 +70,24 @@ export default function WebControlSettingSheet(props: StreamConfigSheetProps) { }) useEffect(() => { - async function handleStartWebControl(webControlPath: string, timeout = 1000 * 10) { - setWebControlSetting({ ...form.getValues(), enableWebControl: true }) + async function handleStartWebControl(timeout = 0) { + const currentWebControlSetting = useWebControlSettingStore.getState().webControlSetting + await setWebControlSetting({ ...currentWebControlSetting, enableWebControl: true }) + const webControlPath = currentWebControlSetting.webControlPath const isSuccess = await startFrpc(webControlPath).catch(() => false) if (!isSuccess) { - setWebControlSetting({ ...form.getValues(), enableWebControl: false }) + await setWebControlSetting({ ...currentWebControlSetting, enableWebControl: false }) toast({ title: t('web_control_setting.start_web_control_failed'), - description: t('web_control_setting.will_retry', { time: timeout / 1000 }), + description: t('web_control_setting.will_retry', { time: (timeout + 1000 * 10) / 1000 }), variant: 'destructive' }) setTimeout(() => { - const currentEnableWebControl = useWebControlSettingStore.getState().webControlSetting.enableWebControl - if (!currentEnableWebControl) { - handleStartWebControl(webControlPath, timeout + 1000 * 10) + const { enableWebControl, webControlPath } = + useWebControlSettingStore.getState().webControlSetting + if (!enableWebControl && webControlPath) { + handleStartWebControl(timeout + 1000 * 10) } }, timeout) } @@ -94,20 +97,21 @@ export default function WebControlSettingSheet(props: StreamConfigSheetProps) { return () => { emitter.off(START_WEB_CONTROL, handleStartWebControl as any) } - }, []) + }, [useWebControlSettingStore]) useEffect(() => { form.reset({ ...webControlSetting }) }, [webControlSetting]) useEffect(() => { - window.api.onFrpcProcessError((err) => { + window.api.onFrpcProcessError(async (err) => { + const currentWebControlSetting = useWebControlSettingStore.getState().webControlSetting toast({ title: t('web_control_setting.frpc_process_error'), description: err, variant: 'destructive' }) - setWebControlSetting({ ...form.getValues(), enableWebControl: false }) + await setWebControlSetting({ ...currentWebControlSetting, enableWebControl: false }) closeWebSocket() }) }, []) @@ -115,7 +119,7 @@ export default function WebControlSettingSheet(props: StreamConfigSheetProps) { const handleSetSheetOpen = async (status: boolean, trigger = false) => { const formValues = form.getValues() as IWebControlSetting if (trigger) { - setWebControlSetting(formValues) + await setWebControlSetting(formValues) } setQrcode('') @@ -148,10 +152,10 @@ export default function WebControlSettingSheet(props: StreamConfigSheetProps) { }).then((res) => { res .json() - .then(({ code, data: webControlPath }) => { + .then(async ({ code, data: webControlPath }) => { if (code === 200) { form.setValue('webControlPath', webControlPath) - setWebControlSetting(form.getValues()) + await setWebControlSetting(form.getValues()) setDialogOpen(false) setShowConfetti(true) toast({ @@ -345,6 +349,7 @@ export default function WebControlSettingSheet(props: StreamConfigSheetProps) { window.api.stopFrpcProcess() closeWebSocket() field.onChange(status) + setWebControlSetting({ ...form.getValues() }) toast({ title: t('web_control_setting.stop_web_control_success'), diff --git a/src/renderer/src/store/useDefaultSettingsStore.ts b/src/renderer/src/store/useDefaultSettingsStore.ts index 6d0e84b..a06eae0 100644 --- a/src/renderer/src/store/useDefaultSettingsStore.ts +++ b/src/renderer/src/store/useDefaultSettingsStore.ts @@ -8,7 +8,7 @@ interface IDefaultSettingsStore { } export const useDefaultSettingsStore = create((set) => ({ - defaultSettingsConfig: { directory: '', lang: 'en', xizhiKey: '' }, + defaultSettingsConfig: { directory: '', lang: 'cn', xizhiKey: '' }, initData: async () => { const defaultSettingsConfig = await localForage.getItem('defaultSettingsConfig') diff --git a/src/renderer/src/store/useWebControlSettingStore.ts b/src/renderer/src/store/useWebControlSettingStore.ts index 9605281..e54b7e5 100644 --- a/src/renderer/src/store/useWebControlSettingStore.ts +++ b/src/renderer/src/store/useWebControlSettingStore.ts @@ -20,11 +20,11 @@ export const useWebControlSettingStore = create((set) = const webControlSetting = await localForage.getItem('webControlSetting') if (webControlSetting) { + set(() => ({ webControlSetting })) const { enableWebControl, webControlPath } = webControlSetting if (enableWebControl && webControlPath) { - emitter.emit(START_WEB_CONTROL, webControlPath) + emitter.emit(START_WEB_CONTROL) } - set(() => ({ webControlSetting })) } }, setWebControlSetting: async (setting: IWebControlSetting) => {