Fixed: #136 || multiple image timestamp rename bug

This commit is contained in:
Molunerfinn 2018-11-22 16:55:34 +08:00
parent 1af9af74ce
commit 8a8b97a937
3 changed files with 4 additions and 9 deletions

View File

@ -74,7 +74,6 @@
"axios": "^0.16.1", "axios": "^0.16.1",
"dateformat": "^3.0.3", "dateformat": "^3.0.3",
"element-ui": "^2.0.5", "element-ui": "^2.0.5",
"fecha": "^2.3.3",
"fs-extra": "^4.0.2", "fs-extra": "^4.0.2",
"image-size": "^0.6.1", "image-size": "^0.6.1",
"keycode": "^2.1.9", "keycode": "^2.1.9",

View File

@ -5,7 +5,7 @@ import {
ipcMain ipcMain
} from 'electron' } from 'electron'
import path from 'path' import path from 'path'
import fecha from 'fecha' import dayjs from 'dayjs'
// eslint-disable-next-line // eslint-disable-next-line
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
@ -67,7 +67,7 @@ const uploader = (img, type, webContents) => {
switch (type) { switch (type) {
case 'imgFromClipboard': case 'imgFromClipboard':
if (img !== null) { if (img !== null) {
const today = fecha.format(new Date(), 'YYYYMMDDHHmmss') + '.png' const today = dayjs().format('YYYYMMDDHHmmss') + '.png'
input = [ input = [
{ {
base64Image: img.imgUrl.replace(/^data\S+,/, ''), base64Image: img.imgUrl.replace(/^data\S+,/, ''),
@ -88,11 +88,11 @@ const uploader = (img, type, webContents) => {
handle: async ctx => { handle: async ctx => {
const rename = picgo.getConfig('settings.rename') const rename = picgo.getConfig('settings.rename')
const autoRename = picgo.getConfig('settings.autoRename') const autoRename = picgo.getConfig('settings.autoRename')
await Promise.all(ctx.output.map(async item => { await Promise.all(ctx.output.map(async (item, index) => {
let name let name
let fileName let fileName
if (autoRename) { if (autoRename) {
fileName = fecha.format(new Date(), 'YYYYMMDDHHmmss') + item.extname fileName = dayjs().add(index, 'second').format('YYYYMMDDHHmmss') + item.extname
} else { } else {
fileName = item.fileName fileName = item.fileName
} }

View File

@ -3660,10 +3660,6 @@ fd-slicer@~1.0.1:
dependencies: dependencies:
pend "~1.2.0" pend "~1.2.0"
fecha@^2.3.3:
version "2.3.3"
resolved "http://registry.npm.taobao.org/fecha/download/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd"
figures@^1.4.0: figures@^1.4.0:
version "1.7.0" version "1.7.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"