mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-01 09:39:37 +08:00
✨ Feature: add remote file delete , picBed management
First version of PicList. In album, you can delete remote file now. Add picBed management function.
This commit is contained in:
@@ -9,12 +9,11 @@ import path from 'path'
|
||||
import axios from 'axios'
|
||||
import windowManager from '../window/windowManager'
|
||||
import { showNotification } from '~/main/utils/common'
|
||||
import { isDev } from '~/universal/utils/common'
|
||||
|
||||
// for test
|
||||
const REMOTE_NOTICE_URL = isDev ? 'http://localhost:8181/remote-notice.json' : 'https://picgo-1251750343.cos.accelerate.myqcloud.com/remote-notice.yml'
|
||||
const REMOTE_NOTICE_URL = 'https://release.piclist.cn/remote-notice.json'
|
||||
|
||||
const REMOTE_NOTICE_LOCAL_STORAGE_FILE = 'picgo-remote-notice.json'
|
||||
const REMOTE_NOTICE_LOCAL_STORAGE_FILE = 'piclist-remote-notice.json'
|
||||
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
|
||||
@@ -106,7 +105,6 @@ class RemoteNoticeHandler {
|
||||
if (this.checkActionCount(action)) {
|
||||
switch (action.type) {
|
||||
case IRemoteNoticeActionType.SHOW_DIALOG: {
|
||||
// SHOW DIALOG
|
||||
const currentWindow = windowManager.getAvailableWindow()
|
||||
dialog.showOpenDialog(currentWindow, action.data?.options)
|
||||
break
|
||||
|
||||
@@ -181,7 +181,6 @@ export function createTray () {
|
||||
}
|
||||
} else {
|
||||
const imgUrl = img.toDataURL()
|
||||
// console.log(imgUrl)
|
||||
obj.push({
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
|
||||
@@ -10,7 +10,6 @@ import db, { GalleryDB } from '~/main/apis/core/datastore'
|
||||
import { handleCopyUrl } from '~/main/utils/common'
|
||||
import { handleUrlEncode } from '#/utils/common'
|
||||
import { T } from '~/main/i18n/index'
|
||||
// import dayjs from 'dayjs'
|
||||
|
||||
const handleClipboardUploading = async (): Promise<false | ImgInfo[]> => {
|
||||
const useBuiltinClipboard = !!db.get('settings.useBuiltinClipboard')
|
||||
|
||||
@@ -11,7 +11,7 @@ import db from '~/main/apis/core/datastore'
|
||||
import windowManager from 'apis/app/window/windowManager'
|
||||
import { IWindowList } from '#/types/enum'
|
||||
import util from 'util'
|
||||
import { IPicGo } from 'picgo'
|
||||
import { IPicGo } from 'piclist'
|
||||
import { showNotification, calcDurationRange, getClipboardFilePath } from '~/main/utils/common'
|
||||
import { RENAME_FILE_NAME, TALKING_DATA_EVENT } from '~/universal/events/constants'
|
||||
import logger from '@core/picgo/logger'
|
||||
@@ -163,6 +163,9 @@ class Uploader {
|
||||
duration: Date.now() - startTime
|
||||
} as IAnalyticsData)
|
||||
}
|
||||
output.forEach((item: ImgInfo) => {
|
||||
item.config = db.get(`picBed.${item.type}`)
|
||||
})
|
||||
return output.filter(item => item.imgUrl)
|
||||
} else {
|
||||
return false
|
||||
|
||||
@@ -11,17 +11,10 @@ import db from '~/main/apis/core/datastore'
|
||||
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '#/events/constants'
|
||||
import { app } from 'electron'
|
||||
import { remoteNoticeHandler } from '../remoteNotice'
|
||||
// import { i18n } from '~/main/i18n'
|
||||
// import { URLSearchParams } from 'url'
|
||||
|
||||
const windowList = new Map<IWindowList, IWindowListItem>()
|
||||
|
||||
const handleWindowParams = (windowURL: string) => {
|
||||
// const [baseURL, hash = ''] = windowURL.split('#')
|
||||
// const search = new URLSearchParams()
|
||||
// const lang = i18n.getLanguage()
|
||||
// search.append('lang', lang)
|
||||
// return `${baseURL}?${search.toString()}#${hash}`
|
||||
return windowURL
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,6 @@ class WindowManager implements IWindowManager {
|
||||
return this.windowMap.has(name)
|
||||
}
|
||||
|
||||
// useless
|
||||
// delete (name: IWindowList) {
|
||||
// const window = this.windowMap.get(name)
|
||||
// if (window) {
|
||||
// this.windowIdMap.delete(window.id)
|
||||
// this.windowMap.delete(name)
|
||||
// }
|
||||
// }
|
||||
deleteById = (id: number) => {
|
||||
const name = this.windowIdMap.get(id)
|
||||
if (name) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import fs from 'fs-extra'
|
||||
import writeFile from 'write-file-atomic'
|
||||
import path from 'path'
|
||||
import { app as APP } from 'electron'
|
||||
import { getLogger } from '@core/utils/localLogger'
|
||||
import { app } from 'electron'
|
||||
import { getLogger } from '../utils/localLogger'
|
||||
import dayjs from 'dayjs'
|
||||
import { T } from '~/main/i18n'
|
||||
const STORE_PATH = APP.getPath('userData')
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const configFilePath = path.join(STORE_PATH, 'data.json')
|
||||
const configFileBackupPath = path.join(STORE_PATH, 'data.bak.json')
|
||||
export const defaultConfigPath = configFilePath
|
||||
@@ -79,7 +79,6 @@ function dbPathChecker (): string {
|
||||
if (_configFilePath) {
|
||||
return _configFilePath
|
||||
}
|
||||
// defaultConfigPath
|
||||
_configFilePath = defaultConfigPath
|
||||
// if defaultConfig path is not exit
|
||||
// do not parse the content of config
|
||||
@@ -98,8 +97,8 @@ function dbPathChecker (): string {
|
||||
}
|
||||
return _configFilePath
|
||||
} catch (e) {
|
||||
const picgoLogPath = path.join(STORE_PATH, 'picgo-gui-local.log')
|
||||
const logger = getLogger(picgoLogPath)
|
||||
const piclistLogPath = path.join(STORE_PATH, 'piclist-gui-local.log')
|
||||
const logger = getLogger(piclistLogPath, 'PicList')
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: T('TIPS_NOTICE'),
|
||||
@@ -123,8 +122,8 @@ function getGalleryDBPath (): {
|
||||
dbBackupPath: string
|
||||
} {
|
||||
const configPath = dbPathChecker()
|
||||
const dbPath = path.join(path.dirname(configPath), 'picgo.db')
|
||||
const dbBackupPath = path.join(path.dirname(dbPath), 'picgo.bak.db')
|
||||
const dbPath = path.join(path.dirname(configPath), 'piclist.db')
|
||||
const dbBackupPath = path.join(path.dirname(dbPath), 'piclist.bak.db')
|
||||
return {
|
||||
dbPath,
|
||||
dbBackupPath
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { dbChecker, dbPathChecker } from 'apis/core/datastore/dbChecker'
|
||||
import pkg from 'root/package.json'
|
||||
import { PicGo } from 'picgo'
|
||||
import { PicGo } from 'piclist'
|
||||
import db from 'apis/core/datastore'
|
||||
import debounce from 'lodash/debounce'
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ const recreateLogFile = (logPath: string): void => {
|
||||
}
|
||||
|
||||
/**
|
||||
* for local log before picgo inited
|
||||
* for local log before piclist inited
|
||||
*/
|
||||
const getLogger = (logPath: string) => {
|
||||
const getLogger = (logPath: string, logtype: string) => {
|
||||
let hasUncathcedError = false
|
||||
try {
|
||||
if (!fs.existsSync(logPath)) {
|
||||
@@ -64,7 +64,7 @@ const getLogger = (logPath: string) => {
|
||||
return
|
||||
}
|
||||
try {
|
||||
let log = `${dayjs().format('YYYY-MM-DD HH:mm:ss')} [PicGo ${type.toUpperCase()}] `
|
||||
let log = `${dayjs().format('YYYY-MM-DD HH:mm:ss')} [${logtype} ${type.toUpperCase()}] `
|
||||
msg.forEach((item: ILogArgvTypeWithError) => {
|
||||
if (typeof item === 'object' && type === 'error') {
|
||||
log += `\n------Error Stack Begin------\n${util.format(item.stack)}\n-------Error Stack End------- `
|
||||
|
||||
Reference in New Issue
Block a user