diff --git a/currentVersion.md b/currentVersion.md index 33c2e1d3..aba59240 100644 --- a/currentVersion.md +++ b/currentVersion.md @@ -25,6 +25,8 @@ - Linux 新增 `rpm` 安装包 - 新增图床编辑卡片页面,解决多配置切换时的混乱问题 - 文件浏览页面新增列表模式支持。 +- 现在第一次启动时根据系统语言自动选择界面语言 +- 现在windows系统第一次启动时会默认显示主界面 - 现在支持手动关闭 GPU 加速,解决部分硬件兼容性导致的黑屏或闪烁问题 - 新增高级动画设置,开启后可获得更佳的 UI 交互体验 diff --git a/currentVersion_en.md b/currentVersion_en.md index 584d4f59..f96f1e14 100644 --- a/currentVersion_en.md +++ b/currentVersion_en.md @@ -25,6 +25,8 @@ Use custom `javascript` scripts to extend PicList's functionality without the ne - Added `rpm` installation package for Linux. - Added image hosting editing card page to resolve confusion when switching multiple configurations. - Added list mode support to the file browsing page. +- Now automatically selects the interface language based on the system language on the first launch. +- Now the main interface will be displayed by default on the first launch of Windows systems. - Now supports manually disabling GPU acceleration to resolve black screen or flickering issues caused by some hardware compatibility. - Added advanced animation settings for a better UI interaction experience when enabled. diff --git a/package.json b/package.json index dc049ebd..d47cce15 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "multer": "^2.0.2", "node-ssh-no-cpu-features": "^2.0.0", "nodejs-file-downloader": "^4.13.0", - "piclist": "^2.3.0", + "piclist": "^2.3.2", "qiniu": "7.14.0", "semver": "^7.7.3", "shell-path": "3.0.0", diff --git a/src/main/lifeCycle/autoUpdater.ts b/src/main/lifeCycle/autoUpdater.ts index fcf477f5..449a558e 100644 --- a/src/main/lifeCycle/autoUpdater.ts +++ b/src/main/lifeCycle/autoUpdater.ts @@ -16,6 +16,7 @@ import yaml from 'yaml' import { configPaths } from '~/utils/configPaths' import { II18nLanguage, IWindowList } from '~/utils/enum' + const dirname = path.dirname(fileURLToPath(import.meta.url)) let newVersion = '' diff --git a/src/main/lifeCycle/index.ts b/src/main/lifeCycle/index.ts index 1c9f94ac..ec8a64fd 100644 --- a/src/main/lifeCycle/index.ts +++ b/src/main/lifeCycle/index.ts @@ -4,6 +4,7 @@ import path from 'node:path' import { pathToFileURL } from 'node:url' import bus from '@core/bus' +import { themesDir } from '@core/datastore/dirs' import picgo from '@core/picgo' import logger from '@core/picgo/logger' import { remoteNoticeHandler } from 'apis/app/remoteNotice' @@ -15,10 +16,10 @@ import { app, globalShortcut, net, Notification, protocol, screen } from 'electr import { installExtension, VUEJS_DEVTOOLS_BETA } from 'electron-devtools-installer' import fs from 'fs-extra' -import { themesDir } from '~/apis/core/datastore/dirs' import busEventList from '~/events/busEventList' import { rpcServer } from '~/events/rpc' import { startFileServer, stopFileServer } from '~/fileServer' +import { i18nManager } from '~/i18n' import { setupAutoUpdater } from '~/lifeCycle/autoUpdater' import fixPath from '~/lifeCycle/fixPath' import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue' @@ -30,13 +31,14 @@ import { isAutoStartEnabled, setAutoStart } from '~/utils/autoStart' import beforeOpen from '~/utils/beforeOpen' import clipboardPoll from '~/utils/clipboardPoll' import { configPaths } from '~/utils/configPaths' -import { IRemoteNoticeTriggerHook, ISartMode, IWindowList } from '~/utils/enum' +import { II18nLanguage, IRemoteNoticeTriggerHook, ISartMode, IWindowList } from '~/utils/enum' import { getUploadFiles } from '~/utils/handleArgv' import { initI18n } from '~/utils/handleI18n' import { notificationList } from '~/utils/notification' import { runScriptInStage } from '~/utils/runScript' import { CLIPBOARD_IMAGE_FOLDER } from '~/utils/static' import updateChecker from '~/utils/updateChecker' + const isDevelopment = process.env.NODE_ENV !== 'production' process.noDeprecation = true @@ -112,8 +114,24 @@ class LifeCycle { } else { picgo.saveConfig({ [configPaths.settings.isListeningClipboard]: false }) } + const locale = app.getLocale() || 'zh-CN' + if (allConfig.settings?.language === undefined) { + if (locale.startsWith('zh')) { + i18nManager.setCurrentLanguage(II18nLanguage.ZH_CN) + picgo.saveConfig({ [configPaths.settings.language]: 'zh-CN' }) + } else { + i18nManager.setCurrentLanguage(II18nLanguage.EN) + picgo.saveConfig({ [configPaths.settings.language]: 'en' }) + } + } const isHideDock = allConfig.settings?.isHideDock || false - let startMode = allConfig.settings?.startMode || ISartMode.MAIN + + let startMode = + allConfig.settings?.startMode !== undefined + ? allConfig.settings.startMode + : process.platform === 'win32' + ? ISartMode.MAIN + : ISartMode.QUIET if (process.platform === 'darwin' && startMode === ISartMode.MINI) { startMode = ISartMode.QUIET } @@ -128,7 +146,6 @@ class LifeCycle { } picgo.saveConfig({ [configPaths.needReload]: false }) updateChecker() - // 不需要阻塞 process.nextTick(() => { shortKeyHandler.init() }) diff --git a/src/renderer/i18n/locales/en.json b/src/renderer/i18n/locales/en.json index 49f244ff..ae222954 100644 --- a/src/renderer/i18n/locales/en.json +++ b/src/renderer/i18n/locales/en.json @@ -909,6 +909,7 @@ "editTheme": "Edit Theme", "enableAdvancedAnimation": "Enable Advanced Animation", "enableAdvancedAnimationDesc": "Do not enable this option on low-performance devices or when GPU acceleration is disabled", + "getThemeContentFailed": "Failed to get theme content", "hideDockHint": "Cannot hide both dock and tray at the same time", "importThemes": "Import Themes", "importThemesFailed": "Failed to import themes", diff --git a/src/renderer/main.ts b/src/renderer/main.ts index 1cc53c22..3170e6e4 100644 --- a/src/renderer/main.ts +++ b/src/renderer/main.ts @@ -22,6 +22,8 @@ import db from '@/utils/db' type MessageSchema = typeof zhCN window.electron.setVisualZoomLevelLimits(1, 1) +const userLanguage = navigator.language || 'zh-CN' +const defaultLanguage = userLanguage.startsWith('zh') ? 'zh-CN' : 'en' const app = createApp(App) @@ -32,7 +34,7 @@ app.config.globalProperties.sendToMain = window.electron.sendToMain const i18n = createI18n<[MessageSchema], 'en' | 'zh-CN' | 'zh-TW'>({ legacy: false, - locale: localStorage.getItem('currentLanguage') || 'zh-CN', + locale: localStorage.getItem('currentLanguage') || defaultLanguage, fallbackLocale: 'zh-CN', messages: { en, diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index a8a8595e..4cf9bf4a 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -1834,7 +1834,12 @@ async function initData() { formOfSetting.value.logLevel = initArray(settings.logLevel || [], ['all']) formOfSetting.value.autoImportPicBed = initArray(settings.autoImportPicBed || [], []) currentLanguage.value = settings.language || 'zh-CN' - currentStartMode.value = settings.startMode || ISartMode.QUIET + currentStartMode.value = + settings.startMode !== undefined + ? settings.startMode + : osGlobal.value === 'win32' + ? ISartMode.MAIN + : ISartMode.QUIET currentSecondMode.value = settings.secondPicBedMode || 'backup' if (osGlobal.value === 'darwin' && currentStartMode.value === ISartMode.MINI) { currentStartMode.value = ISartMode.QUIET diff --git a/yarn.lock b/yarn.lock index 36d1a4b9..908cd98a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9728,10 +9728,10 @@ performance-now@^2.1.0: resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -piclist@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/piclist/-/piclist-2.3.0.tgz#3376b5d67e8068d11b015be577c6bb2389e307f2" - integrity sha512-LwLBi6Afi00tD5Wg5S9luxW3BZAVeL9goUI/vMNItPzKZKdh/qYpjUKkNkhYV19kU71RXZeJ+N26//vs+2xtVg== +piclist@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/piclist/-/piclist-2.3.2.tgz#77cfecc5931b6761d26acc969d6ecda9b7605d6f" + integrity sha512-s03G5r4HJffRgNEI72FefI9GDf8JSvw27LhslDwtmjpu/jvUVHru/VCwGaFBHyItW58nrqDh+W7gCfZ8x6ENhw== dependencies: "@aws-sdk/client-s3" "3.965.0" "@aws-sdk/lib-storage" "3.965.0"