mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-09 22:43:09 +08:00
✨ Feature(custom): split i18n in main and renderer, use vue-i18n
This commit is contained in:
@@ -22,7 +22,7 @@ import { IPasteStyle, IWindowList } from '#/types/enum'
|
||||
import { IBounds, ImgInfo } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { buildPicBedListMenu } from '~/events/remotes/menu'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import clipboardPoll from '~/utils/clipboardPoll'
|
||||
import { ensureFilePath, handleCopyUrl, setTray, tray } from '~/utils/common'
|
||||
import { isMacOSVersionGreaterThanOrEqualTo } from '~/utils/getMacOSVersion'
|
||||
@@ -40,11 +40,11 @@ export function setDockMenu () {
|
||||
const isListeningClipboard = db.get(configPaths.settings.isListeningClipboard) || false
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: T('OPEN_MAIN_WINDOW'),
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
},
|
||||
{
|
||||
label: T('START_WATCH_CLIPBOARD'),
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click () {
|
||||
db.set(configPaths.settings.isListeningClipboard, true)
|
||||
clipboardPoll.startListening()
|
||||
@@ -57,7 +57,7 @@ export function setDockMenu () {
|
||||
visible: !isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('STOP_WATCH_CLIPBOARD'),
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click () {
|
||||
db.set(configPaths.settings.isListeningClipboard, false)
|
||||
clipboardPoll.stopListening()
|
||||
@@ -76,9 +76,9 @@ export function createMenu () {
|
||||
{
|
||||
label: 'PicList',
|
||||
submenu: [
|
||||
{ label: T('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{ label: $t('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{
|
||||
label: T('RELOAD_APP'),
|
||||
label: $t('RELOAD_APP'),
|
||||
click () {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
@@ -86,7 +86,7 @@ export function createMenu () {
|
||||
}
|
||||
]
|
||||
},
|
||||
{ label: T('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
@@ -100,8 +100,8 @@ export function createMenu () {
|
||||
]
|
||||
},
|
||||
{
|
||||
label: T('QUIT'),
|
||||
submenu: [{ label: T('QUIT'), role: 'quit' }]
|
||||
label: $t('QUIT'),
|
||||
submenu: [{ label: $t('QUIT'), role: 'quit' }]
|
||||
}
|
||||
])
|
||||
Menu.setApplicationMenu(appMenu)
|
||||
@@ -133,40 +133,40 @@ export function createContextMenu () {
|
||||
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||
const submenu = buildPicBedListMenu()
|
||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
{ label: T('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{ label: T('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{ label: $t('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{
|
||||
label: T('START_WATCH_CLIPBOARD'),
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('STOP_WATCH_CLIPBOARD'),
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('RELOAD_APP'),
|
||||
label: $t('RELOAD_APP'),
|
||||
click () {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
{ label: T('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
]
|
||||
if (process.platform === 'win32') {
|
||||
template.splice(
|
||||
2,
|
||||
0,
|
||||
{
|
||||
label: T('OPEN_MINI_WINDOW'),
|
||||
label: $t('OPEN_MINI_WINDOW'),
|
||||
click () {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
},
|
||||
{
|
||||
label: T('HIDE_MINI_WINDOW'),
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
}
|
||||
@@ -182,31 +182,31 @@ export function createContextMenu () {
|
||||
// 目前的实现无法正常工作
|
||||
|
||||
contextMenu = Menu.buildFromTemplate([
|
||||
{ label: T('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{ label: $t('OPEN_MAIN_WINDOW'), click: openMainWindow },
|
||||
{
|
||||
label: T('OPEN_MINI_WINDOW'),
|
||||
label: $t('OPEN_MINI_WINDOW'),
|
||||
click () {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
},
|
||||
{
|
||||
label: T('HIDE_MINI_WINDOW'),
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
},
|
||||
{
|
||||
label: T('START_WATCH_CLIPBOARD'),
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('STOP_WATCH_CLIPBOARD'),
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('ABOUT'),
|
||||
label: $t('ABOUT'),
|
||||
click () {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicList',
|
||||
@@ -216,7 +216,7 @@ export function createContextMenu () {
|
||||
})
|
||||
}
|
||||
},
|
||||
{ label: T('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ export function createTray (tooltip: string) {
|
||||
: !!db.get(configPaths.settings.uploadResultNotification)
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_SUCCEED'),
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
// icon: files[i]
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IPicGo } from 'piclist'
|
||||
import { IPasteStyle, IWindowList } from '#/types/enum'
|
||||
import { IFileWithPath, ImgInfo, IStringKeyMap, IUploadOption } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { T } from '~/i18n/index'
|
||||
import { T as $t } from '~/i18n/index'
|
||||
import { handleCopyUrl, handleUrlEncodeWithSetting } from '~/utils/common'
|
||||
import { changeCurrentUploader } from '~/utils/handleUploaderConfig'
|
||||
import pasteTemplate from '~/utils/pasteTemplate'
|
||||
@@ -61,7 +61,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
: !!db.get(configPaths.settings.uploadResultNotification)
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_SUCCEED'),
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
// icon: img[0].imgUrl
|
||||
})
|
||||
@@ -82,8 +82,8 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
}
|
||||
} else {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_FAILED'),
|
||||
body: T('TIPS_UPLOAD_NOT_PICTURES')
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: $t('TIPS_UPLOAD_NOT_PICTURES')
|
||||
})
|
||||
notification.show()
|
||||
return {
|
||||
@@ -141,7 +141,7 @@ export const uploadChoosedFiles = async (
|
||||
: !!db.get(configPaths.settings.uploadResultNotification)
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_SUCCEED'),
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
// icon: files[i].path
|
||||
})
|
||||
|
||||
@@ -11,13 +11,13 @@ import fs from 'fs-extra'
|
||||
import { IPicGo } from 'piclist'
|
||||
import writeFile from 'write-file-atomic'
|
||||
|
||||
import { GET_RENAME_FILE_NAME, RENAME_FILE_NAME, TALKING_DATA_EVENT } from '#/events/constants'
|
||||
import { GET_RENAME_FILE_NAME, RENAME_FILE_NAME } from '#/events/constants'
|
||||
import { ICOREBuildInEvent, IWindowList } from '#/types/enum'
|
||||
import { IAnalyticsData, ImgInfo, ITalkingDataOptions, IUploadOption } from '#/types/types'
|
||||
import { ImgInfo, IUploadOption } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { CLIPBOARD_IMAGE_FOLDER } from '#/utils/static'
|
||||
import { T } from '~/i18n'
|
||||
import { calcDurationRange, getClipboardFilePath, showNotification } from '~/utils/common'
|
||||
import { T as $t } from '~/i18n'
|
||||
import { getClipboardFilePath, showNotification } from '~/utils/common'
|
||||
|
||||
const waitForRename = (window: BrowserWindow, id: number): Promise<string | null> => {
|
||||
return new Promise(resolve => {
|
||||
@@ -33,21 +33,6 @@ const waitForRename = (window: BrowserWindow, id: number): Promise<string | null
|
||||
})
|
||||
}
|
||||
|
||||
const handleTalkingData = (webContents: WebContents, options: IAnalyticsData) => {
|
||||
const { type, fromClipboard, count, duration } = options
|
||||
const data: ITalkingDataOptions = {
|
||||
EventId: 'upload',
|
||||
Label: type,
|
||||
MapKv: {
|
||||
by: fromClipboard ? 'clipboard' : 'files',
|
||||
count,
|
||||
duration: calcDurationRange(duration || 0),
|
||||
type
|
||||
}
|
||||
}
|
||||
webContents.send(TALKING_DATA_EVENT, data)
|
||||
}
|
||||
|
||||
class Uploader {
|
||||
private webContents: WebContents | null = null
|
||||
|
||||
@@ -67,8 +52,8 @@ class Uploader {
|
||||
picgo.on(ICOREBuildInEvent.BEFORE_TRANSFORM, () => {
|
||||
if (db.get(configPaths.settings.uploadNotification)) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_PROGRESS'),
|
||||
body: T('UPLOADING')
|
||||
title: $t('UPLOAD_PROGRESS'),
|
||||
body: $t('UPLOADING')
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -164,19 +149,9 @@ class Uploader {
|
||||
|
||||
async uploadReturnCtx (img?: IUploadOption, skipProcess = false): Promise<IPicGo | false> {
|
||||
try {
|
||||
const startTime = Date.now()
|
||||
const ctx = await picgo.uploadReturnCtx(img, skipProcess)
|
||||
if (!Array.isArray(ctx.output) || !ctx.output.some((item: ImgInfo) => item.imgUrl)) return false
|
||||
|
||||
if (this.webContents) {
|
||||
handleTalkingData(this.webContents, {
|
||||
fromClipboard: !img,
|
||||
type: db.get(configPaths.picBed.uploader) || db.get(configPaths.picBed.current) || 'smms',
|
||||
count: img ? img.length : 1,
|
||||
duration: Date.now() - startTime
|
||||
} as IAnalyticsData)
|
||||
}
|
||||
|
||||
ctx.output.forEach((item: ImgInfo) => {
|
||||
item.config = JSON.parse(JSON.stringify(db.get(`picBed.${item.type}`)))
|
||||
})
|
||||
@@ -186,7 +161,7 @@ class Uploader {
|
||||
logger.error(e)
|
||||
setTimeout(() => {
|
||||
showNotification({
|
||||
title: T('UPLOAD_FAILED'),
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
})
|
||||
@@ -199,18 +174,8 @@ class Uploader {
|
||||
|
||||
async upload (img?: IUploadOption): Promise<ImgInfo[] | false> {
|
||||
try {
|
||||
const startTime = Date.now()
|
||||
const output = await picgo.upload(img)
|
||||
if (!Array.isArray(output) || !output.some((item: ImgInfo) => item.imgUrl)) return false
|
||||
|
||||
if (this.webContents) {
|
||||
handleTalkingData(this.webContents, {
|
||||
fromClipboard: !img,
|
||||
type: db.get(configPaths.picBed.uploader) || db.get(configPaths.picBed.current) || 'smms',
|
||||
count: img ? img.length : 1,
|
||||
duration: Date.now() - startTime
|
||||
} as IAnalyticsData)
|
||||
}
|
||||
output.forEach((item: ImgInfo) => {
|
||||
item.config = JSON.parse(JSON.stringify(db.get(`picBed.${item.type}`)))
|
||||
})
|
||||
@@ -219,7 +184,7 @@ class Uploader {
|
||||
logger.error(e)
|
||||
setTimeout(() => {
|
||||
showNotification({
|
||||
title: T('UPLOAD_FAILED'),
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import { IWindowListItem } from '#/types/electron'
|
||||
import { IWindowList } from '#/types/enum'
|
||||
import { IBrowserWindowOptions } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
import logo from '../../../../../resources/logo.png?asset'
|
||||
import {
|
||||
@@ -171,7 +171,7 @@ const toolboxWindowOptions = {
|
||||
center: true,
|
||||
fullscreenable: false,
|
||||
resizable: false,
|
||||
title: `PicList ${T('TOOLBOX')}`,
|
||||
title: `PicList ${$t('TOOLBOX')}`,
|
||||
vibrancy: 'ultra-dark',
|
||||
icon: logo,
|
||||
webPreferences: {
|
||||
|
||||
@@ -7,7 +7,7 @@ import fs from 'fs-extra'
|
||||
import writeFile from 'write-file-atomic'
|
||||
|
||||
import { notificationList } from '#/utils/notification'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
|
||||
@@ -19,8 +19,8 @@ let _configFilePath = ''
|
||||
let hasCheckPath = false
|
||||
|
||||
const errorMsg = {
|
||||
broken: T('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: T('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
}
|
||||
|
||||
function dbChecker () {
|
||||
@@ -41,7 +41,7 @@ function dbChecker () {
|
||||
}
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: T('TIPS_NOTICE'),
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
}
|
||||
// config save bak
|
||||
@@ -58,7 +58,7 @@ function dbChecker () {
|
||||
JSON.parse(configFile)
|
||||
writeFile.sync(configFilePath, configFile, { encoding: 'utf-8' })
|
||||
const stats = fs.statSync(configFileBackupPath)
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${T('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss')
|
||||
})}`
|
||||
notificationList.push(optionsTpl)
|
||||
@@ -108,8 +108,8 @@ function dbPathChecker (): string {
|
||||
const logger = getLogger(piclistLogPath, 'PicList')
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: T('TIPS_NOTICE'),
|
||||
body: T('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
}
|
||||
notificationList.push(optionsTpl)
|
||||
hasCheckPath = true
|
||||
|
||||
@@ -4,7 +4,7 @@ import fs from 'fs-extra'
|
||||
import { IConfig } from 'piclist'
|
||||
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
interface IJSON {
|
||||
[propsName: string]: string | number | IJSON
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class ConfigStore {
|
||||
enable: true,
|
||||
key: 'CommandOrControl+Alt+P',
|
||||
name: 'upload',
|
||||
label: T('QUICK_UPLOAD')
|
||||
label: $t('QUICK_UPLOAD')
|
||||
})
|
||||
}
|
||||
this.read()
|
||||
|
||||
@@ -12,7 +12,7 @@ import { SHOW_INPUT_BOX } from '#/events/constants'
|
||||
import { IPasteStyle } from '#/types/enum'
|
||||
import { IGuiApi, ImgInfo, IShowFileExplorerOption, IShowInputBoxOption, IShowMessageBoxOption, IShowMessageBoxResult, IShowNotificationOption, IUploadOption } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import { handleCopyUrl } from '~/utils/common'
|
||||
import pasteTemplate from '~/utils/pasteTemplate'
|
||||
|
||||
@@ -104,7 +104,7 @@ class GuiApi implements IGuiApi {
|
||||
: !!db.get(configPaths.settings.uploadResultNotification)
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_SUCCEED'),
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || (imgs[i].imgUrl! as string)
|
||||
// icon: imgs[i].imgUrl
|
||||
})
|
||||
@@ -179,8 +179,8 @@ class GuiApi implements IGuiApi {
|
||||
const guiApi = GuiApi.getInstance()
|
||||
guiApi
|
||||
.showMessageBox({
|
||||
title: T('TIPS_WARNING'),
|
||||
message: T('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
})
|
||||
@@ -202,8 +202,8 @@ class GuiApi implements IGuiApi {
|
||||
const guiApi = GuiApi.getInstance()
|
||||
guiApi
|
||||
.showMessageBox({
|
||||
title: T('TIPS_WARNING'),
|
||||
message: T('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
})
|
||||
|
||||
@@ -18,7 +18,7 @@ import { IWindowList } from '#/types/enum'
|
||||
import { IPicGoPlugin, IUploaderConfig } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { handlePluginUninstall, handlePluginUpdate } from '~/events/rpc/routes/plugin/utils'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import clipboardPoll from '~/utils/clipboardPoll'
|
||||
import { setTrayToolTip } from '~/utils/common'
|
||||
import getPicBeds from '~/utils/getPicBeds'
|
||||
@@ -36,28 +36,28 @@ const buildMiniPageMenu = () => {
|
||||
const submenu = buildPicBedListMenu()
|
||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
{
|
||||
label: T('OPEN_MAIN_WINDOW'),
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
},
|
||||
{
|
||||
label: T('CHOOSE_DEFAULT_PICBED'),
|
||||
label: $t('CHOOSE_DEFAULT_PICBED'),
|
||||
type: 'submenu',
|
||||
submenu
|
||||
},
|
||||
{
|
||||
label: T('UPLOAD_BY_CLIPBOARD'),
|
||||
label: $t('UPLOAD_BY_CLIPBOARD'),
|
||||
click () {
|
||||
uploadClipboardFiles()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('HIDE_MINI_WINDOW'),
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click () {
|
||||
BrowserWindow.getFocusedWindow()!.hide()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('START_WATCH_CLIPBOARD'),
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click () {
|
||||
db.set(configPaths.settings.isListeningClipboard, true)
|
||||
ClipboardWatcher.startListening()
|
||||
@@ -70,7 +70,7 @@ const buildMiniPageMenu = () => {
|
||||
visible: !isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('STOP_WATCH_CLIPBOARD'),
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click () {
|
||||
db.set(configPaths.settings.isListeningClipboard, false)
|
||||
ClipboardWatcher.stopListening()
|
||||
@@ -80,7 +80,7 @@ const buildMiniPageMenu = () => {
|
||||
visible: isListeningClipboard
|
||||
},
|
||||
{
|
||||
label: T('RELOAD_APP'),
|
||||
label: $t('RELOAD_APP'),
|
||||
click () {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
@@ -88,7 +88,7 @@ const buildMiniPageMenu = () => {
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
label: T('QUIT')
|
||||
label: $t('QUIT')
|
||||
}
|
||||
]
|
||||
return Menu.buildFromTemplate(template)
|
||||
@@ -97,7 +97,7 @@ const buildMiniPageMenu = () => {
|
||||
const buildMainPageMenu = (win: BrowserWindow) => {
|
||||
const template = [
|
||||
{
|
||||
label: T('ABOUT'),
|
||||
label: $t('ABOUT'),
|
||||
click () {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicList',
|
||||
@@ -107,26 +107,26 @@ const buildMainPageMenu = (win: BrowserWindow) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('SHOW_PICBED_QRCODE'),
|
||||
label: $t('SHOW_PICBED_QRCODE'),
|
||||
click () {
|
||||
win?.webContents?.send(SHOW_MAIN_PAGE_QRCODE)
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('OPEN_TOOLBOX'),
|
||||
label: $t('OPEN_TOOLBOX'),
|
||||
click () {
|
||||
const window = windowManager.create(IWindowList.TOOLBOX_WINDOW)
|
||||
window?.show()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('SHOW_DEVTOOLS'),
|
||||
label: $t('SHOW_DEVTOOLS'),
|
||||
click () {
|
||||
win?.webContents?.openDevTools({ mode: 'detach' })
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('FEEDBACK'),
|
||||
label: $t('FEEDBACK'),
|
||||
click () {
|
||||
const url = 'https://github.com/Kuingsmile/PicList/issues'
|
||||
shell.openExternal(url)
|
||||
@@ -144,7 +144,7 @@ const buildSecondPicBedMenu = () => {
|
||||
const picBedConfigList = picgo.getConfig<IUploaderConfig>('uploader')
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${T('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||
label: `${$t('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
@@ -196,7 +196,7 @@ const buildPicBedListMenu = () => {
|
||||
const picBedConfigList = picgo.getConfig<IUploaderConfig>('uploader')
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${T('CURRENT_PICBED')} - ${currentPicBedName}`,
|
||||
label: `${$t('CURRENT_PICBED')} - ${currentPicBedName}`,
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
@@ -276,7 +276,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
||||
const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const menu = [
|
||||
{
|
||||
label: T('ENABLE_PLUGIN'),
|
||||
label: $t('ENABLE_PLUGIN'),
|
||||
enabled: !plugin.enabled,
|
||||
click () {
|
||||
picgo.saveConfig({
|
||||
@@ -287,7 +287,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('DISABLE_PLUGIN'),
|
||||
label: $t('DISABLE_PLUGIN'),
|
||||
enabled: plugin.enabled,
|
||||
click () {
|
||||
picgo.saveConfig({
|
||||
@@ -306,7 +306,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('UNINSTALL_PLUGIN'),
|
||||
label: $t('UNINSTALL_PLUGIN'),
|
||||
click () {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
@@ -314,7 +314,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
label: T('UPDATE_PLUGIN'),
|
||||
label: $t('UPDATE_PLUGIN'),
|
||||
click () {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
@@ -325,7 +325,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
for (const i in plugin.config) {
|
||||
if (plugin.config[i].config.length > 0) {
|
||||
const obj = {
|
||||
label: T('CONFIG_THING', {
|
||||
label: $t('CONFIG_THING', {
|
||||
c: `${i} - ${plugin.config[i].fullName || plugin.config[i].name}`
|
||||
}),
|
||||
click () {
|
||||
@@ -345,7 +345,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
||||
const pluginTransformer = plugin.config.transformer.name
|
||||
const obj = {
|
||||
label: `${currentTransformer === pluginTransformer ? T('DISABLE') : T('ENABLE')}transformer - ${plugin.config.transformer.name}`,
|
||||
label: `${currentTransformer === pluginTransformer ? $t('DISABLE') : $t('ENABLE')}transformer - ${plugin.config.transformer.name}`,
|
||||
click () {
|
||||
const transformer = plugin.config.transformer.name
|
||||
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
import { GalleryDB } from '@core/datastore'
|
||||
import picgo from '@core/picgo'
|
||||
import logger from '@core/picgo/logger'
|
||||
import GuiApi from 'apis/gui'
|
||||
import { clipboard } from 'electron'
|
||||
|
||||
import { ICOREBuildInEvent, IPasteStyle, IRPCActionType, IRPCType } from '#/types/enum'
|
||||
import { IIPCEvent } from '#/types/rpc'
|
||||
import { ILogType, ImgInfo, ISftpPlistConfig, IStringKeyMap } from '#/types/types'
|
||||
import { ImgInfo } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { RPCRouter } from '~/events/rpc/router'
|
||||
import {
|
||||
removeFileFromDogeInMain,
|
||||
removeFileFromHuaweiInMain,
|
||||
removeFileFromS3InMain,
|
||||
removeFileFromSFTPInMain
|
||||
} from '~/utils/deleteFunc'
|
||||
import pasteTemplate from '~/utils/pasteTemplate'
|
||||
interface IFilter {
|
||||
orderBy?: 'asc' | 'desc'
|
||||
@@ -98,43 +91,6 @@ const galleryRoutes = [
|
||||
return await dbStore.insertMany(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_LOG_DELETE_MSG,
|
||||
handler: async (_: IIPCEvent, args: [msg: string, logLevel: ILogType]) => {
|
||||
const [msg, logLevel] = args
|
||||
console.log(msg, logLevel)
|
||||
logger[logLevel](msg)
|
||||
}
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_DELETE_SFTP_FILE,
|
||||
handler: async (_: IIPCEvent, args: [config: ISftpPlistConfig, fileName: string]) => {
|
||||
const [config, fileName] = args
|
||||
return await removeFileFromSFTPInMain(config, fileName)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_DELETE_AWS_S3_FILE,
|
||||
handler: async (_: IIPCEvent, args: [configMap: IStringKeyMap]) => {
|
||||
return await removeFileFromS3InMain(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_DELETE_DOGE_FILE,
|
||||
handler: async (_: IIPCEvent, args: [configMap: IStringKeyMap]) => {
|
||||
return await removeFileFromDogeInMain(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_DELETE_HUAWEI_OSS_FILE,
|
||||
handler: async (_: IIPCEvent, args: [configMap: IStringKeyMap]) => {
|
||||
return await removeFileFromHuaweiInMain(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ICOREBuildInEvent, IPicGoHelperType, IWindowList } from '#/types/enum'
|
||||
import { IIPCEvent } from '#/types/rpc'
|
||||
import { IDispose, IPicGoPlugin } from '#/types/types'
|
||||
import { handleStreamlinePluginName, simpleClone } from '#/utils/common'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import { showNotification } from '~/utils/common'
|
||||
|
||||
const STORE_PATH = dbPathDir()
|
||||
@@ -108,8 +108,8 @@ const handleNPMError = (): IDispose => {
|
||||
if (msg === 'NPM is not installed') {
|
||||
dialog
|
||||
.showMessageBox({
|
||||
title: T('TIPS_ERROR'),
|
||||
message: T('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
||||
title: $t('TIPS_ERROR'),
|
||||
message: $t('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
||||
buttons: ['Yes']
|
||||
})
|
||||
.then(res => {
|
||||
@@ -131,7 +131,7 @@ export const handlePluginUpdate = async (fullName: string | string[]) => {
|
||||
window.webContents.send('updateSuccess', res.body[0])
|
||||
} else {
|
||||
showNotification({
|
||||
title: T('PLUGIN_UPDATE_FAILED'),
|
||||
title: $t('PLUGIN_UPDATE_FAILED'),
|
||||
body: res.body as string
|
||||
})
|
||||
}
|
||||
@@ -148,7 +148,7 @@ export const handlePluginUninstall = async (fullName: string) => {
|
||||
shortKeyHandler.unregisterPluginShortKey(res.body[0])
|
||||
} else {
|
||||
showNotification({
|
||||
title: T('PLUGIN_UNINSTALL_FAILED'),
|
||||
title: $t('PLUGIN_UNINSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
})
|
||||
}
|
||||
@@ -165,7 +165,7 @@ export const pluginGetListFunc = async (event: IIPCEvent) => {
|
||||
} catch (e: any) {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: T('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
})
|
||||
picgo.log.error(e)
|
||||
@@ -185,7 +185,7 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
||||
await shortKeyHandler.registerPluginShortKey(res.body[0])
|
||||
} else {
|
||||
showNotification({
|
||||
title: T('PLUGIN_INSTALL_FAILED'),
|
||||
title: $t('PLUGIN_INSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
})
|
||||
}
|
||||
@@ -208,17 +208,17 @@ export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||
} catch (e: any) {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: T('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
})
|
||||
}
|
||||
showNotification({
|
||||
title: T('PLUGIN_IMPORT_SUCCEED'),
|
||||
title: $t('PLUGIN_IMPORT_SUCCEED'),
|
||||
body: ''
|
||||
})
|
||||
} else {
|
||||
showNotification({
|
||||
title: T('PLUGIN_IMPORT_FAILED'),
|
||||
title: $t('PLUGIN_IMPORT_FAILED'),
|
||||
body: res.body as string
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
|
||||
import { IRPCActionType, IRPCType } from '#/types/enum'
|
||||
import { IIPCEvent } from '#/types/rpc'
|
||||
import { IShortKeyConfig } from '#/types/types'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
const notificationFunc = (result: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: T(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
||||
body: T(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`)
|
||||
title: $t(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`)
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import picgo from '@core/picgo'
|
||||
import windowManager from 'apis/app/window/windowManager'
|
||||
import { app, IpcMainEvent, shell } from 'electron'
|
||||
import { IIPCEvent } from 'root/src/universal/types/rpc'
|
||||
|
||||
import { SET_CURRENT_LANGUAGE } from '#/events/constants'
|
||||
import { IRPCActionType, IWindowList } from '#/types/enum'
|
||||
import { IRPCActionType } from '#/types/enum'
|
||||
import { IIPCEvent } from '#/types/rpc'
|
||||
import { i18nManager } from '~/i18n'
|
||||
|
||||
export default [
|
||||
@@ -33,35 +31,12 @@ export default [
|
||||
shell.openExternal(args[0])
|
||||
}
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GET_LANGUAGE_LIST,
|
||||
handler: async (event: IIPCEvent) => {
|
||||
(event as IpcMainEvent).returnValue = i18nManager.languageList
|
||||
}
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GET_CURRENT_LANGUAGE,
|
||||
handler: async (event: IIPCEvent) => {
|
||||
const { lang, locales } = i18nManager.getCurrentLocales()
|
||||
;(event as IpcMainEvent).returnValue = [lang, locales]
|
||||
}
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SET_CURRENT_LANGUAGE,
|
||||
handler: async (_: IIPCEvent, args: [language: string]) => {
|
||||
i18nManager.setCurrentLanguage(args[0])
|
||||
const { lang, locales } = i18nManager.getCurrentLocales()
|
||||
const { lang } = i18nManager.getCurrentLocales()
|
||||
picgo.i18n.setLanguage(lang)
|
||||
if (process.platform === 'darwin') {
|
||||
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)
|
||||
trayWindow?.webContents.send(SET_CURRENT_LANGUAGE, lang, locales)
|
||||
}
|
||||
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)
|
||||
settingWindow?.webContents.send(SET_CURRENT_LANGUAGE, lang, locales)
|
||||
if (windowManager.has(IWindowList.MINI_WINDOW)) {
|
||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)
|
||||
miniWindow?.webContents.send(SET_CURRENT_LANGUAGE, lang, locales)
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -7,7 +7,7 @@ import { IToolboxItemCheckStatus, IToolboxItemType } from '#/types/enum'
|
||||
import { IToolboxCheckerMap, IToolboxFixMap } from '#/types/rpc'
|
||||
import { CLIPBOARD_IMAGE_FOLDER } from '#/utils/static'
|
||||
import { sendToolboxResWithType } from '~/events/rpc/routes/toolbox/utils'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD)
|
||||
|
||||
@@ -25,7 +25,7 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<IToolboxItemType.HAS_PR
|
||||
if (fs.existsSync(clipboardImagePath)) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
||||
path: clipboardImagePath
|
||||
}),
|
||||
value: clipboardImagePath
|
||||
@@ -33,7 +33,7 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<IToolboxItemType.HAS_PR
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: clipboardImagePath
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
@@ -42,7 +42,7 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<IToolboxItemType.HAS_PR
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: defaultClipboardImagePath
|
||||
}),
|
||||
value: path.dirname(defaultClipboardImagePath)
|
||||
@@ -66,7 +66,7 @@ export const fixClipboardUploadMap: IToolboxFixMap<IToolboxItemType.HAS_PROBLEM_
|
||||
return {
|
||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS', {
|
||||
path: clipboardImagePath
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
|
||||
@@ -2,13 +2,13 @@ import path from 'node:path'
|
||||
|
||||
import { DB_PATH, GalleryDB } from '@core/datastore'
|
||||
import { dbPathChecker } from '@core/datastore/dbChecker'
|
||||
import { IpcMainEvent } from 'electron'
|
||||
import type { IpcMainEvent } from 'electron'
|
||||
import fs from 'fs-extra'
|
||||
|
||||
import { IToolboxItemCheckStatus, IToolboxItemType } from '#/types/enum'
|
||||
import { IToolboxCheckerMap, IToolboxFixMap } from '#/types/rpc'
|
||||
import type { IToolboxCheckerMap, IToolboxFixMap } from '#/types/rpc'
|
||||
import { sendToolboxResWithType } from '~/events/rpc/routes/toolbox/utils'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
export const checkFileMap: IToolboxCheckerMap<
|
||||
IToolboxItemType.IS_CONFIG_FILE_BROKEN | IToolboxItemType.IS_GALLERY_FILE_BROKEN
|
||||
@@ -24,7 +24,7 @@ export const checkFileMap: IToolboxCheckerMap<
|
||||
await fs.readJSON(configFilePath)
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
||||
path: configFilePath
|
||||
}),
|
||||
value: configFilePath
|
||||
@@ -33,7 +33,7 @@ export const checkFileMap: IToolboxCheckerMap<
|
||||
} catch (e) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(configFilePath)
|
||||
})
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export const checkFileMap: IToolboxCheckerMap<
|
||||
if (galleryDB.errorList.length === 0) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
|
||||
path: DB_PATH
|
||||
}),
|
||||
value: path.dirname(DB_PATH)
|
||||
@@ -55,7 +55,7 @@ export const checkFileMap: IToolboxCheckerMap<
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(DB_PATH)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import tunnel from 'tunnel'
|
||||
import { IToolboxItemCheckStatus, IToolboxItemType } from '#/types/enum'
|
||||
import { IToolboxCheckerMap } from '#/types/rpc'
|
||||
import { sendToolboxResWithType } from '~/events/rpc/routes/toolbox/utils'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
function getProxy (proxyStr: string): AxiosRequestConfig['proxy'] | null {
|
||||
if (proxyStr) {
|
||||
@@ -39,7 +39,7 @@ export const checkProxyMap: IToolboxCheckerMap<IToolboxItemType.HAS_PROBLEM_WITH
|
||||
if (!config) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ export const checkProxyMap: IToolboxCheckerMap<IToolboxItemType.HAS_PROBLEM_WITH
|
||||
if (!proxy) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
})
|
||||
} else {
|
||||
const proxyOptions = getProxy(proxy)
|
||||
if (!proxyOptions) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT')
|
||||
})
|
||||
} else {
|
||||
const httpsAgent = tunnel.httpsOverHttp({
|
||||
@@ -69,13 +69,13 @@ export const checkProxyMap: IToolboxCheckerMap<IToolboxItemType.HAS_PROBLEM_WITH
|
||||
})
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS')
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ export const checkProxyMap: IToolboxCheckerMap<IToolboxItemType.HAS_PROBLEM_WITH
|
||||
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: T('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { IPasteStyle, IRPCActionType, IRPCType, IWindowList } from '#/types/enum
|
||||
import { IIPCEvent } from '#/types/rpc'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { RPCRouter } from '~/events/rpc/router'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import { generateShortUrl, handleCopyUrl, setTrayToolTip } from '~/utils/common'
|
||||
import pasteTemplate from '~/utils/pasteTemplate'
|
||||
|
||||
@@ -44,7 +44,7 @@ const trayRoutes = [
|
||||
: !!db.get(configPaths.settings.uploadResultNotification)
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: T('UPLOAD_SUCCEED'),
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
// icon: file[0]
|
||||
// icon: img[0].imgUrl
|
||||
|
||||
@@ -23,7 +23,7 @@ import { CLIPBOARD_IMAGE_FOLDER } from '#/utils/static'
|
||||
import busEventList from '~/events/busEventList'
|
||||
import { rpcServer } from '~/events/rpc'
|
||||
import { startFileServer, stopFileServer } from '~/fileServer'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
import fixPath from '~/lifeCycle/fixPath'
|
||||
import UpDownTaskQueue from '~/manage/datastore/upDownTaskQueue'
|
||||
import getManageApi from '~/manage/Main'
|
||||
@@ -95,16 +95,16 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
||||
dialog
|
||||
.showMessageBox({
|
||||
type: 'info',
|
||||
title: T('FIND_NEW_VERSION'),
|
||||
title: $t('FIND_NEW_VERSION'),
|
||||
buttons: ['Yes', 'Go to download page'],
|
||||
message:
|
||||
T('TIPS_FIND_NEW_VERSION', {
|
||||
$t('TIPS_FIND_NEW_VERSION', {
|
||||
v: info.version
|
||||
}) +
|
||||
'\n\n' +
|
||||
displayLog +
|
||||
truncatedNote,
|
||||
checkboxLabel: T('NO_MORE_NOTICE'),
|
||||
checkboxLabel: $t('NO_MORE_NOTICE'),
|
||||
checkboxChecked: false
|
||||
})
|
||||
.then(result => {
|
||||
@@ -132,9 +132,9 @@ updater.autoUpdater.on('update-downloaded', () => {
|
||||
dialog
|
||||
.showMessageBox({
|
||||
type: 'info',
|
||||
title: T('UPDATE_DOWNLOADED'),
|
||||
title: $t('UPDATE_DOWNLOADED'),
|
||||
buttons: ['Yes', 'No'],
|
||||
message: T('TIPS_UPDATE_DOWNLOADED')
|
||||
message: $t('TIPS_UPDATE_DOWNLOADED')
|
||||
})
|
||||
.then(result => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
|
||||
@@ -7,7 +7,7 @@ import fs from 'fs-extra'
|
||||
import writeFile from 'write-file-atomic'
|
||||
|
||||
import { notificationList } from '#/utils/notification'
|
||||
import { T } from '~/i18n'
|
||||
import { T as $t } from '~/i18n'
|
||||
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const manageConfigFilePath = path.join(STORE_PATH, 'manage.json')
|
||||
@@ -17,8 +17,8 @@ let _configFilePath = ''
|
||||
let hasCheckPath = false
|
||||
|
||||
const errorMsg = {
|
||||
broken: T('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: T('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
}
|
||||
|
||||
function manageDbChecker () {
|
||||
@@ -29,7 +29,7 @@ function manageDbChecker () {
|
||||
}
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: T('TIPS_NOTICE'),
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
}
|
||||
// config save bak
|
||||
@@ -48,7 +48,7 @@ function manageDbChecker () {
|
||||
encoding: 'utf-8'
|
||||
})
|
||||
const stats = fs.statSync(manageConfigFileBackupPath)
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${T('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss')
|
||||
})}`
|
||||
notificationList.push(optionsTpl)
|
||||
@@ -101,8 +101,8 @@ function managePathChecker (): string {
|
||||
const logger = getLogger(manageLogPath, 'Manage')
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: T('TIPS_NOTICE'),
|
||||
body: T('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
}
|
||||
notificationList?.push(optionsTpl)
|
||||
hasCheckPath = true
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
import { IStringKeyMap } from '#/types/types'
|
||||
|
||||
const AliyunAreaCodeName: IStringKeyMap = {
|
||||
'oss-cn-hangzhou': '华东1(杭州)',
|
||||
'oss-cn-shanghai': '华东2(上海)',
|
||||
'oss-cn-nanjing': '华东5(南京)',
|
||||
'oss-cn-fuzhou': '华东6(福州)',
|
||||
'oss-cn-wuhan': '华中1(武汉)',
|
||||
'oss-cn-qingdao': '华北1(青岛)',
|
||||
'oss-cn-beijing': '华北2(北京)',
|
||||
'oss-cn-zhangjiakou': '华北3(张家口)',
|
||||
'oss-cn-huhehaote': '华北5(呼和浩特)',
|
||||
'oss-cn-wulanchabu': '华北6(乌兰察布)',
|
||||
'oss-cn-shenzhen': '华南1(深圳)',
|
||||
'oss-cn-heyuan': '华南2(河源)',
|
||||
'oss-cn-guangzhou': '华南3(广州)',
|
||||
'oss-cn-chengdu': '西南1(成都)',
|
||||
'oss-cn-hongkong': '中国香港',
|
||||
'oss-us-west-1': '美国(硅谷)',
|
||||
'oss-us-east-1': '美国(弗吉尼亚)',
|
||||
'oss-ap-northeast-1': '日本(东京)',
|
||||
'oss-ap-northeast-2': '韩国(首尔)',
|
||||
'oss-ap-southeast-1': '新加坡',
|
||||
'oss-ap-southeast-2': '澳大利亚(悉尼)',
|
||||
'oss-ap-southeast-3': '马来西亚(吉隆坡)',
|
||||
'oss-ap-southeast-5': '印度尼西亚(雅加达)',
|
||||
'oss-ap-southeast-6': '菲律宾(马尼拉)',
|
||||
'oss-ap-southeast-7': '泰国(曼谷)',
|
||||
'oss-ap-south-1': '印度(孟买)',
|
||||
'oss-eu-central-1': '德国(法兰克福)',
|
||||
'oss-eu-west-1': '英国(伦敦)',
|
||||
'oss-me-east-1': '阿联酋(迪拜)',
|
||||
'oss-rg-china-mainland': '无地域属性'
|
||||
}
|
||||
|
||||
const QiniuAreaCodeName: IStringKeyMap = {
|
||||
z0: '华东-浙江',
|
||||
'cn-east-2': '华东 浙江2',
|
||||
z1: '华北-河北',
|
||||
z2: '华南-广东',
|
||||
na0: '北美-洛杉矶',
|
||||
as0: '亚太-新加坡',
|
||||
'ap-northeast-1': '亚太-首尔',
|
||||
'ap-southeast-2': '亚太-河内'
|
||||
}
|
||||
|
||||
const TencentAreaCodeName: IStringKeyMap = {
|
||||
'ap-beijing-1': '北京一区',
|
||||
'ap-beijing': '北京',
|
||||
'ap-nanjing': '南京',
|
||||
'ap-shanghai': '上海',
|
||||
'ap-guangzhou': '广州',
|
||||
'ap-chengdu': '成都',
|
||||
'ap-chongqing': '重庆',
|
||||
'ap-shenzhen-fsi': '深圳金融',
|
||||
'ap-shagnhai-fsi': '上海金融',
|
||||
'ap-beijing-fsi': '北京金融',
|
||||
'ap-hongkong': '香港',
|
||||
'ap-singapore': '新加坡',
|
||||
'ap-mumbai': '孟买',
|
||||
'ap-jakarta': '雅加达',
|
||||
'ap-seoul': '首尔',
|
||||
'ap-bangkok': '曼谷',
|
||||
'ap-tokyo': '东京',
|
||||
'na-siliconvalley': '硅谷(美西)',
|
||||
'na-ashburn': '弗吉尼亚(美东)',
|
||||
'na-toronto': '多伦多',
|
||||
'sa-saopaulo': '圣保罗',
|
||||
'eu-frankfurt': '法兰克福'
|
||||
}
|
||||
|
||||
export { AliyunAreaCodeName, QiniuAreaCodeName, TencentAreaCodeName }
|
||||
@@ -10,7 +10,7 @@ import { ICOREBuildInEvent, IWindowList } from '#/types/enum'
|
||||
import { IHttpResponse, ImgInfo, IObj } from '#/types/types'
|
||||
import { configPaths } from '#/utils/configPaths'
|
||||
import { picBedsCanbeDeleted } from '#/utils/static'
|
||||
import { T } from '~/i18n/index'
|
||||
import { T as $t } from '~/i18n/index'
|
||||
|
||||
export const handleResponse = ({
|
||||
response,
|
||||
@@ -54,8 +54,8 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
||||
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
||||
const noteFunc = (value: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: T('MANAGE_BUCKET_BATCH_DELETE_ERROR_MSG_MSG2'),
|
||||
body: T(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED')
|
||||
title: $t('MANAGE_BUCKET_BATCH_DELETE_ERROR_MSG_MSG2'),
|
||||
body: $t(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED')
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
|
||||
@@ -81,20 +81,6 @@ export const showMessageBox = (options: any) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const calcDurationRange = (duration: number) => {
|
||||
if (duration < 1000) return 500
|
||||
if (duration < 1500) return 1000
|
||||
if (duration < 3000) return 2000
|
||||
if (duration < 5000) return 3000
|
||||
if (duration < 7000) return 5000
|
||||
if (duration < 10000) return 8000
|
||||
if (duration < 12000) return 10000
|
||||
if (duration < 20000) return 15000
|
||||
if (duration < 30000) return 20000
|
||||
// max range
|
||||
return 100000
|
||||
}
|
||||
|
||||
/**
|
||||
* macOS public.file-url will get encoded file path,
|
||||
* so we need to decode it
|
||||
|
||||
Reference in New Issue
Block a user