mirror of
https://github.com/Molunerfinn/PicGo.git
synced 2024-04-21 10:31:33 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
783adada58 | ||
|
|
c6f2e16b80 | ||
|
|
ca6e72d4fc | ||
|
|
3d21909d72 | ||
|
|
1d2389c9e7 | ||
|
|
a8a0b9b424 | ||
|
|
7ada9fec39 | ||
|
|
2ecb33ccb0 | ||
|
|
d1602edf65 | ||
|
|
bc31cab735 | ||
|
|
63f8cb631a | ||
|
|
6cf3a50023 | ||
|
|
5fb11f5d89 | ||
|
|
f78bfda258 | ||
|
|
21ceafe649 |
@@ -1,3 +1,4 @@
|
||||
test/unit/coverage/**
|
||||
test/unit/*.js
|
||||
test/e2e/*.js
|
||||
dist/
|
||||
@@ -1,6 +1,7 @@
|
||||
# PicGo
|
||||
|
||||
> 图片上传+管理新体验
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/12621342/33876119-85a5148e-df5f-11e7-8843-46224e595d52.png" alt="">
|
||||
</p>
|
||||
@@ -8,31 +9,74 @@
|
||||
<a href="https://github.com/feross/standard">
|
||||
<img src="https://img.shields.io/badge/code%20style-standard-green.svg?style=flat-square" alt="">
|
||||
</a>
|
||||
<a href="https://travis-ci.org/Molunerfinn/PicGo/builds">
|
||||
<img src="https://img.shields.io/travis/Molunerfinn/PicGo.svg?style=flat-square" alt="">
|
||||
</a>
|
||||
<a href="https://github.com/Molunerfinn/PicGo/releases">
|
||||
<img src="https://img.shields.io/github/downloads/Molunerfinn/PicGo/total.svg?style=flat-square" alt="">
|
||||
</a>
|
||||
<a href="https://github.com/Molunerfinn/PicGo/releases/latest">
|
||||
<img src="https://img.shields.io/github/release/Molunerfinn/PicGo.svg?style=flat-square" alt="">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 精致设计
|
||||
## 应用说明
|
||||
|
||||

|
||||
PicGo目前支持了`微博图床`,`七牛图床`,`腾讯云COS`,`又拍云`。未来将支持更多图床。
|
||||
|
||||
macOS系统下,支持拖拽至menubar图标实现上传。menubar app 窗口显示最新上传的5张图片以及剪贴板里的图片。点击图片自动将上传的链接复制到剪贴板。
|
||||
暂时只支持macOS系统,未来将支持windows和linux。
|
||||
|
||||
## 便捷管理
|
||||
点击此处下载[应用](https://github.com/Molunerfinn/PicGo/releases),macOS用户请下载最新版本的`dmg`文件。
|
||||
|
||||

|
||||
如果第一次使用,请参考应用使用[手册](https://github.com/Molunerfinn/PicGo/wiki)。
|
||||
|
||||
查看你的上传记录,重复使用更方便。支持点击图片大图查看。支持删除图片(仅本地记录),让界面更加干净。
|
||||

|
||||
|
||||
## 可选图床
|
||||

|
||||
|
||||

|
||||
## 开发说明
|
||||
|
||||
目前支持微博图床和七牛图床。未来将支持更多。方便不同图床的上传需求。
|
||||
> 目前仅针对Mac平台。Windows和Linux平台并未测试。
|
||||
|
||||
## 多样链接
|
||||
如果你想要学习、开发、修改或自行构建PicGo,可以依照下面的指示:
|
||||
|
||||

|
||||
1. 你需要有node、git环境。需要了解npm的相关知识。
|
||||
2. `git clone https://github.com/Molunerfinn/PicGo.git` 并进入项目
|
||||
3. `npm install` 下载依赖
|
||||
|
||||
支持4种剪贴板链接格式,让你的文本编辑游刃有余。
|
||||
### 开发模式
|
||||
|
||||
输入`npm run dev`进入开发模式,开发模式具有热重载特性。不过需要注意的是,开发模式不稳定,会有进程崩溃的情况。此时需要:
|
||||
|
||||
```bash
|
||||
ctrl+c # 退出开发模式
|
||||
npm run dev # 重新进入开发模式
|
||||
```
|
||||
|
||||
### 生产模式
|
||||
|
||||
如果你需要自行构建,可以`npm run build`开始进行构建。构建成功后,会在`build`目录里出现构建成功的相应安装文件。
|
||||
|
||||
**注意**:如果你的网络环境不太好,可能会出现`electron-builder`下载`electron`二进制文件失败的情况。这个时候需要在`npm run build`之前指定一下`electron`的源为国内源:
|
||||
|
||||
```bash
|
||||
export ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"
|
||||
npm run build
|
||||
```
|
||||
|
||||
只需第一次构建的时候指定一下国内源即可。后续构建不需要特地指定。二进制文件下载在`~/.electron/`目录下。如果想要更新`electron`构建版本,可以删除`~/.electron/`目录,然后重新运行上一步,让`electron-builder`去下载最新的`electron`二进制文件。
|
||||
|
||||
## 赞助
|
||||
|
||||
如果你喜欢PicGo并且它对你确实有帮助,欢迎给我打赏一杯咖啡的钱哈~
|
||||
|
||||
支付宝:
|
||||
|
||||

|
||||
|
||||
微信:
|
||||
|
||||

|
||||
|
||||
## License
|
||||
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ h1
|
||||
position relative
|
||||
.mask
|
||||
position absolute
|
||||
width 100vw
|
||||
width 100%
|
||||
height 100vh
|
||||
top 0
|
||||
left 0
|
||||
@@ -82,7 +82,7 @@ h1
|
||||
z-index -1
|
||||
#header
|
||||
height 100vh
|
||||
width 100vw
|
||||
width 100%
|
||||
background-image url("https://ws1.sinaimg.cn/large/8700af19ly1fm9ru6fqvjj22p81stdta")
|
||||
background-attachment fixed
|
||||
background-size cover
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "picgo",
|
||||
"version": "1.0.2",
|
||||
"version": "1.2.1",
|
||||
"author": "Molunerfinn <marksz@teamsz.xyz>",
|
||||
"description": "Easy to upload your pic & copy to write",
|
||||
"license": "MIT",
|
||||
@@ -71,6 +71,7 @@
|
||||
"image-size": "^0.6.1",
|
||||
"lodash-id": "^0.14.0",
|
||||
"lowdb": "^1.0.0",
|
||||
"md5": "^2.2.1",
|
||||
"melody.css": "^1.0.2",
|
||||
"qiniu": "^7.1.1",
|
||||
"request": "^2.83.0",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="referrer" content="never">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<title>PicGo</title>
|
||||
<% if (htmlWebpackPlugin.options.nodeModules) { %>
|
||||
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
|
||||
|
||||
+167
-37
@@ -1,9 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
import uploader from './utils/uploader.js'
|
||||
import { app, BrowserWindow, Tray, Menu, Notification, clipboard, ipcMain } from 'electron'
|
||||
import { app, BrowserWindow, Tray, Menu, Notification, clipboard, ipcMain, globalShortcut, dialog } from 'electron'
|
||||
import db from '../datastore'
|
||||
import pasteTemplate from './utils/pasteTemplate'
|
||||
import updateChecker from './utils/updateChecker'
|
||||
import pkg from '../../package.json'
|
||||
/**
|
||||
* Set `__static` path to static files in production
|
||||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
||||
@@ -15,6 +17,7 @@ if (process.env.NODE_ENV !== 'development') {
|
||||
let window
|
||||
let settingWindow
|
||||
let tray
|
||||
let menu
|
||||
const winURL = process.env.NODE_ENV === 'development'
|
||||
? `http://localhost:9080`
|
||||
: `file://${__dirname}/index.html`
|
||||
@@ -22,9 +25,27 @@ const settingWinURL = process.env.NODE_ENV === 'development'
|
||||
? `http://localhost:9080/#setting/upload`
|
||||
: `file://${__dirname}/index.html#setting/upload`
|
||||
|
||||
const uploadFailed = () => {
|
||||
const notification = new Notification({
|
||||
title: '上传失败',
|
||||
body: '请检查你的图床配置!'
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
|
||||
function createTray () {
|
||||
tray = new Tray(`${__static}/menubar.png`)
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '关于',
|
||||
click () {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicGo',
|
||||
message: 'PicGo',
|
||||
detail: `Version: ${pkg.version}\nAuthor: Molunerfinn\nGithub: https://github.com/Molunerfinn/PicGo`
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '打开详细窗口',
|
||||
click () {
|
||||
@@ -58,6 +79,24 @@ function createTray () {
|
||||
db.read().set('picBed.current', 'qiniu')
|
||||
.write()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '腾讯云COS',
|
||||
type: 'radio',
|
||||
checked: db.read().get('picBed.current').value() === 'tcyun',
|
||||
click () {
|
||||
db.read().set('picBed.current', 'tcyun')
|
||||
.write()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '又拍云图床',
|
||||
type: 'radio',
|
||||
checked: db.read().get('picBed.current').value() === 'upyun',
|
||||
click () {
|
||||
db.read().set('picBed.current', 'upyun')
|
||||
.write()
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -99,18 +138,22 @@ function createTray () {
|
||||
tray.on('drop-files', async (event, files) => {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const imgs = await uploader(files, 'imgFromPath', window.webContents)
|
||||
for (let i in imgs) {
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, imgs[i].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: imgs[i].imgUrl,
|
||||
icon: files[i]
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
}, i * 100)
|
||||
if (imgs !== false) {
|
||||
for (let i in imgs) {
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, imgs[i].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: imgs[i].imgUrl,
|
||||
icon: files[i]
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
}, i * 100)
|
||||
}
|
||||
window.webContents.send('dragFiles', imgs)
|
||||
} else {
|
||||
uploadFailed()
|
||||
}
|
||||
window.webContents.send('dragFiles', imgs)
|
||||
})
|
||||
// toggleWindow()
|
||||
}
|
||||
@@ -141,6 +184,7 @@ const createWindow = () => {
|
||||
})
|
||||
|
||||
createSettingWindow()
|
||||
createMenu()
|
||||
}
|
||||
|
||||
const createSettingWindow = () => {
|
||||
@@ -168,6 +212,32 @@ const createSettingWindow = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const createMenu = () => {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
const template = [{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
|
||||
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
|
||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
|
||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
|
||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' },
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'CmdOrCtrl+Q',
|
||||
click () {
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
menu = Menu.buildFromTemplate(template)
|
||||
Menu.setApplicationMenu(menu)
|
||||
}
|
||||
}
|
||||
|
||||
const getWindowPosition = () => {
|
||||
const windowBounds = window.getBounds()
|
||||
const trayBounds = tray.getBounds()
|
||||
@@ -196,42 +266,99 @@ const showWindow = () => {
|
||||
window.focus()
|
||||
}
|
||||
|
||||
const uploadClipboardFiles = async () => {
|
||||
let img = clipboard.readImage()
|
||||
let uploadImg = null
|
||||
if (!img.isEmpty()) {
|
||||
// 从剪贴板来的图片默认转为png
|
||||
const imgUrl = 'data:image/png;base64,' + Buffer.from(img.toPNG(), 'binary').toString('base64')
|
||||
uploadImg = {
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
}
|
||||
}
|
||||
img = await uploader(uploadImg, 'imgFromClipboard', window.webContents)
|
||||
if (img !== false) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: img[0].imgUrl,
|
||||
icon: img[0].imgUrl
|
||||
})
|
||||
notification.show()
|
||||
window.webContents.send('clipboardFiles', [])
|
||||
window.webContents.send('uploadFiles', img)
|
||||
} else {
|
||||
uploadFailed()
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
||||
const img = await uploader(file, 'imgFromClipboard', window.webContents)
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: img[0].imgUrl,
|
||||
icon: file[0]
|
||||
})
|
||||
notification.show()
|
||||
window.webContents.send('clipboardFiles', [])
|
||||
window.webContents.send('uploadFiles', img)
|
||||
if (img !== false) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: img[0].imgUrl,
|
||||
// icon: file[0]
|
||||
icon: img[0].imgUrl
|
||||
})
|
||||
notification.show()
|
||||
window.webContents.send('clipboardFiles', [])
|
||||
window.webContents.send('uploadFiles', img)
|
||||
} else {
|
||||
uploadFailed()
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('uploadChoosedFiles', async (evt, files) => {
|
||||
const imgs = await uploader(files, 'imgFromUploader', settingWindow.webContents)
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
let pasteText = ''
|
||||
for (let i in imgs) {
|
||||
pasteText += pasteTemplate(pasteStyle, imgs[i].imgUrl) + '\r\n'
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: imgs[i].imgUrl,
|
||||
icon: files[i].path
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
}, i * 100)
|
||||
if (imgs !== false) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
let pasteText = ''
|
||||
for (let i in imgs) {
|
||||
pasteText += pasteTemplate(pasteStyle, imgs[i].imgUrl) + '\r\n'
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
body: imgs[i].imgUrl,
|
||||
icon: files[i].path
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
}, i * 100)
|
||||
}
|
||||
clipboard.writeText(pasteText)
|
||||
window.webContents.send('uploadFiles', imgs)
|
||||
} else {
|
||||
uploadFailed()
|
||||
}
|
||||
clipboard.writeText(pasteText)
|
||||
window.webContents.send('uploadFiles', imgs)
|
||||
})
|
||||
|
||||
const isSecondInstance = app.makeSingleInstance(() => {
|
||||
if (settingWindow) {
|
||||
if (settingWindow.isMinimized()) {
|
||||
settingWindow.restore()
|
||||
}
|
||||
settingWindow.focus()
|
||||
}
|
||||
})
|
||||
|
||||
if (isSecondInstance) {
|
||||
console.log('is 2')
|
||||
app.quit()
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
createTray()
|
||||
updateChecker()
|
||||
|
||||
globalShortcut.register('CommandOrControl+Shift+P', () => {
|
||||
uploadClipboardFiles()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
@@ -243,10 +370,13 @@ app.on('window-all-closed', () => {
|
||||
app.on('activate', () => {
|
||||
if (window === null || settingWindow === null) {
|
||||
createWindow()
|
||||
createTray()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('will-quit', () => {
|
||||
globalShortcut.unregisterAll()
|
||||
})
|
||||
|
||||
/**
|
||||
* Auto Updater
|
||||
*
|
||||
|
||||
@@ -21,13 +21,15 @@ const imgFromPath = async (imgPath) => {
|
||||
|
||||
const imgFromClipboard = (file) => {
|
||||
let result = []
|
||||
const today = new Date().toLocaleString().replace(/[ ]+/g, '-')
|
||||
result.push({
|
||||
base64Image: file.imgUrl.replace(/^data\S+,/, ''),
|
||||
fileName: `${today}.png`,
|
||||
width: file.width,
|
||||
height: file.height
|
||||
})
|
||||
if (file !== null) {
|
||||
const today = new Date().toLocaleString().replace(/[ ]+/g, '-').replace(/\/+/g, '-')
|
||||
result.push({
|
||||
base64Image: file.imgUrl.replace(/^data\S+,/, ''),
|
||||
fileName: `${today}.png`,
|
||||
width: file.width,
|
||||
height: file.height
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Notification } from 'electron'
|
||||
|
||||
function postOptions (fileName, token, imgBase64) {
|
||||
const area = selectArea(db.read().get('picBed.qiniu.area').value() || 'z0')
|
||||
const base64FileName = Buffer.from(fileName).toString('base64')
|
||||
const base64FileName = Buffer.from(fileName, 'utf-8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
||||
return {
|
||||
method: 'POST',
|
||||
url: `http://upload${area}.qiniu.com/putb64/-1/key/${base64FileName}`,
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
import request from 'request-promise'
|
||||
import * as img2Base64 from './img2base64'
|
||||
import db from '../../datastore/index'
|
||||
import { Notification, clipboard } from 'electron'
|
||||
import crypto from 'crypto'
|
||||
|
||||
// generate COS signature string
|
||||
const generateSignature = () => {
|
||||
const options = db.read().get('picBed.tcyun').value()
|
||||
const secretId = options.secretId
|
||||
const secretKey = options.secretKey
|
||||
const appId = options.appId
|
||||
const bucket = options.bucket
|
||||
const random = Math.floor(Math.random() * 10000000000)
|
||||
const current = parseInt(new Date().getTime() / 1000) - 1
|
||||
const expired = current + 3600
|
||||
|
||||
const multiSignature = `a=${appId}&b=${bucket}&k=${secretId}&e=${expired}&t=${current}&r=${random}&f=`
|
||||
|
||||
const signHexKey = crypto.createHmac('sha1', secretKey).update(multiSignature).digest()
|
||||
const tempString = Buffer.concat([signHexKey, Buffer.from(multiSignature)])
|
||||
const signature = Buffer.from(tempString).toString('base64')
|
||||
return {
|
||||
signature,
|
||||
appId,
|
||||
bucket
|
||||
}
|
||||
}
|
||||
|
||||
const postOptions = (fileName, signature, imgBase64) => {
|
||||
const area = db.read().get('picBed.tcyun.area').value()
|
||||
const path = db.read().get('picBed.tcyun.path').value()
|
||||
return {
|
||||
method: 'POST',
|
||||
url: `http://${area}.file.myqcloud.com/files/v2/${signature.appId}/${signature.bucket}/${path}${fileName}`,
|
||||
headers: {
|
||||
Host: `${area}.file.myqcloud.com`,
|
||||
Authorization: signature.signature,
|
||||
contentType: 'multipart/form-data'
|
||||
},
|
||||
formData: {
|
||||
op: 'upload',
|
||||
filecontent: Buffer.from(imgBase64, 'base64')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tcYunUpload = async (img, type, webContents) => {
|
||||
try {
|
||||
webContents.send('uploadProgress', 0)
|
||||
const imgList = await img2Base64[type](img)
|
||||
webContents.send('uploadProgress', 30)
|
||||
const singature = generateSignature()
|
||||
const length = imgList.length
|
||||
for (let i in imgList) {
|
||||
const options = postOptions(imgList[i].fileName, singature, imgList[i].base64Image)
|
||||
const res = await request(options)
|
||||
const body = JSON.parse(res)
|
||||
if (body.message === 'SUCCESS') {
|
||||
delete imgList[i].base64Image
|
||||
imgList[i]['imgUrl'] = body.data.source_url
|
||||
imgList[i]['type'] = 'tcyun'
|
||||
if (i - length === -1) {
|
||||
webContents.send('uploadProgress', 60)
|
||||
}
|
||||
} else {
|
||||
webContents.send('uploadProgress', -1)
|
||||
const notification = new Notification({
|
||||
title: '上传失败!',
|
||||
body: res.body.msg
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
}
|
||||
webContents.send('uploadProgress', 100)
|
||||
return imgList
|
||||
} catch (err) {
|
||||
const body = JSON.parse(err.error)
|
||||
webContents.send('uploadProgress', -1)
|
||||
const notification = new Notification({
|
||||
title: '上传失败!',
|
||||
body: `错误码:${body.code},请打开浏览器粘贴地址查看相关原因。`
|
||||
})
|
||||
notification.show()
|
||||
clipboard.writeText('https://cloud.tencent.com/document/product/436/8432')
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
export default tcYunUpload
|
||||
@@ -0,0 +1,80 @@
|
||||
import request from 'request-promise'
|
||||
import * as img2Base64 from './img2base64'
|
||||
import db from '../../datastore/index'
|
||||
import { Notification, clipboard } from 'electron'
|
||||
import crypto from 'crypto'
|
||||
import MD5 from 'md5'
|
||||
|
||||
// generate COS signature string
|
||||
const generateSignature = (fileName) => {
|
||||
const options = db.read().get('picBed.upyun').value()
|
||||
// const apiKey = options.apiKey
|
||||
const operator = options.operator
|
||||
const password = options.password
|
||||
const md5Password = MD5(password)
|
||||
const date = new Date().toGMTString()
|
||||
const uri = `/${options.bucket}/${encodeURI(fileName)}`
|
||||
const value = `PUT&${uri}&${date}`
|
||||
const sign = crypto.createHmac('sha1', md5Password).update(value).digest('base64')
|
||||
return `UPYUN ${operator}:${sign}`
|
||||
}
|
||||
|
||||
const postOptions = (fileName, signature, imgBase64) => {
|
||||
const options = db.read().get('picBed.upyun').value()
|
||||
const bucket = options.bucket
|
||||
return {
|
||||
method: 'PUT',
|
||||
url: `https://v0.api.upyun.com/${bucket}/${encodeURI(fileName)}`,
|
||||
headers: {
|
||||
Authorization: signature,
|
||||
Date: new Date().toGMTString()
|
||||
},
|
||||
body: Buffer.from(imgBase64, 'base64'),
|
||||
resolveWithFullResponse: true
|
||||
}
|
||||
}
|
||||
|
||||
const upYunUpload = async (img, type, webContents) => {
|
||||
try {
|
||||
webContents.send('uploadProgress', 0)
|
||||
const imgList = await img2Base64[type](img)
|
||||
webContents.send('uploadProgress', 30)
|
||||
const length = imgList.length
|
||||
const upyunOptions = db.read().get('picBed.upyun').value()
|
||||
for (let i in imgList) {
|
||||
const singature = generateSignature(imgList[i].fileName)
|
||||
const options = postOptions(imgList[i].fileName, singature, imgList[i].base64Image)
|
||||
const body = await request(options)
|
||||
if (body.statusCode === 200) {
|
||||
delete imgList[i].base64Image
|
||||
imgList[i]['imgUrl'] = `${upyunOptions.url}/${imgList[i].fileName}${upyunOptions.options}`
|
||||
imgList[i]['type'] = 'upyun'
|
||||
if (i - length === -1) {
|
||||
webContents.send('uploadProgress', 60)
|
||||
}
|
||||
} else {
|
||||
webContents.send('uploadProgress', -1)
|
||||
const notification = new Notification({
|
||||
title: '上传失败!',
|
||||
body: '服务端出错,请稍后再试'
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
}
|
||||
webContents.send('uploadProgress', 100)
|
||||
return imgList
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
const body = JSON.parse(err.error)
|
||||
webContents.send('uploadProgress', -1)
|
||||
const notification = new Notification({
|
||||
title: '上传失败!',
|
||||
body: `错误码:${body.code},请打开浏览器粘贴地址查看相关原因。`
|
||||
})
|
||||
notification.show()
|
||||
clipboard.writeText('http://docs.upyun.com/api/errno/')
|
||||
// throw new Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
export default upYunUpload
|
||||
@@ -0,0 +1,58 @@
|
||||
import { dialog, shell } from 'electron'
|
||||
import db from '../../datastore'
|
||||
import axios from 'axios'
|
||||
import pkg from '../../../package.json'
|
||||
const version = pkg.version
|
||||
const release = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
||||
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
|
||||
|
||||
const checkVersion = async () => {
|
||||
let showTip = db.read().get('picBed.showUpdateTip').value()
|
||||
if (showTip === undefined) {
|
||||
db.read().set('picBed.showUpdateTip', true).write()
|
||||
showTip = true
|
||||
}
|
||||
if (showTip) {
|
||||
const res = await axios.get(release)
|
||||
if (res.status === 200) {
|
||||
const latest = res.data.name
|
||||
const result = compareVersion2Update(version, latest)
|
||||
if (result) {
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: '发现新版本',
|
||||
buttons: ['Yes', 'No'],
|
||||
message: '发现新版本,是否去下载最新的版本?',
|
||||
checkboxLabel: '以后不再提醒',
|
||||
checkboxChecked: false
|
||||
}, (res, checkboxChecked) => {
|
||||
if (res === 0) { // if selected yes
|
||||
shell.openExternal(downloadUrl)
|
||||
}
|
||||
db.read().set('picBed.showUpdateTip', !checkboxChecked).write()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// if true -> update else return false
|
||||
const compareVersion2Update = (current, latest) => {
|
||||
const currentVersion = current.split('.').map(item => parseInt(item))
|
||||
const latestVersion = latest.split('.').map(item => parseInt(item))
|
||||
let flag = false
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (currentVersion[i] < latestVersion[i]) {
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
|
||||
return flag
|
||||
}
|
||||
|
||||
export default checkVersion
|
||||
@@ -1,13 +1,33 @@
|
||||
import weiboUpload from './weiboUpload'
|
||||
import qiniuUpload from './qiniuUpload'
|
||||
import tcYunUpload from './tcYunUpload'
|
||||
import upYunUpload from './upYunUpload'
|
||||
import db from '../../datastore/index'
|
||||
|
||||
const checkUploader = (type) => {
|
||||
const currentUploader = db.read().get(`picBed.${type}`).value()
|
||||
if (currentUploader) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const uploader = (img, type, webContents) => {
|
||||
const uploadType = db.read().get('picBed.current').value()
|
||||
switch (uploadType) {
|
||||
case 'weibo':
|
||||
return weiboUpload(img, type, webContents)
|
||||
case 'qiniu':
|
||||
return qiniuUpload(img, type, webContents)
|
||||
if (checkUploader(uploadType)) {
|
||||
switch (uploadType) {
|
||||
case 'weibo':
|
||||
return weiboUpload(img, type, webContents)
|
||||
case 'qiniu':
|
||||
return qiniuUpload(img, type, webContents)
|
||||
case 'tcyun':
|
||||
return tcYunUpload(img, type, webContents)
|
||||
case 'upyun':
|
||||
return upYunUpload(img, type, webContents)
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ const j = request.jar()
|
||||
const rp = request.defaults({jar: j})
|
||||
const UPLOAD_URL = 'http://picupload.service.weibo.com/interface/pic_upload.php?ori=1&mime=image%2Fjpeg&data=base64&url=0&markpos=1&logo=&nick=0&marks=1&app=miniblog'
|
||||
|
||||
function postOptions (formData) {
|
||||
const postOptions = (formData) => {
|
||||
return {
|
||||
method: 'POST',
|
||||
url: 'https://passport.weibo.cn/sso/login',
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
@font-face {font-family: "iconfont";
|
||||
src: url('iconfont.eot?t=1512627299425'); /* IE9*/
|
||||
src: url('iconfont.eot?t=1512627299425#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAccAAsAAAAACgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kgJY21hcAAAAYAAAABtAAABqjJq0p5nbHlmAAAB8AAAAyIAAAOsU27YCmhlYWQAAAUUAAAALwAAADYPvT7DaGhlYQAABUQAAAAcAAAAJAfeA4ZobXR4AAAFYAAAABMAAAAUE+kAAGxvY2EAAAV0AAAADAAAAAwB+gL0bWF4cAAABYAAAAAfAAAAIAEVAHluYW1lAAAFoAAAAUUAAAJtPlT+fXBvc3QAAAboAAAAMwAAAETD3CS1eJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2Bk/s04gYGVgYOpk+kMAwNDP4RmfM1gxMjBwMDEwMrMgBUEpLmmMDgwVDyTYW7438AQw9zA0AAUZgTJAQAmaQyLeJzFkdENgCAMRK+Chhg3gBEcwE+H8csJmLhr4FH64wQceXC9lEAAwAogkJNEQF4Iuh6mYnnAbnnExTpxLFyripbW3GVzXWIdyVzkXvbKhmmSeUf/ddh8e8WXRnV4RXV6rnnQf0XLAMsHNt4SBQAAAHicTVLNixxFFK9X1VU9M91dPd3TUz0f2/O5272ym57dnd7uxI09ugkJmsAoS+IOOWzChkAgehA2e0nIgIgfRIyXRT2tokhELznoJScRvMx/4MH4cQ0hggERR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wD9AAAAAAAAdgEeAYQB1nicY2BkYGBgZchlYGMAASYg5gJCBob/YD4DABQAAY8AeJxlj01OwzAQhV/6B6QSqqhgh+QFYgEo/RGrblhUavdddN+mTpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicY2BigAAuBuyAlZGJkZmRhZGVkY2BsYK1PDUzKZ+ttCAnPzGFtTAzL7OUgQEAX20HdQA=') format('woff'),
|
||||
url('iconfont.ttf?t=1512627299425') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
|
||||
url('iconfont.svg?t=1512627299425#iconfont') format('svg'); /* iOS 4.1- */
|
||||
src: url('iconfont.eot?t=1513753554908'); /* IE9*/
|
||||
src: url('iconfont.eot?t=1513753554908#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAmkAAsAAAAADaAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7kg7Y21hcAAAAYAAAACAAAABzpdE03RnbHlmAAACAAAABYcAAAcM5PoEemhlYWQAAAeIAAAALwAAADYP352haGhlYQAAB7gAAAAcAAAAJAfeA4hobXR4AAAH1AAAABMAAAAcG+kAAGxvY2EAAAfoAAAAEAAAABAFmgd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1frRigfM6rKMhEfBYhPOAuCMDWU1OLaEn6fEMZTn516cED/6WFe9FctG2WbdmvzFYfb1aAleLQRmPaNd69uDsB7RvdZ9zs/ennxp8fC0tfgHfv/wj2te+cjr8AW0vU/1nQJqwB4nGNgZGBgAGINu5sC8fw2Xxm4WRhA4FqCziUE/X8BCwNzApDLwcAEEgUAB9YJeAB4nGNgZGBgbvjfwBDDwgACQJKRARWwAwBHDQJweJxjYWBgYH7JwMDCgIkBFrMBBQAAAAAAAHYBHgI2ApwC7gOGeJxjYGRgYGBnOMDAxgACTEDMBYQMDP/BfAYAHFEB5AB4nGWPTU7DMBCFX/oHpBKqqGCH5AViASj9EatuWFRq911036ZOmyqJI8et1ANwHo7ACTgC3IA78EgnmzaWx9+8eWNPANzgBx6O3y33kT1cMjtyDRe4F65TfxBukF+Em2jjVbhF/U3YxzOmwm10YXmD17hi9oR3YQ8dfAjXcI1P4Tr1L+EG+Vu4iTv8CrfQ8erCPuZeV7iNRy/2x1YvnF6p5UHFockikzm/gple75KFrdLqnGtbxCZTg6BfSVOdaVvdU+zXQ+ciFVmTqgmrOkmMyq3Z6tAFG+fyUa8XiR6EJuVYY/62xgKOcQWFJQ6MMUIYZIjK6Og7VWb0r7FDwl57Vj3N53RbFNT/c4UBAvTPXFO6stJ5Ok+BPV8bUnV0K27LnpQ0kV7NSRKyQl7WtlRC6gE2ZVeOEXpc0Yk/KGdI/wAJWm7IAAAAeJxjYGKAAC4G7ICdkYmRmZGFkZWRjZGdkYOBsYK1PDUzKZ+1JLmyNI+ttCAnPzGFtTAzL7OUtbQAKMTAAADg/QwGAAA=') format('woff'),
|
||||
url('iconfont.ttf?t=1513753554908') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
|
||||
url('iconfont.svg?t=1513753554908#iconfont') format('svg'); /* iOS 4.1- */
|
||||
}
|
||||
|
||||
[class*=" el-icon-ui"], [class^=el-icon-ui] {
|
||||
@@ -17,7 +17,11 @@
|
||||
|
||||
.el-icon-ui-weibo:before { content: "\e61c"; }
|
||||
|
||||
.el-icon-ui-tcyun:before { content: "\e64c"; }
|
||||
|
||||
.el-icon-ui-upload:before { content: "\e61b"; }
|
||||
|
||||
.el-icon-ui-qiniu:before { content: "\e601"; }
|
||||
|
||||
.el-icon-ui-upyun:before { content: "\e602"; }
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 15 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div id="setting-page">
|
||||
<div class="fake-title-bar">
|
||||
PicGo
|
||||
PicGo - {{ version }}
|
||||
</div>
|
||||
<el-row style="padding-top: 22px;">
|
||||
<el-col :span="5">
|
||||
@@ -24,29 +24,90 @@
|
||||
</el-menu-item>
|
||||
<el-menu-item index="qiniu">
|
||||
<i class="el-icon-ui-qiniu"></i>
|
||||
<span slot="title">七牛设置</span>
|
||||
<span slot="title">七牛云设置</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="tcyun">
|
||||
<i class="el-icon-ui-tcyun"></i>
|
||||
<span slot="title">腾讯COS设置</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="upyun">
|
||||
<i class="el-icon-ui-upyun"></i>
|
||||
<span slot="title">又拍云设置</span>
|
||||
</el-menu-item>
|
||||
<i class="el-icon-setting" @click="openDialog"></i>
|
||||
</el-menu>
|
||||
</el-col>
|
||||
<el-col :span="19" :offset="5">
|
||||
<router-view></router-view>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-dialog
|
||||
title="赞助PicGo"
|
||||
:visible.sync="visible"
|
||||
width="70%"
|
||||
top="10vh"
|
||||
>
|
||||
PicGo是免费开源的软件,如果你喜欢它,对你有帮助,不妨请我喝杯咖啡?
|
||||
<el-row class="support">
|
||||
<el-col :span="12">
|
||||
<img src="https://user-images.githubusercontent.com/12621342/34188165-e7cdf372-e56f-11e7-8732-1338c88b9bb7.jpg" alt="支付宝">
|
||||
<div class="support-title">支付宝</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<img src="https://user-images.githubusercontent.com/12621342/34188201-212cda84-e570-11e7-9b7a-abb298699d85.jpg" alt="支付宝">
|
||||
<div class="support-title">微信</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import pkg from '../../../package.json'
|
||||
import { remote } from 'electron'
|
||||
const { Menu, dialog } = remote
|
||||
export default {
|
||||
name: 'setting-page',
|
||||
data () {
|
||||
return {
|
||||
defaultActive: 'upload'
|
||||
version: pkg.version,
|
||||
defaultActive: 'upload',
|
||||
menu: null,
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.buildMenu()
|
||||
},
|
||||
methods: {
|
||||
handleSelect (index) {
|
||||
this.$router.push({
|
||||
name: index
|
||||
})
|
||||
},
|
||||
buildMenu () {
|
||||
const _this = this
|
||||
const template = [
|
||||
{
|
||||
label: '关于',
|
||||
click () {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicGo',
|
||||
message: 'PicGo',
|
||||
detail: `Version: ${pkg.version}\nAuthor: Molunerfinn\nGithub: https://github.com/Molunerfinn/PicGo`
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '赞助PicGo',
|
||||
click () {
|
||||
_this.visible = true
|
||||
}
|
||||
}
|
||||
]
|
||||
this.menu = Menu.buildFromTemplate(template)
|
||||
},
|
||||
openDialog () {
|
||||
this.menu.popup(remote.getCurrentWindow)
|
||||
}
|
||||
},
|
||||
beforeRouteEnter: (to, from, next) => {
|
||||
@@ -73,6 +134,15 @@ export default {
|
||||
border-right none
|
||||
background transparent
|
||||
position fixed
|
||||
.el-icon-setting
|
||||
position absolute
|
||||
bottom 4px
|
||||
left 4px
|
||||
cursor pointer
|
||||
color #878d99
|
||||
transition .2s all ease-in-out
|
||||
&:hover
|
||||
color #409EFF
|
||||
&-item
|
||||
color #eee
|
||||
position relative
|
||||
@@ -90,4 +160,9 @@ export default {
|
||||
right 0
|
||||
top 18px
|
||||
background active-color
|
||||
.support
|
||||
text-align center
|
||||
&-title
|
||||
text-align center
|
||||
color #878d99
|
||||
</style>
|
||||
@@ -36,7 +36,7 @@
|
||||
<el-input v-model="form.bucket" @keyup.native.enter="confirm" placeholder="Bucket"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定上传网址"
|
||||
label="设定访问网址"
|
||||
prop="url"
|
||||
:rules="{
|
||||
required: true, message: '网址不能为空', trigger: 'blur'
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div id="tcyun-view">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="16" :offset="4">
|
||||
<div class="view-title">
|
||||
腾讯云COS设置
|
||||
</div>
|
||||
<el-form
|
||||
ref="tcyun"
|
||||
label-position="right"
|
||||
label-width="120px"
|
||||
:model="form"
|
||||
size="mini">
|
||||
<el-form-item
|
||||
label="设定SecretId"
|
||||
prop="secretId"
|
||||
:rules="{
|
||||
required: true, message: 'SecretId不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.secretId" placeholder="SecretId" @keyup.native.enter="confirm('weiboForm')"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定SecretKey"
|
||||
prop="secretKey"
|
||||
:rules="{
|
||||
required: true, message: 'SecretKey不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.secretKey" type="password" @keyup.native.enter="confirm" placeholder="SecretKey"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定APPID"
|
||||
prop="appId"
|
||||
:rules="{
|
||||
required: true, message: 'APPID不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.appId" @keyup.native.enter="confirm" placeholder="例如1234567890"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定存储空间名"
|
||||
prop="bucket"
|
||||
:rules="{
|
||||
required: true, message: 'Bucket不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.bucket" @keyup.native.enter="confirm" placeholder="Bucket"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="确认存储区域"
|
||||
prop="area"
|
||||
:rules="{
|
||||
required: true, message: '区域代码不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.area" @keyup.native.enter="confirm" placeholder="例如tj"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="指定存储路径"
|
||||
>
|
||||
<el-input v-model="form.path" @keyup.native.enter="confirm" placeholder="例如img/"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import mixin from '../mixin'
|
||||
export default {
|
||||
name: 'tcyun',
|
||||
mixins: [mixin],
|
||||
data () {
|
||||
return {
|
||||
form: {
|
||||
secretId: '',
|
||||
secretKey: '',
|
||||
bucket: '',
|
||||
appId: '',
|
||||
area: '',
|
||||
path: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
const config = this.$db.get('picBed.tcyun').value()
|
||||
if (config) {
|
||||
for (let i in config) {
|
||||
this.form[i] = config[i]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
confirm () {
|
||||
this.$refs.tcyun.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$db.set('picBed.tcyun', this.form).write()
|
||||
const successNotification = new window.Notification('设置结果', {
|
||||
body: '设置成功'
|
||||
})
|
||||
successNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang='stylus'>
|
||||
.view-title
|
||||
color #eee
|
||||
font-size 20px
|
||||
text-align center
|
||||
margin 20px auto
|
||||
#tcyun-view
|
||||
.el-form
|
||||
label
|
||||
line-height 22px
|
||||
padding-bottom 0
|
||||
color #eee
|
||||
.el-button
|
||||
width 100%
|
||||
border-radius 19px
|
||||
.el-input__inner
|
||||
border-radius 19px
|
||||
.el-radio-group
|
||||
width 100%
|
||||
label
|
||||
width 25%
|
||||
.el-radio-button__inner
|
||||
width 100%
|
||||
.el-radio-button:first-child
|
||||
.el-radio-button__inner
|
||||
border-left none
|
||||
border-radius 14px 0 0 14px
|
||||
.el-radio-button:last-child
|
||||
.el-radio-button__inner
|
||||
border-left none
|
||||
border-radius 0 14px 14px 0
|
||||
</style>
|
||||
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div id="tcyun-view">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="16" :offset="4">
|
||||
<div class="view-title">
|
||||
又拍云设置
|
||||
</div>
|
||||
<el-form
|
||||
ref="tcyun"
|
||||
label-position="right"
|
||||
label-width="120px"
|
||||
:model="form"
|
||||
size="mini">
|
||||
<el-form-item
|
||||
label="设定存储空间名"
|
||||
prop="bucket"
|
||||
:rules="{
|
||||
required: true, message: 'Bucket不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.bucket" @keyup.native.enter="confirm" placeholder="Bucket"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定操作员"
|
||||
prop="operator"
|
||||
:rules="{
|
||||
required: true, message: '操作员不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.operator" @keyup.native.enter="confirm" placeholder="例如:me"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定操作员密码"
|
||||
prop="password"
|
||||
:rules="{
|
||||
required: true, message: '操作员密码不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.password" @keyup.native.enter="confirm" placeholder="输入操作员密码" type="password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定加速域名"
|
||||
prop="url"
|
||||
:rules="{
|
||||
required: true, message: '加速域名不能为空', trigger: 'blur'
|
||||
}">
|
||||
<el-input v-model="form.url" placeholder="例如http://xxx.test.upcdn.net" @keyup.native.enter="confirm()"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定网址后缀"
|
||||
>
|
||||
<el-input v-model="form.options" @keyup.native.enter="confirm" placeholder="例如!imgslim"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import mixin from '../mixin'
|
||||
export default {
|
||||
name: 'upyun',
|
||||
mixins: [mixin],
|
||||
data () {
|
||||
return {
|
||||
form: {
|
||||
bucket: '',
|
||||
operator: '',
|
||||
password: '',
|
||||
options: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
const config = this.$db.get('picBed.upyun').value()
|
||||
if (config) {
|
||||
for (let i in config) {
|
||||
this.form[i] = config[i]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
confirm () {
|
||||
this.$refs.tcyun.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$db.set('picBed.upyun', this.form).write()
|
||||
const successNotification = new window.Notification('设置结果', {
|
||||
body: '设置成功'
|
||||
})
|
||||
successNotification.onclick = () => {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang='stylus'>
|
||||
.view-title
|
||||
color #eee
|
||||
font-size 20px
|
||||
text-align center
|
||||
margin 20px auto
|
||||
#tcyun-view
|
||||
.el-form
|
||||
label
|
||||
line-height 22px
|
||||
padding-bottom 0
|
||||
color #eee
|
||||
.el-button
|
||||
width 100%
|
||||
border-radius 19px
|
||||
.el-input__inner
|
||||
border-radius 19px
|
||||
.el-radio-group
|
||||
width 100%
|
||||
label
|
||||
width 25%
|
||||
.el-radio-button__inner
|
||||
width 100%
|
||||
.el-radio-button:first-child
|
||||
.el-radio-button__inner
|
||||
border-left none
|
||||
border-radius 14px 0 0 14px
|
||||
.el-radio-button:last-child
|
||||
.el-radio-button__inner
|
||||
border-left none
|
||||
border-radius 0 14px 14px 0
|
||||
</style>
|
||||
@@ -6,9 +6,13 @@ import App from './App'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import db from '../datastore/index'
|
||||
import { webFrame } from 'electron'
|
||||
import './assets/fonts/iconfont.css'
|
||||
Vue.use(ElementUI)
|
||||
|
||||
webFrame.setVisualZoomLevelLimits(1, 1)
|
||||
webFrame.setLayoutZoomLevelLimits(0, 0)
|
||||
|
||||
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
|
||||
Vue.http = Vue.prototype.$http = axios
|
||||
Vue.prototype.$db = db
|
||||
|
||||
@@ -30,6 +30,16 @@ export default new Router({
|
||||
component: require('@/components/SettingView/Qiniu').default,
|
||||
name: 'qiniu'
|
||||
},
|
||||
{
|
||||
path: 'tcyun',
|
||||
component: require('@/components/SettingView/TcYun').default,
|
||||
name: 'tcyun'
|
||||
},
|
||||
{
|
||||
path: 'upyun',
|
||||
component: require('@/components/SettingView/UpYun').default,
|
||||
name: 'upyun'
|
||||
},
|
||||
{
|
||||
path: 'gallery',
|
||||
component: require('@/components/SettingView/Gallery').default,
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB |
@@ -1861,6 +1861,10 @@ chardet@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.0.tgz#0bbe1355ac44d7a3ed4a925707c4ef70f8190f6c"
|
||||
|
||||
charenc@~0.0.1:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
|
||||
|
||||
check-error@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
||||
@@ -2303,6 +2307,10 @@ cross-unzip@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/cross-unzip/-/cross-unzip-0.0.2.tgz#5183bc47a09559befcf98cc4657964999359372f"
|
||||
|
||||
crypt@~0.0.1:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
|
||||
|
||||
cryptiles@2.x.x:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
|
||||
@@ -4392,7 +4400,7 @@ is-binary-path@^1.0.0:
|
||||
dependencies:
|
||||
binary-extensions "^1.0.0"
|
||||
|
||||
is-buffer@^1.0.2, is-buffer@^1.1.5:
|
||||
is-buffer@^1.0.2, is-buffer@^1.1.5, is-buffer@~1.1.1:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||
|
||||
@@ -5269,6 +5277,14 @@ md5.js@^1.3.4:
|
||||
hash-base "^3.0.0"
|
||||
inherits "^2.0.1"
|
||||
|
||||
md5@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9"
|
||||
dependencies:
|
||||
charenc "~0.0.1"
|
||||
crypt "~0.0.1"
|
||||
is-buffer "~1.1.1"
|
||||
|
||||
media-typer@0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
|
||||
Reference in New Issue
Block a user