mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-31 02:38:46 +08:00
🔨 Refactor: db class
This commit is contained in:
@@ -21,62 +21,47 @@ if (process.type !== 'renderer') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = new FileSync(path.join(STORE_PATH, '/data.json'))
|
class DB {
|
||||||
|
constructor () {
|
||||||
|
const adapter = new FileSync(path.join(STORE_PATH, '/data.json'))
|
||||||
|
|
||||||
const db = Datastore(adapter)
|
this.db = Datastore(adapter)
|
||||||
db._.mixin(LodashId)
|
this.db._.mixin(LodashId)
|
||||||
|
|
||||||
if (!db.has('uploaded').value()) {
|
if (!this.db.has('uploaded').value()) {
|
||||||
db.set('uploaded', []).write()
|
this.db.set('uploaded', []).write()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!db.has('picBed').value()) {
|
if (!this.db.has('picBed').value()) {
|
||||||
db.set('picBed', {
|
this.db.set('picBed', {
|
||||||
current: 'weibo'
|
current: 'weibo'
|
||||||
}).write()
|
}).write()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!db.has('settings.shortKey').value()) {
|
if (!this.db.has('settings.shortKey').value()) {
|
||||||
db.set('settings.shortKey', {
|
this.db.set('settings.shortKey[picgo:upload]', {
|
||||||
upload: 'CommandOrControl+Shift+P'
|
enable: true,
|
||||||
}).write()
|
key: 'CommandOrControl+Shift+P',
|
||||||
}
|
name: 'picgo:upload',
|
||||||
|
label: '快捷上传'
|
||||||
// init generate clipboard image files
|
}).write()
|
||||||
let clipboardFiles = getClipboardFiles()
|
}
|
||||||
if (!fs.pathExistsSync(path.join(STORE_PATH, 'windows10.ps1'))) {
|
}
|
||||||
clipboardFiles.forEach(item => {
|
read () {
|
||||||
fs.copyFileSync(item.origin, item.dest)
|
return this.db.read()
|
||||||
})
|
}
|
||||||
} else {
|
get (key = '') {
|
||||||
clipboardFiles.forEach(item => {
|
return this.read().get(key).value()
|
||||||
diffFilesAndUpdate(item.origin, item.dest)
|
}
|
||||||
})
|
set (key, value) {
|
||||||
}
|
return this.read().set(key, value).write()
|
||||||
|
}
|
||||||
function diffFilesAndUpdate (filePath1, filePath2) {
|
has (key) {
|
||||||
let file1 = fs.readFileSync(filePath1)
|
return this.read().has(key).value()
|
||||||
let file2 = fs.readFileSync(filePath2)
|
}
|
||||||
|
insert (key, value) {
|
||||||
if (!file1.equals(file2)) {
|
return this.read().get(key).insert(value).write()
|
||||||
fs.copyFileSync(filePath1, filePath2)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClipboardFiles () {
|
export default new DB()
|
||||||
let files = [
|
|
||||||
'/linux.sh',
|
|
||||||
'/mac.applescript',
|
|
||||||
'/windows.ps1',
|
|
||||||
'/windows10.ps1'
|
|
||||||
]
|
|
||||||
|
|
||||||
return files.map(item => {
|
|
||||||
return {
|
|
||||||
origin: path.join(__static, item),
|
|
||||||
dest: path.join(STORE_PATH, item)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default db
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ let picBed = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
let picBedFromDB = db.read().get('picBed.list').value() || []
|
let picBedFromDB = db.get('picBed.list') || []
|
||||||
let oldLength = picBedFromDB.length
|
let oldLength = picBedFromDB.length
|
||||||
let newLength = picBed.length
|
let newLength = picBed.length
|
||||||
|
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ function createContextMenu () {
|
|||||||
return {
|
return {
|
||||||
label: item.name,
|
label: item.name,
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: db.read().get('picBed.current').value() === item.type,
|
checked: db.get('picBed.current') === item.type,
|
||||||
click () {
|
click () {
|
||||||
db.read().set('picBed.current', item.type).write()
|
db.set('picBed.current', item.type)
|
||||||
if (settingWindow) {
|
if (settingWindow) {
|
||||||
settingWindow.webContents.send('syncPicBed')
|
settingWindow.webContents.send('syncPicBed')
|
||||||
}
|
}
|
||||||
@@ -112,10 +112,10 @@ function createContextMenu () {
|
|||||||
{
|
{
|
||||||
label: '打开更新助手',
|
label: '打开更新助手',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: db.get('settings.showUpdateTip').value(),
|
checked: db.get('settings.showUpdateTip'),
|
||||||
click () {
|
click () {
|
||||||
const value = db.read().get('settings.showUpdateTip').value()
|
const value = db.get('settings.showUpdateTip')
|
||||||
db.read().set('settings.showUpdateTip', !value).write()
|
db.set('settings.showUpdateTip', !value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -189,7 +189,7 @@ function createTray () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
tray.on('drop-files', async (event, files) => {
|
tray.on('drop-files', async (event, files) => {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
const imgs = await new Uploader(files, window.webContents).upload()
|
const imgs = await new Uploader(files, window.webContents).upload()
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
for (let i in imgs) {
|
for (let i in imgs) {
|
||||||
@@ -202,7 +202,7 @@ function createTray () {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notification.show()
|
notification.show()
|
||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.read().get('uploaded').insert(imgs[i]).write()
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
window.webContents.send('dragFiles', imgs)
|
window.webContents.send('dragFiles', imgs)
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ const createMiniWidow = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db.read().get('settings.miniWindowOntop').value()) {
|
if (db.get('settings.miniWindowOntop')) {
|
||||||
obj.alwaysOnTop = true
|
obj.alwaysOnTop = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ const uploadClipboardFiles = async () => {
|
|||||||
let img = await new Uploader(undefined, win.webContents).upload()
|
let img = await new Uploader(undefined, win.webContents).upload()
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
@@ -378,7 +378,7 @@ const uploadClipboardFiles = async () => {
|
|||||||
icon: img[0].imgUrl
|
icon: img[0].imgUrl
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
db.read().get('uploaded').insert(img[0]).write()
|
db.insert('uploaded', img[0])
|
||||||
window.webContents.send('clipboardFiles', [])
|
window.webContents.send('clipboardFiles', [])
|
||||||
window.webContents.send('uploadFiles', img)
|
window.webContents.send('uploadFiles', img)
|
||||||
if (settingWindow) {
|
if (settingWindow) {
|
||||||
@@ -398,7 +398,7 @@ const uploadChoosedFiles = async (webContents, files) => {
|
|||||||
const input = files.map(item => item.path)
|
const input = files.map(item => item.path)
|
||||||
const imgs = await new Uploader(input, webContents).upload()
|
const imgs = await new Uploader(input, webContents).upload()
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
let pasteText = ''
|
let pasteText = ''
|
||||||
for (let i in imgs) {
|
for (let i in imgs) {
|
||||||
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
||||||
@@ -410,7 +410,7 @@ const uploadChoosedFiles = async (webContents, files) => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notification.show()
|
notification.show()
|
||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.read().get('uploaded').insert(imgs[i]).write()
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
clipboard.writeText(pasteText)
|
clipboard.writeText(pasteText)
|
||||||
window.webContents.send('uploadFiles', imgs)
|
window.webContents.send('uploadFiles', imgs)
|
||||||
@@ -426,7 +426,7 @@ picgoCoreIPC(app, ipcMain)
|
|||||||
ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
||||||
const img = await new Uploader(undefined, window.webContents).upload()
|
const img = await new Uploader(undefined, window.webContents).upload()
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
clipboard.writeText(pasteTemplate(pasteStyle, img[0]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
@@ -435,7 +435,7 @@ ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
|||||||
icon: img[0].imgUrl
|
icon: img[0].imgUrl
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
db.read().get('uploaded').insert(img[0]).write()
|
db.insert('uploaded', img[0])
|
||||||
window.webContents.send('clipboardFiles', [])
|
window.webContents.send('clipboardFiles', [])
|
||||||
if (settingWindow) {
|
if (settingWindow) {
|
||||||
settingWindow.webContents.send('updateGallery')
|
settingWindow.webContents.send('updateGallery')
|
||||||
@@ -558,13 +558,13 @@ app.on('ready', () => {
|
|||||||
if (process.platform === 'darwin' || process.platform === 'win32') {
|
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||||
createTray()
|
createTray()
|
||||||
}
|
}
|
||||||
db.read().set('needReload', false).write()
|
db.set('needReload', false)
|
||||||
updateChecker()
|
updateChecker()
|
||||||
initEventCenter()
|
initEventCenter()
|
||||||
// 不需要阻塞
|
// 不需要阻塞
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
updateShortKeyFromVersion212(db, db.read().get('settings.shortKey').value())
|
updateShortKeyFromVersion212(db, db.get('settings.shortKey'))
|
||||||
initShortKeyRegister(globalShortcut, db.read().get('settings.shortKey').value())
|
initShortKeyRegister(globalShortcut, db.get('settings.shortKey'))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'development') {
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
@@ -606,7 +606,7 @@ app.on('will-quit', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.setLoginItemSettings({
|
app.setLoginItemSettings({
|
||||||
openAtLogin: db.read().get('settings.autoStart').value() || false
|
openAtLogin: db.get('settings.autoStart') || false
|
||||||
})
|
})
|
||||||
|
|
||||||
function initEventCenter () {
|
function initEventCenter () {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const updateShortKeyFromVersion212 = (db, shortKeyConfig) => {
|
|||||||
delete shortKeyConfig.upload
|
delete shortKeyConfig.upload
|
||||||
}
|
}
|
||||||
if (needUpgrade) {
|
if (needUpgrade) {
|
||||||
db.read().set('settings.shortKey', shortKeyConfig).write()
|
db.set('settings.shortKey', shortKeyConfig)
|
||||||
return shortKeyConfig
|
return shortKeyConfig
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
|
import { remote, app } from 'electron'
|
||||||
if (process.env.NODE_ENV !== 'development') {
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||||
}
|
}
|
||||||
if (process.env.DEBUG_ENV === 'debug') {
|
if (process.env.DEBUG_ENV === 'debug') {
|
||||||
global.__static = path.join(__dirname, '../../../static').replace(/\\/g, '\\\\')
|
global.__static = path.join(__dirname, '../../../static').replace(/\\/g, '\\\\')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const APP = process.type === 'renderer' ? remote.app : app
|
||||||
|
const STORE_PATH = APP.getPath('userData')
|
||||||
|
|
||||||
function beforeOpen () {
|
function beforeOpen () {
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
resolveMacWorkFlow()
|
||||||
|
}
|
||||||
|
resolveClipboardImageGenerator()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macOS 右键菜单
|
||||||
|
*/
|
||||||
|
function resolveMacWorkFlow () {
|
||||||
const dest = `${os.homedir}/Library/Services/Upload pictures with PicGo.workflow`
|
const dest = `${os.homedir}/Library/Services/Upload pictures with PicGo.workflow`
|
||||||
if (fs.existsSync(dest)) {
|
if (fs.existsSync(dest)) {
|
||||||
return true
|
return true
|
||||||
@@ -20,4 +35,45 @@ function beforeOpen () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化剪贴板生成图片的脚本
|
||||||
|
*/
|
||||||
|
function resolveClipboardImageGenerator () {
|
||||||
|
let clipboardFiles = getClipboardFiles()
|
||||||
|
if (!fs.pathExistsSync(path.join(STORE_PATH, 'windows10.ps1'))) {
|
||||||
|
clipboardFiles.forEach(item => {
|
||||||
|
fs.copyFileSync(item.origin, item.dest)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
clipboardFiles.forEach(item => {
|
||||||
|
diffFilesAndUpdate(item.origin, item.dest)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function diffFilesAndUpdate (filePath1, filePath2) {
|
||||||
|
let file1 = fs.readFileSync(filePath1)
|
||||||
|
let file2 = fs.readFileSync(filePath2)
|
||||||
|
|
||||||
|
if (!file1.equals(file2)) {
|
||||||
|
fs.copyFileSync(filePath1, filePath2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getClipboardFiles () {
|
||||||
|
let files = [
|
||||||
|
'/linux.sh',
|
||||||
|
'/mac.applescript',
|
||||||
|
'/windows.ps1',
|
||||||
|
'/windows10.ps1'
|
||||||
|
]
|
||||||
|
|
||||||
|
return files.map(item => {
|
||||||
|
return {
|
||||||
|
origin: path.join(__static, item),
|
||||||
|
dest: path.join(STORE_PATH, item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default beforeOpen
|
export default beforeOpen
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const getPicBeds = (app) => {
|
|||||||
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
||||||
const picgo = new PicGo(CONFIG_PATH)
|
const picgo = new PicGo(CONFIG_PATH)
|
||||||
const picBedTypes = picgo.helper.uploader.getIdList()
|
const picBedTypes = picgo.helper.uploader.getIdList()
|
||||||
const picBedFromDB = db.read().get('picBed.list').value() || []
|
const picBedFromDB = db.get('picBed.list') || []
|
||||||
const picBeds = picBedTypes.map(item => {
|
const picBeds = picBedTypes.map(item => {
|
||||||
const visible = picBedFromDB.find(i => i.type === item) // object or undefined
|
const visible = picBedFromDB.find(i => i.type === item) // object or undefined
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class GuiApi {
|
|||||||
async upload (input) {
|
async upload (input) {
|
||||||
const imgs = await new Uploader(input, this[WEBCONTENTS], this[PICGO]).upload()
|
const imgs = await new Uploader(input, this[WEBCONTENTS], this[PICGO]).upload()
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
let pasteText = ''
|
let pasteText = ''
|
||||||
for (let i in imgs) {
|
for (let i in imgs) {
|
||||||
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
||||||
@@ -72,7 +72,7 @@ class GuiApi {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notification.show()
|
notification.show()
|
||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.read().get('uploaded').insert(imgs[i]).write()
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
clipboard.writeText(pasteText)
|
clipboard.writeText(pasteText)
|
||||||
this[WEBCONTENTS].send('uploadFiles', imgs)
|
this[WEBCONTENTS].send('uploadFiles', imgs)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const formatCustomLink = (customLink, item) => {
|
|||||||
|
|
||||||
export default (style, item) => {
|
export default (style, item) => {
|
||||||
let url = item.url || item.imgUrl
|
let url = item.url || item.imgUrl
|
||||||
const customLink = db.read().get('settings.customLink').value() || '$url'
|
const customLink = db.get('settings.customLink') || '$url'
|
||||||
const tpl = {
|
const tpl = {
|
||||||
'markdown': ``,
|
'markdown': ``,
|
||||||
'HTML': `<img src="${url}"/>`,
|
'HTML': `<img src="${url}"/>`,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import GuiApi from './guiApi'
|
import GuiApi from './guiApi'
|
||||||
import { dialog, shell } from 'electron'
|
import { dialog, shell } from 'electron'
|
||||||
|
import db from '../../datastore'
|
||||||
|
|
||||||
// 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
|
||||||
@@ -187,6 +188,17 @@ const handleRemoveFiles = (ipcMain, CONFIG_PATH) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handlePluginShortKeyRegister = (plugin) => {
|
||||||
|
if (plugin.shortKeys && plugin.shortKeys.length > 0) {
|
||||||
|
let shortKeyConfig = db.get('settings.shortKey')
|
||||||
|
plugin.shortKeys.forEach(item => {
|
||||||
|
if (!shortKeyConfig[item.name]) {
|
||||||
|
shortKeyConfig[item.name] = item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default (app, ipcMain) => {
|
export default (app, ipcMain) => {
|
||||||
const STORE_PATH = app.getPath('userData')
|
const STORE_PATH = app.getPath('userData')
|
||||||
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
||||||
@@ -197,4 +209,5 @@ export default (app, ipcMain) => {
|
|||||||
handleGetPicBedConfig(ipcMain, CONFIG_PATH)
|
handleGetPicBedConfig(ipcMain, CONFIG_PATH)
|
||||||
handlePluginActions(ipcMain, CONFIG_PATH)
|
handlePluginActions(ipcMain, CONFIG_PATH)
|
||||||
handleRemoveFiles(ipcMain, CONFIG_PATH)
|
handleRemoveFiles(ipcMain, CONFIG_PATH)
|
||||||
|
handlePluginShortKeyRegister({})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ const release = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
|||||||
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
|
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
|
||||||
|
|
||||||
const checkVersion = async () => {
|
const checkVersion = async () => {
|
||||||
let showTip = db.read().get('settings.showUpdateTip').value()
|
let showTip = db.get('settings.showUpdateTip')
|
||||||
if (showTip === undefined) {
|
if (showTip === undefined) {
|
||||||
db.read().set('settings.showUpdateTip', true).write()
|
db.set('settings.showUpdateTip', true)
|
||||||
showTip = true
|
showTip = true
|
||||||
}
|
}
|
||||||
if (showTip) {
|
if (showTip) {
|
||||||
@@ -29,7 +29,7 @@ const checkVersion = async () => {
|
|||||||
if (res === 0) { // if selected yes
|
if (res === 0) { // if selected yes
|
||||||
shell.openExternal(downloadUrl)
|
shell.openExternal(downloadUrl)
|
||||||
}
|
}
|
||||||
db.read().set('settings.showUpdateTip', !checkboxChecked).write()
|
db.set('settings.showUpdateTip', !checkboxChecked)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if (this.type === this.$db.get('picBed.current').value()) {
|
if (this.type === this.$db.get('picBed.current')) {
|
||||||
this.value = true
|
this.value = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export default {
|
|||||||
deep: true,
|
deep: true,
|
||||||
handler (val) {
|
handler (val) {
|
||||||
this.ruleForm = Object.assign({}, {})
|
this.ruleForm = Object.assign({}, {})
|
||||||
const config = this.$db.read().get(`picBed.${this.id}`).value()
|
const config = this.$db.get(`picBed.${this.id}`)
|
||||||
if (val.length > 0) {
|
if (val.length > 0) {
|
||||||
this.configList = cloneDeep(val).map(item => {
|
this.configList = cloneDeep(val).map(item => {
|
||||||
let defaultValue = item.default !== undefined
|
let defaultValue = item.default !== undefined
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$db.read().get('settings.shortKey')
|
this.$db.get('settings.shortKey')
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export default {
|
|||||||
keyBindingVisible: false,
|
keyBindingVisible: false,
|
||||||
customLinkVisible: false,
|
customLinkVisible: false,
|
||||||
customLink: {
|
customLink: {
|
||||||
value: db.read().get('customLink').value() || '$url'
|
value: db.get('customLink') || '$url'
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
value: [
|
value: [
|
||||||
@@ -194,7 +194,7 @@ export default {
|
|||||||
},
|
},
|
||||||
os: '',
|
os: '',
|
||||||
shortKey: {
|
shortKey: {
|
||||||
upload: db.read().get('shortKey.upload').value()
|
upload: db.get('shortKey.upload')
|
||||||
},
|
},
|
||||||
picBed: [],
|
picBed: [],
|
||||||
// for showInputBox
|
// for showInputBox
|
||||||
@@ -279,22 +279,22 @@ export default {
|
|||||||
},
|
},
|
||||||
cancelKeyBinding () {
|
cancelKeyBinding () {
|
||||||
this.keyBindingVisible = false
|
this.keyBindingVisible = false
|
||||||
this.shortKey = db.read().get('shortKey').value()
|
this.shortKey = db.get('shortKey')
|
||||||
},
|
},
|
||||||
confirmKeyBinding () {
|
confirmKeyBinding () {
|
||||||
const oldKey = db.read().get('shortKey').value()
|
const oldKey = db.get('shortKey')
|
||||||
db.read().set('shortKey', this.shortKey).write()
|
db.set('shortKey', this.shortKey)
|
||||||
this.keyBindingVisible = false
|
this.keyBindingVisible = false
|
||||||
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
||||||
},
|
},
|
||||||
cancelCustomLink () {
|
cancelCustomLink () {
|
||||||
this.customLinkVisible = false
|
this.customLinkVisible = false
|
||||||
this.customLink.value = db.read().get('customLink').value() || '$url'
|
this.customLink.value = db.get('customLink') || '$url'
|
||||||
},
|
},
|
||||||
confirmCustomLink () {
|
confirmCustomLink () {
|
||||||
this.$refs.customLink.validate((valid) => {
|
this.$refs.customLink.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
db.read().set('customLink', this.customLink.value).write()
|
db.set('customLink', this.customLink.value)
|
||||||
this.customLinkVisible = false
|
this.customLinkVisible = false
|
||||||
this.$electron.ipcRenderer.send('updateCustomLink')
|
this.$electron.ipcRenderer.send('updateCustomLink')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export default {
|
|||||||
this.changeZIndexForGallery(false)
|
this.changeZIndexForGallery(false)
|
||||||
},
|
},
|
||||||
copy (item) {
|
copy (item) {
|
||||||
const style = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
const style = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
const copyLink = pasteStyle(style, item)
|
const copyLink = pasteStyle(style, item)
|
||||||
const obj = {
|
const obj = {
|
||||||
title: '复制链接成功',
|
title: '复制链接成功',
|
||||||
@@ -232,7 +232,7 @@ export default {
|
|||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const file = this.$db.read().get('uploaded').getById(id).value()
|
const file = this.$db.get('uploaded').getById(id)
|
||||||
this.$db.read().get('uploaded').removeById(id).write()
|
this.$db.read().get('uploaded').removeById(id).write()
|
||||||
this.$electron.ipcRenderer.send('removeFiles', [file])
|
this.$electron.ipcRenderer.send('removeFiles', [file])
|
||||||
const obj = {
|
const obj = {
|
||||||
@@ -319,7 +319,7 @@ export default {
|
|||||||
multiCopy () {
|
multiCopy () {
|
||||||
if (Object.values(this.choosedList).some(item => item)) {
|
if (Object.values(this.choosedList).some(item => item)) {
|
||||||
let copyString = ''
|
let copyString = ''
|
||||||
const style = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
const style = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
||||||
Object.keys(this.choosedList).forEach(key => {
|
Object.keys(this.choosedList).forEach(key => {
|
||||||
if (this.choosedList[key]) {
|
if (this.choosedList[key]) {
|
||||||
@@ -343,11 +343,10 @@ export default {
|
|||||||
this.handleBarActive = !this.handleBarActive
|
this.handleBarActive = !this.handleBarActive
|
||||||
},
|
},
|
||||||
getPasteStyle () {
|
getPasteStyle () {
|
||||||
this.pasteStyle = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
this.pasteStyle = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
},
|
},
|
||||||
handlePasteStyleChange (val) {
|
handlePasteStyleChange (val) {
|
||||||
this.$db.read().set('settings.pasteStyle', val)
|
this.$db.set('settings.pasteStyle', val)
|
||||||
.write()
|
|
||||||
this.pasteStyle = val
|
this.pasteStyle = val
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
label: item.name,
|
label: item.name,
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: this.$db.read().get('picBed.current').value() === item.type,
|
checked: this.$db.get('picBed.current') === item.type,
|
||||||
click () {
|
click () {
|
||||||
_this.$db.read().set('picBed.current', item.type).write()
|
_this.$db.set('picBed.current', item.type)
|
||||||
_this.$electron.ipcRenderer.send('syncPicBed')
|
_this.$electron.ipcRenderer.send('syncPicBed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ export default {
|
|||||||
return callback()
|
return callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let logLevel = this.$db.read().get('settings.logLevel').value()
|
let logLevel = this.$db.get('settings.logLevel')
|
||||||
if (!Array.isArray(logLevel)) {
|
if (!Array.isArray(logLevel)) {
|
||||||
if (logLevel && logLevel.length > 0) {
|
if (logLevel && logLevel.length > 0) {
|
||||||
logLevel = [logLevel]
|
logLevel = [logLevel]
|
||||||
@@ -300,13 +300,13 @@ export default {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
updateHelper: this.$db.read().get('settings.showUpdateTip').value(),
|
updateHelper: this.$db.get('settings.showUpdateTip'),
|
||||||
showPicBedList: [],
|
showPicBedList: [],
|
||||||
autoStart: this.$db.read().get('settings.autoStart').value() || false,
|
autoStart: this.$db.get('settings.autoStart') || false,
|
||||||
rename: this.$db.read().get('settings.rename').value() || false,
|
rename: this.$db.get('settings.rename') || false,
|
||||||
autoRename: this.$db.read().get('settings.autoRename').value() || false,
|
autoRename: this.$db.get('settings.autoRename') || false,
|
||||||
uploadNotification: this.$db.read().get('settings.uploadNotification').value() || false,
|
uploadNotification: this.$db.get('settings.uploadNotification') || false,
|
||||||
miniWindowOntop: this.$db.read().get('settings.miniWindowOntop').value() || false,
|
miniWindowOntop: this.$db.get('settings.miniWindowOntop') || false,
|
||||||
logLevel
|
logLevel
|
||||||
},
|
},
|
||||||
picBed: [],
|
picBed: [],
|
||||||
@@ -316,12 +316,12 @@ export default {
|
|||||||
checkUpdateVisible: false,
|
checkUpdateVisible: false,
|
||||||
proxyVisible: false,
|
proxyVisible: false,
|
||||||
customLink: {
|
customLink: {
|
||||||
value: this.$db.read().get('settings.customLink').value() || '$url'
|
value: this.$db.get('settings.customLink') || '$url'
|
||||||
},
|
},
|
||||||
shortKey: {
|
shortKey: {
|
||||||
upload: this.$db.read().get('settings.shortKey.upload').value()
|
upload: this.$db.get('settings.shortKey.upload')
|
||||||
},
|
},
|
||||||
proxy: this.$db.read().get('picBed.proxy').value() || undefined,
|
proxy: this.$db.get('picBed.proxy') || undefined,
|
||||||
rules: {
|
rules: {
|
||||||
value: [
|
value: [
|
||||||
{ validator: customLinkRule, trigger: 'blur' }
|
{ validator: customLinkRule, trigger: 'blur' }
|
||||||
@@ -368,22 +368,22 @@ export default {
|
|||||||
},
|
},
|
||||||
cancelKeyBinding () {
|
cancelKeyBinding () {
|
||||||
this.keyBindingVisible = false
|
this.keyBindingVisible = false
|
||||||
this.shortKey = this.$db.read().get('settings.shortKey').value()
|
this.shortKey = this.$db.get('settings.shortKey')
|
||||||
},
|
},
|
||||||
confirmKeyBinding () {
|
confirmKeyBinding () {
|
||||||
const oldKey = this.$db.read().get('settings.shortKey').value()
|
const oldKey = this.$db.get('settings.shortKey')
|
||||||
this.$db.read().set('settings.shortKey', this.shortKey).write()
|
this.$db.set('settings.shortKey', this.shortKey)
|
||||||
this.keyBindingVisible = false
|
this.keyBindingVisible = false
|
||||||
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
||||||
},
|
},
|
||||||
cancelCustomLink () {
|
cancelCustomLink () {
|
||||||
this.customLinkVisible = false
|
this.customLinkVisible = false
|
||||||
this.customLink.value = this.$db.read().get('settings.customLink').value() || '$url'
|
this.customLink.value = this.$db.get('settings.customLink') || '$url'
|
||||||
},
|
},
|
||||||
confirmCustomLink () {
|
confirmCustomLink () {
|
||||||
this.$refs.customLink.validate((valid) => {
|
this.$refs.customLink.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$db.read().set('settings.customLink', this.customLink.value).write()
|
this.$db.set('settings.customLink', this.customLink.value)
|
||||||
this.customLinkVisible = false
|
this.customLinkVisible = false
|
||||||
this.$electron.ipcRenderer.send('updateCustomLink')
|
this.$electron.ipcRenderer.send('updateCustomLink')
|
||||||
} else {
|
} else {
|
||||||
@@ -393,11 +393,11 @@ export default {
|
|||||||
},
|
},
|
||||||
cancelProxy () {
|
cancelProxy () {
|
||||||
this.proxyVisible = false
|
this.proxyVisible = false
|
||||||
this.proxy = this.$db.read().get('picBed.proxy').value() || undefined
|
this.proxy = this.$db.get('picBed.proxy') || undefined
|
||||||
},
|
},
|
||||||
confirmProxy () {
|
confirmProxy () {
|
||||||
this.proxyVisible = false
|
this.proxyVisible = false
|
||||||
this.$db.read().set('picBed.proxy', this.proxy).write()
|
this.$db.set('picBed.proxy', this.proxy)
|
||||||
const successNotification = new window.Notification('设置代理', {
|
const successNotification = new window.Notification('设置代理', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
})
|
})
|
||||||
@@ -406,7 +406,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateHelperChange (val) {
|
updateHelperChange (val) {
|
||||||
this.$db.read().set('settings.showUpdateTip', val).write()
|
this.$db.set('settings.showUpdateTip', val)
|
||||||
},
|
},
|
||||||
handleShowPicBedListChange (val) {
|
handleShowPicBedListChange (val) {
|
||||||
const list = this.picBed.map(item => {
|
const list = this.picBed.map(item => {
|
||||||
@@ -417,18 +417,18 @@ export default {
|
|||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
this.$db.read().set('picBed.list', list).write()
|
this.$db.set('picBed.list', list)
|
||||||
this.$electron.ipcRenderer.send('getPicBeds')
|
this.$electron.ipcRenderer.send('getPicBeds')
|
||||||
},
|
},
|
||||||
handleAutoStartChange (val) {
|
handleAutoStartChange (val) {
|
||||||
this.$db.read().set('settings.autoStart', val).write()
|
this.$db.set('settings.autoStart', val)
|
||||||
this.$electron.ipcRenderer.send('autoStart', val)
|
this.$electron.ipcRenderer.send('autoStart', val)
|
||||||
},
|
},
|
||||||
handleRename (val) {
|
handleRename (val) {
|
||||||
this.$db.read().set('settings.rename', val).write()
|
this.$db.set('settings.rename', val)
|
||||||
},
|
},
|
||||||
handleAutoRename (val) {
|
handleAutoRename (val) {
|
||||||
this.$db.read().set('settings.autoRename', val).write()
|
this.$db.set('settings.autoRename', val)
|
||||||
},
|
},
|
||||||
compareVersion2Update (current, latest) {
|
compareVersion2Update (current, latest) {
|
||||||
const currentVersion = current.split('.').map(item => parseInt(item))
|
const currentVersion = current.split('.').map(item => parseInt(item))
|
||||||
@@ -463,17 +463,17 @@ export default {
|
|||||||
this.checkUpdateVisible = false
|
this.checkUpdateVisible = false
|
||||||
},
|
},
|
||||||
handleUploadNotification (val) {
|
handleUploadNotification (val) {
|
||||||
this.$db.read().set('settings.uploadNotification', val).write()
|
this.$db.set('settings.uploadNotification', val)
|
||||||
},
|
},
|
||||||
handleMiniWindowOntop (val) {
|
handleMiniWindowOntop (val) {
|
||||||
this.$db.read().set('settings.miniWindowOntop', val).write()
|
this.$db.set('settings.miniWindowOntop', val)
|
||||||
this.$message('需要重启生效')
|
this.$message('需要重启生效')
|
||||||
},
|
},
|
||||||
confirmLogLevelSetting () {
|
confirmLogLevelSetting () {
|
||||||
if (this.form.logLevel.length === 0) {
|
if (this.form.logLevel.length === 0) {
|
||||||
return this.$message.error('请选择日志记录等级')
|
return this.$message.error('请选择日志记录等级')
|
||||||
}
|
}
|
||||||
this.$db.read().set('settings.logLevel', this.form.logLevel).write()
|
this.$db.set('settings.logLevel', this.form.logLevel)
|
||||||
const successNotification = new window.Notification('设置日志', {
|
const successNotification = new window.Notification('设置日志', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
})
|
})
|
||||||
@@ -484,7 +484,7 @@ export default {
|
|||||||
},
|
},
|
||||||
cancelLogLevelSetting () {
|
cancelLogLevelSetting () {
|
||||||
this.logFileVisible = false
|
this.logFileVisible = false
|
||||||
let logLevel = this.$db.read().get('settings.logLevel').value()
|
let logLevel = this.$db.get('settings.logLevel')
|
||||||
if (!Array.isArray(logLevel)) {
|
if (!Array.isArray(logLevel)) {
|
||||||
if (logLevel && logLevel.length > 0) {
|
if (logLevel && logLevel.length > 0) {
|
||||||
logLevel = [logLevel]
|
logLevel = [logLevel]
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export default {
|
|||||||
})
|
})
|
||||||
this.getPluginList()
|
this.getPluginList()
|
||||||
this.getSearchResult = debounce(this.getSearchResult, 50)
|
this.getSearchResult = debounce(this.getSearchResult, 50)
|
||||||
this.needReload = this.$db.read().get('needReload').value()
|
this.needReload = this.$db.get('needReload')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildContextMenu (plugin) {
|
buildContextMenu (plugin) {
|
||||||
@@ -192,7 +192,7 @@ export default {
|
|||||||
label: '启用插件',
|
label: '启用插件',
|
||||||
enabled: !plugin.enabled,
|
enabled: !plugin.enabled,
|
||||||
click () {
|
click () {
|
||||||
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, true).write()
|
_this.$db.set(`picgoPlugins.picgo-plugin-${plugin.name}`, true)
|
||||||
plugin.enabled = true
|
plugin.enabled = true
|
||||||
_this.getPicBeds()
|
_this.getPicBeds()
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ export default {
|
|||||||
label: '禁用插件',
|
label: '禁用插件',
|
||||||
enabled: plugin.enabled,
|
enabled: plugin.enabled,
|
||||||
click () {
|
click () {
|
||||||
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, false).write()
|
_this.$db.set(`picgoPlugins.picgo-plugin-${plugin.name}`, false)
|
||||||
plugin.enabled = false
|
plugin.enabled = false
|
||||||
_this.getPicBeds()
|
_this.getPicBeds()
|
||||||
if (plugin.config.transformer.name) {
|
if (plugin.config.transformer.name) {
|
||||||
@@ -238,7 +238,7 @@ export default {
|
|||||||
|
|
||||||
// handle transformer
|
// handle transformer
|
||||||
if (plugin.config.transformer.name) {
|
if (plugin.config.transformer.name) {
|
||||||
let currentTransformer = this.$db.read().get('picBed.transformer').value() || 'path'
|
let currentTransformer = this.$db.get('picBed.transformer') || 'path'
|
||||||
let pluginTransformer = plugin.config.transformer.name
|
let pluginTransformer = plugin.config.transformer.name
|
||||||
const obj = {
|
const obj = {
|
||||||
label: `${currentTransformer === pluginTransformer ? '禁用' : '启用'}transformer - ${plugin.config.transformer.name}`,
|
label: `${currentTransformer === pluginTransformer ? '禁用' : '启用'}transformer - ${plugin.config.transformer.name}`,
|
||||||
@@ -311,7 +311,7 @@ export default {
|
|||||||
this.$electron.remote.app.exit(0)
|
this.$electron.remote.app.exit(0)
|
||||||
},
|
},
|
||||||
handleReload () {
|
handleReload () {
|
||||||
this.$db.read().set('needReload', true).write()
|
this.$db.set('needReload', true)
|
||||||
this.needReload = true
|
this.needReload = true
|
||||||
const successNotification = new window.Notification('更新成功', {
|
const successNotification = new window.Notification('更新成功', {
|
||||||
body: '请点击此通知重启应用以生效'
|
body: '请点击此通知重启应用以生效'
|
||||||
@@ -324,11 +324,11 @@ export default {
|
|||||||
this.searchText = ''
|
this.searchText = ''
|
||||||
},
|
},
|
||||||
toggleTransformer (transformer) {
|
toggleTransformer (transformer) {
|
||||||
let currentTransformer = this.$db.read().get('picBed.transformer').value() || 'path'
|
let currentTransformer = this.$db.get('picBed.transformer') || 'path'
|
||||||
if (currentTransformer === transformer) {
|
if (currentTransformer === transformer) {
|
||||||
this.$db.read().set('picBed.transformer', 'path').write()
|
this.$db.set('picBed.transformer', 'path')
|
||||||
} else {
|
} else {
|
||||||
this.$db.read().set('picBed.transformer', transformer).write()
|
this.$db.set('picBed.transformer', transformer)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleConfirmConfig () {
|
async handleConfirmConfig () {
|
||||||
@@ -336,13 +336,13 @@ export default {
|
|||||||
if (result !== false) {
|
if (result !== false) {
|
||||||
switch (this.currentType) {
|
switch (this.currentType) {
|
||||||
case 'plugin':
|
case 'plugin':
|
||||||
this.$db.read().set(`picgo-plugin-${this.configName}`, result).write()
|
this.$db.set(`picgo-plugin-${this.configName}`, result)
|
||||||
break
|
break
|
||||||
case 'uploader':
|
case 'uploader':
|
||||||
this.$db.read().set(`picBed.${this.configName}`, result).write()
|
this.$db.set(`picBed.${this.configName}`, result)
|
||||||
break
|
break
|
||||||
case 'transformer':
|
case 'transformer':
|
||||||
this.$db.read().set(`transformer.${this.configName}`, result).write()
|
this.$db.set(`transformer.${this.configName}`, result)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const successNotification = new window.Notification('设置结果', {
|
const successNotification = new window.Notification('设置结果', {
|
||||||
@@ -393,15 +393,15 @@ export default {
|
|||||||
// restore Uploader & Transformer
|
// restore Uploader & Transformer
|
||||||
handleRestoreState (item, name) {
|
handleRestoreState (item, name) {
|
||||||
if (item === 'uploader') {
|
if (item === 'uploader') {
|
||||||
const current = this.$db.read().get('picBed.current').value()
|
const current = this.$db.get('picBed.current')
|
||||||
if (current === name) {
|
if (current === name) {
|
||||||
this.$db.read().set('picBed.current', 'smms').write()
|
this.$db.set('picBed.current', 'smms')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item === 'transformer') {
|
if (item === 'transformer') {
|
||||||
const current = this.$db.read().get('picBed.transformer').value()
|
const current = this.$db.get('picBed.transformer')
|
||||||
if (current === name) {
|
if (current === name) {
|
||||||
this.$db.read().set('picBed.transformer', 'path').write()
|
this.$db.set('picBed.transformer', 'path')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const shortKeyConfig = this.$db.read().get('settings.shortKey').value()
|
const shortKeyConfig = this.$db.get('settings.shortKey')
|
||||||
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
|
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -82,8 +82,8 @@ export default {
|
|||||||
toggleEnable (item) {
|
toggleEnable (item) {
|
||||||
const status = !item.enable
|
const status = !item.enable
|
||||||
item.enable = status
|
item.enable = status
|
||||||
this.$db.set(`settings.shortKey.${item.name}.enable`, status).write()
|
this.$db.set(`settings.shortKey.${item.name}.enable`, status)
|
||||||
this.$electron.ipcRenderer.send('updateShortKeyConfig', item)
|
this.$electron.ipcRenderer.send('updateShortKey', item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
this.getData()
|
this.getData()
|
||||||
this.$electron.ipcRenderer.on('dragFiles', (event, files) => {
|
this.$electron.ipcRenderer.on('dragFiles', (event, files) => {
|
||||||
files.forEach(item => {
|
files.forEach(item => {
|
||||||
this.$db.read().get('uploaded').insert(item).write()
|
this.$db.insert('uploaded', item)
|
||||||
})
|
})
|
||||||
this.files = this.$db.read().get('uploaded').slice().reverse().slice(0, 5).value()
|
this.files = this.$db.read().get('uploaded').slice().reverse().slice(0, 5).value()
|
||||||
})
|
})
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
this.notification.body = item.imgUrl
|
this.notification.body = item.imgUrl
|
||||||
this.notification.icon = item.imgUrl
|
this.notification.icon = item.imgUrl
|
||||||
const myNotification = new window.Notification(this.notification.title, this.notification)
|
const myNotification = new window.Notification(this.notification.title, this.notification)
|
||||||
const pasteStyle = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item))
|
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item))
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -130,17 +130,16 @@ export default {
|
|||||||
this.$electron.ipcRenderer.send('uploadChoosedFiles', sendFiles)
|
this.$electron.ipcRenderer.send('uploadChoosedFiles', sendFiles)
|
||||||
},
|
},
|
||||||
getPasteStyle () {
|
getPasteStyle () {
|
||||||
this.pasteStyle = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
this.pasteStyle = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
},
|
},
|
||||||
handlePasteStyleChange (val) {
|
handlePasteStyleChange (val) {
|
||||||
this.$db.read().set('settings.pasteStyle', val)
|
this.$db.set('settings.pasteStyle', val)
|
||||||
.write()
|
|
||||||
},
|
},
|
||||||
uploadClipboardFiles () {
|
uploadClipboardFiles () {
|
||||||
this.$electron.ipcRenderer.send('uploadClipboardFilesFromUploadPage')
|
this.$electron.ipcRenderer.send('uploadClipboardFilesFromUploadPage')
|
||||||
},
|
},
|
||||||
getDefaultPicBed () {
|
getDefaultPicBed () {
|
||||||
const current = this.$db.read().get('picBed.current').value()
|
const current = this.$db.get('picBed.current')
|
||||||
this.picBed.forEach(item => {
|
this.picBed.forEach(item => {
|
||||||
if (item.type === current) {
|
if (item.type === current) {
|
||||||
this.picBedName = item.name
|
this.picBedName = item.name
|
||||||
@@ -161,9 +160,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
label: item.name,
|
label: item.name,
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: this.$db.read().get('picBed.current').value() === item.type,
|
checked: this.$db.get('picBed.current') === item.type,
|
||||||
click () {
|
click () {
|
||||||
_this.$db.read().set('picBed.current', item.type).write()
|
_this.$db.set('picBed.current', item.type)
|
||||||
_this.$electron.ipcRenderer.send('syncPicBed')
|
_this.$electron.ipcRenderer.send('syncPicBed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.aliyun').value()
|
const config = this.$db.get('picBed.aliyun')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.github').value()
|
const config = this.$db.get('picBed.github')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.imgur').value()
|
const config = this.$db.get('picBed.imgur')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export default {
|
|||||||
async handleConfirm () {
|
async handleConfirm () {
|
||||||
const result = await this.$refs.configForm.validate()
|
const result = await this.$refs.configForm.validate()
|
||||||
if (result !== false) {
|
if (result !== false) {
|
||||||
this.$db.read().set(`picBed.${this.type}`, result).write()
|
this.$db.set(`picBed.${this.type}`, result)
|
||||||
const successNotification = new window.Notification('设置结果', {
|
const successNotification = new window.Notification('设置结果', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
})
|
})
|
||||||
@@ -62,7 +62,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setDefaultPicBed (type) {
|
setDefaultPicBed (type) {
|
||||||
this.$db.read().set('picBed.current', type).write()
|
this.$db.set('picBed.current', type)
|
||||||
this.defaultPicBed = type
|
this.defaultPicBed = type
|
||||||
const successNotification = new window.Notification('设置默认图床', {
|
const successNotification = new window.Notification('设置默认图床', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.qiniu').value()
|
const config = this.$db.get('picBed.qiniu')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.tcyun').value()
|
const config = this.$db.get('picBed.tcyun')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.get('picBed.upyun').value()
|
const config = this.$db.get('picBed.upyun')
|
||||||
if (config) {
|
if (config) {
|
||||||
for (let i in config) {
|
for (let i in config) {
|
||||||
this.form[i] = config[i]
|
this.form[i] = config[i]
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
const config = this.$db.read().get('picBed.weibo').value()
|
const config = this.$db.get('picBed.weibo')
|
||||||
if (config) {
|
if (config) {
|
||||||
this.form.username = config.username
|
this.form.username = config.username
|
||||||
this.form.password = config.password
|
this.form.password = config.password
|
||||||
@@ -91,13 +91,13 @@ export default {
|
|||||||
confirm (formName) {
|
confirm (formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$db.read().set('picBed.weibo', {
|
this.$db.set('picBed.weibo', {
|
||||||
username: this.form.username,
|
username: this.form.username,
|
||||||
password: this.form.password,
|
password: this.form.password,
|
||||||
quality: this.quality,
|
quality: this.quality,
|
||||||
cookie: this.form.cookie,
|
cookie: this.form.cookie,
|
||||||
chooseCookie: this.chooseCookie
|
chooseCookie: this.chooseCookie
|
||||||
}).write()
|
})
|
||||||
const successNotification = new window.Notification('设置结果', {
|
const successNotification = new window.Notification('设置结果', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ export default {
|
|||||||
name: '',
|
name: '',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
defaultPicBed: this.$db.read().get('picBed.current').value()
|
defaultPicBed: this.$db.get('picBed.current')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setDefaultPicBed (type) {
|
setDefaultPicBed (type) {
|
||||||
this.$db.read().set('picBed.current', type).write()
|
this.$db.set('picBed.current', type)
|
||||||
this.defaultPicBed = type
|
this.defaultPicBed = type
|
||||||
const successNotification = new window.Notification('设置默认图床', {
|
const successNotification = new window.Notification('设置默认图床', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
|
|||||||
Reference in New Issue
Block a user