diff --git a/AGENTS.md b/AGENTS.md index 09380c5..df90220 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,4 +25,7 @@ Place renderer unit specs in `test/unit/specs` with the `.spec.js` suffix; Karma Commits follow the PicGo conventional preset enforced by Husky (`pnpm lint:dpdm` + Commitlint). Stage your changes and run `pnpm cz` to craft messages that pass CI. Pull requests should explain the change, link related issues, and attach UI screenshots or recordings. Note how you validated the work (dev server, build, Karma, Spectron) and call out migration or configuration steps reviewers must perform. ## Internationalization Tips -Add locales by creating `public/i18n/.yml`, exposing its `LANG_DISPLAY_LABEL`, and registering it in `src/universal/i18n/index.ts`. Finish with `pnpm gen-i18n` so the generated typings stay in sync. +Add locales by creating `public/i18n/.yml`, exposing its `LANG_DISPLAY_LABEL`, and registering it in `src/universal/i18n/index.ts`. After editing `public/i18n/*.yml`, run `pnpm gen-i18n` to regenerate TS typings and keep them in sync. + +## Serena MCP & Context7 Tools +When starting work or if you hit issues, try checking MCP for Serena or Context7 tooling. If available, use those tools to navigate, edit, or fetch docs efficiently. diff --git a/public/i18n/en.yml b/public/i18n/en.yml index 2f05345..da3de10 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -248,6 +248,8 @@ TIPS_SHORTCUT_MODIFIED_SUCCEED: Shortcut modified successfully TIPS_SHORTCUT_MODIFIED_CONFLICT: Shortcut conflict, please reset TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED: Custom link style modified successfully TIPS_FIND_NEW_VERSION: Find new version ${v},update many new features, do you want to download the latest version? +TIPS_DELETE_UPLOADER_CONFIG: Are you sure you want to delete this config? +TIPS_COPY_UPLOADER_CONFIG: Are you sure you want to copy this config? # privacy PRIVACY: > @@ -276,7 +278,6 @@ PRIVACY: > 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; - c) If you violate relevant Chinese laws, regulations or relevant rules, you need to disclose it to a third party; 4. Information Security diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index ba014b4..bcb9f54 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -248,6 +248,8 @@ TIPS_SHORTCUT_MODIFIED_SUCCEED: 快捷键已经修改成功 TIPS_SHORTCUT_MODIFIED_CONFLICT: 快捷键冲突,请重新设置 TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED: 自定义链接格式已经修改成功 TIPS_FIND_NEW_VERSION: 发现新版本${v},更新了很多功能,是否去下载最新的版本? +TIPS_DELETE_UPLOADER_CONFIG: 是否要删除这个配置? +TIPS_COPY_UPLOADER_CONFIG: 是否要复制这个配置? # privacy PRIVACY: > @@ -276,7 +278,6 @@ PRIVACY: > b)根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露; - c)如您出现违反中国有关法律、法规或者相关规则的情况,需要向第三方披露; 4.信息安全 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 38d1446..ba45bc8 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -248,6 +248,8 @@ TIPS_SHORTCUT_MODIFIED_SUCCEED: 快捷鍵已經修改成功 TIPS_SHORTCUT_MODIFIED_CONFLICT: 快捷鍵衝突,請重新設定 TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED: 自訂連結格式已經修改成功 TIPS_FIND_NEW_VERSION: 發現新版本${v},更新了很多功能,是否去下載最新的版本? +TIPS_DELETE_UPLOADER_CONFIG: 是否要刪除這個配置? +TIPS_COPY_UPLOADER_CONFIG: 是否要複製這個配置? # privacy PRIVACY: > @@ -276,7 +278,6 @@ PRIVACY: > b)根據法律的有關規定,或者行政或司法機構的要求,向第三方或者行政、司法機構披露; - c)如您出現違反中國有關法律、法規或者相關規則的情況,需要向第三方披露; 4.信息安全 diff --git a/src/main/events/rpc/routes/config.ts b/src/main/events/rpc/routes/config.ts index 6f88c17..eaa34f3 100644 --- a/src/main/events/rpc/routes/config.ts +++ b/src/main/events/rpc/routes/config.ts @@ -1,6 +1,6 @@ import { IRPCActionType } from '~/universal/types/enum' import { RPCRouter } from '../router' -import { deleteUploaderConfig, getUploaderConfigList, selectUploaderConfig, updateUploaderConfig } from '~/main/utils/handleUploaderConfig' +import { copyUploaderConfig, deleteUploaderConfig, getUploaderConfigList, selectUploaderConfig, updateUploaderConfig } from '~/main/utils/handleUploaderConfig' const configRouter = new RPCRouter() @@ -15,6 +15,11 @@ configRouter const config = deleteUploaderConfig(type, id) return config }) + .add(IRPCActionType.COPY_UPLOADER_CONFIG, async (args) => { + const [type, id] = args as ICopyUploaderConfigArgs + const config = copyUploaderConfig(type, id) + return config + }) .add(IRPCActionType.SELECT_UPLOADER, async (args) => { const [type, id] = args as ISelectUploaderConfigArgs selectUploaderConfig(type, id) diff --git a/src/main/utils/handleUploaderConfig.ts b/src/main/utils/handleUploaderConfig.ts index 237e8f9..74ae960 100644 --- a/src/main/utils/handleUploaderConfig.ts +++ b/src/main/utils/handleUploaderConfig.ts @@ -1,4 +1,4 @@ -import { trimValues } from '#/utils/common' +import { simpleClone, trimValues } from '#/utils/common' import picgo from '@core/picgo' import { v4 as uuid } from 'uuid' @@ -121,6 +121,29 @@ export const deleteUploaderConfig = (type: string, id: string): IUploaderConfigI } } +/** + * copy uploader config by type & id + */ +export const copyUploaderConfig = (type: string, id: string): IUploaderConfigItem | void => { + const { configList, defaultId } = getUploaderConfigList(type) + const existConfig = configList.find((item: IStringKeyMap) => item._id === id) + if (!existConfig) { + return + } + const copiedConfig = completeUploaderMetaConfig({ + ...simpleClone(existConfig), + _configName: `${existConfig._configName || 'Default'} - Copy` + }) + configList.push(copiedConfig) + picgo.saveConfig({ + [`uploader.${type}.configList`]: configList + }) + return { + configList, + defaultId + } +} + /** * upgrade old uploader config to new format */ diff --git a/src/renderer/pages/UploaderConfigPage.vue b/src/renderer/pages/UploaderConfigPage.vue index c5ca2c3..b956482 100644 --- a/src/renderer/pages/UploaderConfigPage.vue +++ b/src/renderer/pages/UploaderConfigPage.vue @@ -43,6 +43,12 @@ > + + +