🐛 Fix(db): fix some db bugs

#873,#806
This commit is contained in:
PiEgg 2022-06-12 20:20:08 +08:00
parent 8d861be161
commit d3bb5caa83
27 changed files with 238 additions and 107 deletions

48
.vscode/launch.json vendored
View File

@ -1,38 +1,36 @@
{ {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Launch", "name": "Electron: Main",
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/src/main/index.dev.js", "protocol": "inspector",
"env": {
"DEBUG_ENV": "debug"
},
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
// this points to the electron task runner
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"runtimeArgs": [ "windows": {
"--nolazy" "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
], },
"sourceMaps": true "preLaunchTask": "electron-debug",
"args": ["--remote-debugging-port=9223", "./dist_electron"],
"outFiles": ["${workspaceFolder}/dist_electron/**/*.js"]
}, },
{ {
"name": "Attach", "name": "Electron: Renderer",
"type": "node", "type": "chrome",
"request": "attach", "request": "attach",
"port": 5858, "port": 9223,
"sourceMaps": true, "urlFilter": "http://localhost:*",
"restart": true, "timeout": 30000,
"outFiles": [], "webRoot": "${workspaceFolder}/src",
"localRoot": "${workspaceRoot}", "sourceMapPathOverrides": {
"protocol": "inspector", "webpack:///./src/*": "${webRoot}/*"
"remoteRoot": null }
}
],
"compounds": [
{
"name": "Electron: All",
"configurations": ["Electron: Main", "Electron: Renderer"]
} }
] ]
} }

27
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,27 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "electron-debug",
"type": "process",
"command": "./node_modules/.bin/vue-cli-service",
"windows": {
"command": "./node_modules/.bin/vue-cli-service.cmd"
},
"isBackground": true,
"args": ["electron:serve", "--debug"],
"problemMatcher": {
"owner": "custom",
"pattern": {
"regexp": ""
},
"background": {
"beginsPattern": "Starting development server\\.\\.\\.",
"endsPattern": "Not launching electron as debug argument was passed\\."
}
}
}
]
}

View File

@ -15,7 +15,7 @@
"bump": "bump-version", "bump": "bump-version",
"release": "vue-cli-service electron:build --publish always" "release": "vue-cli-service electron:build --publish always"
}, },
"main": "background.js", "main": "index.js",
"husky": { "husky": {
"hooks": { "hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
@ -36,7 +36,7 @@
}, },
"dependencies": { "dependencies": {
"@picgo/i18n": "^1.0.0", "@picgo/i18n": "^1.0.0",
"@picgo/store": "^1.0.3", "@picgo/store": "2.0.1",
"axios": "^0.19.0", "axios": "^0.19.0",
"core-js": "^3.3.2", "core-js": "^3.3.2",
"element-ui": "^2.13.0", "element-ui": "^2.13.0",
@ -44,7 +44,7 @@
"keycode": "^2.2.0", "keycode": "^2.2.0",
"lodash-id": "^0.14.0", "lodash-id": "^0.14.0",
"lowdb": "^1.0.0", "lowdb": "^1.0.0",
"picgo": "^1.5.0-alpha.3", "picgo": "^1.5.0-alpha.4",
"qrcode.vue": "^1.7.0", "qrcode.vue": "^1.7.0",
"shell-path": "2.1.0", "shell-path": "2.1.0",
"uuidv4": "^6.2.11", "uuidv4": "^6.2.11",

View File

@ -177,7 +177,7 @@ class ShortKeyHandler {
keyList.forEach(item => { keyList.forEach(item => {
globalShortcut.unregister(item.key) globalShortcut.unregister(item.key)
shortKeyService.unregisterCommand(item.command) shortKeyService.unregisterCommand(item.command)
picgo.unsetConfig('settings.shortKey', item.command) db.unset('settings.shortKey', item.command)
}) })
} }
} }

View File

