diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 4df34da..ef3fad8 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -22,7 +22,7 @@ body: label: 前置阅读 | Pre-reading description: 我已经自行查找、阅读以下内容(阅读了请打勾) | I have searched and read the following on my own (Please tick after reading) options: - - label: "[文档/Doc](https://picgo.github.io/PicGo-Doc/)" + - label: "[文档/Doc](https://docs.picgo.app/gui/)" required: true - label: "[Issues](https://github.com/Molunerfinn/PicGo/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aclosed)" required: true @@ -60,4 +60,4 @@ body: 最后,喜欢 PicGo 的话不妨给它点个 star~ 如果可以的话,请我喝杯咖啡?首页有赞助二维码,谢谢你的支持! Finally, if you like PicGo, give it a star~ - Buy me a cup of coffee if you can? There is a sponsorship QR code on the homepage, thank you for your support! \ No newline at end of file + Buy me a cup of coffee if you can? There is a sponsorship QR code on the homepage, thank you for your support! diff --git a/.gitignore b/.gitignore index dd13f3e..aadc1a3 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ test.js specs/ .cache/ openspec/ +bug* \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index c4ee24b..4bf56a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,12 +12,20 @@ PicGo is an Electron + Vue 3 desktop client. Source lives in `src/`: `src/main` - `pnpm lint` / `pnpm lint:fix` — run or auto-fix ESLint (Standard, TypeScript, Vue rules). - `pnpm lint:dpdm` — fail fast on circular dependencies in `src/`. - `pnpm check` — run `tsc` + `lint` (run once before finishing a task). +- Before completing a task, always run `pnpm check` and resolve any issues it reports. - `pnpm gen-i18n` — regenerate typed locales after touching `public/i18n/*.yml`. ## Coding Style & Naming Conventions Follow ESLint Standard defaults: two-space indentation, single quotes, trailing commas where allowed, and no stray semicolons. Author new modules in TypeScript. Keep renderer files browser-safe; route Node APIs through IPC helpers such as `src/main/events/picgoCoreIPC.ts`. Name Vue components in PascalCase (`UploadPanel.vue`) and use camelCase for utilities. Centralize IPC event names inside `src/universal/events/constants.ts`, and store enums/types under `src/universal/types/` so they stay reusable. Static assets are served from `public/` and resolved via `getStaticPath`/`getStaticFileUrl` (`src/universal/utils/staticPath.ts`); avoid using `__static` directly. Static assets are served from `public/`. In the main process use `getStaticPath`/`getStaticFileUrl` (`src/universal/utils/staticPath.ts`). In the renderer, place assets under `public/` and resolve them via `import.meta.env.BASE_URL + filename` (helper: `src/renderer/utils/static.ts`); do not rely on `__static` in renderer code. - Do not use `as any` under any circumstances; keep typings explicit and safe. +- Avoid `as any` in tests as well; build concrete typed stubs (e.g., `IpcMainInvokeEvent`) instead. +- Do not prefix method calls with `void` (e.g. use `store?.refreshPicBeds()` rather than `void store?.refreshPicBeds()`). +- If a renderer → main request mutates persisted config/state without using `saveConfig`, call `notifyAppConfigUpdated()` in main to inform renderers. +- Prefer enums over union types for discrete value sets (e.g., encryption methods). Avoid introducing new string literal union types. +- Renderer page/component styles should prefer Tailwind utility classes; avoid adding new Vue ` diff --git a/docs/main.js b/docs/main.js deleted file mode 100644 index 903e5e1..0000000 --- a/docs/main.js +++ /dev/null @@ -1,10 +0,0 @@ -import Vue from 'vue' -import App from './APP.vue' -import 'melody.css' -import axios from 'axios' - -Vue.prototype.$http = axios - -new Vue({ - render: h => h(App) -}).$mount('#app') diff --git a/docs/template.html b/docs/template.html deleted file mode 100644 index 88af599..0000000 --- a/docs/template.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - PicGo - - -
- - \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 191cafe..4f5c2ea 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -63,7 +63,8 @@ module.exports = [ 'test/unit/coverage/**', 'test/unit/*.js', 'test/e2e/*.js', - 'node_modules/**' + 'node_modules/**', + 'vitest.config.ts', ] }, { diff --git a/package.json b/package.json index 57b224c..eaa4efe 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "build:local": "dotenv -e .env -- electron-vite build && electron-builder --config electron-builder.config.ts --publish never", "lint": "pnpm lint:dpdm && eslint --ext .js,.jsx,.ts,.tsx,.vue src/", "tsc": "tsc --noEmit", + "vue-tsc": "vue-tsc --noEmit", "bump": "bump-version", "cz": "git-cz", "dev": "electron-vite dev", @@ -26,8 +27,8 @@ "postuninstall": "electron-builder install-app-deps", "upload-dist": "node ./scripts/upload-dist.js", "lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/background.ts", - "check": "pnpm run tsc && pnpm run lint", - "test": "vitest run src/__tests__", + "check": "pnpm run tsc && pnpm run vue-tsc&& pnpm run lint", + "test": "vitest run", "prepare": "husky", "commitlint": "commitlint --edit" }, @@ -38,6 +39,7 @@ "@picgo/video-duration": "^1.0.1", "axios": "^0.19.0", "clip-filepaths": "^0.3.0", + "comment-json": "^4.5.1", "compare-versions": "^4.1.3", "core-js": "^3.27.1", "dayjs": "^1.11.19", @@ -53,7 +55,7 @@ "mime-types": "^3.0.2", "mitt": "^3.0.1", "multer": "^1.4.5-lts.1", - "picgo": "^1.8.1", + "picgo": "^2.0.0", "qrcode.vue": "^3.3.3", "semver": "^7.7.3", "shell-path": "2.1.0", @@ -112,7 +114,8 @@ "tailwindcss": "^3.3.2", "typescript": "^5.9.3", "vite": "^7.2.6", - "vitest": "^4.0.16" + "vitest": "^4.0.16", + "vue-tsc": "^3.2.3" }, "commitlint": { "extends": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4307c2f..01e8ff4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: clip-filepaths: specifier: ^0.3.0 version: 0.3.0 + comment-json: + specifier: ^4.5.1 + version: 4.5.1 compare-versions: specifier: ^4.1.3 version: 4.1.4 @@ -72,8 +75,8 @@ importers: specifier: ^1.4.5-lts.1 version: 1.4.5-lts.2 picgo: - specifier: ^1.8.1 - version: 1.8.1 + specifier: ^2.0.0 + version: 2.0.0 qrcode.vue: specifier: ^3.3.3 version: 3.6.0(vue@3.5.25(typescript@5.9.3)) @@ -246,6 +249,9 @@ importers: vitest: specifier: ^4.0.16 version: 4.0.16(@types/node@20.19.26)(jiti@1.21.7)(stylus@0.54.8) + vue-tsc: + specifier: ^3.2.3 + version: 3.2.3(typescript@5.9.3) packages: @@ -835,6 +841,12 @@ packages: '@floating-ui/utils@0.2.10': resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==} + '@hono/node-server@1.19.9': + resolution: {integrity: sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw==} + engines: {node: '>=18.14.1'} + peerDependencies: + hono: ^4 + '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -1666,6 +1678,15 @@ packages: '@vitest/utils@4.0.16': resolution: {integrity: sha512-h8z9yYhV3e1LEfaQ3zdypIrnAg/9hguReGZoS7Gl0aBG5xgA410zBqECqmaF/+RkTggRsfnzc1XaAHA6bmUufA==} + '@volar/language-core@2.4.27': + resolution: {integrity: sha512-DjmjBWZ4tJKxfNC1F6HyYERNHPYS7L7OPFyCrestykNdUZMFYzI9WTyvwPcaNaHlrEUwESHYsfEw3isInncZxQ==} + + '@volar/source-map@2.4.27': + resolution: {integrity: sha512-ynlcBReMgOZj2i6po+qVswtDUeeBRCTgDurjMGShbm8WYZgJ0PA4RmtebBJ0BCYol1qPv3GQF6jK7C9qoVc7lg==} + + '@volar/typescript@2.4.27': + resolution: {integrity: sha512-eWaYCcl/uAPInSK2Lze6IqVWaBu/itVqR5InXcHXFyles4zO++Mglt3oxdgj75BDcv1Knr9Y93nowS8U3wqhxg==} + '@vue/compiler-core@3.5.25': resolution: {integrity: sha512-vay5/oQJdsNHmliWoZfHPoVZZRmnSWhug0BYT34njkYTPqClh3DNWLkZNJBVSjsNMrg0CCrBfoKkjZQPM/QVUw==} @@ -1681,6 +1702,9 @@ packages: '@vue/devtools-api@6.6.4': resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==} + '@vue/language-core@3.2.3': + resolution: {integrity: sha512-VpN/GnYDzGLh44AI6i1OB/WsLXo6vwnl0EWHBelGc4TyC0yEq6azwNaed/+Tgr8anFlSdWYnMEkyHJDPe7ii7A==} + '@vue/reactivity@3.5.25': resolution: {integrity: sha512-5xfAypCQepv4Jog1U4zn8cZIcbKKFka3AgWHEFQeK65OW+Ys4XybP6z2kKgws4YB43KGpqp5D/K3go2UPPunLA==} @@ -1747,6 +1771,9 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + alien-signals@3.1.2: + resolution: {integrity: sha512-d9dYqZTS90WLiU0I5c6DHj/HcKkF8ZyGN3G5x8wSbslulz70KOxaqCT0hQCo9KOyhVqzqGojvNdJXoTumZOtcw==} + ansi-escapes@3.2.0: resolution: {integrity: sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==} engines: {node: '>=4'} @@ -1834,6 +1861,10 @@ packages: array-timsort@1.0.3: resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==} + array-union@2.1.0: + resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} + engines: {node: '>=8'} + array.prototype.findlastindex@1.2.6: resolution: {integrity: sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==} engines: {node: '>= 0.4'} @@ -1907,8 +1938,8 @@ packages: resolution: {integrity: sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==} deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 - axios@1.13.2: - resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==} + axios@1.13.3: + resolution: {integrity: sha512-ERT8kdX7DZjtUm7IitEyV7InTHAF42iJuMArIiDIV5YtPanJkgw4hw5Dyg9fh0mihdWNn1GKaeIWErfe56UQ1g==} babel-polyfill@6.26.0: resolution: {integrity: sha512-F2rZGQnAdaHWQ8YAoeRbukc7HS9QgdgeyJ0rQDd485v9opwuPvjpPFcOOT/WmkKTdgy9ESgSPXDcTNpzrGr6iQ==} @@ -1984,6 +2015,10 @@ packages: builder-util@26.1.0: resolution: {integrity: sha512-BTUhmpkCuEAAUmc8EJkJOg7fMGsDSSRMPn1QTpoUpYpGp3SjyJV18LlCPTu3+UBfuQ/5ua7KqDLrsK9NAXO7fg==} + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} + busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -2110,6 +2145,12 @@ packages: resolution: {integrity: sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==} engines: {node: '>=8'} + citty@0.1.6: + resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} + + citty@0.2.0: + resolution: {integrity: sha512-8csy5IBFI2ex2hTVpaHN2j+LNE199AgiI7y4dMintrr8i0lQiFn+0AWMZrWdHKIgMOer65f8IThysYhoReqjWA==} + cli-cursor@2.1.0: resolution: {integrity: sha512-8lgKz8LmCRYZZQDpRyT2m5rKJ08TnU4tR9FFFW2rxpxR1FzWi4PQ/NfyODchAatHaUgnSPVcx/R5w6NuTBzFiw==} engines: {node: '>=4'} @@ -2236,10 +2277,6 @@ packages: resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} engines: {node: ^12.20.0 || >=14} - comment-json@4.4.1: - resolution: {integrity: sha512-r1To31BQD5060QdkC+Iheai7gHwoSZobzunqkf2/kQ6xIAfJyrKNAFUwdKvkK7Qgu7pVTKQEa7ok7Ed3ycAJgg==} - engines: {node: '>= 6'} - comment-json@4.5.1: resolution: {integrity: sha512-taEtr3ozUmOB7it68Jll7s0Pwm+aoiHyXKrEC8SEodL4rNpdfDLqa7PfBlrgFoCNNdR8ImL+muti5IGvktJAAg==} engines: {node: '>= 6'} @@ -2269,6 +2306,10 @@ packages: resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==} engines: {'0': node >= 0.8} + consola@3.4.2: + resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} + engines: {node: ^14.18.0 || >=16.10.0} + conventional-changelog-angular@1.6.6: resolution: {integrity: sha512-suQnFSqCxRwyBxY68pYTsFkG0taIdinHLNEAX5ivtw8bCRnIgnpvcHmlR/yjUyZIrNPYAoXlY1WiEKWgSE4BNg==} @@ -2497,6 +2538,14 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + default-browser-id@5.0.1: + resolution: {integrity: sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==} + engines: {node: '>=18'} + + default-browser@5.4.0: + resolution: {integrity: sha512-XDuvSq38Hr1MdN47EDvYtx3U0MTqpCEn+F6ft8z2vYDzMrvQhVp0ui9oQdqW3MvK3vqUETglt1tVGgjLuJ5izg==} + engines: {node: '>=18'} + default-shell@1.0.1: resolution: {integrity: sha512-/Os8tTMPSriNHCsVj3VLjMZblIl1sIg8EXz3qg7C5K+y9calfTA/qzlfPvCQ+LEgLWmtZ9wCnzE1w+S6TPPFyQ==} engines: {node: '>=4'} @@ -2512,10 +2561,17 @@ packages: resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} engines: {node: '>= 0.4'} + define-lazy-prop@3.0.0: + resolution: {integrity: sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==} + engines: {node: '>=12'} + define-properties@1.2.1: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} + delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} @@ -2541,6 +2597,10 @@ packages: dir-compare@4.2.0: resolution: {integrity: sha512-2xMCmOoMrdQIPHdsTawECdNPwlVFB9zGcz3kuhmBO6U3oU+UQjsue0i8ayLKpgBcm+hcXPMVSGUN9d+pvJ6+VQ==} + dir-glob@3.0.1: + resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} + engines: {node: '>=8'} + dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} @@ -3105,6 +3165,10 @@ packages: resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==} engines: {node: '>= 0.4'} + giget@2.0.0: + resolution: {integrity: sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==} + hasBin: true + git-raw-commits@1.3.6: resolution: {integrity: sha512-svsK26tQ8vEKnMshTDatSIQSMDdz8CxIIqKsvPqbtV23Etmw6VNaFAitu8zwZ0VrOne7FztwPyRLxK7/DIUTQg==} hasBin: true @@ -3174,6 +3238,10 @@ packages: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} + globby@11.1.0: + resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} + engines: {node: '>=10'} + gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} @@ -3229,6 +3297,10 @@ packages: resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==} engines: {node: '>=0.10.0'} + hono@4.11.6: + resolution: {integrity: sha512-ofIiiHyl34SV6AuhE3YT2mhO5HRWokce+eUYE82TsP6z0/H3JeJcjVWEMSIAiw2QkjDOEpES/lYsg8eEbsLtdw==} + engines: {node: '>=16.9.0'} + hosted-git-info@2.8.9: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} @@ -3414,6 +3486,11 @@ packages: engines: {node: '>=8'} hasBin: true + is-docker@3.0.0: + resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -3438,6 +3515,15 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-in-ssh@1.0.0: + resolution: {integrity: sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==} + engines: {node: '>=20'} + + is-inside-container@1.0.0: + resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} + engines: {node: '>=14.16'} + hasBin: true + is-interactive@1.0.0: resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} engines: {node: '>=8'} @@ -3532,6 +3618,10 @@ packages: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} + is-wsl@3.1.0: + resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} + engines: {node: '>=16'} + isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -3964,6 +4054,9 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + muggle-string@0.4.1: + resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} + multer@1.4.5-lts.2: resolution: {integrity: sha512-VzGiVigcG9zUAoCNU+xShztrlr1auZOlurXynNvO9GiWD1/mTBbUljOKY+qMeazBqXgRnjzeEgJI/wyjJUHg9A==} engines: {node: '>= 6.0.0'} @@ -4010,6 +4103,9 @@ packages: node-api-version@0.2.1: resolution: {integrity: sha512-2xP/IGGMmmSQpI1+O/k72jF/ykvZ89JeuKX3TLJAYPDVLUalrshrLHkeVcCCZqG/eEa635cr8IBYzgnDvM2O8Q==} + node-fetch-native@1.6.7: + resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==} + node-gyp@11.5.0: resolution: {integrity: sha512-ra7Kvlhxn5V9Slyus0ygMa2h+UqExPqUIkfk7Pc8QTLT956JLSy51uWFwHtIYy0vI8cB4BDhc/S03+880My/LQ==} engines: {node: ^18.17.0 || >=20.5.0} @@ -4056,6 +4152,11 @@ packages: resolution: {integrity: sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==} engines: {node: '>=0.10.0'} + nypm@0.6.4: + resolution: {integrity: sha512-1TvCKjZyyklN+JJj2TS3P4uSQEInrM/HkkuSXsEzm1ApPgBffOn8gFguNnZf07r/1X6vlryfIqMUkJKQMzlZiw==} + engines: {node: '>=18'} + hasBin: true + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -4102,6 +4203,10 @@ packages: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} + open@11.0.0: + resolution: {integrity: sha512-smsWv2LzFjP03xmvFoJ331ss6h+jixfA4UUV/Bsiyuu4YJPfN+FIQGOIiv4w9/+MoHkfkJ22UIaQWRVFRfH6Vw==} + engines: {node: '>=20'} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -4196,6 +4301,9 @@ packages: resolution: {integrity: sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==} engines: {node: '>=0.10.0'} + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} @@ -4227,6 +4335,10 @@ packages: resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} engines: {node: '>=4'} + path-type@4.0.0: + resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} + engines: {node: '>=8'} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -4237,9 +4349,9 @@ packages: pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} - picgo@1.8.1: - resolution: {integrity: sha512-FDwo1iZN8kFtF1nzM+2BYtpAw4oXPlikvrJ75o7/qEaBazLApJ4DXVyAocK2OQ9exFWV2beKuavtxIcro3lTrg==} - engines: {node: '>= 22.12.0'} + picgo@2.0.0: + resolution: {integrity: sha512-FefLRpMHuYP19C6TpKHs83kot9BQxOT9GwpwM6DxFh4YW35Ttg1IwdQwVQAgWYLA7Pzwpd6Aro+yw+x07XMz/Q==} + engines: {node: '>= 20.19.0'} hasBin: true picocolors@1.1.1: @@ -4344,6 +4456,10 @@ packages: engines: {node: '>=14.0.0'} hasBin: true + powershell-utils@0.1.0: + resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==} + engines: {node: '>=20'} + prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -4554,6 +4670,10 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + run-applescript@7.1.0: + resolution: {integrity: sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==} + engines: {node: '>=18'} + run-async@2.4.1: resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==} engines: {node: '>=0.12.0'} @@ -4709,6 +4829,10 @@ packages: resolution: {integrity: sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==} engines: {node: '>=6'} + slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + slice-ansi@3.0.0: resolution: {integrity: sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==} engines: {node: '>=8'} @@ -5221,6 +5345,9 @@ packages: jsdom: optional: true + vscode-uri@3.1.0: + resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==} + vue-demi@0.12.5: resolution: {integrity: sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==} engines: {node: '>=12'} @@ -5254,6 +5381,12 @@ packages: peerDependencies: vue: ^3.5.0 + vue-tsc@3.2.3: + resolution: {integrity: sha512-1RdRB7rQXGFMdpo0aXf9spVzWEPGAk7PEb/ejHQwVrcuQA/HsGiixIc3uBQeqY2YjeEEgvr2ShQewBgcN4c1Cw==} + hasBin: true + peerDependencies: + typescript: '>=5.0.0' + vue3-lazyload@0.3.8: resolution: {integrity: sha512-UiJHRT7mzry102WbhtrRgJh+f8Z8u4Z+H1RU4dvPmQeq7wFSDFxZB9iJOWGihH2FscXN/8rMGLDOQJAmjwqpCg==} peerDependencies: @@ -5348,6 +5481,10 @@ packages: resolution: {integrity: sha512-YnlPC6JqnZl6aO4uRc+dx5PHguiR9S6WeoLtpxNT9wIG+BDya7ZNE1q7KOjVgaA73hKhKLpVPgJ5QA9THQ5BRg==} engines: {node: ^20.17.0 || >=22.9.0} + wsl-utils@0.3.1: + resolution: {integrity: sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==} + engines: {node: '>=20'} + xml-name-validator@4.0.0: resolution: {integrity: sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==} engines: {node: '>=12'} @@ -6374,6 +6511,10 @@ snapshots: '@floating-ui/utils@0.2.10': {} + '@hono/node-server@1.19.9(hono@4.11.6)': + dependencies: + hono: 4.11.6 + '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.7': @@ -6621,7 +6762,7 @@ snapshots: '@types/bson': 4.2.4 '@types/graceful-fs': 4.1.9 '@types/lodash': 4.17.21 - comment-json: 4.4.1 + comment-json: 4.5.1 fflate: 0.7.4 lodash: 4.17.21 lodash-id: 0.14.1 @@ -7368,6 +7509,18 @@ snapshots: '@vitest/pretty-format': 4.0.16 tinyrainbow: 3.0.3 + '@volar/language-core@2.4.27': + dependencies: + '@volar/source-map': 2.4.27 + + '@volar/source-map@2.4.27': {} + + '@volar/typescript@2.4.27': + dependencies: + '@volar/language-core': 2.4.27 + path-browserify: 1.0.1 + vscode-uri: 3.1.0 + '@vue/compiler-core@3.5.25': dependencies: '@babel/parser': 7.28.5 @@ -7400,6 +7553,16 @@ snapshots: '@vue/devtools-api@6.6.4': {} + '@vue/language-core@3.2.3': + dependencies: + '@volar/language-core': 2.4.27 + '@vue/compiler-dom': 3.5.25 + '@vue/shared': 3.5.25 + alien-signals: 3.1.2 + muggle-string: 0.4.1 + path-browserify: 1.0.1 + picomatch: 4.0.3 + '@vue/reactivity@3.5.25': dependencies: '@vue/shared': 3.5.25 @@ -7481,6 +7644,8 @@ snapshots: require-from-string: 2.0.2 optional: true + alien-signals@3.1.2: {} + ansi-escapes@3.2.0: {} ansi-escapes@4.3.2: @@ -7589,6 +7754,8 @@ snapshots: array-timsort@1.0.3: {} + array-union@2.1.0: {} + array.prototype.findlastindex@1.2.6: dependencies: call-bind: 1.0.8 @@ -7667,7 +7834,7 @@ snapshots: transitivePeerDependencies: - supports-color - axios@1.13.2: + axios@1.13.3: dependencies: follow-redirects: 1.15.11 form-data: 4.0.5 @@ -7775,6 +7942,10 @@ snapshots: transitivePeerDependencies: - supports-color + bundle-name@4.1.0: + dependencies: + run-applescript: 7.1.0 + busboy@1.6.0: dependencies: streamsearch: 1.1.0 @@ -7909,6 +8080,12 @@ snapshots: ci-info@4.3.1: {} + citty@0.1.6: + dependencies: + consola: 3.4.2 + + citty@0.2.0: {} + cli-cursor@2.1.0: dependencies: restore-cursor: 2.0.0 @@ -8009,12 +8186,6 @@ snapshots: commander@9.5.0: optional: true - comment-json@4.4.1: - dependencies: - array-timsort: 1.0.3 - core-util-is: 1.0.3 - esprima: 4.0.1 - comment-json@4.5.1: dependencies: array-timsort: 1.0.3 @@ -8064,6 +8235,8 @@ snapshots: readable-stream: 2.3.8 typedarray: 0.0.6 + consola@3.4.2: {} + conventional-changelog-angular@1.6.6: dependencies: compare-func: 1.3.4 @@ -8344,6 +8517,13 @@ snapshots: deep-is@0.1.4: {} + default-browser-id@5.0.1: {} + + default-browser@5.4.0: + dependencies: + bundle-name: 4.1.0 + default-browser-id: 5.0.1 + default-shell@1.0.1: {} defaults@1.0.4: @@ -8358,12 +8538,16 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 + define-lazy-prop@3.0.0: {} + define-properties@1.2.1: dependencies: define-data-property: 1.1.4 has-property-descriptors: 1.0.2 object-keys: 1.1.1 + defu@6.1.4: {} + delayed-stream@1.0.0: {} detect-file@1.0.0: {} @@ -8382,6 +8566,10 @@ snapshots: minimatch: 3.1.2 p-limit: 3.1.0 + dir-glob@3.0.1: + dependencies: + path-type: 4.0.0 + dlv@1.1.3: {} dmg-builder@26.1.0(electron-builder-squirrel-windows@26.1.0): @@ -9158,6 +9346,15 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.3.0 + giget@2.0.0: + dependencies: + citty: 0.1.6 + consola: 3.4.2 + defu: 6.1.4 + node-fetch-native: 1.6.7 + nypm: 0.6.4 + pathe: 2.0.3 + git-raw-commits@1.3.6: dependencies: dargs: 4.1.0 @@ -9256,6 +9453,15 @@ snapshots: define-properties: 1.2.1 gopd: 1.2.0 + globby@11.1.0: + dependencies: + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.3 + ignore: 5.3.2 + merge2: 1.4.1 + slash: 3.0.0 + gopd@1.2.0: {} got@11.8.6: @@ -9313,6 +9519,8 @@ snapshots: dependencies: parse-passwd: 1.0.0 + hono@4.11.6: {} + hosted-git-info@2.8.9: {} hosted-git-info@4.1.0: @@ -9526,6 +9734,8 @@ snapshots: is-docker@2.2.1: {} + is-docker@3.0.0: {} + is-extglob@2.1.1: {} is-finalizationregistry@1.1.1: @@ -9548,6 +9758,12 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-in-ssh@1.0.0: {} + + is-inside-container@1.0.0: + dependencies: + is-docker: 3.0.0 + is-interactive@1.0.0: {} is-map@2.0.3: {} @@ -9624,6 +9840,10 @@ snapshots: dependencies: is-docker: 2.2.1 + is-wsl@3.1.0: + dependencies: + is-inside-container: 1.0.0 + isarray@1.0.0: {} isarray@2.0.5: {} @@ -10044,6 +10264,8 @@ snapshots: ms@2.1.3: {} + muggle-string@0.4.1: {} + multer@1.4.5-lts.2: dependencies: append-field: 1.0.0 @@ -10087,6 +10309,8 @@ snapshots: dependencies: semver: 7.7.3 + node-fetch-native@1.6.7: {} + node-gyp@11.5.0: dependencies: env-paths: 2.2.1 @@ -10140,6 +10364,12 @@ snapshots: number-is-nan@1.0.1: {} + nypm@0.6.4: + dependencies: + citty: 0.2.0 + pathe: 2.0.3 + tinyexec: 1.0.2 + object-assign@4.1.1: {} object-hash@3.0.0: {} @@ -10191,6 +10421,15 @@ snapshots: dependencies: mimic-fn: 2.1.0 + open@11.0.0: + dependencies: + default-browser: 5.4.0 + define-lazy-prop: 3.0.0 + is-in-ssh: 1.0.0 + is-inside-container: 1.0.0 + powershell-utils: 0.1.0 + wsl-utils: 0.3.1 + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -10291,6 +10530,8 @@ snapshots: parse-passwd@1.0.0: {} + path-browserify@1.0.1: {} + path-exists@3.0.0: {} path-exists@4.0.0: {} @@ -10312,24 +10553,32 @@ snapshots: dependencies: pify: 3.0.0 + path-type@4.0.0: {} + pathe@2.0.3: {} pe-library@0.4.1: {} pend@1.2.0: {} - picgo@1.8.1: + picgo@2.0.0: dependencies: + '@hono/node-server': 1.19.9(hono@4.11.6) '@picgo/i18n': 1.0.0 '@picgo/store': 2.1.0 - axios: 1.13.2 + axios: 1.13.3 chalk: 2.4.2 commander: 8.3.0 comment-json: 4.5.1 cross-spawn: 6.0.6 dayjs: 1.11.19 + dotenv: 17.2.3 + ejs: 3.1.10 form-data: 4.0.5 fs-extra: 6.0.1 + giget: 2.0.0 + globby: 11.1.0 + hono: 4.11.6 image-size: 0.8.3 inquirer: 6.5.2 is-wsl: 2.2.0 @@ -10338,6 +10587,7 @@ snapshots: md5: 2.3.0 mime-types: 3.0.2 minimist: 1.2.8 + open: 11.0.0 resolve: 1.22.11 tunnel: 0.0.6 transitivePeerDependencies: @@ -10424,6 +10674,8 @@ snapshots: commander: 9.5.0 optional: true + powershell-utils@0.1.0: {} + prelude-ls@1.2.1: {} proc-log@5.0.0: {} @@ -10662,6 +10914,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.53.3 fsevents: 2.3.3 + run-applescript@7.1.0: {} + run-async@2.4.1: {} run-async@4.0.6: {} @@ -10816,6 +11070,8 @@ snapshots: slash@2.0.0: {} + slash@3.0.0: {} + slice-ansi@3.0.0: dependencies: ansi-styles: 4.3.0 @@ -11360,6 +11616,8 @@ snapshots: - tsx - yaml + vscode-uri@3.1.0: {} + vue-demi@0.12.5(vue@3.5.25(typescript@5.9.3)): dependencies: vue: 3.5.25(typescript@5.9.3) @@ -11385,6 +11643,12 @@ snapshots: '@vue/devtools-api': 6.6.4 vue: 3.5.25(typescript@5.9.3) + vue-tsc@3.2.3(typescript@5.9.3): + dependencies: + '@volar/typescript': 2.4.27 + '@vue/language-core': 3.2.3 + typescript: 5.9.3 + vue3-lazyload@0.3.8(vue@3.5.25(typescript@5.9.3)): dependencies: vue: 3.5.25(typescript@5.9.3) @@ -11503,6 +11767,11 @@ snapshots: imurmurhash: 0.1.4 signal-exit: 4.1.0 + wsl-utils@0.3.1: + dependencies: + is-wsl: 3.1.0 + powershell-utils: 0.1.0 + xml-name-validator@4.0.0: {} xmlbuilder@15.1.1: {} diff --git a/public/i18n/en.yml b/public/i18n/en.yml index ecc066d..c0543da 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -3,7 +3,7 @@ ABOUT: About OPEN_MAIN_WINDOW: Open Main Window CHOOSE_DEFAULT_PICBED: Choose Default Picbed OPEN_UPDATE_HELPER: Open Update Helper -PRIVACY_AGREEMENT: Privacy Agreement +PRIVACY_TERMS_AGREEMENT: Privacy & Terms Agreement RELOAD_APP: Reload App UPLOAD_FAILED: Upload Failed UPLOAD_SUCCEED: Upload Succeed @@ -34,6 +34,75 @@ GALLERY: Gallery PICBEDS_SETTINGS: Picbeds Settings PICGO_SETTINGS: PicGo Settings PLUGIN_SETTINGS: Plugins Settings +PICGO_CLOUD_TITLE: PicGo Cloud +PICGO_CLOUD_ERROR_TITLE: PicGo Cloud Error +PICGO_CLOUD_NOT_LOGGED_IN: Not logged in to PicGo Cloud. +PICGO_CLOUD_LOGIN: Log In +PICGO_CLOUD_LOGOUT: Log Out +PICGO_CLOUD_CANCEL_LOGIN: Cancel Login +PICGO_CLOUD_RETRY: Retry +PICGO_CLOUD_CONFIG_SYNC: Config Sync +PICGO_CLOUD_LOGIN_IN_PROGRESS: Login in progress. Please finish login in your browser. +PICGO_CLOUD_LOGGED_IN_AS: "Logged in as: ${user}" +PICGO_CLOUD_OPEN: Open PicGo Cloud +PICGO_CLOUD_LOGIN_TIMEOUT: Login timed out. Please try again. +PICGO_CLOUD_LOGIN_FAILED: Login failed. Please try again. +PICGO_CLOUD_AGREE_PREFIX: "I have read and agree to PicGo's " +PICGO_CLOUD_TERMS_OF_SERVICE: Terms of Service +PICGO_CLOUD_AGREE_AND: " and " +PICGO_CLOUD_PRIVACY_POLICY: Privacy Policy +PICGO_CLOUD_LOGIN_EXPIRED: Login expired. Please log in again. +PICGO_CLOUD_ENCRYPTION_MODE_LABEL: Encryption mode +PICGO_CLOUD_ENCRYPTION_MODE_AUTO: Auto +PICGO_CLOUD_ENCRYPTION_MODE_SERVER: Server-side encryption +PICGO_CLOUD_ENCRYPTION_MODE_E2E: End-to-end encryption +PICGO_CLOUD_ENCRYPTION_MODE_TIP_AUTO: "Auto: follow the cloud's last used encryption method (defaults to server-side)." +PICGO_CLOUD_ENCRYPTION_MODE_TIP_SERVER: "Server-side encryption: your config is encrypted on the server before being stored. No PIN required." +PICGO_CLOUD_ENCRYPTION_MODE_TIP_E2E: "End-to-end encryption: use your PIN to encrypt/decrypt data. PicGo does not store your PIN; losing it means data cannot be recovered." +PICGO_CLOUD_ENCRYPTION_MODE_TIP_DOC: Read full docs +PICGO_CLOUD_E2E_CHECKBOX_LABEL: Enable E2E encryption +PICGO_CLOUD_E2E_ENABLE_WARNING_TITLE: Enable E2E Encryption +PICGO_CLOUD_E2E_ENABLE_WARNING_MESSAGE: "E2E encryption requires you to keep your PIN safe. If you lose your PIN, the encrypted data cannot be recovered. PicGo does not store your PIN or any recovery data." +PICGO_CLOUD_REMOTE_E2E_AUTO_ENABLED: Remote config is E2E-encrypted. E2E has been enabled locally. +PICGO_CLOUD_E2E_PIN_SETUP_TITLE: Set up E2E PIN +PICGO_CLOUD_E2E_PIN_DECRYPT_TITLE: Enter E2E PIN +PICGO_CLOUD_E2E_PIN_RETRY_TITLE: "Incorrect PIN. Please try again (attempt ${retryCount})." +PICGO_CLOUD_E2E_PIN_PLACEHOLDER: PIN +PICGO_CLOUD_E2E_PIN_CONFIRM_PLACEHOLDER: Confirm PIN +PICGO_CLOUD_CONFIG_SYNC_SUCCESS: Config sync succeeded. +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_DETECTED: Conflict detected. Please resolve the conflicts. +PICGO_CLOUD_CONFIG_SYNC_FAILED: Config sync failed. +PICGO_CLOUD_CONFIG_SYNC_ABORTED: Config sync cancelled. +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE: Confirm switch encryption method? +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_BODY: "You are switching from \"${from}\" to \"${to}\".\n\nNote: Switching encryption modes will clear all your cloud history versions.\nThis is because older history versions cannot be decrypted or verified under the new mode.\nAfter switching, the system will immediately create a new backup as the starting point." +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM: Confirm switch and clear history +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL: Cancel +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED: Encryption switch cancelled by user +PICGO_CLOUD_CONFIG_SYNC_FAILED_WITH_REASON: "Config sync failed: ${reason}" +PICGO_CLOUD_CONFIG_SYNC_PIN_MAX_RETRY: Too many incorrect PIN attempts. Please try again. +PICGO_CLOUD_CONFIG_SYNC_LOCAL_CONFIG_INVALID: Local config is invalid. Please check your config file. +PICGO_CLOUD_CONFIG_SYNC_IN_PROGRESS: Config sync is in progress. +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_PENDING: There is a pending conflict session. Please resolve conflicts first. +PICGO_CLOUD_CONFIG_SYNC_NO_CONFLICT_SESSION: No conflict session found. +PICGO_CLOUD_CONFIG_SYNC_RESOLUTION_INCOMPLETE: Please choose Local or Cloud for all conflict items. +PICGO_CLOUD_CONFIG_SYNC_STARTING: Config sync started... +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_TITLE: "Conflict Detected (${count})" +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_LOCAL: Choose All Local +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_CLOUD: Choose All Cloud +PICGO_CLOUD_CONFIG_SYNC_RESET_ALL: Reset All +PICGO_CLOUD_CONFIG_SYNC_LOCAL_VERSION: Local Version +PICGO_CLOUD_CONFIG_SYNC_CLOUD_VERSION: Cloud Version +PICGO_CLOUD_CONFIG_SYNC_ABORT: Abort +PICGO_CLOUD_CONFIG_SYNC_CONFIRM_AND_SYNC: Confirm & Sync +PICGO_CLOUD_CONFIG_SYNC_VALUE_UNDEFINED: (empty) +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_RESOLVED: Conflicts resolved. +PICGO_CLOUD_LAST_SYNC_TIME: "Last local sync time: ${time}" +PICGO_CLOUD_LAST_SYNC_TIME_NONE: None +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_TITLE: Restart Required? +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_MESSAGE: Some settings may require a restart to take effect. Restart now? +PICGO_CLOUD_CONFIG_SYNC_RESTART_NOW: Restart Now +PICGO_CLOUD_CONFIG_SYNC_RESTART_LATER: Later +INPUT_BOX_CONFIRM_MISMATCH: The two inputs do not match. PICGO_SPONSOR_TEXT: PicGo is a free software, if you like it, please don't forget to buy me a cup of coffee. ALIPAY: Alipay WECHATPAY: Wechat Pay @@ -309,37 +378,6 @@ TIPS_UPLOADER_CONFIG_NOT_FOUND: Config not found TIPS_UPLOADER_CONFIG_CANNOT_DELETE_LAST: Cannot delete the last config # privacy -PRIVACY: > - - This software respects and protects the personal privacy of all users who use the service. In order to provide you with more accurate and better services, this software will use and collect some of your behavioral information in accordance with the provisions of this Privacy Policy. When you agree to the software service use agreement, you are deemed to have agreed to the entire content of this privacy policy. This privacy policy is an integral part of the software service use agreement, and it will not be used if you do not agree. - This Agreement will be updated periodically. - - 1. Scope of application - - - a) When you use this software, this software will record some information about your operation behavior of this software, including but not limited to the time-consuming, type, quantity and other information of your use of this software to upload files. - - - 2. Use of Information - - - a) After obtaining your usage data, the software will upload it to the data analysis server so as to provide you with better services after analyzing the data. - - - 3. Information disclosure - - - a) This software will not disclose your information to untrusted third parties. - - - b) In accordance with the relevant provisions of the law, or the requirements of administrative or judicial institutions, disclose to third parties or administrative or judicial institutions; - - - - - 4. Information Security - - - a) This software does not collect your personal information, key information and other private information, and the collected information is only used for improving the software, optimizing the experience, and understanding the daily activities of the software. +PRIVACY: "Please read and agree to the Privacy Policy ${privacyUrl} and Terms of Service ${termsUrl} before using." PRIVACY_TIPS: Please agree the privacy policy to upload QUIT: Quit diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 99ef2f9..6b56d52 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -3,7 +3,7 @@ ABOUT: 关于 OPEN_MAIN_WINDOW: 打开主窗口 CHOOSE_DEFAULT_PICBED: 选择默认图床 OPEN_UPDATE_HELPER: 打开更新助手 -PRIVACY_AGREEMENT: 隐私协议 +PRIVACY_TERMS_AGREEMENT: 隐私与条款协议 RELOAD_APP: 重启应用 UPLOAD_SUCCEED: 上传成功 UPLOAD_FAILED: 上传失败 @@ -34,6 +34,75 @@ GALLERY: 相册 PICBEDS_SETTINGS: 图床设置 PICGO_SETTINGS: PicGo设置 PLUGIN_SETTINGS: 插件设置 +PICGO_CLOUD_TITLE: PicGo Cloud +PICGO_CLOUD_ERROR_TITLE: PicGo Cloud 错误 +PICGO_CLOUD_NOT_LOGGED_IN: 尚未登录 PicGo Cloud +PICGO_CLOUD_LOGIN: 登录 +PICGO_CLOUD_LOGOUT: 退出登录 +PICGO_CLOUD_CANCEL_LOGIN: 取消登录 +PICGO_CLOUD_RETRY: 重试 +PICGO_CLOUD_CONFIG_SYNC: 配置同步 +PICGO_CLOUD_LOGIN_IN_PROGRESS: 登录进行中,请在浏览器完成登录。 +PICGO_CLOUD_LOGGED_IN_AS: "已登录:${user}" +PICGO_CLOUD_OPEN: 打开 PicGo Cloud +PICGO_CLOUD_LOGIN_TIMEOUT: 登录超时,请重试。 +PICGO_CLOUD_LOGIN_FAILED: 登录失败,请重试。 +PICGO_CLOUD_AGREE_PREFIX: 我已阅读并同意 PicGo 的 +PICGO_CLOUD_TERMS_OF_SERVICE: 服务条款 +PICGO_CLOUD_AGREE_AND: 以及 +PICGO_CLOUD_PRIVACY_POLICY: 隐私政策 +PICGO_CLOUD_LOGIN_EXPIRED: 登录失效,请重新登录。 +PICGO_CLOUD_ENCRYPTION_MODE_LABEL: 加密模式 +PICGO_CLOUD_ENCRYPTION_MODE_AUTO: 自动 +PICGO_CLOUD_ENCRYPTION_MODE_SERVER: 服务端加密 +PICGO_CLOUD_ENCRYPTION_MODE_E2E: 端到端加密 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_AUTO: 自动:跟随云端上一次配置的加密方式(默认服务端加密)。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_SERVER: 服务端加密:我们会在服务端对你的配置加密后再存储,不需要 PIN。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_E2E: 端到端加密:需要你输入 PIN 来加密/解密数据。PicGo 不存储 PIN,丢失将无法找回数据。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_DOC: 查看完整文档 +PICGO_CLOUD_E2E_CHECKBOX_LABEL: 开启 E2E 加密 +PICGO_CLOUD_E2E_ENABLE_WARNING_TITLE: 开启 E2E 加密 +PICGO_CLOUD_E2E_ENABLE_WARNING_MESSAGE: E2E 加密需要你自行妥善保管 PIN。PIN 丢失将无法恢复加密数据。PicGo 不会存储 PIN 或任何恢复信息。 +PICGO_CLOUD_REMOTE_E2E_AUTO_ENABLED: 检测到远端配置已开启 E2E 加密,已自动在本地开启 E2E。 +PICGO_CLOUD_E2E_PIN_SETUP_TITLE: 设置 E2E PIN +PICGO_CLOUD_E2E_PIN_DECRYPT_TITLE: 输入 E2E PIN +PICGO_CLOUD_E2E_PIN_RETRY_TITLE: "PIN 错误,请重试(第 ${retryCount} 次)。" +PICGO_CLOUD_E2E_PIN_PLACEHOLDER: PIN +PICGO_CLOUD_E2E_PIN_CONFIRM_PLACEHOLDER: 确认 PIN +PICGO_CLOUD_CONFIG_SYNC_SUCCESS: 配置同步成功。 +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_DETECTED: 检测到配置冲突,请选择解决方案。 +PICGO_CLOUD_CONFIG_SYNC_FAILED: 配置同步失败。 +PICGO_CLOUD_CONFIG_SYNC_ABORTED: 已取消配置同步。 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE: 确认切换加密方式吗? +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_BODY: "您正在从“${from}”切换为“${to}”。\n\n注意:切换加密模式将清空您所有的云端历史版本记录。\n这是因为旧的历史版本无法在新模式下被解密或验证。\n切换后,系统将立即为您创建一份新的备份作为起点。" +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM: 确认切换并清空历史 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL: 取消 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED: 已取消切换加密方式 +PICGO_CLOUD_CONFIG_SYNC_FAILED_WITH_REASON: "配置同步失败:${reason}" +PICGO_CLOUD_CONFIG_SYNC_PIN_MAX_RETRY: PIN 错误次数过多,请稍后重试。 +PICGO_CLOUD_CONFIG_SYNC_LOCAL_CONFIG_INVALID: 本地配置文件格式错误,请检查配置文件。 +PICGO_CLOUD_CONFIG_SYNC_IN_PROGRESS: 配置同步进行中… +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_PENDING: 存在未解决的冲突,请先处理。 +PICGO_CLOUD_CONFIG_SYNC_NO_CONFLICT_SESSION: 未找到可处理的冲突会话。 +PICGO_CLOUD_CONFIG_SYNC_RESOLUTION_INCOMPLETE: 请为所有冲突项选择本地或云端。 +PICGO_CLOUD_CONFIG_SYNC_STARTING: 配置同步已开始… +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_TITLE: "冲突处理(${count} 项)" +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_LOCAL: 全选本地 +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_CLOUD: 全选云端 +PICGO_CLOUD_CONFIG_SYNC_RESET_ALL: 重置全部 +PICGO_CLOUD_CONFIG_SYNC_LOCAL_VERSION: 本地版本 +PICGO_CLOUD_CONFIG_SYNC_CLOUD_VERSION: 云端版本 +PICGO_CLOUD_CONFIG_SYNC_ABORT: 放弃同步 +PICGO_CLOUD_CONFIG_SYNC_CONFIRM_AND_SYNC: 确认并同步 +PICGO_CLOUD_CONFIG_SYNC_VALUE_UNDEFINED: (空) +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_RESOLVED: 配置冲突已解决。 +PICGO_CLOUD_LAST_SYNC_TIME: "上次本地同步时间:${time}" +PICGO_CLOUD_LAST_SYNC_TIME_NONE: 无 +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_TITLE: 需要重启吗? +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_MESSAGE: 部分配置可能需要重启后生效,是否立即重启? +PICGO_CLOUD_CONFIG_SYNC_RESTART_NOW: 立即重启 +PICGO_CLOUD_CONFIG_SYNC_RESTART_LATER: 稍后 +INPUT_BOX_CONFIRM_MISMATCH: 两次输入不一致,请重新输入。 PICGO_SPONSOR_TEXT: PicGo是免费开源的软件,如果你喜欢它,对你有帮助,不妨请我喝杯咖啡? ALIPAY: 支付宝 WECHATPAY: 微信支付 @@ -309,37 +378,6 @@ TIPS_UPLOADER_CONFIG_NOT_FOUND: 未找到该配置 TIPS_UPLOADER_CONFIG_CANNOT_DELETE_LAST: 无法删除最后一个配置 # privacy -PRIVACY: > - - 本软件尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更优质的服务,本软件会按照本隐私权政策的规定使用和收集您的一些行为信息。您在同意本软件服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本软件服务使用协议不可分割的一部分,如果不同意将无法使用。本协议会定期更新。 - - - 1.适用范围 - - - a)在您使用本软件时,本软件会记录的您对本软件的一些操作行为信息,包括但不限于您使用本软件进行文件上传的耗时、类型、数量等信息。 - - - 2.信息的使用 - - - a)在获得您的使用数据之后,本软件会将其上传至数据分析服务器,以便分析数据后,提供给您更好的服务。 - - - 3.信息披露 - - - a)本软件不会将您的信息披露给不受信任的第三方。 - - - b)根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露; - - - - - 4.信息安全 - - - a)本软件不会收集您的个人信息、密钥信息等隐私信息,所收集的信息仅仅作为改善软件、优化体验、了解软件日活等用途。 +PRIVACY: "使用前请阅读并同意隐私政策 ${privacyUrl} 与服务条款 ${termsUrl},同意后方可使用。" PRIVACY_TIPS: 请同意隐私协议,否则无法上传。 QUIT: 退出 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index b367a64..5e59429 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -3,7 +3,7 @@ ABOUT: 關於 OPEN_MAIN_WINDOW: 打開主視窗 CHOOSE_DEFAULT_PICBED: 選擇預設圖床 OPEN_UPDATE_HELPER: 開啟更新助手 -PRIVACY_AGREEMENT: 隱私協議 +PRIVACY_TERMS_AGREEMENT: 隱私與條款協議 RELOAD_APP: 重啟程式 UPLOAD_SUCCEED: 上傳成功 UPLOAD_FAILED: 上傳失敗 @@ -34,6 +34,75 @@ GALLERY: 相簿 PICBEDS_SETTINGS: 圖床設定 PICGO_SETTINGS: PicGo設定 PLUGIN_SETTINGS: 插件設定 +PICGO_CLOUD_TITLE: PicGo Cloud +PICGO_CLOUD_ERROR_TITLE: PicGo Cloud 錯誤 +PICGO_CLOUD_NOT_LOGGED_IN: 尚未登入 PicGo Cloud +PICGO_CLOUD_LOGIN: 登入 +PICGO_CLOUD_LOGOUT: 登出 +PICGO_CLOUD_CANCEL_LOGIN: 取消登入 +PICGO_CLOUD_RETRY: 重試 +PICGO_CLOUD_CONFIG_SYNC: 配置同步 +PICGO_CLOUD_LOGIN_IN_PROGRESS: 登入進行中,請在瀏覽器完成登入。 +PICGO_CLOUD_LOGGED_IN_AS: "已登入:${user}" +PICGO_CLOUD_OPEN: 打開 PicGo Cloud +PICGO_CLOUD_LOGIN_TIMEOUT: 登入逾時,請重試。 +PICGO_CLOUD_LOGIN_FAILED: 登入失敗,請重試。 +PICGO_CLOUD_AGREE_PREFIX: 我已閱讀並同意 PicGo 的 +PICGO_CLOUD_TERMS_OF_SERVICE: 服務條款 +PICGO_CLOUD_AGREE_AND: 以及 +PICGO_CLOUD_PRIVACY_POLICY: 隱私政策 +PICGO_CLOUD_LOGIN_EXPIRED: 登入失效,請重新登入。 +PICGO_CLOUD_ENCRYPTION_MODE_LABEL: 加密模式 +PICGO_CLOUD_ENCRYPTION_MODE_AUTO: 自動 +PICGO_CLOUD_ENCRYPTION_MODE_SERVER: 服務端加密 +PICGO_CLOUD_ENCRYPTION_MODE_E2E: 端到端加密 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_AUTO: 自動:跟隨雲端上一次配置的加密方式(預設服務端加密)。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_SERVER: 服務端加密:我們會在服務端對你的配置加密後再儲存,不需要 PIN。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_E2E: 端到端加密:需要你輸入 PIN 來加密/解密資料。PicGo 不儲存 PIN,遺失將無法找回資料。 +PICGO_CLOUD_ENCRYPTION_MODE_TIP_DOC: 查看完整文檔 +PICGO_CLOUD_E2E_CHECKBOX_LABEL: 開啟 E2E 加密 +PICGO_CLOUD_E2E_ENABLE_WARNING_TITLE: 開啟 E2E 加密 +PICGO_CLOUD_E2E_ENABLE_WARNING_MESSAGE: E2E 加密需要你自行妥善保管 PIN。PIN 遺失將無法恢復加密資料。PicGo 不會儲存 PIN 或任何恢復資訊。 +PICGO_CLOUD_REMOTE_E2E_AUTO_ENABLED: 偵測到遠端配置已開啟 E2E 加密,已自動在本地開啟 E2E。 +PICGO_CLOUD_E2E_PIN_SETUP_TITLE: 設定 E2E PIN +PICGO_CLOUD_E2E_PIN_DECRYPT_TITLE: 輸入 E2E PIN +PICGO_CLOUD_E2E_PIN_RETRY_TITLE: "PIN 錯誤,請重試(第 ${retryCount} 次)。" +PICGO_CLOUD_E2E_PIN_PLACEHOLDER: PIN +PICGO_CLOUD_E2E_PIN_CONFIRM_PLACEHOLDER: 確認 PIN +PICGO_CLOUD_CONFIG_SYNC_SUCCESS: 配置同步成功。 +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_DETECTED: 偵測到配置衝突,請選擇解決方案。 +PICGO_CLOUD_CONFIG_SYNC_FAILED: 配置同步失敗。 +PICGO_CLOUD_CONFIG_SYNC_ABORTED: 已取消配置同步。 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE: 確認切換加密方式嗎? +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_BODY: "您正在從「${from}」切換為「${to}」。\n\n注意:切換加密模式將清空您所有的雲端歷史版本記錄。\n這是因為舊的歷史版本無法在新模式下被解密或驗證。\n切換後,系統將立即為您建立一份新的備份作為起點。" +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM: 確認切換並清空歷史 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL: 取消 +PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED: 已取消切換加密方式 +PICGO_CLOUD_CONFIG_SYNC_FAILED_WITH_REASON: "配置同步失敗:${reason}" +PICGO_CLOUD_CONFIG_SYNC_PIN_MAX_RETRY: PIN 錯誤次數過多,請稍後重試。 +PICGO_CLOUD_CONFIG_SYNC_LOCAL_CONFIG_INVALID: 本地配置檔格式錯誤,請檢查配置檔。 +PICGO_CLOUD_CONFIG_SYNC_IN_PROGRESS: 配置同步進行中… +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_PENDING: 存在未解決的衝突,請先處理。 +PICGO_CLOUD_CONFIG_SYNC_NO_CONFLICT_SESSION: 未找到可處理的衝突工作階段。 +PICGO_CLOUD_CONFIG_SYNC_RESOLUTION_INCOMPLETE: 請為所有衝突項選擇本地或雲端。 +PICGO_CLOUD_CONFIG_SYNC_STARTING: 配置同步已開始… +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_TITLE: "衝突處理(${count} 項)" +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_LOCAL: 全選本地 +PICGO_CLOUD_CONFIG_SYNC_CHOOSE_ALL_CLOUD: 全選雲端 +PICGO_CLOUD_CONFIG_SYNC_RESET_ALL: 重置全部 +PICGO_CLOUD_CONFIG_SYNC_LOCAL_VERSION: 本地版本 +PICGO_CLOUD_CONFIG_SYNC_CLOUD_VERSION: 雲端版本 +PICGO_CLOUD_CONFIG_SYNC_ABORT: 放棄同步 +PICGO_CLOUD_CONFIG_SYNC_CONFIRM_AND_SYNC: 確認並同步 +PICGO_CLOUD_CONFIG_SYNC_VALUE_UNDEFINED: (空) +PICGO_CLOUD_CONFIG_SYNC_CONFLICT_RESOLVED: 配置衝突已解決。 +PICGO_CLOUD_LAST_SYNC_TIME: "上次本地同步時間:${time}" +PICGO_CLOUD_LAST_SYNC_TIME_NONE: 無 +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_TITLE: 需要重啟嗎? +PICGO_CLOUD_CONFIG_SYNC_RESTART_PROMPT_MESSAGE: 部分配置可能需要重啟後生效,是否立即重啟? +PICGO_CLOUD_CONFIG_SYNC_RESTART_NOW: 立即重啟 +PICGO_CLOUD_CONFIG_SYNC_RESTART_LATER: 稍後 +INPUT_BOX_CONFIRM_MISMATCH: 兩次輸入不一致,請重新輸入。 PICGO_SPONSOR_TEXT: PicGo是開放原始碼的軟體,如果你喜歡它,對你有幫助,不妨請我喝杯咖啡? ALIPAY: 支付寶 WECHATPAY: 微信支付 @@ -309,37 +378,6 @@ TIPS_UPLOADER_CONFIG_NOT_FOUND: 未找到該配置 TIPS_UPLOADER_CONFIG_CANNOT_DELETE_LAST: 無法刪除最後一個配置 # privacy -PRIVACY: > - - 本軟體尊重並保護所有使用服務用戶的個人隱私權。為了給您提供更準確、更優質的服務,本軟體會按照本隱私權政策的規定使用和收集您的一些行為信息。您在同意本軟體服務使用協議之時,即視為您已經同意本隱私權政策全部內容。本隱私權政策屬於本軟體服務使用協議不可分割的一部分,如果不同意將無法使用。本協議會定期更新。 - - - 1.適用範圍 - - - a)在您使用本軟體時,本軟體會記錄的您對本軟體的一些操作行為信息,包括但不限於您使用本軟體進行文件上傳的耗時、類型、數量等信息。 - - - 2.信息的使用 - - - a)在獲得您的使用數據之後,本軟體會將其上傳至數據分析服務器,以便分析數據後,提供給您更好的服務。 - - - 3.信息披露 - - - a)本軟體不會將您的信息披露給不受信任的第三方。 - - - b)根據法律的有關規定,或者行政或司法機構的要求,向第三方或者行政、司法機構披露; - - - - - 4.信息安全 - - - a)本軟體不會收集您的個人信息、密鑰信息等隱私信息,所收集的信息僅僅作為改善軟體、優化體驗、了解軟體日活等用途。 +PRIVACY: "使用前請閱讀並同意隱私政策 ${privacyUrl} 與服務條款 ${termsUrl},同意後方可使用。" PRIVACY_TIPS: 請同意隱私協議,否則無法上傳。 QUIT: 退出 diff --git a/scripts/gen-i18n-types.js b/scripts/gen-i18n-types.js index 3f15626..c20c130 100644 --- a/scripts/gen-i18n-types.js +++ b/scripts/gen-i18n-types.js @@ -1,3 +1,4 @@ +/* eslint-disable @stylistic/indent */ const yaml = require('js-yaml') const path = require('path') const fs = require('fs') diff --git a/src/__tests__/main/cloud-config-sync.spec.ts b/src/__tests__/main/cloud-config-sync.spec.ts new file mode 100644 index 0000000..5f99de6 --- /dev/null +++ b/src/__tests__/main/cloud-config-sync.spec.ts @@ -0,0 +1,186 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { IpcMainInvokeEvent } from 'electron' +import os from 'node:os' +import path from 'node:path' +import fs from 'fs-extra' +import { IRPCActionType } from '~/universal/types/enum' +import { IPicGoCloudConfigSyncToastType } from '#/types/cloudConfigSync' + +type OnAskEncryptionSwitch = (context: { from: string; to: string }) => Promise + +type SyncImplementation = (askSwitch?: OnAskEncryptionSwitch) => Promise<{ status: string; message?: string }> + +const showMessageBoxMock = vi.fn() +const showInputBoxMock = vi.fn() +const getUserInfoMock = vi.fn() +const getConfigMock = vi.fn() +const saveConfigMock = vi.fn() +const i18nTranslateMock = vi.fn((key: string) => key) + +let baseDir = '' +let syncImplementation: SyncImplementation | null = null + +const createInvokeEvent = (): IpcMainInvokeEvent => { + const event = { + sender: { + send: vi.fn() + } + } + return event as unknown as IpcMainInvokeEvent +} + +vi.mock('@core/picgo', () => { + return { + default: { + get baseDir () { + return baseDir + }, + getConfig: getConfigMock, + saveConfig: saveConfigMock, + cloud: { + getUserInfo: getUserInfoMock, + login: vi.fn(), + logout: vi.fn(), + disposeLoginFlow: vi.fn() + }, + i18n: { + translate: i18nTranslateMock + } + } + } +}) + +vi.mock('apis/gui', () => { + return { + default: { + getInstance: () => ({ + showInputBox: showInputBoxMock, + showMessageBox: showMessageBoxMock + }) + } + } +}) + +vi.mock('apis/core/picgo/logger', () => { + return { + default: { + info: vi.fn(), + warn: vi.fn(), + error: vi.fn() + } + } +}) + +vi.mock('picgo', () => { + const SyncStatus = { + SUCCESS: 'success', + CONFLICT: 'conflict', + FAILED: 'failed' + } + const EncryptionMethod = { + AUTO: 'auto', + SSE: 'sse', + E2EE: 'e2ee' + } + const E2EAskPinReason = { + SETUP: 'setup', + DECRYPT: 'decrypt', + RETRY: 'retry' + } + const ConflictType = { + CONFLICT: 'conflict' + } + + class ConfigSyncManager { + private readonly onAskEncryptionSwitch?: OnAskEncryptionSwitch + + constructor (_ctx: unknown, options: { onAskEncryptionSwitch?: OnAskEncryptionSwitch } = {}) { + this.onAskEncryptionSwitch = options.onAskEncryptionSwitch + } + + async sync (): Promise<{ status: string; message?: string }> { + if (syncImplementation) { + return syncImplementation(this.onAskEncryptionSwitch) + } + return { status: SyncStatus.SUCCESS } + } + } + + return { + ConfigSyncManager, + ConflictType, + E2EAskPinReason, + EncryptionMethod, + SyncStatus + } +}) + +describe('config sync encryption switch confirmation (main)', () => { + beforeEach(async () => { + vi.clearAllMocks() + syncImplementation = null + getConfigMock.mockReturnValue(undefined) + getUserInfoMock.mockResolvedValue({ user: 'tester' }) + i18nTranslateMock.mockImplementation((key: string) => key) + baseDir = await fs.mkdtemp(path.join(os.tmpdir(), 'picgo-gui-config-sync-')) + }) + + afterEach(async () => { + if (baseDir) { + await fs.remove(baseDir) + } + }) + + it('prompts for confirmation and proceeds on confirm', async () => { + showMessageBoxMock.mockResolvedValue({ result: 0, checkboxChecked: false }) + syncImplementation = async (askSwitch) => { + if (askSwitch) { + const confirmed = await askSwitch({ from: 'e2ee', to: 'sse' }) + if (!confirmed) { + return { status: 'failed', message: i18nTranslateMock('CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED') } + } + } + return { status: 'success', message: 'ok' } + } + + const { cloudRouter } = await import('../../main/events/rpc/routes/cloud') + const handler = cloudRouter.routes().get(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_START) + const res = await handler?.([], createInvokeEvent()) + + expect(showMessageBoxMock).toHaveBeenCalledTimes(1) + expect(showMessageBoxMock).toHaveBeenCalledWith({ + title: 'PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE', + message: 'PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_BODY', + type: 'warning', + buttons: [ + 'PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM', + 'PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL' + ] + }) + expect(res?.success).toBe(true) + expect(res?.data.toastType).toBe(IPicGoCloudConfigSyncToastType.SUCCESS) + expect(res?.data.message).toBe('PICGO_CLOUD_CONFIG_SYNC_SUCCESS') + }) + + it('maps encryption-switch cancel to warning', async () => { + showMessageBoxMock.mockResolvedValue({ result: 1, checkboxChecked: false }) + syncImplementation = async (askSwitch) => { + if (askSwitch) { + const confirmed = await askSwitch({ from: 'sse', to: 'e2ee' }) + if (!confirmed) { + return { status: 'failed', message: i18nTranslateMock('CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED') } + } + } + return { status: 'success', message: 'ok' } + } + + const { cloudRouter } = await import('../../main/events/rpc/routes/cloud') + const handler = cloudRouter.routes().get(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_START) + const res = await handler?.([], createInvokeEvent()) + + expect(showMessageBoxMock).toHaveBeenCalledTimes(1) + expect(res?.success).toBe(true) + expect(res?.data.toastType).toBe(IPicGoCloudConfigSyncToastType.WARNING) + expect(res?.data.message).toBe('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED') + }) +}) diff --git a/src/__tests__/main/server.spec.ts b/src/__tests__/main/server.spec.ts new file mode 100644 index 0000000..2a71d0d --- /dev/null +++ b/src/__tests__/main/server.spec.ts @@ -0,0 +1,309 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import fs from 'fs-extra' +import os from 'node:os' +import path from 'node:path' + +type ServerConfig = { + port: number | string + host: string + enable: boolean +} + +type HonoContextLike = { + req: { + raw: Request + formData: () => Promise + } + json: (data: unknown, status?: number) => Response +} + +type UploadHandler = (c: HonoContextLike) => Promise + +const isRecord = (value: unknown): value is Record => { + return typeof value === 'object' && value !== null +} + +const createJsonContext = (req: Request): HonoContextLike => { + return { + req: { + raw: req, + formData: async () => new FormData() + }, + json: (data: unknown, status: number = 200) => { + return new Response(JSON.stringify(data), { + status, + headers: { + 'content-type': 'application/json' + } + }) + } + } +} + +const readJson = async (res: Response): Promise => { + const text = await res.text() + try { + return JSON.parse(text) + } catch { + return text + } +} + +let serverConfig: ServerConfig | undefined +let registeredUploadHandler: UploadHandler | undefined +let formImageDir: string + +const getConfigMock = vi.fn((key?: string) => { + if (key === 'settings.server') return serverConfig + return undefined +}) + +const saveConfigMock = vi.fn((patch: unknown) => { + if (!isRecord(patch)) return + const next = patch['settings.server'] + if (isRecord(next) && 'port' in next && 'host' in next && 'enable' in next) { + serverConfig = next as unknown as ServerConfig + } +}) + +const registerPostMock = vi.fn((routePath: string, handler: unknown, isInternal?: boolean) => { + if (routePath === '/upload' && typeof handler === 'function') { + registeredUploadHandler = handler as unknown as UploadHandler + } + return { routePath, isInternal } +}) + +const listenMock = vi.fn() +const shutdownMock = vi.fn() + +const loggerMock = { + info: vi.fn(), + warn: vi.fn(), + error: vi.fn() +} + +const getAvailableWindowMock = vi.fn() +const uploadClipboardFilesMock = vi.fn() +const uploadSelectedFilesMock = vi.fn() + +const dbPathDirMock = vi.fn(() => path.join(os.tmpdir(), 'picgo-gui-store')) +const getFormImageFolderPathMock = vi.fn(() => formImageDir) + +const cleanupFormUploaderFilesMock = vi.fn((fileInfoList?: unknown) => { + if (!Array.isArray(fileInfoList)) return + for (const item of fileInfoList) { + if (typeof item === 'string') { + try { + fs.removeSync(item) + } catch { + // ignore + } + } + } +}) + +vi.mock('@core/picgo', () => { + return { + default: { + getConfig: getConfigMock, + saveConfig: saveConfigMock, + server: { + registerPost: registerPostMock, + listen: listenMock, + shutdown: shutdownMock + } + } + } +}) + +vi.mock('@core/picgo/logger', () => { + return { default: loggerMock } +}) + +vi.mock('apis/app/window/windowManager', () => { + return { + default: { + getAvailableWindow: getAvailableWindowMock + } + } +}) + +vi.mock('apis/app/uploader/apis', () => { + return { + uploadClipboardFiles: uploadClipboardFilesMock, + uploadSelectedFiles: uploadSelectedFilesMock + } +}) + +vi.mock('apis/core/datastore/dbChecker', () => { + return { + dbPathDir: dbPathDirMock, + getFormImageFolderPath: getFormImageFolderPathMock + } +}) + +vi.mock('~/main/utils/cleanupFormUploaderFiles', () => { + return { + cleanupFormUploaderFiles: cleanupFormUploaderFilesMock + } +}) + +describe('main/server (GUI adapter to picgo-core)', () => { + beforeEach(async () => { + serverConfig = undefined + registeredUploadHandler = undefined + formImageDir = await fs.mkdtemp(path.join(os.tmpdir(), 'picgo-gui-form-')) + + vi.clearAllMocks() + vi.resetModules() + }) + + afterEach(async () => { + await fs.remove(formImageDir) + }) + + it('backfills default settings.server when missing', async () => { + serverConfig = undefined + + await import('../../main/server') + + expect(saveConfigMock).toHaveBeenCalledWith({ + 'settings.server': { + port: 36677, + host: '127.0.0.1', + enable: true + } + }) + expect(serverConfig).toEqual({ + port: 36677, + host: '127.0.0.1', + enable: true + }) + }) + + it('does not listen when settings.server.enable is false', async () => { + serverConfig = { port: 36677, host: '127.0.0.1', enable: false } + const mod = await import('../../main/server') + const server = mod.default + + server.startup() + + expect(registerPostMock).not.toHaveBeenCalled() + expect(listenMock).not.toHaveBeenCalled() + }) + + it('registers internal /upload override and delegates listen/shutdown to picgo.server', async () => { + serverConfig = { port: '36677', host: '127.0.0.1', enable: true } + listenMock.mockResolvedValue(36677) + + const mod = await import('../../main/server') + const server = mod.default + + server.startup() + + expect(registerPostMock).toHaveBeenCalledTimes(1) + expect(registerPostMock).toHaveBeenCalledWith('/upload', expect.any(Function), true) + expect(listenMock).toHaveBeenCalledWith(36677, '127.0.0.1') + + server.shutdown() + expect(shutdownMock).toHaveBeenCalledTimes(1) + }) + + it('implements GUI-compatible /upload JSON semantics with core-style status codes', async () => { + serverConfig = { port: 36677, host: '127.0.0.1', enable: true } + uploadClipboardFilesMock.mockResolvedValue('https://a.example/clipboard.png') + uploadSelectedFilesMock.mockResolvedValue(['https://a.example/a.png']) + getAvailableWindowMock.mockReturnValue({ webContents: {} }) + + const mod = await import('../../main/server') + const server = mod.default + server.startup() + + expect(registeredUploadHandler).toBeDefined() + const handler = registeredUploadHandler! + + const resEmpty = await handler(createJsonContext(new Request('http://127.0.0.1/upload', { method: 'POST' }))) + expect(resEmpty.status).toBe(200) + expect(await readJson(resEmpty)).toEqual({ success: true, result: ['https://a.example/clipboard.png'] }) + + const resObj = await handler(createJsonContext(new Request('http://127.0.0.1/upload', { method: 'POST', body: '{}' }))) + expect(resObj.status).toBe(200) + expect(await readJson(resObj)).toEqual({ success: true, result: ['https://a.example/clipboard.png'] }) + + const resEmptyList = await handler(createJsonContext(new Request('http://127.0.0.1/upload', { + method: 'POST', + body: JSON.stringify({ list: [] }) + }))) + expect(resEmptyList.status).toBe(200) + expect(await readJson(resEmptyList)).toEqual({ success: true, result: ['https://a.example/clipboard.png'] }) + + const resList = await handler(createJsonContext(new Request('http://127.0.0.1/upload', { + method: 'POST', + body: JSON.stringify({ list: ['/a.png'] }) + }))) + expect(resList.status).toBe(200) + expect(await readJson(resList)).toEqual({ success: true, result: ['https://a.example/a.png'] }) + + const resInvalid = await handler(createJsonContext(new Request('http://127.0.0.1/upload', { method: 'POST', body: '{' }))) + expect(resInvalid.status).toBe(400) + expect(await readJson(resInvalid)).toMatchObject({ success: false }) + }) + + it('writes multipart files to fixed temp folder and always cleans up (success/failure)', async () => { + serverConfig = { port: 36677, host: '127.0.0.1', enable: true } + getAvailableWindowMock.mockReturnValue({ webContents: {} }) + + const mod = await import('../../main/server') + const server = mod.default + server.startup() + + const handler = registeredUploadHandler! + + const makeMultipartContext = async (): Promise<{ ctx: HonoContextLike; expectedPath: string }> => { + const fd = new FormData() + fd.append('files', new Blob([Buffer.from('hello')], { type: 'image/png' }), 'a.png') + + const req = new Request('http://127.0.0.1/upload', { + method: 'POST', + headers: { + 'content-type': 'multipart/form-data' + } + }) + const expectedPath = path.join(formImageDir, 'a.png') + return { + ctx: { + req: { + raw: req, + formData: async () => fd + }, + json: (data: unknown, status: number = 200) => new Response(JSON.stringify(data), { status }) + }, + expectedPath + } + } + + // success case + uploadSelectedFilesMock.mockImplementation(async (_webContents: unknown, list: Array<{ path: string }>) => { + for (const item of list) { + expect(await fs.pathExists(item.path)).toBe(true) + } + return ['https://a.example/form.png'] + }) + + const { ctx: ctxSuccess, expectedPath: pathSuccess } = await makeMultipartContext() + const resSuccess = await handler(ctxSuccess) + expect(resSuccess.status).toBe(200) + expect(await readJson(resSuccess)).toEqual({ success: true, result: ['https://a.example/form.png'] }) + expect(await fs.pathExists(pathSuccess)).toBe(false) + + // failure case still cleans up + uploadSelectedFilesMock.mockRejectedValueOnce(new Error('fail')) + + const { ctx: ctxFail, expectedPath: pathFail } = await makeMultipartContext() + const resFail = await handler(ctxFail) + expect(resFail.status).toBe(500) + expect(await readJson(resFail)).toMatchObject({ success: false }) + expect(await fs.pathExists(pathFail)).toBe(false) + }) +}) + diff --git a/src/__tests__/renderer/store/appConfig.spec.ts b/src/__tests__/renderer/store/appConfig.spec.ts new file mode 100644 index 0000000..5162321 --- /dev/null +++ b/src/__tests__/renderer/store/appConfig.spec.ts @@ -0,0 +1,58 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { createApp } from 'vue' +import type { IConfig } from 'picgo' +import { getConfig, getPicBeds } from '@/utils/dataSender' +import { store, storeKey, type IStore } from '@/store' + +vi.mock('@/utils/dataSender', () => { + return { + getConfig: vi.fn(), + getPicBeds: vi.fn(), + saveConfig: vi.fn() + } +}) + +const buildStore = (): IStore => { + const app = createApp({}) + store.install(app) + return app._context.provides[storeKey as symbol] as IStore +} + +describe('renderer/store appConfig', () => { + const getConfigMock = vi.mocked(getConfig) + const getPicBedsMock = vi.mocked(getPicBeds) + + beforeEach(() => { + vi.clearAllMocks() + }) + + it('refreshAppConfig updates appConfig and defaultPicBed', async () => { + const config: IConfig = { + picBed: { + uploader: 'github', + current: 'smms' + }, + picgoPlugins: {} + } + getConfigMock.mockResolvedValue(config) + + const storeInstance = buildStore() + await storeInstance.refreshAppConfig() + + expect(storeInstance.state.appConfig).toStrictEqual(config) + expect(storeInstance.state.defaultPicBed).toBe('github') + }) + + it('refreshPicBeds updates picBeds', async () => { + const picBeds: IPicBedType[] = [ + { type: 'smms', name: 'SM.MS', visible: true }, + { type: 'github', name: 'GitHub', visible: true } + ] + getPicBedsMock.mockResolvedValue(picBeds) + + const storeInstance = buildStore() + await storeInstance.refreshPicBeds() + + expect(storeInstance.state.picBeds).toEqual(picBeds) + }) +}) diff --git a/src/__tests__/renderer/utils/dataSender.spec.ts b/src/__tests__/renderer/utils/dataSender.spec.ts new file mode 100644 index 0000000..070d7f3 --- /dev/null +++ b/src/__tests__/renderer/utils/dataSender.spec.ts @@ -0,0 +1,33 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { saveConfig } from '@/utils/dataSender' +import { PICGO_SAVE_CONFIG } from '#/events/constants' +import { ipcRenderer } from 'electron' + +vi.mock('electron', () => { + return { + ipcRenderer: { + invoke: vi.fn(), + on: vi.fn(), + once: vi.fn(), + send: vi.fn(), + removeListener: vi.fn() + } + } +}) + +describe('renderer/utils/dataSender', () => { + const ipcRendererMock = vi.mocked(ipcRenderer) + + beforeEach(() => { + vi.clearAllMocks() + ipcRendererMock.invoke.mockResolvedValue(true) + }) + + it('invokes save config IPC after saveConfig', async () => { + await saveConfig('settings.language', 'en') + + expect(ipcRendererMock.invoke).toHaveBeenCalledWith(PICGO_SAVE_CONFIG, { + 'settings.language': 'en' + }) + }) +}) diff --git a/src/main/apis/app/system/index.ts b/src/main/apis/app/system/index.ts index dfeddb2..be3c363 100644 --- a/src/main/apis/app/system/index.ts +++ b/src/main/apis/app/system/index.ts @@ -66,7 +66,7 @@ export function createContextMenu () { } }, { - label: T('PRIVACY_AGREEMENT'), + label: T('PRIVACY_TERMS_AGREEMENT'), click () { privacyManager.show(false) } diff --git a/src/main/apis/app/uploader/index.ts b/src/main/apis/app/uploader/index.ts index c8378be..86de881 100644 --- a/src/main/apis/app/uploader/index.ts +++ b/src/main/apis/app/uploader/index.ts @@ -19,7 +19,6 @@ import path from 'path' import { privacyManager } from '~/main/utils/privacyManager' import writeFile from 'write-file-atomic' import { CLIPBOARD_IMAGE_FOLDER } from '~/universal/utils/static' -import { cleanupFormUploaderFiles } from '~/main/utils/cleanupFormUploaderFiles' import { IpcMainEvent } from 'electron/main' import { dataReportManager } from '~/main/utils/dataReport' @@ -161,7 +160,6 @@ class Uploader { return false } finally { ipcMain.removeAllListeners(GET_RENAME_FILE_NAME) - cleanupFormUploaderFiles(img) } } } diff --git a/src/main/apis/app/window/windowList.ts b/src/main/apis/app/window/windowList.ts index a845bc9..9189e3a 100644 --- a/src/main/apis/app/window/windowList.ts +++ b/src/main/apis/app/window/windowList.ts @@ -12,7 +12,7 @@ import { CREATE_APP_MENU } from '@core/bus/constants' import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants' import { app } from 'electron' import { T } from '~/main/i18n' -import { isLinux } from '~/universal/utils/common' +import { isLinux, isWindows } from '~/universal/utils/common' import { getStaticPath } from '#/utils/staticPath' import picgo from '@core/picgo' // import { URLSearchParams } from 'url' @@ -37,7 +37,7 @@ const handleWindowParams = (windowURL: string) => { } export const isWindowShouldShowOnStartup = (currentWindow: IWindowList) => { - const startupMode = picgo.getConfig('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE) + const startupMode = picgo.getConfig('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : isWindows ? IStartupMode.SHOW_MAIN_WINDOW : IStartupMode.HIDE) switch (currentWindow) { case IWindowList.MINI_WINDOW: { return startupMode === IStartupMode.SHOW_MINI_WINDOW diff --git a/src/main/apis/core/picgo/index.ts b/src/main/apis/core/picgo/index.ts index ec452de..9b55147 100644 --- a/src/main/apis/core/picgo/index.ts +++ b/src/main/apis/core/picgo/index.ts @@ -1,4 +1,5 @@ import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker' +import { shell } from 'electron' import pkg from 'root/package.json' import { PicGo } from 'picgo' @@ -15,6 +16,10 @@ picgo.saveConfig({ global.PICGO_GUI_VERSION = pkg.version picgo.GUI_VERSION = global.PICGO_GUI_VERSION +picgo.openUrl = (url: string) => { + return shell.openExternal(url) +} + // const originPicGoSaveConfig = picgo.saveConfig.bind(picgo) // function flushDB () { diff --git a/src/main/events/picgoCoreIPC.ts b/src/main/events/picgoCoreIPC.ts index 69744d8..597805f 100644 --- a/src/main/events/picgoCoreIPC.ts +++ b/src/main/events/picgoCoreIPC.ts @@ -38,6 +38,7 @@ import { GalleryDB } from 'apis/core/datastore' import { IObject, IFilter } from '@picgo/store/dist/types' import pasteTemplate from '../utils/pasteTemplate' import { i18nManager, T } from '~/main/i18n' +import { notifyAppConfigUpdated } from '~/main/utils/appConfigNotifier' import { rpcServer } from './rpc' const STORE_PATH = path.dirname(dbPathChecker()) @@ -259,6 +260,7 @@ const handleRemoveFiles = () => { const handlePicGoSaveConfig = () => { ipcMain.handle(PICGO_SAVE_CONFIG, (_event, data: IObj) => { picgo.saveConfig(data) + notifyAppConfigUpdated() return true }) } diff --git a/src/main/events/remotes/menu.ts b/src/main/events/remotes/menu.ts index 4f52c41..3e730ed 100644 --- a/src/main/events/remotes/menu.ts +++ b/src/main/events/remotes/menu.ts @@ -49,7 +49,7 @@ const buildMiniPageMenu = () => { } }, { - label: T('PRIVACY_AGREEMENT'), + label: T('PRIVACY_TERMS_AGREEMENT'), click () { privacyManager.show(false) } @@ -110,7 +110,7 @@ const buildMainPageMenu = (win: BrowserWindow) => { } }, { - label: T('PRIVACY_AGREEMENT'), + label: T('PRIVACY_TERMS_AGREEMENT'), click () { privacyManager.show(false) } diff --git a/src/main/events/rpc/index.ts b/src/main/events/rpc/index.ts index 86419e0..9babaf3 100644 --- a/src/main/events/rpc/index.ts +++ b/src/main/events/rpc/index.ts @@ -1,4 +1,4 @@ -import { ipcMain, IpcMainEvent } from 'electron' +import { ipcMain, IpcMainEvent, IpcMainInvokeEvent } from 'electron' import { IRPCActionType } from '~/universal/types/enum' import { RPC_ACTIONS } from '#/events/constants' import { configRouter } from './routes/config' @@ -6,11 +6,13 @@ import { versionRouter } from './routes/version' import { toolboxRouter } from './routes/toolbox' import { systemRouter } from './routes/system' import { galleryToolboxRouter } from './routes/galleryToolbox' +import { cloudRouter } from './routes/cloud' +import { fail, isIRPCResult, ok } from './utils' class RPCServer implements IRPCServer { private routes: IRPCRoutes = new Map() - private rpcEventHandler = async (event: IpcMainEvent, action: IRPCActionType, args: any[], callbackId: string) => { + private rpcEventHandler = async (event: IpcMainEvent, action: IRPCActionType, args: any[], callbackId?: string) => { try { const handler = this.routes.get(action) if (!handler) { @@ -23,11 +25,25 @@ class RPCServer implements IRPCServer { } } + private rpcInvokeHandler = async (_event: IpcMainInvokeEvent, action: IRPCActionType, args: any[] = []) => { + const handler = this.routes.get(action) + if (!handler) { + return fail(new Error(`RPC action not supported: ${action}`)) + } + try { + const res = await handler(args, _event) + // For invoke-based RPC, normalize the return value to IRPCResult. + return isIRPCResult(res) ? res : ok(res) + } catch (e) { + return fail(e) + } + } + /** * if sendback data is null, then it means that the action is not supported or error occurs * if there is no callbackId, then do not send back */ - private sendBack (event: IpcMainEvent, action: IRPCActionType, data: any, callbackId: string) { + private sendBack (event: IpcMainEvent, action: IRPCActionType, data: any, callbackId?: string) { if (callbackId) { event.sender.send(RPC_ACTIONS, data, action, callbackId) } @@ -35,6 +51,7 @@ class RPCServer implements IRPCServer { start () { ipcMain.on(RPC_ACTIONS, this.rpcEventHandler) + ipcMain.handle(RPC_ACTIONS, this.rpcInvokeHandler) } use (routes: IRPCRoutes) { @@ -45,6 +62,7 @@ class RPCServer implements IRPCServer { stop () { ipcMain.off(RPC_ACTIONS, this.rpcEventHandler) + ipcMain.removeHandler(RPC_ACTIONS) } } @@ -55,6 +73,7 @@ rpcServer.use(versionRouter.routes()) rpcServer.use(toolboxRouter.routes()) rpcServer.use(systemRouter.routes()) rpcServer.use(galleryToolboxRouter.routes()) +rpcServer.use(cloudRouter.routes()) export { rpcServer diff --git a/src/main/events/rpc/routes/cloud.ts b/src/main/events/rpc/routes/cloud.ts new file mode 100644 index 0000000..3099710 --- /dev/null +++ b/src/main/events/rpc/routes/cloud.ts @@ -0,0 +1,560 @@ +import { IRPCActionType } from '~/universal/types/enum' +import { RPCRouter } from '../router' +import picgo from '@core/picgo' +import type { IPicGoCloudUserInfo } from '#/types/cloud' +import { T } from '~/main/i18n' +import { fail, ok } from '../utils' +import GuiApi from 'apis/gui' +import fs from 'fs-extra' +import { parse } from 'comment-json' +import { cloneDeep, isPlainObject, set, unset } from 'lodash' +import path from 'path' +import logger from 'apis/core/picgo/logger' +import { + ConfigSyncManager, + ConflictType, + E2EAskPinReason, + EncryptionMethod, + SyncStatus, + type IDiffNode, + type IConfig +} from 'picgo' +import { + IPicGoCloudConfigSyncConflictChoice, + IPicGoCloudConfigSyncRunStatus, + IPicGoCloudConfigSyncSessionStatus, + IPicGoCloudConfigSyncToastType, + IPicGoCloudEncryptionMethod, + type IPicGoCloudConfigSyncConflictItem, + type IPicGoCloudConfigSyncResolution, + type IPicGoCloudConfigSyncRunResult, + type IPicGoCloudConfigSyncState +} from '#/types/cloudConfigSync' + +const cloudRouter = new RPCRouter() + +const LOGIN_TIMEOUT_MS = 5 * 60 * 1000 +const USER_ABORTED_CODE = 'PICGO_CLOUD_CONFIG_SYNC_ABORTED' + +/** + * Config sync session state MUST live in the main process (memory only) so the UI can re-hydrate + * after window hide/show without losing an in-progress/conflict state. + */ +let configSyncSessionStatus: IPicGoCloudConfigSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.IDLE +let configSyncConflictDiffTree: IDiffNode | null = null +let configSyncConflictItems: IPicGoCloudConfigSyncConflictItem[] = [] +let configSyncManager: ConfigSyncManager | null = null + +const clearConfigSyncSession = (): void => { + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.IDLE + configSyncConflictDiffTree = null + configSyncConflictItems = [] +} + +const logConfigSyncOutcome = ( + stage: 'sync' | 'applyResolvedConfig', + status: SyncStatus, + message?: string, + meta: { conflictCount?: number } = {} +): void => { + const prefix = `[PicGo Cloud][config-sync][${stage}]` + if (status === SyncStatus.SUCCESS) { + logger.info(`${prefix} success`) + return + } + + if (status === SyncStatus.CONFLICT) { + const count = typeof meta.conflictCount === 'number' ? meta.conflictCount : 0 + logger.warn(`${prefix} conflict`, `count=${count}`) + return + } + + if (message === USER_ABORTED_CODE || message === 'Invalid PIN input') { + logger.warn(`${prefix} aborted`) + return + } + + logger.error(`${prefix} failed`, message || '') +} + +const getLocalEncryptionMethod = (): IPicGoCloudEncryptionMethod | undefined => { + const value = picgo.getConfig('settings.picgoCloud.encryptionMethod') + if ( + value === IPicGoCloudEncryptionMethod.AUTO + || value === IPicGoCloudEncryptionMethod.SSE + || value === IPicGoCloudEncryptionMethod.E2EE + ) { + return value + } + return undefined +} + +const toSyncEncryptionMethod = (method?: IPicGoCloudEncryptionMethod): EncryptionMethod | undefined => { + if (method === IPicGoCloudEncryptionMethod.AUTO) return EncryptionMethod.AUTO + if (method === IPicGoCloudEncryptionMethod.SSE) return EncryptionMethod.SSE + if (method === IPicGoCloudEncryptionMethod.E2EE) return EncryptionMethod.E2EE + return undefined +} + +const getSnapshotUpdatedAt = async (): Promise => { + try { + const snapshotPath = path.join(picgo.baseDir, 'config.snapshot.json') + if (!(await fs.pathExists(snapshotPath))) return undefined + const content = await fs.readFile(snapshotPath, 'utf8') + const parsed: unknown = parse(content) + if (!isPlainObject(parsed)) return undefined + const updatedAt = (parsed as { updatedAt?: unknown }).updatedAt + return typeof updatedAt === 'string' && updatedAt ? updatedAt : undefined + } catch { + return undefined + } +} + +const buildConfigSyncState = async (): Promise => { + return { + sessionStatus: configSyncSessionStatus, + encryptionMethod: getLocalEncryptionMethod(), + lastSyncedAt: await getSnapshotUpdatedAt(), + conflicts: configSyncSessionStatus === IPicGoCloudConfigSyncSessionStatus.CONFLICT ? configSyncConflictItems : undefined + } +} + +const readLocalConfigWithComments = async (): Promise => { + if (!(await fs.pathExists(picgo.configPath))) { + return picgo.getConfig() + } + const content = await fs.readFile(picgo.configPath, 'utf8') + const parsed: unknown = parse(content) + if (!isPlainObject(parsed)) { + throw new Error(T('PICGO_CLOUD_CONFIG_SYNC_LOCAL_CONFIG_INVALID')) + } + return parsed as IConfig +} + +const extractConflictItems = (diffTree: IDiffNode): IPicGoCloudConfigSyncConflictItem[] => { + const items: IPicGoCloudConfigSyncConflictItem[] = [] + + const walk = (node: IDiffNode, pathSegments: string[]) => { + const nextSegments = node.key === 'root' ? pathSegments : [...pathSegments, node.key] + + if (node.status === ConflictType.CONFLICT) { + // If the conflict is an object-level aggregation, surface leaf conflicts instead. + if (node.children && node.children.length > 0) { + node.children.forEach(child => walk(child, nextSegments)) + return + } + + items.push({ + path: nextSegments.join('.'), + localValue: node.localValue, + remoteValue: node.remoteValue + }) + return + } + + if (node.children && node.children.length > 0) { + node.children.forEach(child => walk(child, nextSegments)) + } + } + + walk(diffTree, []) + return items +} + +const localizeConfigSyncResult = (status: SyncStatus, message: string | undefined): { message: string, toastType: IPicGoCloudConfigSyncToastType } => { + if (status === SyncStatus.SUCCESS) { + return { + message: T('PICGO_CLOUD_CONFIG_SYNC_SUCCESS'), + toastType: IPicGoCloudConfigSyncToastType.SUCCESS + } + } + + if (status === SyncStatus.CONFLICT) { + return { + message: T('PICGO_CLOUD_CONFIG_SYNC_CONFLICT_DETECTED'), + toastType: IPicGoCloudConfigSyncToastType.INFO + } + } + + const raw = message || T('PICGO_CLOUD_CONFIG_SYNC_FAILED') + + const isEncryptionSwitchCancelled = message === picgo.i18n.translate('CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED') + if (raw === USER_ABORTED_CODE || raw === 'Invalid PIN input' || isEncryptionSwitchCancelled) { + return { + message: isEncryptionSwitchCancelled + ? T('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCELLED') + : T('PICGO_CLOUD_CONFIG_SYNC_ABORTED'), + toastType: IPicGoCloudConfigSyncToastType.WARNING + } + } + + if (raw === 'Maximum retry attempts exceeded') { + return { + message: T('PICGO_CLOUD_CONFIG_SYNC_PIN_MAX_RETRY'), + toastType: IPicGoCloudConfigSyncToastType.ERROR + } + } + + return { + message: T('PICGO_CLOUD_CONFIG_SYNC_FAILED_WITH_REASON', { reason: raw }), + toastType: IPicGoCloudConfigSyncToastType.ERROR + } +} + +const getEncryptionMethodLabel = (method: EncryptionMethod): string => { + if (method === EncryptionMethod.E2EE) return T('PICGO_CLOUD_ENCRYPTION_MODE_E2E') + return T('PICGO_CLOUD_ENCRYPTION_MODE_SERVER') +} + +const getConfigSyncManager = (): ConfigSyncManager => { + if (configSyncManager) return configSyncManager + + const guiApi = GuiApi.getInstance() + configSyncManager = new ConfigSyncManager(picgo, { + onAskPin: async (reason: E2EAskPinReason, retryCount: number) => { + const inputOptions: IShowInputBoxOption = { + title: (() => { + if (reason === E2EAskPinReason.SETUP) return T('PICGO_CLOUD_E2E_PIN_SETUP_TITLE') + if (reason === E2EAskPinReason.DECRYPT) return T('PICGO_CLOUD_E2E_PIN_DECRYPT_TITLE') + return T('PICGO_CLOUD_E2E_PIN_RETRY_TITLE', { retryCount }) + })(), + placeholder: T('PICGO_CLOUD_E2E_PIN_PLACEHOLDER'), + inputType: 'password', + width: 520, + confirm: reason === E2EAskPinReason.SETUP + ? { placeholder: T('PICGO_CLOUD_E2E_PIN_CONFIRM_PLACEHOLDER') } + : undefined + } + + const value = await guiApi.showInputBox(inputOptions) + if (!value) { + // Throw a sentinel code so we can treat it as a user-aborted flow in the GUI. + throw new Error(USER_ABORTED_CODE) + } + return value + }, + onAskEncryptionSwitch: async ({ from, to }: { from: EncryptionMethod, to: EncryptionMethod }): Promise => { + const title = T('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_TITLE') + const message = T('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_BODY', { + from: getEncryptionMethodLabel(from), + to: getEncryptionMethodLabel(to) + }) + const res = await guiApi.showMessageBox({ + title, + message, + type: 'warning', + buttons: [ + T('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CONFIRM'), + T('PICGO_CLOUD_CONFIG_SYNC_ENCRYPTION_SWITCH_CANCEL') + ] + }) + return res.result === 0 + } + }) + + return configSyncManager +} + +const buildResolvedConfig = async (resolution: IPicGoCloudConfigSyncResolution): Promise => { + const base = await readLocalConfigWithComments() + + for (const item of configSyncConflictItems) { + const choice = resolution[item.path] + if (choice === IPicGoCloudConfigSyncConflictChoice.CLOUD) { + if (item.remoteValue === undefined) { + unset(base, item.path) + } else { + set(base, item.path, cloneDeep(item.remoteValue)) + } + } + } + + return base +} + +const getUserInfo = async (): Promise => { + return await picgo.cloud.getUserInfo() +} + +const loginWithTimeout = async (): Promise => { + const loginPromise = picgo.cloud.login() + + let timeoutId: ReturnType | undefined + const timeoutPromise = new Promise((_resolve, reject) => { + timeoutId = setTimeout(() => { + picgo.cloud.disposeLoginFlow() + reject(new Error(T('PICGO_CLOUD_LOGIN_TIMEOUT'))) + }, LOGIN_TIMEOUT_MS) + }) + + try { + await Promise.race([loginPromise, timeoutPromise]) + } finally { + if (timeoutId) clearTimeout(timeoutId) + // Avoid unhandled rejection when timeout disposes the core login flow. + loginPromise.catch(() => {}) + } +} + +cloudRouter + .add(IRPCActionType.PICGO_CLOUD_GET_USER_INFO, async () => { + try { + const userInfo = await getUserInfo() + return ok(userInfo) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_LOGIN, async () => { + try { + await loginWithTimeout() + const userInfo = await getUserInfo() + console.log('userInfo after login', userInfo) + if (!userInfo) { + return fail(T('PICGO_CLOUD_LOGIN_FAILED')) + } + return ok(userInfo) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_LOGOUT, async () => { + try { + picgo.cloud.logout() + clearConfigSyncSession() + return ok(true) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_DISPOSE_LOGIN_FLOW, async () => { + try { + picgo.cloud.disposeLoginFlow() + return ok(true) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_GET_STATE, async () => { + try { + return ok(await buildConfigSyncState()) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_SET_E2E_PREFERENCE, async (args) => { + try { + const [mode] = args as [IPicGoCloudEncryptionMethod] + if (mode === IPicGoCloudEncryptionMethod.AUTO) { + picgo.saveConfig({ + 'settings.picgoCloud.encryptionMethod': IPicGoCloudEncryptionMethod.AUTO + }) + } else if (mode === IPicGoCloudEncryptionMethod.SSE) { + picgo.saveConfig({ + 'settings.picgoCloud.encryptionMethod': IPicGoCloudEncryptionMethod.SSE + }) + } else { + picgo.saveConfig({ + 'settings.picgoCloud.encryptionMethod': IPicGoCloudEncryptionMethod.E2EE + }) + } + return ok(getLocalEncryptionMethod()) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_ABORT, async () => { + try { + clearConfigSyncSession() + return ok(await buildConfigSyncState()) + } catch (e) { + return fail(e) + } + }) + .add(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_START, async () => { + const fallbackState = await buildConfigSyncState() + + if (configSyncSessionStatus === IPicGoCloudConfigSyncSessionStatus.SYNCING) { + logger.info('[PicGo Cloud][config-sync][sync] already in progress') + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: T('PICGO_CLOUD_CONFIG_SYNC_IN_PROGRESS'), + toastType: IPicGoCloudConfigSyncToastType.INFO, + state: fallbackState + } + return ok(runRes) + } + + if (configSyncSessionStatus === IPicGoCloudConfigSyncSessionStatus.CONFLICT) { + logger.info('[PicGo Cloud][config-sync][sync] pending conflict session') + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.CONFLICT, + message: T('PICGO_CLOUD_CONFIG_SYNC_CONFLICT_PENDING'), + toastType: IPicGoCloudConfigSyncToastType.INFO, + state: fallbackState + } + return ok(runRes) + } + + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.SYNCING + + try { + const userInfo = await getUserInfo() + if (!userInfo) { + logger.warn('[PicGo Cloud][config-sync][sync] login expired') + clearConfigSyncSession() + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: T('PICGO_CLOUD_LOGIN_EXPIRED'), + toastType: IPicGoCloudConfigSyncToastType.WARNING, + authInvalidated: true, + state: await buildConfigSyncState() + } + return ok(runRes) + } + + const manager = getConfigSyncManager() + const encryptionMethod = toSyncEncryptionMethod(getLocalEncryptionMethod()) + const res = encryptionMethod + ? await manager.sync({ encryptionMethod }) + : await manager.sync() + + if (res.status === SyncStatus.CONFLICT && res.diffTree) { + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.CONFLICT + configSyncConflictDiffTree = res.diffTree + configSyncConflictItems = extractConflictItems(res.diffTree) + logConfigSyncOutcome('sync', res.status, res.message, { conflictCount: configSyncConflictItems.length }) + } else { + clearConfigSyncSession() + logConfigSyncOutcome('sync', res.status, res.message) + } + + const localized = localizeConfigSyncResult(res.status, res.message) + const runStatus = res.status === SyncStatus.SUCCESS + ? IPicGoCloudConfigSyncRunStatus.SUCCESS + : res.status === SyncStatus.CONFLICT + ? IPicGoCloudConfigSyncRunStatus.CONFLICT + : IPicGoCloudConfigSyncRunStatus.FAILED + + const runRes: IPicGoCloudConfigSyncRunResult = { + status: runStatus, + message: localized.message, + toastType: localized.toastType, + shouldShowRestartPrompt: res.status === SyncStatus.SUCCESS, + state: await buildConfigSyncState() + } + return ok(runRes) + } catch (e) { + logger.error('[PicGo Cloud][config-sync][sync] error', e) + clearConfigSyncSession() + const localized = localizeConfigSyncResult(SyncStatus.FAILED, e instanceof Error ? e.message : String(e)) + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: localized.message, + toastType: localized.toastType, + state: await buildConfigSyncState() + } + return ok(runRes) + } + }) + .add(IRPCActionType.PICGO_CLOUD_CONFIG_SYNC_APPLY_RESOLUTION, async (args) => { + try { + const [resolution] = args as [IPicGoCloudConfigSyncResolution] + + if (configSyncSessionStatus !== IPicGoCloudConfigSyncSessionStatus.CONFLICT || !configSyncConflictDiffTree) { + logger.warn('[PicGo Cloud][config-sync][applyResolvedConfig] no conflict session') + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: T('PICGO_CLOUD_CONFIG_SYNC_NO_CONFLICT_SESSION'), + toastType: IPicGoCloudConfigSyncToastType.ERROR, + state: await buildConfigSyncState() + } + return ok(runRes) + } + + const expectedPaths = new Set(configSyncConflictItems.map(item => item.path)) + const providedPaths = new Set(Object.keys(resolution)) + for (const path of expectedPaths) { + if (!providedPaths.has(path)) { + logger.warn('[PicGo Cloud][config-sync][applyResolvedConfig] resolution incomplete') + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: T('PICGO_CLOUD_CONFIG_SYNC_RESOLUTION_INCOMPLETE'), + toastType: IPicGoCloudConfigSyncToastType.ERROR, + state: await buildConfigSyncState() + } + return ok(runRes) + } + } + + const userInfo = await getUserInfo() + if (!userInfo) { + logger.warn('[PicGo Cloud][config-sync][applyResolvedConfig] login expired') + clearConfigSyncSession() + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: T('PICGO_CLOUD_LOGIN_EXPIRED'), + toastType: IPicGoCloudConfigSyncToastType.WARNING, + authInvalidated: true, + state: await buildConfigSyncState() + } + return ok(runRes) + } + + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.SYNCING + + const resolvedConfig = await buildResolvedConfig(resolution) + + const encryptionMethod = getLocalEncryptionMethod() + const manager = getConfigSyncManager() + const applyRes = await manager.applyResolvedConfig( + resolvedConfig, + encryptionMethod === IPicGoCloudEncryptionMethod.E2EE + ? { useE2E: true } + : encryptionMethod === IPicGoCloudEncryptionMethod.SSE + ? { useE2E: false } + : {} + ) + + if (applyRes.status === SyncStatus.SUCCESS) { + clearConfigSyncSession() + } else { + // Keep conflict session so the user can retry. + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.CONFLICT + } + + logConfigSyncOutcome('applyResolvedConfig', applyRes.status, applyRes.message, { conflictCount: configSyncConflictItems.length }) + + const localized = localizeConfigSyncResult(applyRes.status, applyRes.message) + const runStatus = applyRes.status === SyncStatus.SUCCESS + ? IPicGoCloudConfigSyncRunStatus.SUCCESS + : applyRes.status === SyncStatus.CONFLICT + ? IPicGoCloudConfigSyncRunStatus.CONFLICT + : IPicGoCloudConfigSyncRunStatus.FAILED + + const runRes: IPicGoCloudConfigSyncRunResult = { + status: runStatus, + message: localized.message, + toastType: localized.toastType, + shouldShowRestartPrompt: applyRes.status === SyncStatus.SUCCESS, + state: await buildConfigSyncState() + } + return ok(runRes) + } catch (e) { + logger.error('[PicGo Cloud][config-sync][applyResolvedConfig] error', e) + // Keep the conflict session so user can retry from UI. + configSyncSessionStatus = IPicGoCloudConfigSyncSessionStatus.CONFLICT + const localized = localizeConfigSyncResult(SyncStatus.FAILED, e instanceof Error ? e.message : String(e)) + const runRes: IPicGoCloudConfigSyncRunResult = { + status: IPicGoCloudConfigSyncRunStatus.FAILED, + message: localized.message, + toastType: localized.toastType, + state: await buildConfigSyncState() + } + return ok(runRes) + } + }) + +export { + cloudRouter +} diff --git a/src/main/events/rpc/routes/config.ts b/src/main/events/rpc/routes/config.ts index d952191..4cda53e 100644 --- a/src/main/events/rpc/routes/config.ts +++ b/src/main/events/rpc/routes/config.ts @@ -2,24 +2,11 @@ import { IRPCActionType } from '~/universal/types/enum' import { RPCRouter } from '../router' import picgo from '@core/picgo' import { T } from '~/main/i18n' +import { fail, ok } from '../utils' +import { notifyAppConfigUpdated } from '~/main/utils/appConfigNotifier' const configRouter = new RPCRouter() -const errorToMessage = (e: unknown): string => { - if (e instanceof Error) return e.message - return String(e) -} - -const ok = (data: T): IRPCResult => ({ - success: true, - data -}) - -const fail = (e: unknown): IRPCResult => ({ - success: false, - error: errorToMessage(e) -}) - configRouter .add(IRPCActionType.GET_PICBED_CONFIG_LIST, async (args) => { try { @@ -44,6 +31,7 @@ configRouter picgo.uploaderConfig.remove(type, configName) const configList = picgo.uploaderConfig.getConfigList(type) const activeConfig = picgo.uploaderConfig.getActiveConfig(type) + notifyAppConfigUpdated() return ok({ configList, defaultId: activeConfig?._id ?? '' @@ -58,6 +46,7 @@ configRouter picgo.uploaderConfig.copy(type, configName, newConfigName) const configList = picgo.uploaderConfig.getConfigList(type) const activeConfig = picgo.uploaderConfig.getActiveConfig(type) + notifyAppConfigUpdated() return ok({ configList, defaultId: activeConfig?._id ?? '' @@ -70,6 +59,7 @@ configRouter try { const [type, configName] = args as ISelectUploaderConfigArgs const activeConfig = picgo.uploaderConfig.use(type, configName) + notifyAppConfigUpdated() return ok(activeConfig._id) } catch (e) { return fail(e) @@ -97,6 +87,7 @@ configRouter picgo.uploaderConfig.rename(type, oldConfigName, configName) } picgo.uploaderConfig.createOrUpdate(type, configName, config) + notifyAppConfigUpdated() return ok(true) } catch (e) { return fail(e) diff --git a/src/main/events/rpc/routes/toolbox/checkFile.ts b/src/main/events/rpc/routes/toolbox/checkFile.ts index f75d009..0ef7c2f 100644 --- a/src/main/events/rpc/routes/toolbox/checkFile.ts +++ b/src/main/events/rpc/routes/toolbox/checkFile.ts @@ -1,5 +1,4 @@ import fs from 'fs-extra' -import { IpcMainEvent } from 'electron' import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum' import { sendToolboxResWithType } from './utils' import { dbPathChecker, getGalleryDBPath } from '~/main/apis/core/datastore/dbChecker' @@ -10,7 +9,7 @@ import { T } from '~/main/i18n' export const checkFileMap: IToolboxCheckerMap< IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN > = { - [IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async (event: IpcMainEvent) => { + [IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async (event) => { const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_CONFIG_FILE_BROKEN) sendToolboxRes(event, { status: IToolboxItemCheckStatus.LOADING diff --git a/src/main/events/rpc/routes/toolbox/utils.ts b/src/main/events/rpc/routes/toolbox/utils.ts index ed4befe..eedb797 100644 --- a/src/main/events/rpc/routes/toolbox/utils.ts +++ b/src/main/events/rpc/routes/toolbox/utils.ts @@ -1,7 +1,7 @@ -import { IpcMainEvent } from 'electron' +import type { IpcMainEvent, IpcMainInvokeEvent } from 'electron' import { IRPCActionType, IToolboxItemType } from '~/universal/types/enum' -export const sendToolboxResWithType = (type: IToolboxItemType) => (event: IpcMainEvent, res?: Omit) => { +export const sendToolboxResWithType = (type: IToolboxItemType) => (event: IpcMainEvent | IpcMainInvokeEvent, res?: Omit) => { return event.sender.send(IRPCActionType.TOOLBOX_CHECK_RES, { ...res, type diff --git a/src/main/events/rpc/utils.ts b/src/main/events/rpc/utils.ts new file mode 100644 index 0000000..939461d --- /dev/null +++ b/src/main/events/rpc/utils.ts @@ -0,0 +1,25 @@ +const errorToMessage = (e: unknown): string => { + if (e instanceof Error) return e.message + return String(e) +} + +export const ok = (data: T): IRPCResult => ({ + success: true, + data +}) + +export const fail = (e: unknown): IRPCResult => ({ + success: false, + error: errorToMessage(e) +}) + +export const isIRPCResult = (value: unknown): value is IRPCResult => { + if (!value || typeof value !== 'object') return false + const maybe = value as { success?: unknown, data?: unknown, error?: unknown } + if (typeof maybe.success !== 'boolean') return false + + // success=true MUST have data; success=false MUST have error. + if (maybe.success) return 'data' in maybe + return typeof maybe.error === 'string' +} + diff --git a/src/main/i18n/index.ts b/src/main/i18n/index.ts index b2b8370..b5658eb 100644 --- a/src/main/i18n/index.ts +++ b/src/main/i18n/index.ts @@ -10,8 +10,8 @@ class I18nManager { private builtinI18nFolder = getStaticPath('i18n') private outerI18nFolder = '' private localesMap: Map = new Map() - private currentLanguage: string = 'zh-CN' - readonly defaultLanguage: string = 'zh-CN' + private currentLanguage: string = 'en' + readonly defaultLanguage: string = 'en' private i18nFileList: II18nItem[] = builtinI18nList setOuterI18nFolder (folder: string) { diff --git a/src/main/migrate/index.ts b/src/main/migrate/index.ts index 490d4fe..b3968eb 100644 --- a/src/main/migrate/index.ts +++ b/src/main/migrate/index.ts @@ -11,7 +11,7 @@ const updateShortKeyFromVersion212 = (picgo: PicGoCore) => { if (shortKeyConfig === undefined) { const defaultShortKeyConfig = { enable: true, - key: 'CommandOrControl+Shift+P', + key: 'CommandOrControl+Shift+U', name: 'upload', label: T('QUICK_UPLOAD') } diff --git a/src/main/server/handler.ts b/src/main/server/handler.ts new file mode 100644 index 0000000..b96482f --- /dev/null +++ b/src/main/server/handler.ts @@ -0,0 +1,134 @@ +import logger from '@core/picgo/logger' +import windowManager from 'apis/app/window/windowManager' +import { uploadClipboardFiles, uploadSelectedFiles } from 'apis/app/uploader/apis' +import path from 'path' +import { dbPathDir, getFormImageFolderPath } from 'apis/core/datastore/dbChecker' +import fs from 'fs-extra' +import { cleanupFormUploaderFiles } from '~/main/utils/cleanupFormUploaderFiles' +import { + buildError, + buildSuccess, + getFormDataFileName, + isFileLike, + isRecord, + type HonoContextLike +} from './utils' + +const STORE_PATH = dbPathDir() +const LOG_PATH = path.join(STORE_PATH, 'picgo.log') + +const errorMessage = `upload error. see ${LOG_PATH} for more detail.` + +const handleClipboardUpload = async (c: HonoContextLike): Promise => { + try { + logger.info('[PicGo Server] upload clipboard file') + const res = await uploadClipboardFiles() + if (res) { + return c.json(buildSuccess([res])) + } + return c.json(buildError(errorMessage), 500) + } catch (e: unknown) { + logger.error('[PicGo Server] upload clipboard error', e) + return c.json(buildError(errorMessage), 500) + } +} + +const handleListUpload = async (c: HonoContextLike, list: string[]): Promise => { + try { + logger.info('[PicGo Server] upload files in list') + const win = windowManager.getAvailableWindow() + if (!win) { + return c.json(buildError(errorMessage), 500) + } + const pathList = list.map(item => ({ path: item })) + const res = await uploadSelectedFiles(win.webContents, pathList) + if (res.length) { + return c.json(buildSuccess(res)) + } + return c.json(buildError(errorMessage), 500) + } catch (e: unknown) { + logger.error('[PicGo Server] upload list error', e) + return c.json(buildError(errorMessage), 500) + } +} + +export const uploadHandler = async (c: HonoContextLike): Promise => { + const contentType = c.req.raw.headers.get('content-type') || '' + + if (contentType.includes('multipart/form-data')) { + const tempFiles: string[] = [] + try { + const formData = await c.req.formData() + const files = formData.getAll('files') as unknown[] + if (files.length === 0) { + return c.json(buildError('No files found in form-data: files'), 400) + } + + // Pre-validate to avoid leaking already-written temp files. + const fileLikes: Array[0]> = [] + for (const file of files) { + if (!isFileLike(file)) { + return c.json(buildError('Invalid form-data: files must be file(s)'), 400) + } + fileLikes.push(file) + } + + const formImagesPath = getFormImageFolderPath() + await fs.ensureDir(formImagesPath) + + for (const file of fileLikes) { + const fileName = getFormDataFileName(file) + const safeName = path.basename(fileName) + const filePath = path.join(formImagesPath, safeName) + const buffer = Buffer.from(await file.arrayBuffer()) + await fs.writeFile(filePath, buffer) + tempFiles.push(filePath) + } + + return await handleListUpload(c, tempFiles) + } catch (e: unknown) { + logger.error('[PicGo Server] process form upload error', e) + return c.json(buildError(errorMessage), 500) + } finally { + cleanupFormUploaderFiles(tempFiles) + } + } + + const bodyText = await c.req.raw.text().catch(() => '') + + // No request body -> upload from clipboard. + if (bodyText.trim() === '') { + return await handleClipboardUpload(c) + } + + let body: unknown + try { + body = JSON.parse(bodyText) + } catch { + return c.json(buildError('Invalid JSON body'), 400) + } + + // GUI compatibility: JSON without list (or empty list) -> upload from clipboard. + if (!isRecord(body) || !('list' in body)) { + return await handleClipboardUpload(c) + } + + const listValue = body.list + if (listValue === undefined) { + return await handleClipboardUpload(c) + } + + if (!Array.isArray(listValue)) { + return c.json(buildError('Invalid request body: { list: string[] } required'), 400) + } + + if (listValue.length === 0) { + return await handleClipboardUpload(c) + } + + if (!listValue.every((item) => typeof item === 'string')) { + return c.json(buildError('Invalid request body: { list: string[] } required'), 400) + } + + return await handleListUpload(c, listValue) +} diff --git a/src/main/server/index.ts b/src/main/server/index.ts index 3f3422d..8494206 100644 --- a/src/main/server/index.ts +++ b/src/main/server/index.ts @@ -1,34 +1,12 @@ -import http from 'http' -import routers from './routerManager' -import { - handleResponse, - ensureHTTPLink -} from './utils' import picgo from '@core/picgo' import logger from '@core/picgo/logger' -import axios from 'axios' -import formUploader from './middlewares/formUploader' +import { uploadHandler } from './handler' class Server { - private httpServer: http.Server private config: IServerConfig + private hasRegisteredUploadOverride = false constructor () { - let config = picgo.getConfig('settings.server') - const result = this.checkIfConfigIsValid(config) - if (result) { - this.config = config - } else { - config = { - port: 36677, - host: '127.0.0.1', - enable: true - } - this.config = config - picgo.saveConfig({ - 'settings.server': config - }) - } - this.httpServer = http.createServer(this.handleRequest) + this.config = this.ensureConfig() } private checkIfConfigIsValid (config: IObj | undefined) { @@ -39,98 +17,46 @@ class Server { } } - private handleRequest = (request: http.IncomingMessage, response: http.ServerResponse) => { - if (request.method === 'OPTIONS') { - handleResponse({ - response - }) - return + private ensureConfig (): IServerConfig { + let config = picgo.getConfig('settings.server') + if (this.checkIfConfigIsValid(config)) { + return config } - if (request.method === 'POST') { - if (!routers.getHandler(request.url!)) { - logger.warn(`[PicGo Server] don't support [${request.url}] url`) - handleResponse({ - response, - statusCode: 404, - body: { - success: false - } - }) - } else if (formUploader.isFileUpload(request)) { - formUploader.handleFileUpload(request, response) - } else { - let body: string = '' - let postObj: IObj - request.on('data', chunk => { - body += chunk - }) - request.on('end', () => { - try { - postObj = (body === '') ? {} : JSON.parse(body) - } catch (err: any) { - logger.error('[PicGo Server]', err) - return handleResponse({ - response, - body: { - success: false, - message: 'Not sending data in JSON format' - } - }) - } - logger.info('[PicGo Server] get the request', body) - const handler = routers.getHandler(request.url!) - handler!({ - ...postObj, - response - }) - }) - } - } else { - logger.warn(`[PicGo Server] don't support [${request.method}] method`) - response.statusCode = 404 - response.end() + config = { + port: 36677, + host: '127.0.0.1', + enable: true } + picgo.saveConfig({ + 'settings.server': config + }) + return config } - // port as string is a bug - private listen = (port: number | string) => { - logger.info(`[PicGo Server] is listening at ${port}`) - if (typeof port === 'string') { - port = parseInt(port, 10) - } - this.httpServer.listen(port, this.config.host).on('error', async (err: ErrnoException) => { - if (err.errno === 'EADDRINUSE') { - try { - // make sure the system has a PicGo Server instance - await axios.post(ensureHTTPLink(`${this.config.host}:${port}/heartbeat`)) - this.shutdown(true) - } catch (e) { - logger.warn(`[PicGo Server] ${port} is busy, trying with port ${(port as number) + 1}`) - // fix a bug: not write an increase number to config file - // to solve the auto number problem - this.listen((port as number) + 1) - } - } - }) + private ensureUploadOverrideRegistered () { + if (this.hasRegisteredUploadOverride) return + // @ts-expect-error override internal handler + picgo.server.registerPost('/upload', uploadHandler, true) + this.hasRegisteredUploadOverride = true } startup () { - console.log('startup', this.config.enable) + this.config = this.ensureConfig() if (this.config.enable) { - this.listen(this.config.port) + this.ensureUploadOverrideRegistered() + // let core resolve config defaults when possible, but preserve GUI config semantics. + const port = typeof this.config.port === 'string' ? parseInt(this.config.port, 10) : this.config.port + picgo.server.listen(port, this.config.host) } } - shutdown (hasStarted?: boolean) { - this.httpServer.close() - if (!hasStarted) { - logger.info('[PicGo Server] shutdown') - } + shutdown () { + picgo.server.shutdown() + logger.info('[PicGo Server] shutdown') } restart () { - this.config = picgo.getConfig('settings.server') this.shutdown() this.startup() } diff --git a/src/main/server/middlewares/formUploader.ts b/src/main/server/middlewares/formUploader.ts deleted file mode 100644 index f32397a..0000000 --- a/src/main/server/middlewares/formUploader.ts +++ /dev/null @@ -1,125 +0,0 @@ -import http from 'http' -import multer from 'multer' -import path from 'path' -import fs from 'fs' -import { dbPathDir } from 'apis/core/datastore/dbChecker' -import logger from '@core/picgo/logger' -import { handleResponse } from '../utils' -import routers from '../routerManager' -import { FORM_IMAGE_FOLDER } from '~/universal/utils/static' - -// Multer 错误类型定义 -export interface MulterError extends Error { - code: string - field?: string - storageErrors?: any[] -} - -// Multer 中间件适配器类型 -export type MulterMiddleware = ( - req: http.IncomingMessage, - res: http.ServerResponse, - callback: (error?: MulterError) => void -) => void - -// 扩展 multer 函数的返回类型 -declare module 'multer' { - interface Multer { - array(fieldname: string, maxCount?: number): MulterMiddleware; - single(fieldname: string): MulterMiddleware; - fields(fields: { name: string; maxCount?: number }[]): MulterMiddleware; - none(): MulterMiddleware; - } -} - -class FormUploader { - private upload!: multer.Multer - private formImagesPath!: string - - constructor () { - this.initializeStorage() - this.setupMulter() - } - - private initializeStorage () { - const STORE_PATH = dbPathDir() - this.formImagesPath = path.join(STORE_PATH, FORM_IMAGE_FOLDER) - if (!fs.existsSync(this.formImagesPath)) { - fs.mkdirSync(this.formImagesPath, { recursive: true }) - } - } - - private setupMulter () { - const storage = multer.diskStorage({ - destination: (req: http.IncomingMessage, file: Express.Multer.File, cb: (error: Error | null, destination: string) => void) => { - cb(null, this.formImagesPath) - }, - filename: (req: http.IncomingMessage, file: Express.Multer.File, cb: (error: Error | null, filename: string) => void) => { - cb(null, file.originalname || Date.now() + path.extname(file.originalname)) - } - }) - - this.upload = multer({ - storage - }) - } - - /** - * 处理文件上传的中间件 - */ - public handleFileUpload = (request: http.IncomingMessage, response: http.ServerResponse): void => { - logger.info('[PicGo Server] handling file upload') - - this.upload.array('files')(request, response, async (err?: MulterError) => { - if (err) { - logger.error('[PicGo Server] file upload error', err) - return handleResponse({ - response, - body: { - success: false, - message: 'File upload failed' - } - }) - } - - try { - const files = request.files - if (!files || files.length === 0) { - return handleResponse({ - response, - body: { - success: false, - message: 'No files were uploaded' - } - }) - } - const filePaths = files.map((file) => file.path) - logger.info('[PicGo Server] files uploaded: ' + filePaths.join(', ')) - - const handler = routers.getHandler(request.url!) - handler!({ - list: filePaths, - response - }) - } catch (err: any) { - logger.error('[PicGo Server] process upload files error', err) - handleResponse({ - response, - body: { - success: false, - message: 'Failed to process uploaded files' - } - }) - } - }) - } - - /** - * 检查请求是否为文件上传 - */ - public isFileUpload (request: http.IncomingMessage): boolean { - return !!(request.headers['content-type'] && request.headers['content-type'].includes('multipart/form-data')) - } -} - -export default new FormUploader() diff --git a/src/main/server/router.ts b/src/main/server/router.ts deleted file mode 100644 index 4c984ae..0000000 --- a/src/main/server/router.ts +++ /dev/null @@ -1,21 +0,0 @@ -class Router { - private router = new Map() - - get (url: string, callback: routeHandler): void { - this.router.set(url, callback) - } - - post (url: string, callback: routeHandler): void { - this.router.set(url, callback) - } - - getHandler (url: string) { - if (this.router.has(url)) { - return this.router.get(url) - } else { - return null - } - } -} - -export default new Router() diff --git a/src/main/server/routerManager.ts b/src/main/server/routerManager.ts deleted file mode 100644 index 3af1750..0000000 --- a/src/main/server/routerManager.ts +++ /dev/null @@ -1,100 +0,0 @@ -import router from './router' -import { - handleResponse -} from './utils' -import logger from '@core/picgo/logger' -import windowManager from 'apis/app/window/windowManager' -import { uploadSelectedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis' -import path from 'path' -import { dbPathDir } from 'apis/core/datastore/dbChecker' -const STORE_PATH = dbPathDir() -const LOG_PATH = path.join(STORE_PATH, 'picgo.log') - -const errorMessage = `upload error. see ${LOG_PATH} for more detail.` - -router.post('/upload', async ({ - response, - list = [] -} : { - response: IHttpResponse, - list?: string[] -}): Promise => { - try { - if (list.length === 0) { - // upload with clipboard - logger.info('[PicGo Server] upload clipboard file') - const res = await uploadClipboardFiles() - logger.info('[PicGo Server] upload result:', res) - if (res) { - handleResponse({ - response, - body: { - success: true, - result: [res] - } - }) - } else { - handleResponse({ - response, - body: { - success: false, - message: errorMessage - } - }) - } - } else { - logger.info('[PicGo Server] upload files in list') - // upload with files - const pathList = list.map(item => { - return { - path: item - } - }) - const win = windowManager.getAvailableWindow() - const res = await uploadSelectedFiles(win.webContents, pathList) - logger.info('[PicGo Server] upload result', res.join(' ; ')) - if (res.length) { - handleResponse({ - response, - body: { - success: true, - result: res - } - }) - } else { - handleResponse({ - response, - body: { - success: false, - message: errorMessage - } - }) - } - } - } catch (err: any) { - logger.error(err) - handleResponse({ - response, - body: { - success: false, - message: errorMessage - } - }) - } -}) - -router.post('/heartbeat', async ({ - response -} : { - response: IHttpResponse, -}) => { - handleResponse({ - response, - body: { - success: true, - result: 'alive' - } - }) -}) - -export default router diff --git a/src/main/server/utils.ts b/src/main/server/utils.ts index 7adf4c1..6b6c7ba 100644 --- a/src/main/server/utils.ts +++ b/src/main/server/utils.ts @@ -1,33 +1,48 @@ -import logger from '@core/picgo/logger' +import { randomUUID } from 'node:crypto' -export const handleResponse = ({ - response, - statusCode = 200, - header = { - 'Content-Type': 'application/json', - 'access-control-allow-headers': '*', - 'access-control-allow-methods': 'POST, GET, OPTIONS', - 'access-control-allow-origin': '*' - }, - body = { - success: false - } -} : { - response: IHttpResponse, - statusCode?: number, - header?: IObj, - body?: any -}) => { - if (body?.success === false) { - logger.warn('[PicGo Server] upload failed, see picgo.log for more detail ↑') - } - response.writeHead(statusCode, header) - response.write(JSON.stringify(body)) - response.end() +export type UploadResponseBody = { + success: boolean + result: string[] + message?: string } -export const ensureHTTPLink = (url: string): string => { - return url.startsWith('http') - ? url - : `http://${url}` +export type HonoContextLike = { + req: { + raw: Request + formData: () => Promise + } + json: (data: unknown, status?: number) => Response } + +type FormDataFileLike = { + name?: string + arrayBuffer: () => Promise +} + +export const isFileLike = (value: unknown): value is FormDataFileLike => { + if (typeof value !== 'object' || value === null) return false + if (!('arrayBuffer' in value)) return false + return typeof (value as { arrayBuffer?: unknown }).arrayBuffer === 'function' +} + +export const isRecord = (value: unknown): value is Record => { + return typeof value === 'object' && value !== null +} + +export const buildSuccess = (result: string[]): UploadResponseBody => ({ + success: true, + result +}) + +export const buildError = (message: string): UploadResponseBody => ({ + success: false, + result: [], + message +}) + +export const getFormDataFileName = (value: FormDataFileLike): string => { + const name = value.name + if (typeof name === 'string' && name.trim() !== '') return name + return `${randomUUID()}.png` +} + diff --git a/src/main/utils/appConfigNotifier.ts b/src/main/utils/appConfigNotifier.ts new file mode 100644 index 0000000..e54dcdd --- /dev/null +++ b/src/main/utils/appConfigNotifier.ts @@ -0,0 +1,16 @@ +import { APP_CONFIG_UPDATED } from '#/events/constants' +import { IWindowList } from '#/types/enum' +import windowManager from 'apis/app/window/windowManager' + +const TARGET_WINDOWS: IWindowList[] = [ + IWindowList.SETTING_WINDOW, + IWindowList.TRAY_WINDOW, + IWindowList.MINI_WINDOW +] + +export const notifyAppConfigUpdated = (): void => { + TARGET_WINDOWS.forEach((windowType) => { + if (!windowManager.has(windowType)) return + windowManager.get(windowType)?.webContents.send(APP_CONFIG_UPDATED) + }) +} diff --git a/src/main/utils/handleI18n.ts b/src/main/utils/handleI18n.ts index d61e228..941cabd 100644 --- a/src/main/utils/handleI18n.ts +++ b/src/main/utils/handleI18n.ts @@ -1,6 +1,6 @@ import picgo from '@core/picgo' import { i18nManager } from '~/main/i18n' export const initI18n = () => { - const currentLanguage = picgo.getConfig('settings.language') || 'zh-CN' + const currentLanguage = picgo.getConfig('settings.language') || 'en' i18nManager.setCurrentLanguage(currentLanguage) } diff --git a/src/main/utils/privacyManager.ts b/src/main/utils/privacyManager.ts index 3d7425e..5b8116b 100644 --- a/src/main/utils/privacyManager.ts +++ b/src/main/utils/privacyManager.ts @@ -4,13 +4,13 @@ import { T } from '~/main/i18n' class PrivacyManager { async check () { - if (picgo.getConfig('settings.privacyEnsure') !== true) { + if (picgo.getConfig('settings.privacyEnsure') !== '20260127') { const res = await this.show(true) // cancel if (res.result === 1) { return false } else { - picgo.saveConfig({ 'settings.privacyEnsure': true }) + picgo.saveConfig({ 'settings.privacyEnsure': '20260127' }) return true } } @@ -18,11 +18,16 @@ class PrivacyManager { } async show (showCancel = true) { + const privacyUrl = 'https://picgo.app/privacy/' + const termsUrl = 'https://picgo.app/terms/' const res = await showMessageBox({ type: 'info', buttons: showCancel ? ['Yes', 'No'] : ['Yes'], - title: T('PRIVACY_AGREEMENT'), - message: T('PRIVACY') + title: T('PRIVACY_TERMS_AGREEMENT'), + message: T('PRIVACY', { + privacyUrl, + termsUrl + }) }) return res } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 41c36f8..260a8ef 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -7,22 +7,27 @@ + + diff --git a/src/renderer/components/settings/SwitchFormItem.vue b/src/renderer/components/settings/SwitchFormItem.vue index 01a2589..fe5e2c1 100644 --- a/src/renderer/components/settings/SwitchFormItem.vue +++ b/src/renderer/components/settings/SwitchFormItem.vue @@ -7,7 +7,6 @@ + + + + + PicGo Cloud + @@ -205,6 +211,7 @@ import { UploadFilled, PictureFilled, Menu, + Cloudy, Share, InfoFilled, Minus, @@ -213,7 +220,7 @@ import { } from '@element-plus/icons-vue' import { ElMessage as $message } from 'element-plus' import { T as $T } from '@/i18n/index' -import { ref, onBeforeUnmount, Ref, onBeforeMount, watch, nextTick, reactive } from 'vue' +import { ref, onBeforeUnmount, Ref, onBeforeMount, watch, nextTick, reactive, computed } from 'vue' import { onBeforeRouteUpdate, useRouter } from 'vue-router' import QrcodeVue from 'qrcode.vue' import pick from 'lodash/pick' @@ -221,7 +228,6 @@ import pkg from 'root/package.json' import * as config from '@/router/config' import { ipcRenderer, - IpcRendererEvent, clipboard } from 'electron' import InputBoxDialog from '@/components/dialog/InputBoxDialog.vue' @@ -230,18 +236,19 @@ import { CLOSE_WINDOW, SHOW_MAIN_PAGE_MENU, SHOW_MAIN_PAGE_QRCODE, - SHOW_MAIN_PAGE_DONATION, - GET_PICBEDS + SHOW_MAIN_PAGE_DONATION } from '~/universal/events/constants' import { getConfig, sendToMain } from '@/utils/dataSender' import { useOS } from '@/hooks/useOS' +import { useStore } from '@/hooks/useStore' const version = ref(process.env.NODE_ENV === 'production' ? pkg.version : 'Dev') const routerConfig = reactive(config) const defaultActive = ref(routerConfig.UPLOAD_PAGE) const visible = ref(false) const os = useOS() const $router = useRouter() -const picBed: Ref = ref([]) +const store = useStore() +const picBed = computed(() => store?.state.picBeds ?? []) const qrcodeVisible = ref(false) const picBedConfigString = ref('') const choosedPicBedForQRCode: Ref = ref([]) @@ -249,8 +256,7 @@ const choosedPicBedForQRCode: Ref = ref([]) const keepAlivePages = $router.getRoutes().filter(item => item.meta.keepAlive).map(item => item.name as string) onBeforeMount(() => { - sendToMain(GET_PICBEDS) - ipcRenderer.on(GET_PICBEDS, getPicBeds) + store?.refreshPicBeds() handleGetPicPeds() ipcRenderer.on(SHOW_MAIN_PAGE_QRCODE, () => { qrcodeVisible.value = true @@ -263,7 +269,7 @@ onBeforeMount(() => { watch(() => choosedPicBedForQRCode, (val) => { if (val.value.length > 0) { nextTick(async () => { - const picBedConfig = await getConfig('picBed') + const picBedConfig = store?.state.appConfig?.picBed ?? await getConfig('picBed') const config = pick(picBedConfig, ...choosedPicBedForQRCode.value) picBedConfigString.value = JSON.stringify(config) }) @@ -271,7 +277,7 @@ watch(() => choosedPicBedForQRCode, (val) => { }, { deep: true }) const handleGetPicPeds = () => { - sendToMain(GET_PICBEDS) + store?.refreshPicBeds() } const handleSelect = (index: string) => { @@ -325,10 +331,6 @@ function handleCopyPicBedConfig () { $message.success($T('COPY_PICBED_CONFIG_SUCCEED')) } -function getPicBeds (event: IpcRendererEvent, picBeds: IPicBedType[]) { - picBed.value = picBeds -} - onBeforeRouteUpdate(async (to) => { if (to.params.type) { defaultActive.value = `${routerConfig.UPLOADER_CONFIG_PAGE}-${to.params.type}` @@ -338,7 +340,8 @@ onBeforeRouteUpdate(async (to) => { }) onBeforeUnmount(() => { - ipcRenderer.removeListener(GET_PICBEDS, getPicBeds) + ipcRenderer.removeAllListeners(SHOW_MAIN_PAGE_QRCODE) + ipcRenderer.removeAllListeners(SHOW_MAIN_PAGE_DONATION) }) diff --git a/src/renderer/main.ts b/src/renderer/main.ts index 829d516..2fbd3c3 100644 --- a/src/renderer/main.ts +++ b/src/renderer/main.ts @@ -12,7 +12,7 @@ import { dragMixin } from '@/utils/mixin' import { initTalkingData } from './utils/analytics' import db from './utils/db' import { i18nManager, T } from './i18n/index' -import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender' +import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender' import { store } from '@/store' import vue3PhotoPreview from 'vue3-photo-preview' import 'vue3-photo-preview/dist/index.css' @@ -37,7 +37,6 @@ app.config.globalProperties.$http = axios app.config.globalProperties.$T = T app.config.globalProperties.$i18n = i18nManager app.config.globalProperties.getConfig = getConfig -app.config.globalProperties.triggerRPC = triggerRPC app.config.globalProperties.saveConfig = saveConfig app.config.globalProperties.sendToMain = sendToMain diff --git a/src/renderer/pages/Gallery.vue b/src/renderer/pages/Gallery.vue index 2d0e4c3..1fd0870 100644 --- a/src/renderer/pages/Gallery.vue +++ b/src/renderer/pages/Gallery.vue @@ -187,16 +187,15 @@ diff --git a/src/renderer/pages/PicGoCloud.vue b/src/renderer/pages/PicGoCloud.vue new file mode 100644 index 0000000..74d4b91 --- /dev/null +++ b/src/renderer/pages/PicGoCloud.vue @@ -0,0 +1,583 @@ + + + + + diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index f34547e..cd070b9 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -49,14 +49,14 @@ import { Reading } from '@element-plus/icons-vue' import { IConfig } from 'picgo' import { T as $T } from '@/i18n/index' import { enforceNumber, isLinux } from '~/universal/utils/common' -import { onBeforeMount, reactive, ref } from 'vue' -import { getConfig } from '@/utils/dataSender' +import { computed, onBeforeMount, reactive, ref, watch, type DeepReadonly } from 'vue' import ButtonAreaSettings from './components/settings/buttonArea/ButtonAreaSettings.vue' import SwitchAreaSettings from './components/settings/switchArea/SwitchAreaSettings.vue' import CustomAreaSettings from './components/settings/customArea/CustomAreaSettings.vue' import SelectAreaSettings from './components/settings/selectArea/SelectAreaSettings.vue' import { openURL } from '@/utils/common' import { IStartupMode } from '#/types/enum' +import { useStore } from '@/hooks/useStore' const form = reactive({ showUpdateTip: false, @@ -71,7 +71,7 @@ const form = reactive({ autoCopyUrl: true, checkBetaUpdate: true, useBuiltinClipboard: false, - language: 'zh-CN', + language: 'en', logFileSizeLimit: 10, encodeOutputURL: true, showDockIcon: true, @@ -88,41 +88,50 @@ const form = reactive({ }) const proxy = ref('') +const store = useStore() +const appConfig = computed(() => store?.state.appConfig ?? null) onBeforeMount(() => { - initData() + store?.refreshAppConfig() }) -async function initData () { - const config = (await getConfig())! - if (config !== undefined) { - const settings = config.settings || {} - const picBed = config.picBed - form.showUpdateTip = settings.showUpdateTip || false - form.autoStart = settings.autoStart || false - form.rename = settings.rename || false - form.autoRename = settings.autoRename || false - form.uploadNotification = settings.uploadNotification || false - form.notificationSound = settings.notificationSound === undefined ? true : settings.notificationSound - form.miniWindowOnTop = settings.miniWindowOnTop || false - form.logLevel = initLogLevel(settings.logLevel || []) - form.autoCopyUrl = settings.autoCopyUrl === undefined ? true : settings.autoCopyUrl - form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate - form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard - form.language = settings.language ?? 'zh-CN' - form.encodeOutputURL = settings.encodeOutputURL === undefined ? false : settings.encodeOutputURL - form.customLink = settings.customLink || '$url' - form.npmProxy = settings.npmProxy || '' - form.npmRegistry = settings.npmRegistry || '' - proxy.value = picBed.proxy || '' - form.server = settings.server - form.logFileSizeLimit = enforceNumber(settings.logFileSizeLimit) || 10 - form.showDockIcon = settings.showDockIcon === undefined ? true : settings.showDockIcon - form.showMenubarIcon = settings.showMenubarIcon === undefined ? true : settings.showMenubarIcon - form.startupMode = settings.startupMode || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE) +const applyAppConfig = (config: DeepReadonly | null) => { + if (!config) return + const settings = config.settings || {} + const picBed = config.picBed + form.showUpdateTip = settings.showUpdateTip || false + form.autoStart = settings.autoStart || false + form.rename = settings.rename || false + form.autoRename = settings.autoRename || false + form.uploadNotification = settings.uploadNotification || false + form.notificationSound = settings.notificationSound === undefined ? true : settings.notificationSound + form.miniWindowOnTop = settings.miniWindowOnTop || false + form.logLevel = initLogLevel(settings.logLevel ? [...settings.logLevel] : []) + form.autoCopyUrl = settings.autoCopyUrl === undefined ? true : settings.autoCopyUrl + form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate + form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard + form.language = settings.language ?? 'en' + form.encodeOutputURL = settings.encodeOutputURL === undefined ? false : settings.encodeOutputURL + form.customLink = settings.customLink || '$url' + form.npmProxy = settings.npmProxy || '' + form.npmRegistry = settings.npmRegistry || '' + proxy.value = picBed.proxy || '' + const server = settings.server ?? {} + form.server = { + port: enforceNumber(server.port ?? 36677) || 36677, + host: server.host || '127.0.0.1', + enable: server.enable ?? true } + form.logFileSizeLimit = enforceNumber(settings.logFileSizeLimit ?? 10) || 10 + form.showDockIcon = settings.showDockIcon === undefined ? true : settings.showDockIcon + form.showMenubarIcon = settings.showMenubarIcon === undefined ? true : settings.showMenubarIcon + form.startupMode = settings.startupMode || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE) } +watch(appConfig, (config) => { + applyAppConfig(config) +}, { immediate: true }) + function initLogLevel (logLevel: string | string[]) { if (!Array.isArray(logLevel)) { if (logLevel && logLevel.length > 0) { @@ -135,7 +144,7 @@ function initLogLevel (logLevel: string | string[]) { } function goConfigPage () { - openURL('https://picgo.github.io/PicGo-Doc/guide/config.html#picgo设置') + openURL('https://docs.picgo.app/gui/guide/config#picgo-setting') } diff --git a/src/renderer/pages/Toolbox.vue b/src/renderer/pages/Toolbox.vue index e7c7ebd..eec03c9 100644 --- a/src/renderer/pages/Toolbox.vue +++ b/src/renderer/pages/Toolbox.vue @@ -96,8 +96,8 @@