Compare commits

..
5 Commits
Author SHA1 Message Date
PiEgg 3a9ff25071 🎉 Release: v2.4.2 2026-01-07 16:13:28 +08:00
PiEgg 2c9a188dbb 📝 Docs(2.4.2): update changelog 2026-01-07 16:13:04 +08:00
PiEgg 525492bed1 🐛 Fix(tray): clamp image titles to two lines
Prevent long file names from stretching the tray item layout.
2026-01-07 15:45:11 +08:00
PiEgg 50881b071a 🔨 Refactor(db): rm config store (#1371) 2026-01-07 15:13:25 +08:00
PiEgg 2936b19008 Feature(notification): refactor notification and add notificationSound settings (#1370)
ISSUES CLOSED: #1229
2026-01-04 17:08:19 +08:00
57 changed files with 571 additions and 473 deletions
+3 -1
View File
@@ -25,4 +25,6 @@ scripts/*.yml
/dist_electron
.serena/
dist/*
test.js
test.js
specs/
.cache/
+2 -1
View File
@@ -4,13 +4,14 @@
PicGo is an Electron + Vue 3 desktop client. Source lives in `src/`: `src/main` for main-process and IPC logic, `src/renderer` for Vue views, and `src/universal` for shared helpers (`types/`, `events/constants.ts`). `background.ts` wires Electron Builder. Static assets and locale YAML files stay in `public/` (add languages under `public/i18n/`), while `docs/` hosts user-facing guides. Automation scripts live in `scripts/`, and legacy tests sit under `test/unit` (Karma) and `test/e2e` (Spectron).
## Build, Test, and Development Commands
- `pnpm install` — install dependencies; `npm install` is unsupported.
- `pnpm install` — install dependencies; `npm install` is unsupported. Only run this when the user explicitly asks/coordinates it.
- Always add/remove dependencies with `pnpm` (never edit package.json versions by hand then install).
- `pnpm dev` — electron-vite dev server for main/preload/renderer.
- `pnpm build` — electron-vite build outputs to `dist/main`, `dist/preload`, `dist/renderer`; `pnpm preview` for preview mode.
- Packaging config lives in `electron-builder.yml` (read by electron-builder via package.json `build` field/extraResources); set `ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/` if downloads are slow.
- `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).
- `pnpm gen-i18n` — regenerate typed locales after touching `public/i18n/*.yml`.
## Coding Style & Naming Conventions
+19
View File
@@ -1,3 +1,22 @@
## :tada: 2.4.2 (2026-01-07)
### :sparkles: Features
* **notification:** refactor notification and add notificationSound settings ([#1370](https://github.com/Molunerfinn/PicGo/issues/1370)) ([2936b19](https://github.com/Molunerfinn/PicGo/commit/2936b19)), closes [#1229](https://github.com/Molunerfinn/PicGo/issues/1229)
### :bug: Bug Fixes
* **tray:** clamp image titles to two lines ([525492b](https://github.com/Molunerfinn/PicGo/commit/525492b))
### :pencil: Documentation
* **2.4.2:** update changelog ([2c9a188](https://github.com/Molunerfinn/PicGo/commit/2c9a188))
## :tada: 2.4.2-beta.0 (2025-12-31)
+48 -48
View File
@@ -1,66 +1,66 @@
# PicGo 2.4.0 Changelog
## Features
- Add filename display in the gallery (#1050).
- Add default placeholders when images/URLs cannot be shown in the gallery or tray window (#1050).
- Add filename display in the gallery (#1050)
- Add default placeholders when images/URLs cannot be shown in the gallery or tray window (#1050)
![image](https://user-images.githubusercontent.com/12621342/210806238-e77bc3b1-5e32-4c9f-af5c-278c5706450d.png)
- Add filename display in the macOS tray window (#1054).
- Allow multiple configs per uploader type and choose one for upload (thanks @STDSuperman, #1016).
- Add filename display in the macOS tray window (#1054)
- Allow multiple configs per uploader type and choose one for upload (thanks @STDSuperman, #1016)
![](https://user-images.githubusercontent.com/44311619/203093104-9537e08a-2ef0-450d-a59d-c470dbcdd6c8.png)
- Allow the uploader selection menu to pick a specific config entry for that uploader type.
- Allow the uploader selection menu to pick a specific config entry for that uploader type
![image](https://user-images.githubusercontent.com/12621342/210804413-4f78804f-a451-4ca5-93a3-63d461261b18.png)
- Add Dock icon visibility option (#1045).
- Add Dock icon visibility option (#1045)
<img width="787" alt="image" src="https://github.com/Molunerfinn/PicGo/assets/12621342/bb9492f1-6522-45ce-ae5d-c614901d8b06" />
- Add PicGo Repair Toolbox for self-diagnosis.
- Add PicGo Repair Toolbox for self-diagnosis
<img width="324" alt="image" src="https://github.com/Molunerfinn/PicGo/assets/12621342/98cf6e64-7313-4ebe-83d0-aa86e4514109" />
- Add option to encode/escape output URLs (#731).
- Add option to encode/escape output URLs (#731)
<img width="775" alt="image" src="https://github.com/Molunerfinn/PicGo/assets/12621342/6e0c13dd-3404-4b07-9c99-412321835b27" />
- Support drag-and-drop uploads for arbitrary file formats (#1052).
- Tencent COS: add Endpoint and Intelligent Compression settings (thanks @palmcivet @yc910920).
- Support drag-and-drop uploads for arbitrary file formats (#1052)
- Tencent COS: add Endpoint and Intelligent Compression settings (thanks @palmcivet @yc910920)
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/6e623751-d330-47f8-89bc-986031452914)
- Add Markdown-rendered tips for uploader config (see tcyun uploader config).
- Add Markdown-rendered tips for uploader config (see tcyun uploader config)
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/2f9b8734-717a-4f49-b397-1ddb9437bc3c)
- Show the active uploader config name in the upload screen.
- Show the active uploader config name in the upload screen
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/52c58fff-4810-4b91-92d7-5ade512eaca8)
- Gallery toolbar: bulk replace image URL host (#875).
Note: select images first; you can filter by uploader; e.g., replace `https://www.a.com/...` with `https://www.b.com/...`.
- Gallery toolbar: bulk replace image URL host (#875)
Note: select images first; you can filter by uploader; e.g., replace `https://www.a.com/...` with `https://www.b.com/...`
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/ee314dfc-7699-4ceb-8638-cafe7948bd5a)
- Add “Startup Mode”: Silent (default) / Main Window; Windows/Linux also support Mini Window (#915).
- Add “Startup Mode”: Silent (default) / Main Window; Windows/Linux also support Mini Window (#915)
<img width="577" alt="image" src="https://github.com/Molunerfinn/PicGo/assets/12621342/7e63bb5c-44b0-480e-824f-3c2edbed4fbb" />
- PicGo Server: support multipart form uploads (field `files`, #428, thanks @happy-game).
- PicGo Server: support multipart form uploads (field `files`, #428, thanks @happy-game)
<img width="951" alt="image" src="https://github.com/user-attachments/assets/14244f1d-60f5-487f-bde6-6d0e009645fb" />
## Bug Fixes
- Fix Windows context-menu config script generation (#1019).
- Fix custom link URL encoding (#1112).
- Fix potential logging dead loop (#1101).
- Fix drag-to-tray upload error (#1107).
- Fix filename encoding (#1121).
- Prevent errors on GitHub uploads with duplicate filenames.
- Fix beta.2 style issues.
- Fix slow filename display in the rename window (#1130).
- Fix “open config file” actually opening the log file (#1163).
- Fix plugin config dialog not reading/saving correctly.
- Fix inability to add new uploader configs (created as edit) (#1198, #1196).
- Fix macOS context menu disappearing (thanks @muwoo, #1179).
- Fix macOS tray window flashing after right-click (thanks @QThans, #1217).
- Fix uploader config page not scrollable when many fields (#1237).
- Fix Tencent COS URL encoding (#1265).
- Fix plugin list search not working (#1297).
- Fix clipboard filename losing “seconds” (#1293).
- Fix macOS tray copy-link failing on click (#1280, #1210).
- Fix auto-copy URL toggle not turning off (#1294, thanks @happy-game).
- Fix Wayland clipboard image upload issue (#1261, thanks @happy-game).
- Fix URL uploads with Chinese characters being encoded in filenames (#1339).
- Fix Windows context-menu config script generation (#1019)
- Fix custom link URL encoding (#1112)
- Fix potential logging dead loop (#1101)
- Fix drag-to-tray upload error (#1107)
- Fix filename encoding (#1121)
- Prevent errors on GitHub uploads with duplicate filenames
- Fix beta.2 style issues
- Fix slow filename display in the rename window (#1130)
- Fix “open config file” actually opening the log file (#1163)
- Fix plugin config dialog not reading/saving correctly
- Fix inability to add new uploader configs (created as edit) (#1198, #1196)
- Fix macOS context menu disappearing (thanks @muwoo, #1179)
- Fix macOS tray window flashing after right-click (thanks @QThans, #1217)
- Fix uploader config page not scrollable when many fields (#1237)
- Fix Tencent COS URL encoding (#1265)
- Fix plugin list search not working (#1297)
- Fix clipboard filename losing “seconds” (#1293)
- Fix macOS tray copy-link failing on click (#1280, #1210)
- Fix auto-copy URL toggle not turning off (#1294, thanks @happy-game)
- Fix Wayland clipboard image upload issue (#1261, thanks @happy-game)
- Fix URL uploads with Chinese characters being encoded in filenames (#1339)
## Other
- COS distribution paused due to malicious traffic charges.
- Upgrade to Vue3.
- Refactor parts of the code.
- Refactor parts of the code (again).
- Add more detailed hotkey logs (#1031).
- Known issue: some button styles were incorrect (fixed in later betas).
- Update README scoop installation section (thanks @wuhang2003).
- COS distribution paused due to malicious traffic charges
- Upgrade to Vue3
- Refactor parts of the code
- Refactor parts of the code (again)
- Add more detailed hotkey logs (#1031)
- Known issue: some button styles were incorrect (fixed in later betas)
- Update README scoop installation section (thanks @wuhang2003)
----------
@@ -87,7 +87,7 @@
- 新增 上传界面展示当前图床使用的配置名
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/52c58fff-4810-4b91-92d7-5ade512eaca8)
- 新增 相册页工具栏,目前内置 `批量修改图片 URL HOST 的功能` 。参考 #875
注意:需要先选中指定的图片,然后会根据已选中的图片进行修改,你可以通过图床筛选功能只筛选出需要修改的图片
注意:需要先选中指定的图片,然后会根据已选中的图片进行修改,你可以通过图床筛选功能只筛选出需要修改的图片
例如,你有一批图片都是 `https://www.a.com/...` 打头的 URL,你想把 `www.a.com` 批量修改成 `www.b.com` ,就可以用这个功能
![image](https://github.com/Molunerfinn/PicGo/assets/12621342/ee314dfc-7699-4ceb-8638-cafe7948bd5a)
- 新增 `启动模式`,可以设置启动的时候是否要打开窗口。全平台支持 `静默启动`(默认值) & `打开主窗口`Windows 和 Linux 额外支持 `打开 Mini 窗口`。参考 #915
@@ -102,11 +102,11 @@
- 修复 日志写入可能存在死循环问题,参考 #1101
- 修复 拖拽文件到顶部栏图标报错问题,参考 #1107
- 修复 文件名 encode 问题。参考 #1121
- 修复 GitHub 重名文件上传不再报错
- 修复 GitHub 重名文件上传不再报错
- 修复 beta.2 版本部分样式问题
- 修复 重命名窗口某些情况下显示文件名过慢的问题,参考 #1130
- 修复 打开配置文件打开的是日志文件的 bug,参考 #1163
- 修复 插件配置弹窗打开后无法正确读取和保存配置的问题
- 修复 插件配置弹窗打开后无法正确读取和保存配置的问题
- 修复 无法新增图床配置的问题(新增变成了编辑)。参考 #1198#1196
- 修复 macOS 右键菜单消失问题。感谢 @muwoo 。参考 #1179
- 修复 macOS 顶部栏窗口右键之后一闪而过的问题。 感谢 @QThans。 参考 #1217
@@ -120,7 +120,7 @@
- 修复 直接通过 URL 上传图片的时候,带有汉字的 URL 上传后,文件名被 encode 的问题。 参考 #1339
## Other
- 由于 PicGo 存储的 COS 空间被恶意刷大量流量导致欠费,暂时停止 COS 渠道的 PicGo 分发
- 由于 PicGo 存储的 COS 空间被恶意刷大量流量导致欠费,暂时停止 COS 渠道的 PicGo 分发
- 更新至 Vue3
- 重构部分代码
- 重构部分代码
+8 -8
View File
@@ -2,23 +2,23 @@
## Features
- Add `showMenubarIcon` setting to control the visibility of the macOS menu bar icon. See #1222 for details.
- Add `showMenubarIcon` setting to control the visibility of the macOS menu bar icon. See #1222 for details
## Bug Fixes
- Fix: An issue where the macOS menu bar window could not read images from the clipboard. See https://github.com/Molunerfinn/PicGo/issues/1310 for details.
- Fix: An issue where the macOS Intel build could not be opened. Please take a look at #1363 and #1310 for details.
- Fix: An issue where the macOS menu bar window could not read images from the clipboard. See https://github.com/Molunerfinn/PicGo/issues/1310 for details
- Fix: An issue where the macOS Intel build could not be opened. Please take a look at #1363 and #1310 for details
## Other
- Upgraded Electron to v38 and migrated the underlying build framework to Electron-vite.
- Unified the main window UI on Windows/Linux to match the macOS style.
- Upgraded Electron to v38 and migrated the underlying build framework to Electron-vite
- Unified the main window UI on Windows/Linux to match the macOS style
<img width="821" height="472" alt="image" src="https://github.com/user-attachments/assets/dbafadeb-7a9f-40e5-bd87-d4012c9a3902" />
- Updated ARM64 builds for Windows & Linux, and added Linux deb packages.
- Updated ARM64 builds for Windows & Linux, and added Linux deb packages
----------
## Features
- 新增 `showMenubarIcon` 配置项,用于控制 macOS 顶部栏图标的显示与隐藏。参考 #1222
- 新增 `showMenubarIcon` 配置项,用于控制 macOS 顶部栏图标的显示与隐藏。参考 #1222
## Bug Fixes
- 修复 macOS 顶部栏窗口无法获取剪贴板图片的问题。参考 https://github.com/Molunerfinn/PicGo/issues/1310
@@ -28,4 +28,4 @@
- 更新 Electron 版本到 38 以及切换底层开发框架到 Electron-vite
- 更新 Windows\Linux 系统现在主窗口的样式跟 macOS 一致了
<img width="821" height="472" alt="image" src="https://github.com/user-attachments/assets/dbafadeb-7a9f-40e5-bd87-d4012c9a3902" />
- 更新 Windows & Linux 平台的 ARM64 架构构建产物;新增 Linux `deb` 构建产物
- 更新 Windows & Linux 平台的 ARM64 架构构建产物;新增 Linux `deb` 构建产物
+31
View File
@@ -0,0 +1,31 @@
# PicGo 2.4.2 Changelog
## Features
- New: macOS version with signature && notarization. No more manual handling
<img width="260" height="260" alt="image" src="https://github.com/user-attachments/assets/dc1b7114-1f10-40e3-b45e-e3b330712399" />
- Add duplicate button for image host config item. And add a double confirm dialog for `duplicate` and `delete` config item action
<img width="800" height="450" alt="image" src="https://github.com/user-attachments/assets/238881e3-e993-4cb7-9699-fd2f7441ce02" />
- Add: Refactor notifications and add `notificationSound` setting (#1370)
## Bug Fixes
- Fix: An issue that the app icon will be too big under macOS 26. See #1367 for more details
- Fix: Clamp tray image titles to two lines or the style will be broken
## Other
- Refactor: Remove config store (#1371)
----------
## Features
- 新增:macOS 版本签名+公证,现在不再需要手动放行,可以直接下载安装使用
<img width="260" height="260" alt="image" src="https://github.com/user-attachments/assets/dc1b7114-1f10-40e3-b45e-e3b330712399" />
- 新增:图床配置界面新增复制按钮,可以一键复制已有配置,方便进行多样化操作。同时复制和删除均增加二次确认弹窗
<img width="800" height="450" alt="image" src="https://github.com/user-attachments/assets/238881e3-e993-4cb7-9699-fd2f7441ce02" />
- 新增:重构通知并新增 `notificationSound` 设置(#1370
## Bug Fixes
- 修复:在 macOS 26 版本下 app 图标过大的问题。参考 #1367
- 修复:托盘图片标题最多显示两行否则样式会被破坏的问题
## Other
- 重构:移除 config store#1371
+37 -35
View File
@@ -1,48 +1,50 @@
# gen_changelog.md
This guide describes how to generate a consolidated changelog for any PicGo release series (e.g., 2.4.0, 2.5.0) from the GitHub release notes of its betas and finals.
This guide describes how to generate a consolidated changelog for any PicGo release series (e.g., 2.4.0, 2.5.0) from the GitHub release notes of its betas and finals
## Source of truth
- Use GitHub release pages only (e.g., `https://github.com/Molunerfinn/PicGo/releases/tag/vX.Y.Z-beta.N` and `vX.Y.Z` if present). You can fetch these via MCP GitHub APIs (e.g., `get_release_by_tag`, `list_releases`) instead of manual browsing.
- Do **not** use `CHANGELOG.md` in the repo.
- Preserve all text and images exactly as written in the releases.
- Use GitHub release pages only (e.g., `https://github.com/Molunerfinn/PicGo/releases/tag/vX.Y.Z-beta.N` and `vX.Y.Z` if present). You can fetch these via MCP GitHub APIs (e.g., `get_release_by_tag`, `list_releases`) instead of manual browsing
- Do **not** use `CHANGELOG.md` in the repo
- Preserve all text and images exactly as written in the releases
- Exception: Remove holiday greetings (e.g., "Happy New Year!", "新年快乐!") from the generated changelog. These can stay in GitHub release notes but should not appear in `changelog/X.Y.Z.md`
## Structure
- Target file: `changelog/X.Y.Z.md` (replace with the series version).
- Three top-level sections: `## Features`, `## Bug Fixes`, `## Other`.
- Do **not** nest content under individual beta version headers; merge all items into these sections.
- Keep items in chronological order (early → late) within each section, mirroring the beta sequence.
- Keep inline issue references, thanks, and notes as-is.
- Remove download-link sections entirely.
- After the English sections, insert a line with `----------`, then add a full Chinese translation with the same structure/content (including images).
- Target file: `changelog/X.Y.Z.md` (replace with the series version)
- Three top-level sections: `## Features`, `## Bug Fixes`, `## Other`
- Do **not** nest content under individual beta version headers; merge all items into these sections
- Keep items in chronological order (early → late) within each section, mirroring the beta sequence
- Keep inline issue references, thanks, and notes as-is
- Remove download-link sections entirely
- After the English sections, insert a line with `----------`, then add a full Chinese translation with the same structure/content (including images)
## Formatting rules
- Markdown, plain ASCII.
- Bullet lists only; no numbered lists required.
- Indent images under their bullet with two spaces to keep association clear.
- Keep inline HTML image tags from the releases (e.g., `<img width="...">`) untouched.
- Keep line breaks and multi-line notes intact.
- Do not reword or summarize; copy content verbatim except for removing beta headers and download sections.
- Chinese translation must mirror the English bullets in order and content (keep images alongside the translated bullets).
- Markdown, plain ASCII
- Bullet lists only; no numbered lists required
- Indent images under their bullet with two spaces to keep association clear
- Keep inline HTML image tags from the releases (e.g., `<img width="...">`) untouched
- Keep line breaks and multi-line notes intact
- Do not reword or summarize; copy content verbatim except for removing beta headers and download sections
- If you need to add items from git commit logs (for the same release series), do not paste raw commit messages. Normalize them to the existing changelog style (e.g., use `Add:`, `Fix:`, `Refactor:` prefixes without emoji)
- Chinese translation must mirror the English bullets in order and content (keep images alongside the translated bullets)
## Regeneration steps
1) Collect all release bodies for the target series (e.g., `vX.Y.Z-beta.0…N` and, if present, `vX.Y.Z`) from GitHub releases.
1) Collect all release bodies for the target series (e.g., `vX.Y.Z-beta.0…N` and, if present, `vX.Y.Z`) from GitHub releases
2) For each release, copy bullets and images into the appropriate section:
- Features ↔ “Feature(s)” or “Features” blocks.
- Bug Fixes ↔ “Bug Fixes” blocks.
- Other ↔ “Other”, “Notice”, or misc notes that are not features/bugs.
3) Omit “国内可下载链接” (or any download links) entirely.
4) Drop beta subheadings; keep only section-level bullets in chronological order.
5) Ensure images remain adjacent to their bullets with indentation.
6) After the English sections are complete, insert `----------` on its own line.
7) Append the Chinese translation, preserving bullet order and images, under `## Features`, `## Bug Fixes`, `## Other` again (same section titles, just Chinese content; no “(Chinese)” suffix).
8) Save the result to `changelog/X.Y.Z.md`.
- Features ↔ “Feature(s)” or “Features” blocks
- Bug Fixes ↔ “Bug Fixes” blocks
- Other ↔ “Other”, “Notice”, or misc notes that are not features/bugs
3) Omit “国内可下载链接” (or any download links) entirely
4) Drop beta subheadings; keep only section-level bullets in chronological order
5) Ensure images remain adjacent to their bullets with indentation
6) After the English sections are complete, insert `----------` on its own line
7) Append the Chinese translation, preserving bullet order and images, under `## Features`, `## Bug Fixes`, `## Other` again (same section titles, just Chinese content; no “(Chinese)” suffix)
8) Save the result to `changelog/X.Y.Z.md`
## Quick checklist
- [ ] All features present with images kept.
- [ ] All bug fixes present.
- [ ] All “Other” notes present.
- [ ] No beta headers.
- [ ] No download links.
- [ ] Chronological ordering preserved.
- [ ] Chinese translation present with matching bullets/images after `----------`.
- [ ] All features present with images kept
- [ ] All bug fixes present
- [ ] All “Other” notes present
- [ ] No beta headers
- [ ] No download links
- [ ] Chronological ordering preserved
- [ ] Chinese translation present with matching bullets/images after `----------`
+7 -2
View File
@@ -6,6 +6,7 @@ const tsParser = require('@typescript-eslint/parser')
const importPlugin = require('eslint-plugin-import')
const promisePlugin = require('eslint-plugin-promise')
const vuePlugin = require('eslint-plugin-vue')
const stylistic = require('@stylistic/eslint-plugin')
const isProduction = process.env.NODE_ENV === 'production'
const vueConfigs = vuePlugin.configs['flat/recommended'].map(config => ({
@@ -76,7 +77,8 @@ module.exports = [
},
plugins: {
import: importPlugin,
promise: promisePlugin
promise: promisePlugin,
'@stylistic': stylistic
},
settings: {
'import/resolver': {
@@ -98,7 +100,10 @@ module.exports = [
'no-debugger': isProduction ? 'error' : 'off',
'no-async-promise-executor': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-unused-vars': 'off'
'no-unused-vars': 'off',
'@stylistic/indent': ['error', 2],
'@stylistic/semi': ['error', 'never'],
'no-unexpected-multiline': 'error'
}
},
...vueConfigs,
+5 -3
View File
@@ -1,6 +1,6 @@
{
"name": "picgo",
"version": "2.4.2-beta.0",
"version": "2.4.2",
"private": true,
"main": "dist_electron/main/index.js",
"description": "A powerful & simple image uploader for creators.",
@@ -14,7 +14,7 @@
"build:mac": "npm run build && electron-builder --config electron-builder.config.ts --mac --publish never",
"build:linux": "npm run build && electron-builder --config electron-builder.config.ts --linux --publish never",
"build:local": "dotenv -e .env -- electron-vite build && electron-builder --config electron-builder.config.ts --publish never",
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.vue src/",
"lint": "pnpm lint:dpdm && eslint --ext .js,.jsx,.ts,.tsx,.vue src/",
"tsc": "tsc --noEmit",
"bump": "bump-version",
"cz": "git-cz",
@@ -25,7 +25,8 @@
"postinstall": "electron-builder install-app-deps",
"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"
"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"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
@@ -68,6 +69,7 @@
"@eslint/js": "^9.39.1",
"@molunerfinn/vite-plugin-electron-renderer": "^0.14.7",
"@picgo/bump-version": "^2.0.0",
"@stylistic/eslint-plugin": "^5.6.1",
"@types/electron-devtools-installer": "^2.2.0",
"@types/fs-extra": "^9.0.13",
"@types/inquirer": "^6.5.0",
+22 -2
View File
@@ -123,6 +123,9 @@ importers:
'@picgo/bump-version':
specifier: ^2.0.0
version: 2.0.0(@types/node@20.19.26)(typescript@5.9.3)
'@stylistic/eslint-plugin':
specifier: ^5.6.1
version: 5.6.1(eslint@9.39.1(jiti@1.21.7))
'@types/electron-devtools-installer':
specifier: ^2.2.0
version: 2.2.5
@@ -215,7 +218,7 @@ importers:
version: 7.2.1(eslint@9.39.1(jiti@1.21.7))
eslint-plugin-vue:
specifier: ^10.6.2
version: 10.6.2(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7)))
version: 10.6.2(@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7)))(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7)))
globals:
specifier: ^16.5.0
version: 16.5.0
@@ -1408,6 +1411,12 @@ packages:
resolution: {integrity: sha512-4aUIteuyxtBUhVdiQqcDhKFitwfd9hqoSDYY2KRXiWtgoWJ9Bmise+KfEPDiVHWeJepvF8xJO9/9+WDIciMFFw==}
engines: {node: '>=18.0.0'}
'@stylistic/eslint-plugin@5.6.1':
resolution: {integrity: sha512-JCs+MqoXfXrRPGbGmho/zGS/jMcn3ieKl/A8YImqib76C8kjgZwq5uUFzc30lJkMvcchuRn6/v8IApLxli3Jyw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: '>=9.0.0'
'@sxzz/popperjs-es@2.11.7':
resolution: {integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==}
@@ -7352,6 +7361,16 @@ snapshots:
dependencies:
tslib: 2.8.1
'@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7))':
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
'@typescript-eslint/types': 8.49.0
eslint: 9.39.1(jiti@1.21.7)
eslint-visitor-keys: 4.2.1
espree: 10.4.0
estraverse: 5.3.0
picomatch: 4.0.3
'@sxzz/popperjs-es@2.11.7': {}
'@szmarczak/http-timer@4.0.6':
@@ -9165,7 +9184,7 @@ snapshots:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
eslint: 9.39.1(jiti@1.21.7)
eslint-plugin-vue@10.6.2(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7))):
eslint-plugin-vue@10.6.2(@stylistic/eslint-plugin@5.6.1(eslint@9.39.1(jiti@1.21.7)))(@typescript-eslint/parser@8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3))(eslint@9.39.1(jiti@1.21.7))(vue-eslint-parser@10.2.0(eslint@9.39.1(jiti@1.21.7))):
dependencies:
'@eslint-community/eslint-utils': 4.9.0(eslint@9.39.1(jiti@1.21.7))
eslint: 9.39.1(jiti@1.21.7)
@@ -9176,6 +9195,7 @@ snapshots:
vue-eslint-parser: 10.2.0(eslint@9.39.1(jiti@1.21.7))
xml-name-validator: 4.0.0
optionalDependencies:
'@stylistic/eslint-plugin': 5.6.1(eslint@9.39.1(jiti@1.21.7))
'@typescript-eslint/parser': 8.49.0(eslint@9.39.1(jiti@1.21.7))(typescript@5.9.3)
eslint-scope@8.4.0:
+1
View File
@@ -80,6 +80,7 @@ SETTINGS_LAUNCH_ON_BOOT: Launch On Boot
SETTINGS_RENAME_BEFORE_UPLOAD: Rename Before Upload
SETTINGS_TIMESTAMP_RENAME: Timestamp Rename
SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips
SETTINGS_NOTIFICATION_SOUND: Play Notification Sound
SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: Auto Copy URL After Upload
SETTINGS_TIPS_PLACEHOLDER_URL: Use $url to represent url position
+1
View File
@@ -80,6 +80,7 @@ SETTINGS_LAUNCH_ON_BOOT: 开机自启
SETTINGS_RENAME_BEFORE_UPLOAD: 上传前重命名
SETTINGS_TIMESTAMP_RENAME: 时间戳重命名
SETTINGS_OPEN_UPLOAD_TIPS: 开启上传提示
SETTINGS_NOTIFICATION_SOUND: 开启通知提示音
SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上传后自动复制URL
SETTINGS_TIPS_PLACEHOLDER_URL: 用占位符 $url 来表示url的位置
+1
View File
@@ -80,6 +80,7 @@ SETTINGS_LAUNCH_ON_BOOT: 開機時啟動
SETTINGS_RENAME_BEFORE_UPLOAD: 上傳前重新命名
SETTINGS_TIMESTAMP_RENAME: 以時間戳命名
SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示
SETTINGS_NOTIFICATION_SOUND: 開啟通知提示音
SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上傳後自動複製URL
SETTINGS_TIPS_PLACEHOLDER_URL: 用佔位符 $url 來表示URL的位置
+1 -1
View File
@@ -116,7 +116,7 @@ class RemoteNoticeHandler {
body: action.data?.content || '',
clickToCopy: !!action.data?.copyToClipboard,
copyContent: action.data?.copyToClipboard || '',
clickFn () {
callback () {
if (action.data?.url) {
shell.openExternal(action.data.url)
}
@@ -4,7 +4,6 @@ import {
} from 'electron'
import logger from '@core/picgo/logger'
import GuiApi from '../../gui'
import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import shortKeyService from './shortKeyService'
import picgo from '@core/picgo'
@@ -25,7 +24,7 @@ class ShortKeyHandler {
}
private initBuiltInShortKey () {
const commands = db.get('settings.shortKey') as IShortKeyConfigs
const commands = picgo.getConfig<IShortKeyConfigs>('settings.shortKey') || {}
Object.keys(commands)
.filter(item => item.includes('picgo:'))
.forEach(command => {
@@ -57,8 +56,8 @@ class ShortKeyHandler {
const commands = plugin.commands(picgo) as IPluginShortKeyConfig[]
for (const cmd of commands) {
const command = `${item}:${cmd.name}`
if (db.has(`settings.shortKey[${command}]`)) {
const commandConfig = db.get(`settings.shortKey.${command}`) as IShortKeyConfig
const commandConfig = picgo.getConfig<IShortKeyConfig | undefined>(`settings.shortKey.${command}`)
if (commandConfig) {
// if disabled, don't register #534
if (commandConfig.enable) {
this.registerShortKey(commandConfig, command, cmd.handle, false)
@@ -168,8 +167,8 @@ class ShortKeyHandler {
const commands = plugin.commands(picgo) as IPluginShortKeyConfig[]
for (const cmd of commands) {
const command = `${pluginName}:${cmd.name}`
if (db.has(`settings.shortKey[${command}]`)) {
const commandConfig = db.get(`settings.shortKey[${command}]`) as IShortKeyConfig
const commandConfig = picgo.getConfig<IShortKeyConfig | undefined>(`settings.shortKey.${command}`)
if (commandConfig) {
this.registerShortKey(commandConfig, command, cmd.handle, false)
} else {
this.registerShortKey(cmd, command, cmd.handle, true)
@@ -179,7 +178,7 @@ class ShortKeyHandler {
}
unregisterPluginShortKey (pluginName: string) {
const commands = db.get('settings.shortKey') as IShortKeyConfigs
const commands = picgo.getConfig<IShortKeyConfigs>('settings.shortKey') || {}
const keyList = Object.keys(commands)
.filter(command => command.includes(pluginName))
.map(command => {
@@ -191,7 +190,7 @@ class ShortKeyHandler {
keyList.forEach(item => {
globalShortcut.unregister(item.key)
shortKeyService.unregisterCommand(item.command)
db.unset('settings.shortKey', item.command)
picgo.removeConfig('settings.shortKey', item.command)
})
}
}
+19 -20
View File
@@ -4,16 +4,16 @@ import {
Tray,
dialog,
clipboard,
Notification,
nativeTheme
} from 'electron'
import uploader from 'apis/app/uploader'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from '~/main/apis/core/datastore'
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import { IPasteStyle, IWindowList } from '#/types/enum'
import pasteTemplate from '~/main/utils/pasteTemplate'
import pkg from 'root/package.json'
import { ensureFilePath, getClipboardFilePathList, handleCopyUrl } from '~/main/utils/common'
import { ensureFilePath, getClipboardFilePathList, handleCopyUrl, showNotification } from '~/main/utils/common'
import { privacyManager } from '~/main/utils/privacyManager'
import { T } from '~/main/i18n'
import { isMacOSVersionGreaterThanOrEqualTo } from '~/main/utils/getMacOSVersion'
@@ -59,10 +59,10 @@ export function createContextMenu () {
{
label: T('OPEN_UPDATE_HELPER'),
type: 'checkbox',
checked: db.get('settings.showUpdateTip'),
checked: picgo.getConfig<boolean>('settings.showUpdateTip') !== false,
click () {
const value = db.get('settings.showUpdateTip')
db.set('settings.showUpdateTip', !value)
const value = picgo.getConfig<boolean>('settings.showUpdateTip') !== false
picgo.saveConfig({ 'settings.showUpdateTip': !value })
}
},
{
@@ -108,10 +108,10 @@ export function createContextMenu () {
{
label: T('OPEN_UPDATE_HELPER'),
type: 'checkbox',
checked: db.get('settings.showUpdateTip'),
checked: picgo.getConfig<boolean>('settings.showUpdateTip') !== false,
click () {
const value = db.get('settings.showUpdateTip')
db.set('settings.showUpdateTip', !value)
const value = picgo.getConfig<boolean>('settings.showUpdateTip') !== false
picgo.saveConfig({ 'settings.showUpdateTip': !value })
}
},
{
@@ -217,7 +217,7 @@ export function createTray () {
// drop-files only be supported in macOS
// so the tray window must be available
tray.on('drop-files', async (event, files: string[]) => {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
const imgs = await uploader
.setWebContents(trayWindow.webContents)
@@ -226,15 +226,14 @@ export function createTray () {
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(
pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink'))
pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink'))
)
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
// icon: files[i]
})
setTimeout(() => {
notification.show()
showNotification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
// icon: files[i]
})
}, i * 100)
await GalleryDB.getInstance().insert(imgs[i])
}
@@ -273,7 +272,7 @@ export function handleMenubarIcon (visible?: boolean) {
}
return
}
const shouldShow = visible !== undefined ? visible : (db.get('settings.showMenubarIcon') !== false)
const shouldShow = visible !== undefined ? visible : (picgo.getConfig<boolean>('settings.showMenubarIcon') !== false)
if (shouldShow) {
if (!tray) {
createTray()
@@ -285,7 +284,7 @@ export function handleMenubarIcon (visible?: boolean) {
export function handleDockIcon () {
if (isMacOS) {
if (db.get('settings.showDockIcon') !== false) {
if (picgo.getConfig<boolean>('settings.showDockIcon') !== false) {
app.dock?.show()
app.dock?.setMenu(createContextMenu())
} else {
+20 -23
View File
@@ -1,19 +1,19 @@
import {
Notification,
WebContents
} from 'electron'
import windowManager from 'apis/app/window/windowManager'
import { IRPCActionType, IWindowList } from '#/types/enum'
import { IPasteStyle, IRPCActionType, IWindowList } from '#/types/enum'
import uploader from '.'
import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { handleCopyUrl, handleUrlEncodeWithSetting } from '~/main/utils/common'
import { GalleryDB } from '~/main/apis/core/datastore'
import { handleCopyUrl, handleUrlEncodeWithSetting, showNotification } from '~/main/utils/common'
import { T } from '~/main/i18n/index'
import logger from '@core/picgo/logger'
import picgo from '@core/picgo'
// import dayjs from 'dayjs'
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
const useBuiltinClipboard = !!db.get('settings.useBuiltinClipboard')
const useBuiltinClipboard = !!picgo.getConfig<boolean>('settings.useBuiltinClipboard')
const win = windowManager.getAvailableWindow()
if (useBuiltinClipboard) {
return await uploader.setWebContents(win!.webContents).uploadWithBuildInClipboard()
@@ -27,15 +27,14 @@ export const uploadClipboardFiles = async (): Promise<string> => {
if (img !== false) {
if (img.length > 0) {
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!
// icon: img[0].imgUrl
})
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
notification.show()
showNotification({
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!
// icon: img[0].imgUrl
})
}, 100)
await GalleryDB.getInstance().insert(img[0])
// trayWindow just be created in mac/windows, not in linux
@@ -46,11 +45,10 @@ export const uploadClipboardFiles = async (): Promise<string> => {
}
return handleUrlEncodeWithSetting(img[0].imgUrl as string)
} else {
const notification = new Notification({
showNotification({
title: T('UPLOAD_FAILED'),
body: T('TIPS_UPLOAD_NOT_PICTURES')
})
notification.show()
return ''
}
} else {
@@ -63,17 +61,16 @@ export const uploadSelectedFiles = async (webContents: WebContents, files: IFile
const imgs = await uploader.setWebContents(webContents).upload(input)
const result = []
if (imgs !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
// icon: files[i].path
})
pasteText.push(pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
notification.show()
showNotification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl!
// icon: files[i].path
})
}, i * 100)
await GalleryDB.getInstance().insert(imgs[i])
result.push(handleUrlEncodeWithSetting(imgs[i].imgUrl!))
+8 -11
View File
@@ -1,5 +1,4 @@
import {
Notification,
BrowserWindow,
ipcMain,
WebContents,
@@ -7,7 +6,6 @@ import {
} from 'electron'
import dayjs from 'dayjs'
import picgo from '@core/picgo'
import db from '~/main/apis/core/datastore'
import windowManager from 'apis/app/window/windowManager'
import { IWindowList } from '#/types/enum'
import util from 'util'
@@ -48,27 +46,26 @@ class Uploader {
}
init () {
picgo.on('notification', (message: Electron.NotificationConstructorOptions | undefined) => {
const notification = new Notification(message)
notification.show()
picgo.on('notification', (message: IShowNotificationOption | undefined) => {
if (!message) return
showNotification(message)
})
picgo.on('uploadProgress', (progress: any) => {
this.webContents?.send('uploadProgress', progress)
})
picgo.on('beforeTransform', () => {
if (db.get('settings.uploadNotification')) {
const notification = new Notification({
if (picgo.getConfig<boolean>('settings.uploadNotification')) {
showNotification({
title: T('UPLOAD_PROGRESS'),
body: T('UPLOADING')
})
notification.show()
}
})
picgo.helper.beforeUploadPlugins.register('renameFn', {
handle: async (ctx: IPicGo) => {
const rename = db.get('settings.rename')
const autoRename = db.get('settings.autoRename')
const rename = picgo.getConfig<boolean>('settings.rename')
const autoRename = picgo.getConfig<boolean>('settings.autoRename')
if (autoRename || rename) {
await Promise.all(ctx.output.map(async (item, index) => {
let name: undefined | string | null
@@ -146,7 +143,7 @@ class Uploader {
fromClipboard: !img,
duration: Date.now() - startTime,
outputList: output
});
})
}
return output.filter(item => item.imgUrl)
} else {
+4 -4
View File
@@ -9,12 +9,12 @@ import {
import { IStartupMode, IWindowList } from '#/types/enum'
import bus from '@core/bus'
import { CREATE_APP_MENU } from '@core/bus/constants'
import db from '~/main/apis/core/datastore'
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
import { app } from 'electron'
import { T } from '~/main/i18n'
import { isLinux } from '~/universal/utils/common'
import { getStaticPath } from '#/utils/staticPath'
import picgo from '@core/picgo'
// import { URLSearchParams } from 'url'
const windowList = new Map<IWindowList, IWindowListItem>()
@@ -37,7 +37,7 @@ const handleWindowParams = (windowURL: string) => {
}
export const isWindowShouldShowOnStartup = (currentWindow: IWindowList) => {
const startupMode = db.get('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE)
const startupMode = picgo.getConfig<IStartupMode | undefined>('settings.startupMode') || (isLinux ? IStartupMode.SHOW_MINI_WINDOW : IStartupMode.HIDE)
switch (currentWindow) {
case IWindowList.MINI_WINDOW: {
return startupMode === IStartupMode.SHOW_MINI_WINDOW
@@ -82,7 +82,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
isValid: true,
multiple: false,
options () {
const showDockIcon = db.get('settings.showDockIcon') !== false
const showDockIcon = picgo.getConfig<boolean>('settings.showDockIcon') !== false
const options: IBrowserWindowOptions = {
height: 450,
width: 800,
@@ -142,7 +142,7 @@ windowList.set(IWindowList.MINI_WINDOW, {
}
}
if (db.get('settings.miniWindowOnTop')) {
if (picgo.getConfig<boolean>('settings.miniWindowOnTop')) {
obj.alwaysOnTop = true
}
return obj
+6 -77
View File
@@ -1,85 +1,14 @@
import path from 'path'
import fs from 'fs-extra'
import { dbPathChecker, dbPathDir, getGalleryDBPath } from './dbChecker'
import { DBStore, JSONStore } from '@picgo/store'
import { T } from '~/main/i18n'
import { DBStore } from '@picgo/store'
import { getGalleryDBPath } from './dbChecker'
const STORE_PATH = dbPathDir()
const DB_PATH: string = getGalleryDBPath().dbPath
fs.ensureDirSync(path.dirname(DB_PATH))
if (!fs.pathExistsSync(STORE_PATH)) {
fs.mkdirpSync(STORE_PATH)
}
const CONFIG_PATH: string = dbPathChecker()
export const DB_PATH: string = getGalleryDBPath().dbPath
class ConfigStore {
private db: JSONStore
constructor () {
this.db = new JSONStore(CONFIG_PATH)
if (!this.db.has('picBed')) {
this.db.set('picBed', {
current: 'smms', // deprecated
uploader: 'smms',
smms: {
token: ''
}
})
}
if (!this.db.has('settings.shortKey')) {
this.db.set('settings.shortKey[picgo:upload]', {
enable: true,
key: 'CommandOrControl+Shift+P',
name: 'upload',
label: T('QUICK_UPLOAD')
})
}
this.read()
}
flush () {
this.db = new JSONStore(CONFIG_PATH)
}
read () {
this.db.read()
return this.db
}
get (key = ''): any {
if (key === '') {
return this.db.read()
}
return this.db.get(key)
}
set (key: string, value: any): void {
return this.db.set(key, value)
}
has (key: string) {
return this.db.has(key)
}
unset (key: string, value: any): boolean {
return this.db.unset(key, value)
}
getConfigPath () {
return CONFIG_PATH
}
}
const db = new ConfigStore()
export default db
// v2.3.0 add gallery db
class GalleryDB {
private static instance: DBStore
private constructor () {
console.log('init gallery db')
}
private constructor () {}
public static getInstance (): DBStore {
if (!GalleryDB.instance) {
+10 -12
View File
@@ -1,8 +1,6 @@
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
import pkg from 'root/package.json'
import { PicGo } from 'picgo'
import db from 'apis/core/datastore'
import debounce from 'lodash/debounce'
const CONFIG_PATH = dbPathChecker()
@@ -17,18 +15,18 @@ picgo.saveConfig({
global.PICGO_GUI_VERSION = pkg.version
picgo.GUI_VERSION = global.PICGO_GUI_VERSION
const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
// const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
function flushDB () {
db.flush()
}
// function flushDB () {
// db.flush()
// }
const debounced = debounce(flushDB, 1000)
// const debounced = debounce(flushDB, 1000)
picgo.saveConfig = (config: IStringKeyMap) => {
originPicGoSaveConfig(config)
// flush electron's db
debounced()
}
// picgo.saveConfig = (config: IStringKeyMap) => {
// originPicGoSaveConfig(config)
// // flush electron's db
// debounced()
// }
export default picgo
+12 -17
View File
@@ -1,14 +1,14 @@
import {
dialog,
BrowserWindow,
Notification,
ipcMain
} from 'electron'
import db, { GalleryDB } from 'apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from 'apis/core/datastore'
import { dbPathChecker, defaultConfigPath, getGalleryDBPath } from 'apis/core/datastore/dbChecker'
import uploader from 'apis/app/uploader'
import pasteTemplate from '~/main/utils/pasteTemplate'
import { handleCopyUrl } from '~/main/utils/common'
import { handleCopyUrl, showNotification as showMainNotification } from '~/main/utils/common'
import {
getWindowId,
getSettingWindowId
@@ -18,7 +18,7 @@ import {
} from '~/universal/events/constants'
import { DBStore } from '@picgo/store'
import { T } from '~/main/i18n'
import { IRPCActionType } from '~/universal/types/enum'
import { IPasteStyle, IRPCActionType } from '~/universal/types/enum'
class GuiApi implements IGuiApi {
private static instance: GuiApi
@@ -77,17 +77,16 @@ class GuiApi implements IGuiApi {
const webContents = this.getWebContentsByWindowId(this.windowId)
const imgs = await uploader.setWebContents(webContents!).upload(input)
if (imgs !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
pasteText.push(pasteTemplate(pasteStyle, imgs[i], db.get('settings.customLink')))
const notification = new Notification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl as string
// icon: imgs[i].imgUrl
})
pasteText.push(pasteTemplate(pasteStyle, imgs[i], picgo.getConfig<string>('settings.customLink')))
setTimeout(() => {
notification.show()
showMainNotification({
title: T('UPLOAD_SUCCEED'),
body: imgs[i].imgUrl as string
// icon: imgs[i].imgUrl
})
}, i * 100)
await GalleryDB.getInstance().insert(imgs[i])
}
@@ -103,11 +102,7 @@ class GuiApi implements IGuiApi {
title: '',
body: ''
}) {
const notification = new Notification({
title: options.title,
body: options.body
})
notification.show()
showMainNotification(options)
}
showMessageBox (options: IShowMessageBoxOption = {
+13 -19
View File
@@ -2,15 +2,15 @@ import {
app,
ipcMain,
shell,
Notification,
IpcMainEvent,
BrowserWindow
} from 'electron'
import windowManager from 'apis/app/window/windowManager'
import { IRPCActionType, IWindowList } from '#/types/enum'
import { IPasteStyle, IRPCActionType, IWindowList } from '#/types/enum'
import uploader from 'apis/app/uploader'
import pasteTemplate from '~/main/utils/pasteTemplate'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { GalleryDB } from '~/main/apis/core/datastore'
import server from '~/main/server'
import getPicBeds from '~/main/utils/getPicBeds'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
@@ -34,7 +34,7 @@ import {
uploadSelectedFiles
} from '~/main/apis/app/uploader/apis'
import picgoCoreIPC from './picgoCoreIPC'
import { handleCopyUrl } from '~/main/utils/common'
import { handleCopyUrl, showNotification } from '~/main/utils/common'
import { buildMainPageMenu, buildMiniPageMenu, buildPluginPageMenu, buildPicBedListMenu } from './remotes/menu'
import path from 'path'
import { T } from '~/main/i18n'
@@ -49,15 +49,14 @@ export default {
// macOS use builtin clipboard is OK
const img = await uploader.setWebContents(trayWindow.webContents).uploadWithBuildInClipboard()
if (img !== false) {
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], db.get('settings.customLink')))
const notification = new Notification({
const pasteStyle = picgo.getConfig<IPasteStyle>('settings.pasteStyle') || 'markdown'
handleCopyUrl(pasteTemplate(pasteStyle, img[0], picgo.getConfig<string>('settings.customLink')))
showNotification({
title: T('UPLOAD_SUCCEED'),
body: img[0].imgUrl!
// icon: file[0]
// icon: img[0].imgUrl
})
notification.show()
await GalleryDB.getInstance().insert(img[0])
trayWindow.webContents.send('clipboardFiles', [])
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
@@ -80,43 +79,38 @@ export default {
const result = shortKeyHandler.updateShortKey(item, oldKey, from)
evt.sender.send('updateShortKeyResponse', result)
if (result) {
const notification = new Notification({
showNotification({
title: T('OPERATION_SUCCEED'),
body: T('TIPS_SHORTCUT_MODIFIED_SUCCEED')
})
notification.show()
} else {
const notification = new Notification({
showNotification({
title: T('OPERATION_FAILED'),
body: T('TIPS_SHORTCUT_MODIFIED_CONFLICT')
})
notification.show()
}
})
ipcMain.on('bindOrUnbindShortKey', (evt: IpcMainEvent, item: IShortKeyConfig, from: string) => {
const result = shortKeyHandler.bindOrUnbindShortKey(item, from)
if (result) {
const notification = new Notification({
showNotification({
title: T('OPERATION_SUCCEED'),
body: T('TIPS_SHORTCUT_MODIFIED_SUCCEED')
})
notification.show()
} else {
const notification = new Notification({
showNotification({
title: T('OPERATION_FAILED'),
body: T('TIPS_SHORTCUT_MODIFIED_CONFLICT')
})
notification.show()
}
})
ipcMain.on('updateCustomLink', () => {
const notification = new Notification({
showNotification({
title: T('OPERATION_SUCCEED'),
body: T('TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED')
})
notification.show()
})
ipcMain.on('autoStart', (evt: IpcMainEvent, val: boolean) => {
@@ -136,7 +130,7 @@ export default {
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
if (db.get('settings.miniWindowOnTop')) {
if (picgo.getConfig<boolean>('settings.miniWindowOnTop')) {
miniWindow.setAlwaysOnTop(true)
}
+2 -1
View File
@@ -257,8 +257,9 @@ const handleRemoveFiles = () => {
}
const handlePicGoSaveConfig = () => {
ipcMain.on(PICGO_SAVE_CONFIG, (event: IpcMainEvent, data: IObj) => {
ipcMain.handle(PICGO_SAVE_CONFIG, (_event, data: IObj) => {
picgo.saveConfig(data)
return true
})
}
+20
View File
@@ -3,6 +3,8 @@ import { RPCRouter } from '../router'
import { app, clipboard, shell } from 'electron'
import windowManager from '~/main/apis/app/window/windowManager'
import { handleMenubarIcon } from '~/main/apis/app/system'
import { PICGO_NOTIFICATION_CLICKED } from '~/universal/events/constants'
import { showNotification } from '~/main/utils/common'
const systemRouter = new RPCRouter()
@@ -35,6 +37,24 @@ systemRouter
const [visible] = args as IShowMenubarIconArgs
handleMenubarIcon(visible)
})
.add(IRPCActionType.SHOW_NOTIFICATION, async (args, event) => {
const [title, body, id] = args as IShowNotificationArgs
const options: IPrivateShowNotificationOption = {
title,
body
}
if (id) {
options.callback = () => {
if (!event.sender.isDestroyed()) {
event.sender.send(PICGO_NOTIFICATION_CLICKED, id)
}
}
}
showNotification(options)
})
export {
systemRouter
@@ -11,7 +11,7 @@ const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_
const defaultClipboardImagePath = path.join(defaultConfigPath, CLIPBOARD_IMAGE_FOLDER)
export const checkClipboardUploadMap: IToolboxCheckerMap<
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async (event) => {
sendToolboxRes(event, {
@@ -51,7 +51,7 @@ IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
}
export const fixClipboardUploadMap: IToolboxFixMap<
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async () => {
const configFilePath = dbPathChecker()
@@ -2,8 +2,8 @@ import fs from 'fs-extra'
import { IpcMainEvent } from 'electron'
import { IToolboxItemCheckStatus, IToolboxItemType } from '~/universal/types/enum'
import { sendToolboxResWithType } from './utils'
import { dbPathChecker } from '~/main/apis/core/datastore/dbChecker'
import { GalleryDB, DB_PATH } from '~/main/apis/core/datastore'
import { dbPathChecker, getGalleryDBPath } from '~/main/apis/core/datastore/dbChecker'
import { GalleryDB } from '~/main/apis/core/datastore'
import path from 'path'
import { T } from '~/main/i18n'
@@ -40,20 +40,21 @@ IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.LOADING
})
const { dbPath } = getGalleryDBPath()
const galleryDB = GalleryDB.getInstance()
if (galleryDB.errorList.length === 0) {
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.SUCCESS,
msg: T('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
path: DB_PATH
path: dbPath
}),
value: path.dirname(DB_PATH)
value: path.dirname(dbPath)
})
} else {
sendToolboxRes(event, {
status: IToolboxItemCheckStatus.ERROR,
msg: T('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
value: path.dirname(DB_PATH)
value: path.dirname(dbPath)
})
}
}
@@ -75,7 +76,7 @@ IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN
},
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
try {
fs.unlinkSync(DB_PATH)
fs.unlinkSync(getGalleryDBPath().dbPath)
} catch (e) {
// do nothing
}
@@ -25,7 +25,7 @@ const getProxy = (proxyStr: string): AxiosRequestConfig['proxy'] | false => {
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_PROXY)
export const checkProxyMap: IToolboxCheckerMap<
IToolboxItemType.HAS_PROBLEM_WITH_PROXY
IToolboxItemType.HAS_PROBLEM_WITH_PROXY
> = {
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async (event) => {
sendToolboxRes(event, {
+11 -10
View File
@@ -2,8 +2,7 @@ import './errorHandler'
import {
app,
globalShortcut,
protocol,
Notification
protocol
} from 'electron'
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
import beforeOpen from '~/main/utils/beforeOpen'
@@ -26,7 +25,7 @@ import server from '~/main/server/index'
import updateChecker from '~/main/utils/updateChecker'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import { getUploadFiles } from '~/main/utils/handleArgv'
import db, { GalleryDB } from '~/main/apis/core/datastore'
import { GalleryDB } from '~/main/apis/core/datastore'
import bus from '@core/bus'
import logger from 'apis/core/picgo/logger'
import picgo from 'apis/core/picgo'
@@ -35,6 +34,7 @@ import { initI18n } from '~/main/utils/handleI18n'
import { remoteNoticeHandler } from 'apis/app/remoteNotice'
import { isMacOS } from '../utils/getMacOSVersion'
import { isWindowShouldShowOnStartup } from '../apis/app/window/windowList'
import { showNotification } from '../utils/common'
import { initStaticPath, isDev } from '../utils/env'
const isDevelopment = isDev
@@ -65,8 +65,8 @@ class LifeCycle {
initI18n()
ipcList.listen()
busEventList.listen()
updateShortKeyFromVersion212(db, db.get('settings.shortKey'))
await migrateGalleryFromVersion230(db, GalleryDB.getInstance(), picgo)
updateShortKeyFromVersion212(picgo)
await migrateGalleryFromVersion230(GalleryDB.getInstance(), picgo)
}
private onReady () {
@@ -98,7 +98,7 @@ class LifeCycle {
}
handleMenubarIcon()
handleDockIcon()
db.set('needReload', false)
picgo.saveConfig({ needReload: false })
updateChecker()
// 不需要阻塞
process.nextTick(() => {
@@ -112,8 +112,9 @@ class LifeCycle {
if (global.notificationList && global.notificationList?.length > 0) {
while (global.notificationList?.length) {
const option = global.notificationList.pop()
const notice = new Notification(option!)
notice.show()
if (option) {
showNotification(option)
}
}
}
await remoteNoticeHandler.init()
@@ -146,13 +147,13 @@ class LifeCycle {
// click dock to open setting window
if (isMacOS) {
handleDockIcon()
if (db.get('settings.showDockIcon') !== false) {
if (picgo.getConfig<boolean>('settings.showDockIcon') !== false) {
windowManager.get(IWindowList.SETTING_WINDOW)?.show()
}
}
})
app.setLoginItemSettings({
openAtLogin: db.get('settings.autoStart') || false
openAtLogin: picgo.getConfig<boolean>('settings.autoStart') || false
})
if (process.platform === 'win32') {
app.setAppUserModelId('com.molunerfinn.picgo')
+19 -14
View File
@@ -1,12 +1,12 @@
import { DBStore } from '@picgo/store'
import ConfigStore from '~/main/apis/core/datastore'
import path from 'path'
import fse from 'fs-extra'
import { PicGo as PicGoCore } from 'picgo'
import { T } from '~/main/i18n'
import { SHORTKEY_COMMAND_UPLOAD } from 'apis/core/bus/constants'
// from v2.1.2
const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IShortKeyConfigs | IOldShortKeyConfigs) => {
const updateShortKeyFromVersion212 = (picgo: PicGoCore) => {
const shortKeyConfig = picgo.getConfig<IShortKeyConfigs | IOldShortKeyConfigs | undefined>('settings.shortKey')
// #557 极端情况可能会出现配置不存在,需要重新写入
if (shortKeyConfig === undefined) {
const defaultShortKeyConfig = {
@@ -15,33 +15,38 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS
name: 'upload',
label: T('QUICK_UPLOAD')
}
db.set('settings.shortKey[picgo:upload]', defaultShortKeyConfig)
picgo.saveConfig({
[`settings.shortKey[${SHORTKEY_COMMAND_UPLOAD}]`]: defaultShortKeyConfig
})
return true
}
if (shortKeyConfig.upload) {
// @ts-ignore
shortKeyConfig[SHORTKEY_COMMAND_UPLOAD] = {
if (typeof (shortKeyConfig as IOldShortKeyConfigs).upload === 'string') {
const oldKey = (shortKeyConfig as IOldShortKeyConfigs).upload
const nextConfig = Object.fromEntries(
Object.entries(shortKeyConfig).filter(([key]) => key !== 'upload')
) as IShortKeyConfigs
nextConfig[SHORTKEY_COMMAND_UPLOAD] = {
enable: true,
key: shortKeyConfig.upload,
key: oldKey,
name: 'upload',
label: T('QUICK_UPLOAD')
}
// @ts-ignore
delete shortKeyConfig.upload
db.set('settings.shortKey', shortKeyConfig)
picgo.saveConfig({
'settings.shortKey': nextConfig
})
return true
}
return false
}
const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => {
const originGallery: ImgInfo[] = picgo.getConfig('uploaded')
const migrateGalleryFromVersion230 = async (galleryDB: DBStore, picgo: PicGoCore) => {
const originGallery = picgo.getConfig<ImgInfo[] | undefined>('uploaded')
// if hasMigrate, we don't need to migrate
const hasMigrate: boolean = configDB.get('__migrateUploaded')
const hasMigrate = picgo.getConfig<boolean | undefined>('__migrateUploaded') === true
if (hasMigrate) {
return
}
const configPath = configDB.getConfigPath()
const configPath = picgo.configPath
const configBakPath = path.join(path.dirname(configPath), 'config.bak.json')
// migrate gallery from config to gallery db
if (originGallery && Array.isArray(originGallery) && originGallery?.length > 0) {
+1 -1
View File
@@ -20,7 +20,7 @@ export type MulterMiddleware = (
req: http.IncomingMessage,
res: http.ServerResponse,
callback: (error?: MulterError) => void
) => void;
) => void
// 扩展 multer 函数的返回类型
declare module 'multer' {
+28 -17
View File
@@ -1,12 +1,13 @@
import fs from 'fs-extra'
import db from '~/main/apis/core/datastore'
import logger from '@core/picgo/logger'
import { clipboard, Notification, dialog } from 'electron'
import { handleUrlEncode } from '~/universal/utils/common'
import { readClipboardFilePaths } from 'clip-filepaths'
import crypto from 'node:crypto'
import picgo from '@core/picgo'
export const handleCopyUrl = (str: string): void => {
if (db.get('settings.autoCopyUrl') !== false) {
if (picgo.getConfig<boolean>('settings.autoCopyUrl') !== false) {
clipboard.writeText(str)
}
}
@@ -18,21 +19,31 @@ export const handleCopyUrl = (str: string): void => {
export const showNotification = (options: IPrivateShowNotificationOption = {
title: '',
body: '',
text: '',
clickToCopy: false,
copyContent: '',
clickFn: () => {}
callback: () => {}
}) => {
if (options.text) {
logger.info('[PicGo Notification]', options.text)
clipboard.writeText(options.text)
}
const title = options.title || ''
const body = options.body || options.text || ''
const silent = picgo.getConfig('settings.notificationSound') === false
const notification = new Notification({
title: options.title,
body: options.body
title,
body,
silent
// icon: options.icon || undefined
})
const handleClick = () => {
if (options.clickToCopy) {
clipboard.writeText(options.copyContent || options.body)
clipboard.writeText(options.copyContent || body)
}
if (options.clickFn) {
options.clickFn()
if (options.callback) {
options.callback()
}
}
notification.once('click', handleClick)
@@ -83,18 +94,18 @@ export const calcUploadProcessDurationRange = (duration: number) => {
export const calcUploadBigFileSizeRange = (fileSizeMB: number) => {
if (fileSizeMB < 10) {
// 3.2 -> 3, 3.6 -> 4
const result = Math.round(fileSizeMB);
return result === 0 && fileSizeMB > 0 ? 1 : result;
const result = Math.round(fileSizeMB)
return result === 0 && fileSizeMB > 0 ? 1 : result
}
else if (fileSizeMB < 100) {
// 13 -> 1.3 -> 1 -> 10
// 17 -> 1.7 -> 2 -> 20
return Math.round(fileSizeMB / 10) * 10;
return Math.round(fileSizeMB / 10) * 10
}
else {
// 135 -> 1.35 -> 1 -> 100
// 160 -> 1.60 -> 2 -> 200
return Math.round(fileSizeMB / 100) * 100;
return Math.round(fileSizeMB / 100) * 100
}
}
@@ -102,18 +113,18 @@ export const calcUploadBigFileSizeRange = (fileSizeMB: number) => {
export const calcVideoDurationRange = (durationSec: number) => {
if (durationSec < 10) {
// 3.2 -> 3, 3.6 -> 4
const result = Math.round(durationSec);
return result === 0 && durationSec > 0 ? 1 : result;
const result = Math.round(durationSec)
return result === 0 && durationSec > 0 ? 1 : result
}
else if (durationSec < 100) {
// 13 -> 1.3 -> 1 -> 10
// 17 -> 1.7 -> 2 -> 20
return Math.round(durationSec / 10) * 10;
return Math.round(durationSec / 10) * 10
}
else {
// 135 -> 1.35 -> 1 -> 100
// 160 -> 1.60 -> 2 -> 200
return Math.round(durationSec / 100) * 100;
return Math.round(durationSec / 100) * 100
}
}
@@ -143,7 +154,7 @@ export const getClipboardFilePathList = (): string[] => {
}
export const handleUrlEncodeWithSetting = (url: string) => {
if (db.get('settings.encodeOutputURL') === true) {
if (picgo.getConfig<boolean>('settings.encodeOutputURL') === true) {
url = handleUrlEncode(url)
}
return url
+46 -46
View File
@@ -1,12 +1,12 @@
import { ipcMain, IpcMainEvent, type WebContents } from "electron";
import { deviceIdManager } from "./deviceId";
import { REGISTER_DEVICE_ID, TALKING_DATA_EVENT } from "~/universal/events/constants";
import type { IImgInfo } from "picgo";
import { calcUploadBigFileSizeRange, calcUploadProcessDurationRange, calcVideoDurationRange } from "./common";
import { app } from "electron/main";
import db from "~/main/apis/core/datastore";
import { getVideoDuration } from "@picgo/video-duration";
import { MB, SECOND } from "./constants";
import { ipcMain, IpcMainEvent, type WebContents } from "electron"
import { deviceIdManager } from "./deviceId"
import { REGISTER_DEVICE_ID, TALKING_DATA_EVENT } from "~/universal/events/constants"
import type { IImgInfo } from "picgo"
import { calcUploadBigFileSizeRange, calcUploadProcessDurationRange, calcVideoDurationRange } from "./common"
import { app } from "electron/main"
import picgo from "@core/picgo"
import { getVideoDuration } from "@picgo/video-duration"
import { MB, SECOND } from "./constants"
export interface IReportUploadDataOptions {
fromClipboard: boolean;
@@ -15,26 +15,26 @@ export interface IReportUploadDataOptions {
}
class DataReportManager {
private deviceId: string | null = null;
private hasRegisterDeviceID: boolean = false;
private deviceId: string | null = null
private hasRegisterDeviceID: boolean = false
constructor () {
this.init()
this.handleRegisterDeviceID()
}
private handleRegisterDeviceID() {
ipcMain.once(REGISTER_DEVICE_ID, (_evt: IpcMainEvent) => {
this.hasRegisterDeviceID = true;
console.log('Device ID registered');
});
this.hasRegisterDeviceID = true
console.log('Device ID registered')
})
}
private async init () {
if (this.deviceId) return;
if (this.deviceId) return
this.deviceId = await deviceIdManager.getId()
}
public async reportUploadData(webContents: WebContents, options: IReportUploadDataOptions) {
await this.init();
await this.registerDeviceID(webContents);
const { fromClipboard, duration, outputList } = options;
await this.init()
await this.registerDeviceID(webContents)
const { fromClipboard, duration, outputList } = options
const fileList = outputList.map(item => {
return {
fileName: item.fileName,
@@ -50,56 +50,56 @@ class DataReportManager {
by: fromClipboard ? 'clipboard' : 'files', // 上传剪贴板图片还是选择的文文件
count: fileList.length, // 上传的数量
duration: calcUploadProcessDurationRange(duration || 0), // 上传耗时
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
}
}
this.reportDataToWebContents(webContents, uploadEventData);
this.reportDataToWebContents(webContents, uploadEventData)
fileList.forEach(async file => {
if (file?.mimeType?.startsWith('video/') && file.filePath) {
const metadata = await getVideoDuration(file.filePath);
const sizeMB = metadata.size / MB;
const durationSec = (metadata.duration / SECOND) || 0;
const metadata = await getVideoDuration(file.filePath)
const sizeMB = metadata.size / MB
const durationSec = (metadata.duration / SECOND) || 0
const videoEventData: ITalkingDataOptions = {
EventId: 'upload_video',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType,
sizeRange: calcUploadBigFileSizeRange(sizeMB),
durationRange: calcVideoDurationRange(durationSec),
}
};
this.reportDataToWebContents(webContents, videoEventData);
}
this.reportDataToWebContents(webContents, videoEventData)
} else if (file?.mimeType?.startsWith('image/') || fromClipboard) {
const imageEventData: ITalkingDataOptions = {
EventId: 'upload_image',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType || 'image/png',
sizeRange: calcUploadBigFileSizeRange(file.size / MB)
}
};
this.reportDataToWebContents(webContents, imageEventData);
}
this.reportDataToWebContents(webContents, imageEventData)
} else {
const otherEventData: ITalkingDataOptions = {
EventId: 'upload_file',
Label: '',
MapKv: {
type: db.get('picBed.uploader') || db.get('picBed.current') || 'smms',
type: picgo.getConfig<string>('picBed.uploader') || picgo.getConfig<string>('picBed.current') || 'smms',
mimeType: file.mimeType || 'UNKNOWN',
sizeRange: calcUploadBigFileSizeRange(file.size / MB)
}
};
this.reportDataToWebContents(webContents, otherEventData);
}
this.reportDataToWebContents(webContents, otherEventData)
}
});
})
}
public async registerDeviceID(webContents: WebContents) {
if (this.hasRegisterDeviceID) return;
await this.init();
webContents.send(REGISTER_DEVICE_ID, this.deviceId);
if (this.hasRegisterDeviceID) return
await this.init()
webContents.send(REGISTER_DEVICE_ID, this.deviceId)
}
private reportDataToWebContents(webContents: WebContents, data: ITalkingDataOptions) {
@@ -111,22 +111,22 @@ class DataReportManager {
version: app.getVersion(),
area: this.getAreaFromTimezone()
}
});
})
}
private getAreaFromTimezone() {
try {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (!timeZone) return 'UNKNOWN';
try {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
if (!timeZone) return 'UNKNOWN'
if (timeZone === 'Asia/Shanghai') return 'CN';
if (timeZone === 'Asia/Shanghai') return 'CN'
const region = timeZone.split('/')[0]; // Asia, America, Europe
return region;
} catch (e) {
return 'UNKNOWN';
const region = timeZone.split('/')[0] // Asia, America, Europe
return region
} catch (e) {
return 'UNKNOWN'
}
}
}
}
export const dataReportManager = new DataReportManager()
+2 -2
View File
@@ -1,6 +1,6 @@
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { i18nManager } from '~/main/i18n'
export const initI18n = () => {
const currentLanguage = db.get('settings.language') || 'zh-CN'
const currentLanguage = picgo.getConfig<string>('settings.language') || 'zh-CN'
i18nManager.setCurrentLanguage(currentLanguage)
}
+3 -3
View File
@@ -1,16 +1,16 @@
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import { showMessageBox } from '~/main/utils/common'
import { T } from '~/main/i18n'
class PrivacyManager {
async check () {
if (db.get('settings.privacyEnsure') !== true) {
if (picgo.getConfig<boolean>('settings.privacyEnsure') !== true) {
const res = await this.show(true)
// cancel
if (res.result === 1) {
return false
} else {
db.set('settings.privacyEnsure', true)
picgo.saveConfig({ 'settings.privacyEnsure': true })
return true
}
}
+6 -6
View File
@@ -1,5 +1,5 @@
import { dialog, shell } from 'electron'
import db from '~/main/apis/core/datastore'
import picgo from '@core/picgo'
import pkg from 'root/package.json'
import { lt } from 'semver'
import { T } from '~/main/i18n'
@@ -10,13 +10,13 @@ const version = pkg.version
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
const checkVersion = async () => {
let showTip = db.get('settings.showUpdateTip')
let showTip = picgo.getConfig<boolean | undefined>('settings.showUpdateTip')
if (showTip === undefined) {
db.set('settings.showUpdateTip', true)
picgo.saveConfig({ 'settings.showUpdateTip': true })
showTip = true
}
if (showTip) {
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
const isCheckBetaUpdate = picgo.getConfig<boolean>('settings.checkBetaUpdate') !== false
const res: string = await getLatestVersion(isCheckBetaUpdate)
if (res !== '') {
const latest = res
@@ -35,7 +35,7 @@ const checkVersion = async () => {
if (res.response === 0) { // if selected yes
shell.openExternal(downloadUrl)
}
db.set('settings.showUpdateTip', !res.checkboxChecked)
picgo.saveConfig({ 'settings.showUpdateTip': !res.checkboxChecked })
})
}
} else {
@@ -50,7 +50,7 @@ const checkVersion = async () => {
const compareVersion2Update = (current: string, latest: string) => {
try {
if (latest.includes('beta')) {
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
const isCheckBetaUpdate = picgo.getConfig<boolean>('settings.checkBetaUpdate') !== false
if (!isCheckBetaUpdate) {
return false
}
@@ -34,7 +34,7 @@
import { T as $T } from '@/i18n'
import { saveConfig } from '@/utils/dataSender'
import { QuestionFilled } from '@element-plus/icons-vue'
import { showNotification } from '@/utils/common'
import { showNotification } from '@/utils/notification'
import { useVModel } from '@/hooks/useVModel'
interface IProps {
@@ -50,11 +50,14 @@ const emit = defineEmits(['update:modelValue', 'change'])
const value = useVModel(props, 'modelValue')
const handleChange = (value: ISwitchValueType) => {
saveConfig(`settings.${props.settingProps}`, value)
const handleChange = async (value: ISwitchValueType) => {
await saveConfig(`settings.${props.settingProps}`, value)
emit('update:modelValue', value)
emit('change', value)
showNotification(props.label, $T('TIPS_SET_SUCCEED'))
showNotification({
title: props.label,
body: $T('TIPS_SET_SUCCEED')
})
}
</script>
+21 -20
View File
@@ -203,6 +203,7 @@ import $$db from '@/utils/db'
import GalleryToolbar from './components/gallery/GalleryToolbar.vue'
import { IRPCActionType } from '~/universal/types/enum'
import { getRawData } from '@/utils/common'
import { showNotification } from '@/utils/notification'
const images = ref<ImgInfo[]>([])
const dialogVisible = ref(false)
const imgInfo = reactive({
@@ -375,10 +376,10 @@ async function copy (item: ImgInfo) {
// sometimes will cause lagging
// icon: item.url || item.imgUrl
}
const myNotification = new Notification(obj.title, obj)
myNotification.onclick = () => {
return true
}
showNotification({
title: obj.title,
body: obj.body
})
}
function remove (id?: string) {
@@ -395,10 +396,10 @@ function remove (id?: string) {
title: $T('OPERATION_SUCCEED'),
body: ''
}
const myNotification = new Notification(obj.title, obj)
myNotification.onclick = () => {
return true
}
showNotification({
title: obj.title,
body: obj.body
})
updateGallery()
}).catch((e) => {
console.log(e)
@@ -422,10 +423,10 @@ async function confirmModify () {
body: imgInfo.imgUrl
// icon: this.imgInfo.imgUrl
}
const myNotification = new Notification(obj.title, obj)
myNotification.onclick = () => {
return true
}
showNotification({
title: obj.title,
body: obj.body
})
dialogVisible.value = false
updateGallery()
}
@@ -478,10 +479,10 @@ function multiRemove () {
body: ''
}
sendToMain('removeFiles', files)
const myNotification = new Notification(obj.title, obj)
myNotification.onclick = () => {
return true
}
showNotification({
title: obj.title,
body: obj.body
})
updateGallery()
}).catch(() => {
return true
@@ -509,11 +510,11 @@ async function multiCopy () {
title: $T('BATCH_COPY_LINK_SUCCEED'),
body: copyString.join('\n')
}
const myNotification = new Notification(obj.title, obj)
clipboard.writeText(copyString.join('\n'))
myNotification.onclick = () => {
return true
}
showNotification({
title: obj.title,
body: obj.body
})
}
}
+2
View File
@@ -65,6 +65,7 @@ const form = reactive<ISettingForm>({
rename: false,
autoRename: false,
uploadNotification: false,
notificationSound: true,
miniWindowOnTop: false,
logLevel: ['all'],
autoCopyUrl: true,
@@ -102,6 +103,7 @@ async function initData () {
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
+7 -9
View File
@@ -214,6 +214,7 @@ import {
} from '#/events/constants'
import { computed, ref, onBeforeMount, onBeforeUnmount, watch } from 'vue'
import { getConfig, saveConfig, sendRPC, sendToMain } from '@/utils/dataSender'
import { showNotification } from '@/utils/notification'
import { ElMessageBox } from 'element-plus'
import axios from 'axios'
import { getRendererStaticFileUrl } from '@/utils/static'
@@ -405,12 +406,11 @@ async function handleReload () {
needReload: true
})
needReload.value = true
const successNotification = new Notification($T('PLUGIN_UPDATE_SUCCEED'), {
body: $T('TIPS_NEED_RELOAD')
showNotification({
title: $T('PLUGIN_UPDATE_SUCCEED'),
body: $T('TIPS_NEED_RELOAD'),
callback: reloadApp
})
successNotification.onclick = () => {
reloadApp()
}
}
function cleanSearch () {
@@ -437,12 +437,10 @@ async function handleConfirmConfig () {
})
break
}
const successNotification = new Notification($T('SETTINGS_RESULT'), {
showNotification({
title: $T('SETTINGS_RESULT'),
body: $T('TIPS_SET_SUCCEED')
})
successNotification.onclick = () => {
return true
}
dialogVisible.value = false
getPluginList()
}
+11 -5
View File
@@ -71,6 +71,7 @@ import { PASTE_TEXT, OPEN_WINDOW } from '#/events/constants'
import { IWindowList } from '#/types/enum'
import { sendToMain } from '@/utils/dataSender'
import { getRawData } from '@/utils/common'
import { showNotification } from '@/utils/notification'
import { IpcRendererEvent } from 'electron/renderer'
const files = ref<IResult<ImgInfo>[]>([])
@@ -95,10 +96,10 @@ async function getData () {
async function copyTheLink (item: ImgInfo) {
notification.body = item.imgUrl!
await ipcRenderer.invoke(PASTE_TEXT, getRawData(item))
const myNotification = new Notification(notification.title, notification)
myNotification.onclick = () => {
return true
}
showNotification({
title: notification.title,
body: notification.body
})
}
// function calcHeight (width: number, height: number): number {
@@ -238,9 +239,14 @@ body::-webkit-scrollbar
cursor not-allowed
&__title
text-align center
width 100%
overflow hidden
text-overflow ellipsis
white-space nowrap
white-space normal
word-break break-all
display -webkit-box
-webkit-box-orient vertical
-webkit-line-clamp 2
color #ddd
font-size 14px
margin-top 4px
+3 -4
View File
@@ -98,6 +98,7 @@
import { Delete, DocumentCopy, Edit, Plus } from '@element-plus/icons-vue'
import { ElMessageBox } from 'element-plus'
import { saveConfig, triggerRPC } from '@/utils/dataSender'
import { showNotification } from '@/utils/notification'
import dayjs from 'dayjs'
import { IRPCActionType } from '~/universal/types/enum'
import { T as $T } from '@/i18n/index'
@@ -207,12 +208,10 @@ function setDefaultPicBed (type: string) {
})
store?.setDefaultPicBed(type)
const successNotification = new Notification($T('SETTINGS_DEFAULT_PICBED'), {
showNotification({
title: $T('SETTINGS_DEFAULT_PICBED'),
body: $T('TIPS_SET_SUCCEED')
})
successNotification.onclick = () => {
return true
}
}
</script>
<script lang="ts">
@@ -74,7 +74,8 @@
import { T as $T } from '@/i18n'
import { saveConfig } from '@/utils/dataSender'
import { useVModel } from '@/hooks/useVModel'
import { openFile, showNotification } from '@/utils/common'
import { openFile } from '@/utils/common'
import { showNotification } from '@/utils/notification'
import { ElMessage as $message } from 'element-plus'
import { useVModelValues } from '@/hooks/useVModelValues'
@@ -121,7 +122,10 @@ function confirmLogLevelSetting () {
'settings.logLevel': form.logLevel,
'settings.logFileSizeLimit': form.logFileSizeLimit
})
showNotification($T('SETTINGS_SET_LOG_FILE'), $T('TIPS_SET_SUCCEED'))
showNotification({
title: $T('SETTINGS_SET_LOG_FILE'),
body: $T('TIPS_SET_SUCCEED')
})
updateProps()
dialogVisible.value = false
}
@@ -61,7 +61,7 @@ import { T as $T } from '@/i18n'
import { useVModel } from '@/hooks/useVModel'
import { saveConfig } from '@/utils/dataSender'
import { useVModelValues } from '@/hooks/useVModelValues'
import { showNotification } from '@/utils/common'
import { showNotification } from '@/utils/notification'
interface IProps {
modelValue: boolean
@@ -82,7 +82,10 @@ function confirmProxy () {
'settings.npmProxy': form.npmProxy,
'settings.npmRegistry': form.npmRegistry
})
showNotification($T('SETTINGS_SET_PROXY_AND_MIRROR'), $T('TIPS_SET_SUCCEED'))
showNotification({
title: $T('SETTINGS_SET_PROXY_AND_MIRROR'),
body: $T('TIPS_SET_SUCCEED')
})
updateProps()
}
@@ -67,7 +67,7 @@ import { T as $T } from '@/i18n'
import { useVModel } from '@/hooks/useVModel'
import { useVModelValues } from '@/hooks/useVModelValues'
import { saveConfig, sendToMain } from '@/utils/dataSender'
import { showNotification } from '@/utils/common'
import { showNotification } from '@/utils/notification'
interface IProps {
modelValue: boolean
@@ -86,7 +86,10 @@ function confirmServerSetting () {
saveConfig({
'settings.server': form
})
showNotification($T('SETTINGS_SET_PICGO_SERVER'), $T('TIPS_SET_SUCCEED'))
showNotification({
title: $T('SETTINGS_SET_PICGO_SERVER'),
body: $T('TIPS_SET_SUCCEED')
})
dialogVisible.value = false
sendToMain('updateServer')
updateProps()
@@ -31,6 +31,11 @@
setting-props="uploadNotification"
:label="$T('SETTINGS_OPEN_UPLOAD_TIPS')"
/>
<SwitchFormItem
v-model="form.notificationSound"
setting-props="notificationSound"
:label="$T('SETTINGS_NOTIFICATION_SOUND')"
/>
<SwitchFormItem
v-if="os !== 'darwin'"
v-model="form.miniWindowOnTop"
+3 -4
View File
@@ -46,6 +46,7 @@ import { IRPCActionType } from '~/universal/types/enum'
import { ref, onBeforeMount } from 'vue'
import { T as $T } from '@/i18n/index'
import { sendToMain, triggerRPC } from '@/utils/dataSender'
import { showNotification } from '@/utils/notification'
import { useRoute, useRouter } from 'vue-router'
import ConfigForm from '@/components/ConfigForm.vue'
// import mixin from '@/utils/ConfirmButtonMixin'
@@ -72,12 +73,10 @@ const handleConfirm = async () => {
const result = (await $configForm.value?.validate()) || false
if (result !== false) {
await triggerRPC<void>(IRPCActionType.UPDATE_UPLOADER_CONFIG, type.value, result?._id, result)
const successNotification = new Notification($T('SETTINGS_RESULT'), {
showNotification({
title: $T('SETTINGS_RESULT'),
body: $T('TIPS_SET_SUCCEED')
})
successNotification.onclick = () => {
return true
}
$router.back()
}
}
+6 -6
View File
@@ -24,13 +24,13 @@ ipcRenderer.on(TALKING_DATA_EVENT, (_, data: ITalkingDataOptions) => {
// 0ANONYMOUS,匿名账号;
// 1REGISTERED,自有帐户显性注册;
ipcRenderer.on(TALKING_DATA_DEVICE_ID_EVENT, (_, deviceId: string) => {
window.TDAPP.register({
window.TDAPP.register({
profileId: deviceId,
profileType: 1
})
window.TDAPP.login({
})
window.TDAPP.login({
profileId: deviceId,
profileType: 1
})
ipcRenderer.send(REGISTER_DEVICE_ID)
});
})
ipcRenderer.send(REGISTER_DEVICE_ID)
})
-9
View File
@@ -54,15 +54,6 @@ export const getRawData = (args: any): any => {
return args
}
export const showNotification = (title: string, body: string) => {
const notification = new Notification(title, {
body
})
notification.onclick = () => {
return true
}
}
export const openFile = (fileName: string) => {
sendToMain(PICGO_OPEN_FILE, fileName)
}
+2 -2
View File
@@ -4,7 +4,7 @@ import { v4 as uuid } from 'uuid'
import { IRPCActionType } from '~/universal/types/enum'
import { getRawData } from './common'
export function saveConfig (_config: IObj | string, value?: any) {
export async function saveConfig (_config: IObj | string, value?: any) {
let config
if (typeof _config === 'string') {
config = {
@@ -13,7 +13,7 @@ export function saveConfig (_config: IObj | string, value?: any) {
} else {
config = getRawData(_config)
}
ipcRenderer.send(PICGO_SAVE_CONFIG, config)
await ipcRenderer.invoke(PICGO_SAVE_CONFIG, config)
}
export function getConfig<T> (key?: string): Promise<T | undefined> {
+44
View File
@@ -0,0 +1,44 @@
import { ipcRenderer } from 'electron'
import { v4 as uuid } from 'uuid'
import { sendRPC } from './dataSender'
import { PICGO_NOTIFICATION_CLICKED } from '~/universal/events/constants'
import { IRPCActionType } from '~/universal/types/enum'
const notificationCallbacks = new Map<string, () => void>()
const MAX_CALLBACK_LIMIT = 10
const handleNotificationClick = (_event: Electron.IpcRendererEvent, id: string) => {
const callback = notificationCallbacks.get(id)
if (!callback) return
try {
callback()
} finally {
notificationCallbacks.delete(id)
}
}
// HMR Protection: Remove existing listener before adding a new one
ipcRenderer.removeAllListeners(PICGO_NOTIFICATION_CLICKED)
ipcRenderer.on(PICGO_NOTIFICATION_CLICKED, handleNotificationClick)
interface NotificationOptions {
title: string
body: string
callback?: () => void
}
export const showNotification = (options: NotificationOptions) => {
const id = uuid()
if (options.callback) {
if (notificationCallbacks.size >= MAX_CALLBACK_LIMIT) {
const oldestId = notificationCallbacks.keys().next().value
if (oldestId) {
notificationCallbacks.delete(oldestId)
}
}
notificationCallbacks.set(id, options.callback)
}
sendRPC(IRPCActionType.SHOW_NOTIFICATION, options.title, options.body, id)
}
+1
View File
@@ -37,6 +37,7 @@ export const FORCE_UPDATE = 'FORCE_UPDATE'
export const OPEN_WINDOW = 'OPEN_WINDOW'
export const GET_PICBEDS = 'GET_PICBEDS'
export const RPC_ACTIONS = 'RPC_ACTIONS'
export const PICGO_NOTIFICATION_CLICKED = 'PICGO_NOTIFICATION_CLICKED'
export const GET_PICBED_CONFIG = 'GET_PICBED_CONFIG'
export const REGISTER_DEVICE_ID = 'REGISTER_DEVICE_ID'
// i18n
+1
View File
@@ -74,6 +74,7 @@ export enum IRPCActionType {
COPY_TEXT = 'COPY_TEXT',
SHOW_DOCK_ICON = 'SHOW_DOCK_ICON',
SHOW_MENUBAR_ICON = 'SHOW_MENUBAR_ICON',
SHOW_NOTIFICATION = 'SHOW_NOTIFICATION',
// gallery and toolbox rpc
UPDATE_GALLERY = 'UPDATE_GALLERY',
+1
View File
@@ -75,6 +75,7 @@ interface ILocales {
SETTINGS_RENAME_BEFORE_UPLOAD: string
SETTINGS_TIMESTAMP_RENAME: string
SETTINGS_OPEN_UPLOAD_TIPS: string
SETTINGS_NOTIFICATION_SOUND: string
SETTINGS_MINI_WINDOW_ON_TOP: string
SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: string
SETTINGS_TIPS_PLACEHOLDER_URL: string
+1
View File
@@ -10,6 +10,7 @@ type IOpenFileArgs = [filePath: string]
type ICopyTextArgs = [text: string]
type IShowDockIconArgs = [visible: boolean]
type IShowMenubarIconArgs = [visible: boolean]
type IShowNotificationArgs = [title: string, body: string, id?: string]
type IGetGalleryMenuListArgs = [selectedList: IGalleryItem[]]
interface IRPCServer {
+6 -3
View File
@@ -256,7 +256,10 @@ type IUploadOption = string[] | ImgInfo[]
interface IShowNotificationOption {
title: string
body: string
// icon?: string | import('electron').NativeImage
/**
* will log text
*/
text?: string
}
interface IPrivateShowNotificationOption extends IShowNotificationOption{
@@ -265,7 +268,7 @@ interface IPrivateShowNotificationOption extends IShowNotificationOption{
*/
clickToCopy?: boolean
copyContent?: string // something to copy
clickFn?: () => void
callback?: () => void
}
interface IShowMessageBoxOption {
@@ -356,7 +359,7 @@ type ILoggerType = string | Error | boolean | number | undefined
interface IAppNotification {
title: string
body: string
icon?: string
text?: string
}
interface ITalkingDataOptions {
+1
View File
@@ -5,6 +5,7 @@ interface ISettingForm {
rename: boolean
autoRename: boolean
uploadNotification: boolean
notificationSound: boolean
miniWindowOnTop: boolean
logLevel: string[]
autoCopyUrl: boolean