@ -18,6 +18,7 @@ import logger from '@core/picgo/logger'
import { T } from '~/universal/i18n' import { T } from '~/universal/i18n'
import fse from 'fs-extra' import fse from 'fs-extra'
import path from 'path' import path from 'path'
import { privacyManager } from '~/main/utils/privacyManager'
const waitForShow = (webcontent: WebContents) => { const waitForShow = (webcontent: WebContents) => {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
@ -140,6 +141,10 @@ class Uploader {
async upload (img?: IUploadOption): Promise<ImgInfo[]|false> { async upload (img?: IUploadOption): Promise<ImgInfo[]|false> {
try { try {
const privacyCheckRes = await privacyManager.check()
if (!privacyCheckRes) {
throw Error(T('PRIVACY_TIPS'))
}
const startTime = Date.now() const startTime = Date.now()
const output = await picgo.upload(img) const output = await picgo.upload(img)
if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) { if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) {

View File

@ -1,10 +1,6 @@
import Datastore from 'lowdb'
// @ts-ignore
import LodashId from 'lodash-id'
import FileSync from 'lowdb/adapters/FileSync'
import fs from 'fs-extra' import fs from 'fs-extra'
import { dbPathChecker, dbPathDir, getGalleryDBPath } from './dbChecker' import { dbPathChecker, dbPathDir, getGalleryDBPath } from './dbChecker'
import { DBStore } from '@picgo/store' import { DBStore, JSONStore } from '@picgo/store'
import { T } from '~/universal/i18n' import { T } from '~/universal/i18n'
const STORE_PATH = dbPathDir() const STORE_PATH = dbPathDir()
@ -15,68 +11,55 @@ if (!fs.pathExistsSync(STORE_PATH)) {
const CONFIG_PATH: string = dbPathChecker() const CONFIG_PATH: string = dbPathChecker()
const DB_PATH: string = getGalleryDBPath().dbPath const DB_PATH: string = getGalleryDBPath().dbPath
// TODO: use JSONStore with @picgo/store
class ConfigStore { class ConfigStore {
private db: Datastore.LowdbSync<Datastore.AdapterSync> private db: JSONStore
constructor () { constructor () {
const adapter = new FileSync(CONFIG_PATH) this.db = new JSONStore(CONFIG_PATH)
this.db = Datastore(adapter) if (!this.db.has('picBed')) {
this.db._.mixin(LodashId)
if (!this.db.has('picBed').value()) {
this.db.set('picBed', { this.db.set('picBed', {
current: 'smms', // deprecated current: 'smms', // deprecated
uploader: 'smms', uploader: 'smms',
smms: { smms: {
token: '' token: ''
} }
}).write() })
} }
if (!this.db.has('settings.shortKey').value()) { if (!this.db.has('settings.shortKey')) {
this.db.set('settings.shortKey[picgo:upload]', { this.db.set('settings.shortKey[picgo:upload]', {
enable: true, enable: true,
key: 'CommandOrControl+Shift+P', key: 'CommandOrControl+Shift+P',
name: 'upload', name: 'upload',
label: T('QUICK_UPLOAD') label: T('QUICK_UPLOAD')
}).write() })
} }
this.read()
} }
read () { read (flush = false) {
return this.db.read() // if flush -> true, read origin file again
this.db.read(flush)
return this.db
} }
get (key = '') { get (key = ''): any {
return this.read().get(key).value() if (key === '') {
return this.db.read()
}
return this.db.get(key)
} }
set (key: string, value: any) { set (key: string, value: any): void {
return this.read().set(key, value).write() return this.db.set(key, value)
} }
has (key: string) { has (key: string) {
return this.read().has(key).value() return this.db.has(key)
}
insert (key: string, value: any): void {
// @ts-ignore
return this.read().get(key).insert(value).write()
} }
unset (key: string, value: any): boolean { unset (key: string, value: any): boolean {
return this.read().get(key).unset(value).value() return this.db.unset(key, value)
}
getById (key: string, id: string) {
// @ts-ignore
return this.read().get(key).getById(id).value()
}
removeById (key: string, id: string) {
// @ts-ignore
return this.read().get(key).removeById(id).write()
} }
getConfigPath () { getConfigPath () {
@ -84,7 +67,9 @@ class ConfigStore {
} }
} }
export default new ConfigStore() const db = new ConfigStore()
export default db
// v2.3.0 add gallery db // v2.3.0 add gallery db
class GalleryDB { class GalleryDB {

View File

@ -1,6 +1,7 @@
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker' import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
import pkg from 'root/package.json' import pkg from 'root/package.json'
import { PicGo } from 'picgo' import { PicGo } from 'picgo'
import db from 'apis/core/datastore'
const CONFIG_PATH = dbPathChecker() const CONFIG_PATH = dbPathChecker()
@ -15,4 +16,14 @@ picgo.saveConfig({
global.PICGO_GUI_VERSION = pkg.version global.PICGO_GUI_VERSION = pkg.version
picgo.GUI_VERSION = global.PICGO_GUI_VERSION picgo.GUI_VERSION = global.PICGO_GUI_VERSION
const originPicGoSaveConfig = picgo.saveConfig.bind(picgo)
picgo.saveConfig = (config: IStringKeyMap) => {
originPicGoSaveConfig(config)
// flush electron's db
setTimeout(() => {
db.read(true)
}, 0)
}
export default picgo export default picgo

View File

@ -146,6 +146,27 @@ class GuiApi implements IGuiApi {
get galleryDB (): DBStore { get galleryDB (): DBStore {
return new Proxy<DBStore>(GalleryDB.getInstance(), { return new Proxy<DBStore>(GalleryDB.getInstance(), {
get (target, prop: keyof DBStore) { get (target, prop: keyof DBStore) {
if (prop === 'overwrite') {
return new Proxy(GalleryDB.getInstance().overwrite, {
apply (target, ctx, args) {
return new Promise((resolve) => {
const guiApi = GuiApi.getInstance()
guiApi.showMessageBox({
title: T('TIPS_WARNING'),
message: T('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
type: 'info',
buttons: ['Yes', 'No']
}).then(res => {
if (res.result === 0) {
resolve(Reflect.apply(target, ctx, args))
} else {
resolve(undefined)
}
})
})
}
})
}
if (prop === 'removeById') { if (prop === 'removeById') {
return new Proxy(GalleryDB.getInstance().removeById, { return new Proxy(GalleryDB.getInstance().removeById, {
apply (target, ctx, args) { apply (target, ctx, args) {

View File

@ -10,7 +10,7 @@ import {
import { IPasteStyle, IPicGoHelperType, IWindowList } from '#/types/enum' import { IPasteStyle, IPicGoHelperType, IWindowList } from '#/types/enum'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler' import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import picgo from '@core/picgo' import picgo from '@core/picgo'
import { handleStreamlinePluginName } from '~/universal/utils/common' import { handleStreamlinePluginName, simpleClone } from '~/universal/utils/common'
import { IGuiMenuItem, PicGo as PicGoCore } from 'picgo' import { IGuiMenuItem, PicGo as PicGoCore } from 'picgo'
import windowManager from 'apis/app/window/windowManager' import windowManager from 'apis/app/window/windowManager'
import { showNotification } from '~/main/utils/common' import { showNotification } from '~/main/utils/common'
@ -128,10 +128,19 @@ const getPluginList = (): IPicGoPlugin[] => {
const handleGetPluginList = () => { const handleGetPluginList = () => {
ipcMain.on('getPluginList', (event: IpcMainEvent) => { ipcMain.on('getPluginList', (event: IpcMainEvent) => {
const list = getPluginList() try {
// here can just send JS Object not function const list = simpleClone(getPluginList())
// or will cause [Failed to serialize arguments] error // here can just send JS Object not function
event.sender.send('pluginList', list) // or will cause [Failed to serialize arguments] error
event.sender.send('pluginList', list)
} catch (e: any) {
event.sender.send('pluginList', [])
showNotification({
title: T('TIPS_GET_PLUGIN_LIST_FAILED'),
body: e.message
})
picgo.log.error(e)
}
}) })
} }
@ -267,8 +276,16 @@ const handleImportLocalPlugin = () => {
if (filePaths.length > 0) { if (filePaths.length > 0) {
const res = await picgo.pluginHandler.install(filePaths) const res = await picgo.pluginHandler.install(filePaths)
if (res.success) { if (res.success) {
const list = getPluginList() try {
event.sender.send('pluginList', list) const list = simpleClone(getPluginList())
event.sender.send('pluginList', list)
} catch (e: any) {
event.sender.send('pluginList', [])
showNotification({
title: T('TIPS_GET_PLUGIN_LIST_FAILED'),
body: e.message
})
}
showNotification({ showNotification({
title: T('PLUGIN_IMPORT_SUCCEED'), title: T('PLUGIN_IMPORT_SUCCEED'),
body: '' body: ''

View File

@ -31,7 +31,6 @@ import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import { getUploadFiles } from '~/main/utils/handleArgv' import { getUploadFiles } from '~/main/utils/handleArgv'
import db, { GalleryDB } from '~/main/apis/core/datastore' import db, { GalleryDB } from '~/main/apis/core/datastore'
import bus from '@core/bus' import bus from '@core/bus'
import { privacyManager } from '~/main/utils/privacyManager'
import logger from 'apis/core/picgo/logger' import logger from 'apis/core/picgo/logger'
import picgo from 'apis/core/picgo' import picgo from 'apis/core/picgo'
import fixPath from './fixPath' import fixPath from './fixPath'
@ -81,10 +80,6 @@ class LifeCycle {
console.error('Vue Devtools failed to install:', e.toString()) console.error('Vue Devtools failed to install:', e.toString())
} }
} }
const res = await privacyManager.init()
if (!res) {
return app.quit()
}
windowManager.create(IWindowList.TRAY_WINDOW) windowManager.create(IWindowList.TRAY_WINDOW)
windowManager.create(IWindowList.SETTING_WINDOW) windowManager.create(IWindowList.SETTING_WINDOW)
createTray() createTray()

View File

@ -34,7 +34,7 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS
} }
const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => { const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => {
const originGallery: ImgInfo[] = configDB.get('uploaded') const originGallery: ImgInfo[] = picgo.getConfig('uploaded')
// if hasMigrate, we don't need to migrate // if hasMigrate, we don't need to migrate
const hasMigrate: boolean = configDB.get('__migrateUploaded') const hasMigrate: boolean = configDB.get('__migrateUploaded')
if (hasMigrate) { if (hasMigrate) {

View File

@ -10,6 +10,11 @@ const getPicBeds = () => {
name: picgo.helper.uploader.get(item)!.name || item, name: picgo.helper.uploader.get(item)!.name || item,
visible: visible ? visible.visible : true visible: visible ? visible.visible : true
} }
}).sort((a) => {
if (a.type === 'tcyun') {
return -1
}
return 0
}) as IPicBedType[] }) as IPicBedType[]
return picBeds return picBeds
} }

View File

@ -1,14 +1,9 @@
import db from '~/main/apis/core/datastore' import db from '~/main/apis/core/datastore'
import { ipcMain } from 'electron'
import { showMessageBox } from '~/main/utils/common' import { showMessageBox } from '~/main/utils/common'
import { SHOW_PRIVACY_MESSAGE } from '~/universal/events/constants'
import { T } from '~/universal/i18n' import { T } from '~/universal/i18n'
class PrivacyManager { class PrivacyManager {
async init () { async check () {
ipcMain.on(SHOW_PRIVACY_MESSAGE, () => {
this.show(false)
})
if (db.get('settings.privacyEnsure') !== true) { if (db.get('settings.privacyEnsure') !== true) {
const res = await this.show(true) const res = await this.show(true)
// cancel // cancel

View File

@ -72,6 +72,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'aliyun', name: 'aliyun',
mixins: [mixin] mixins: [mixin]
@ -99,7 +100,7 @@ export default class extends Vue {
this.$refs.aliyun.validate((valid) => { this.$refs.aliyun.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.aliyun': this.form 'picBed.aliyun': trimValues(this.form)
}) })
const successNotification = new window.Notification('设置结果', { const successNotification = new window.Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -59,6 +59,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'github', name: 'github',
mixins: [mixin] mixins: [mixin]
@ -84,7 +85,7 @@ export default class extends Vue {
this.$refs.github.validate((valid) => { this.$refs.github.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.github': this.form 'picBed.github': trimValues(this.form)
}) })
const successNotification = new Notification('设置结果', { const successNotification = new Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -39,6 +39,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'imgur', name: 'imgur',
mixins: [mixin] mixins: [mixin]
@ -61,7 +62,7 @@ export default class extends Vue {
this.$refs.imgur.validate((valid) => { this.$refs.imgur.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.imgur': this.form 'picBed.imgur': trimValues(this.form)
}) })
const successNotification = new Notification('设置结果', { const successNotification = new Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -35,6 +35,7 @@ import {
ipcRenderer, ipcRenderer,
IpcRendererEvent IpcRendererEvent
} from 'electron' } from 'electron'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'OtherPicBed', name: 'OtherPicBed',
@ -58,7 +59,7 @@ export default class extends Vue {
const result = await this.$refs.configForm.validate() const result = await this.$refs.configForm.validate()
if (result !== false) { if (result !== false) {
this.saveConfig({ this.saveConfig({
[`picBed.${this.type}`]: result [`picBed.${this.type}`]: trimValues(result)
}) })
const successNotification = new Notification(this.$T('SETTINGS_RESULT'), { const successNotification = new Notification(this.$T('SETTINGS_RESULT'), {
body: this.$T('TIPS_SET_SUCCEED') body: this.$T('TIPS_SET_SUCCEED')

View File

@ -74,6 +74,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'qiniu', name: 'qiniu',
mixins: [mixin] mixins: [mixin]
@ -101,7 +102,7 @@ export default class extends Vue {
this.$refs.qiniu.validate((valid) => { this.$refs.qiniu.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.qiniu': this.form 'picBed.qiniu': trimValues(this.form)
}) })
const successNotification = new Notification('设置结果', { const successNotification = new Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -33,6 +33,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'smms', name: 'smms',
mixins: [mixin] mixins: [mixin]
@ -54,7 +55,7 @@ export default class extends Vue {
this.$refs.smms.validate((valid) => { this.$refs.smms.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.smms': this.form 'picBed.smms': trimValues(this.form)
}) })
const successNotification = new window.Notification('设置结果', { const successNotification = new window.Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -96,6 +96,7 @@ import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { OPEN_URL } from '#/events/constants' import { OPEN_URL } from '#/events/constants'
import { ITcyunConfig } from 'picgo/dist/types' import { ITcyunConfig } from 'picgo/dist/types'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'tcyun', name: 'tcyun',
mixins: [mixin] mixins: [mixin]
@ -125,7 +126,7 @@ export default class extends Vue {
this.$refs.tcyun.validate((valid) => { this.$refs.tcyun.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.tcyun': this.form 'picBed.tcyun': trimValues(this.form)
}) })
const successNotification = new window.Notification('设置结果', { const successNotification = new window.Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -68,6 +68,7 @@
import { Component, Vue } from 'vue-property-decorator' import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin' import mixin from '@/utils/ConfirmButtonMixin'
import { IUpyunConfig } from 'picgo/dist/types' import { IUpyunConfig } from 'picgo/dist/types'
import { trimValues } from '@/utils/common'
@Component({ @Component({
name: 'upyun', name: 'upyun',
mixins: [mixin] mixins: [mixin]
@ -94,7 +95,7 @@ export default class extends Vue {
this.$refs.tcyun.validate((valid) => { this.$refs.tcyun.validate((valid) => {
if (valid) { if (valid) {
this.saveConfig({ this.saveConfig({
'picBed.upyun': this.form 'picBed.upyun': trimValues(this.form)
}) })
const successNotification = new Notification('设置结果', { const successNotification = new Notification('设置结果', {
body: '设置成功' body: '设置成功'

View File

@ -8,3 +8,11 @@ export const handleTalkingDataEvent = (data: ITalkingDataOptions) => {
console.log('talkingData', data) console.log('talkingData', data)
} }
} }
export const trimValues = (obj: IStringKeyMap) => {
const newObj = {} as IStringKeyMap
Object.keys(obj).forEach(key => {
newObj[key] = typeof obj[key] === 'string' ? obj[key].trim() : obj[key]
})
return newObj
}

View File

@ -157,6 +157,7 @@ export const EN: ILocales = {
TIPS_SET_SUCCEED: 'Set successfully', TIPS_SET_SUCCEED: 'Set successfully',
TIPS_PLUGIN_NOT_GUI_IMPLEMENT: 'This plugin is not optimized for the GUI, continue?', TIPS_PLUGIN_NOT_GUI_IMPLEMENT: 'This plugin is not optimized for the GUI, continue?',
TIPS_CLICK_NOTIFICATION_TO_RELOAD: 'Click notification to reload app', TIPS_CLICK_NOTIFICATION_TO_RELOAD: 'Click notification to reload app',
TIPS_GET_PLUGIN_LIST_FAILED: 'Get plugin list failed',
// ---renderer i18n end--- // ---renderer i18n end---
// plugins // plugins
@ -177,7 +178,8 @@ export const EN: ILocales = {
TIPS_WARNING: 'Warning', TIPS_WARNING: 'Warning',
TIPS_ERROR: 'Error', TIPS_ERROR: 'Error',
TIPS_INSTALL_NODE_AND_RELOAD_PICGO: 'Please install Node.js and restart PicGo to continue', TIPS_INSTALL_NODE_AND_RELOAD_PICGO: 'Please install Node.js and restart PicGo to continue',
TIPS_PLUGIN_REMOVE_GALLERY_ITEM: 'Plugin is trying to remove some images from the album, continue?', TIPS_PLUGIN_REMOVE_GALLERY_ITEM: 'Plugin is trying to remove some images from the album gallery, continue?',
TIPS_PLUGIN_OVERWRITE_GALLERY: 'Plugin is trying to overwrite the album gallery, continue?',
TIPS_UPLOAD_NOT_PICTURES: 'The latest clipboard item is not a picture', TIPS_UPLOAD_NOT_PICTURES: 'The latest clipboard item is not a picture',
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: 'PicGo config file broken, has been restored to default', TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: 'PicGo config file broken, has been restored to default',
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: 'PicGo config file broken, has been restored to backup', TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: 'PicGo config file broken, has been restored to backup',
@ -212,6 +214,7 @@ c) If you violate relevant Chinese laws, regulations or relevant rules, you need
a) This software does not collect your personal information, key information and other private information, and the collected information is only used for improving the software, optimizing the experience, and understanding the daily activities of the software. a) This software does not collect your personal information, key information and other private information, and the collected information is only used for improving the software, optimizing the experience, and understanding the daily activities of the software.
`, `,
PRIVACY_TIPS: 'Please agree the privacy policy to upload',
// action // action
QUIT: 'Quit' QUIT: 'Quit'
} }

View File

@ -156,6 +156,7 @@ export const ZH_CN = {
TIPS_SET_SUCCEED: '设置成功', TIPS_SET_SUCCEED: '设置成功',
TIPS_PLUGIN_NOT_GUI_IMPLEMENT: '该插件未对可视化界面进行优化, 是否继续安装?', TIPS_PLUGIN_NOT_GUI_IMPLEMENT: '该插件未对可视化界面进行优化, 是否继续安装?',
TIPS_CLICK_NOTIFICATION_TO_RELOAD: '请点击此通知重启应用以生效', TIPS_CLICK_NOTIFICATION_TO_RELOAD: '请点击此通知重启应用以生效',
TIPS_GET_PLUGIN_LIST_FAILED: '获取插件列表失败',
// ---renderer i18n end--- // ---renderer i18n end---
// plugins // plugins
@ -177,6 +178,7 @@ export const ZH_CN = {
TIPS_ERROR: '发生错误', TIPS_ERROR: '发生错误',
TIPS_INSTALL_NODE_AND_RELOAD_PICGO: '请安装Node.js并重启PicGo再继续操作', TIPS_INSTALL_NODE_AND_RELOAD_PICGO: '请安装Node.js并重启PicGo再继续操作',
TIPS_PLUGIN_REMOVE_GALLERY_ITEM: '有插件正在试图删除一些相册图片,是否继续', TIPS_PLUGIN_REMOVE_GALLERY_ITEM: '有插件正在试图删除一些相册图片,是否继续',
TIPS_PLUGIN_OVERWRITE_GALLERY: '有插件正在试图覆盖相册列表,是否继续',
TIPS_UPLOAD_NOT_PICTURES: '剪贴板最新的一条记录不是图片', TIPS_UPLOAD_NOT_PICTURES: '剪贴板最新的一条记录不是图片',
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: 'PicGo 配置文件损坏,已经恢复为默认配置', TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT: 'PicGo 配置文件损坏,已经恢复为默认配置',
TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: 'PicGo 配置文件损坏,已经恢复为备份配置', TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP: 'PicGo 配置文件损坏,已经恢复为备份配置',
@ -211,6 +213,7 @@ c)如您出现违反中国有关法律、法规或者相关规则的情况,需
a) a)
`, `,
PRIVACY_TIPS: '请同意隐私协议,否则无法上传。',
// action // action
QUIT: '退出' QUIT: '退出'
} }

View File

@ -30,3 +30,10 @@ export const handleStreamlinePluginName = (name: string) => {
return name.replace(/picgo-plugin-/, '') return name.replace(/picgo-plugin-/, '')
} }
} }
/**
* for just simple clone an object
*/
export const simpleClone = (obj: any) => {
return JSON.parse(JSON.stringify(obj))
}

View File

@ -32,6 +32,10 @@ const config = {
.set('#', resolve('src/universal')) .set('#', resolve('src/universal'))
.set('apis', resolve('src/main/apis')) .set('apis', resolve('src/main/apis'))
.set('@core', resolve('src/main/apis/core')) .set('@core', resolve('src/main/apis/core'))
config.resolve.mainFields
.clear()
.add('main') // fix some modules will use browser target
.add('module')
}, },
builderOptions: { builderOptions: {
productName: 'PicGo', productName: 'PicGo',

View File

@ -1109,6 +1109,18 @@
dependencies: dependencies:
chalk "^4.0.0" chalk "^4.0.0"
"@commonify/lowdb@^3.0.0":
version "3.0.0"
resolved "https://registry.npmmirror.com/@commonify/lowdb/-/lowdb-3.0.0.tgz#09c33ffd19057eab67440a1dc22847569407cafe"
integrity sha512-GwZq68zStvMENxEzN6EE8pacgY2Rlrs5L00BpvB6NvpDW96JUxIa8PJXd9T7qIdx07ro0ITBtw6HfSJw/qboGw==
dependencies:
"@commonify/steno" "2.1.0"
"@commonify/steno@2.1.0", "@commonify/steno@^2.1.0":
version "2.1.0"
resolved "https://registry.npmmirror.com/@commonify/steno/-/steno-2.1.0.tgz#7d1e68a0e239bf4fd35abfd167006a3e56140b28"
integrity sha512-3W0LmYb84EU82Ky18M+D0tB33W66ccoC/Ot/8mm3uBQFuaTpiWaoxntQGBTL3+bIpV4e77ks53IE3sy9BRFBxA==
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":
version "0.8.0" version "0.8.0"
resolved "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" resolved "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"
@ -1332,17 +1344,21 @@
chalk "4.1.2" chalk "4.1.2"
tslib "^2.3.1" tslib "^2.3.1"
"@picgo/store@^1.0.3": "@picgo/store@2.0.1":
version "1.0.3" version "2.0.1"
resolved "https://registry.npmjs.org/@picgo/store/-/store-1.0.3.tgz#cfe346ad30c80f378e0bc81311e7468df436bc1f" resolved "https://registry.npmmirror.com/@picgo/store/-/store-2.0.1.tgz#9dce62a6e61e5539c06d261628c1c6c29b8e07eb"
integrity sha512-quyu56yuUsFFJGQ88suTwUSEzKosZPzR1M52eyqzyQ2HZWZVn0pa/eBBsh7OYefS0V13YLR5llnIkQaL8y11Ww== integrity sha512-DLv1/EpSWNec8AAFxVCHSFfArotuU4WdUs3KZePtDK7nwKYIqQMnfcCYOUadoAZn3mn1hS1byv7i26qyIPcKaw==
dependencies: dependencies:
"@commonify/lowdb" "^3.0.0"
"@commonify/steno" "^2.1.0"
"@types/bson" "^4.0.1" "@types/bson" "^4.0.1"
"@types/graceful-fs" "^4.1.3" "@types/graceful-fs" "^4.1.3"
bson "^4.0.3" "@types/lodash" "^4.14.182"
comment-json "^4.1.0" comment-json "^4.1.0"
fflate "^0.7.3"
lodash "^4.17.21"
lodash-id "^0.14.0" lodash-id "^0.14.0"
lowdb "^1.0.0" write-file-atomic "^4.0.1"
"@sindresorhus/is@^0.14.0": "@sindresorhus/is@^0.14.0":
version "0.14.0" version "0.14.0"
@ -1514,6 +1530,11 @@
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8" resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw== integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==
"@types/lodash@^4.14.182":
version "4.14.182"
resolved "https://registry.npmmirror.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2"
integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==
"@types/lowdb@^1.0.9": "@types/lowdb@^1.0.9":
version "1.0.11" version "1.0.11"
resolved "https://registry.npmjs.org/@types/lowdb/-/lowdb-1.0.11.tgz#d8336a635ea0dbd48a7f6f62fb9fccc5ec358ae3" resolved "https://registry.npmjs.org/@types/lowdb/-/lowdb-1.0.11.tgz#d8336a635ea0dbd48a7f6f62fb9fccc5ec358ae3"
@ -3087,7 +3108,7 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.17.5, browserslist@^4
node-releases "^2.0.1" node-releases "^2.0.1"
picocolors "^1.0.0" picocolors "^1.0.0"
bson@*, bson@^4.0.3: bson@*:
version "4.6.0" version "4.6.0"
resolved "https://registry.npmjs.org/bson/-/bson-4.6.0.tgz#15c3b39ba3940c3d915a0c44d51459f4b4fbf1b2" resolved "https://registry.npmjs.org/bson/-/bson-4.6.0.tgz#15c3b39ba3940c3d915a0c44d51459f4b4fbf1b2"
integrity sha512-8jw1NU1hglS+Da1jDOUYuNcBJ4cNHCFIqzlwoFNnsTOg2R/ox0aTYcTiBN4dzRa9q7Cvy6XErh3L8ReTEb9AQQ== integrity sha512-8jw1NU1hglS+Da1jDOUYuNcBJ4cNHCFIqzlwoFNnsTOg2R/ox0aTYcTiBN4dzRa9q7Cvy6XErh3L8ReTEb9AQQ==
@ -5994,6 +6015,11 @@ fd-slicer@~1.1.0:
dependencies: dependencies:
pend "~1.2.0" pend "~1.2.0"
fflate@^0.7.3:
version "0.7.3"
resolved "https://registry.npmmirror.com/fflate/-/fflate-0.7.3.tgz#288b034ff0e9c380eaa2feff48c787b8371b7fa5"
integrity sha512-0Zz1jOzJWERhyhsimS54VTqOteCNwRtIlh8isdL0AXLo0g7xNTfTL7oWrkmCnPhZGocKIkWHBistBrrpoNH3aw==
figgy-pudding@^3.5.1: figgy-pudding@^3.5.1:
version "3.5.2" version "3.5.2"
resolved "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" resolved "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
@ -9782,10 +9808,10 @@ performance-now@^2.1.0:
resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" resolved "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
picgo@^1.5.0-alpha.3: picgo@^1.5.0-alpha.4:
version "1.5.0-alpha.3" version "1.5.0-alpha.4"
resolved "https://registry.npmmirror.com/picgo/-/picgo-1.5.0-alpha.3.tgz#1d30de78d0a963de131b6a3739706160a6a7598f" resolved "https://registry.npmmirror.com/picgo/-/picgo-1.5.0-alpha.4.tgz#bca46bf6124a2855222c8536bd4e3522ebf2699c"
integrity sha512-87jotY0snEjQrjmy0Ka46ZvKLjPlfGOghRs5ArvDDZ8g2l5PuikXAyu8AEFxc2WcJ8RiMwjG/tbS15l1dzM5JQ== integrity sha512-igNNBHSZywwTvtA28TtwoXJtO8omgDu+8TX3em2c4F1e4yHSmPsTJdWbHSf69KujULs0J0SV11eLp8gyI3B7nw==
dependencies: dependencies:
"@picgo/i18n" "^1.0.0" "@picgo/i18n" "^1.0.0"
chalk "^2.4.1" chalk "^2.4.1"
@ -11313,6 +11339,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz#24e630c4b0f03fea446a2bd299e62b4a6ca8d0af" resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz#24e630c4b0f03fea446a2bd299e62b4a6ca8d0af"
integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ== integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==
signal-exit@^3.0.7:
version "3.0.7"
resolved "https://registry.npmmirror.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
simple-swizzle@^0.2.2: simple-swizzle@^0.2.2:
version "0.2.2" version "0.2.2"
resolved "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" resolved "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
@ -13237,6 +13268,14 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2" signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5" typedarray-to-buffer "^3.1.5"
write-file-atomic@^4.0.1:
version "4.0.1"
resolved "https://registry.npmmirror.com/write-file-atomic/-/write-file-atomic-4.0.1.tgz#9faa33a964c1c85ff6f849b80b42a88c2c537c8f"
integrity sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ==
dependencies:
imurmurhash "^0.1.4"
signal-exit "^3.0.7"
ws@^6.0.0, ws@^6.2.1: ws@^6.0.0, ws@^6.2.1:
version "6.2.2" version "6.2.2"
resolved "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz#dd5cdbd57a9979916097652d78f1cc5faea0c32e" resolved "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz#dd5cdbd57a9979916097652d78f1cc5faea0c32e"