Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
mzvast committed Mar 19, 2017
1 parent 82c9c5c commit ef9a96b
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 12 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Picorz是一个七牛云图床,开发的目的是为个人写markdown博客使

# 效果图
## 主界面
![](http://ogscovhkh.bkt.clouddn.com/Picorz-clipboard--2017-03-18T22:45:16+08:00)
![](http://ogscovhkh.bkt.clouddn.com/Picorz-clipboard-)

## 设置界面
![](http://ogscovhkh.bkt.clouddn.com/bbq-111.png-bbq-2017-03-17T23:47:08+08:00)
![](http://ogscovhkh.bkt.clouddn.com/Picorz-pasteshot--2017-03-19T17:45:51+08:00)

## 生成地址
![](http://ogscovhkh.bkt.clouddn.com/snipaste_20170317_154629.png(2017-03-17T15:49:04+08:00))
Expand All @@ -40,16 +40,17 @@ Picorz是一个七牛云图床,开发的目的是为个人写markdown博客使

1.0版本
- 剪贴板上传[x]
- markdown开关
- 界面风格统一
- markdown开关[x]
- 界面风格统一[x]
- 自定义后缀前缀规则[x]
- 多仓库


2.0版本
- 托盘上传
- 右键上传
- 悬浮窗上
- 历史记录15张图片
- 多仓库

3.0
- 图片压缩
Expand Down
13 changes: 13 additions & 0 deletions app/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,17 @@ body{
}
.picker{
left: 50vw;
}

.cp-URL,.cp-MD{
bottom: 80vh;
background-color: RGB(246, 172, 197);
}

.cp-URL{
left: 10vw;
}

.cp-MD{
left: 50vw;
}
2 changes: 1 addition & 1 deletion app/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ body{
/*height: 4em;*/
position: relative;
left:20em;
top:2em;
top:1em;
/*right: 10vw;
bottom: 13vh;*/
border-radius: 0;
Expand Down
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@



<button type="button" class="btn btn-large btn-block my-btn cp-URL">URL</button>
<button type="button" class="btn btn-large btn-block my-btn cp-MD">MD</button>
<button type="button" class="btn btn-large btn-block my-btn go-resource">Resource</button>

<button type="button" class="btn btn-large btn-block my-btn clip">Paste</button>
Expand Down
25 changes: 23 additions & 2 deletions app/js/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const configuration = require('../configuration.js');
const { ipcRenderer, clipboard, shell,remote } = require('electron')
const { ipcRenderer, clipboard, shell, remote } = require('electron')
const { dialog } = require('electron').remote
const container = document.getElementById('container')
const clipEle = document.querySelector('.clip');
const pickerEle = document.querySelector('.picker');
const goResourceEle = document.querySelector('.go-resource');

const cpURLEle = document.querySelector('.cp-URL');
const cpMDEle = document.querySelector('.cp-MD');
container.ondragover = () => {
return false;
}
Expand Down Expand Up @@ -38,6 +39,17 @@ clipEle.onclick = (e) => {
e.preventDefault();
ipcRenderer.send('upload-clipboard')
}
pickerEle.onclick = (e) => {
e.preventDefault();
dialog.showOpenDialog(null, {
properties:[
'openFile'
]
},(paths)=>{
let path = paths[0];
ipcRenderer.send('upload',path);
});
}

goResourceEle.onclick = (e) => {
e.preventDefault(e);
Expand All @@ -48,4 +60,13 @@ goResourceEle.onclick = (e) => {
}
let nextUrl = 'https://portal.qiniu.com/bucket/' + configuration.readSettings('keys')[2] + '/resource';
shell.openExternal(nextUrl);
}
cpURLEle.onclick = (e) => {
e.preventDefault(e);
ipcRenderer.send('cp-URL');
}

cpMDEle.onclick = (e) => {
e.preventDefault(e);
ipcRenderer.send('cp-MD');
}
3 changes: 3 additions & 0 deletions configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function initConfig() {
if (!readSettings('markdown')) {
saveSettings('markdown', true);
}
if (!readSettings('URLHistory')) {
saveSettings('URLHistory', []);
}
}

module.exports = {
Expand Down
32 changes: 29 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,29 @@ const path = require('path')
const url = require('url')
const moment = require('moment')
const configuration = require('./configuration.js')
var qn = require('qn');
const qn = require('qn');
require('electron-debug')({ showDevTools: true });
let URLHistory = [];
let currentURL;

function addURLtoHistory(newURL){
URLHistory.push(newURL);
currentURL = newURL;
}

function saveHistoryToJSON(){
let oldHistory = configuration.readSettings('URLHistory');
configuration.saveSettings('URLHistory',oldHistory.concat(URLHistory));
}

function cpCurrentURL(){
if(!currentURL) {return promptErr('No history')};
setClipboardURL(currentURL,0);
}
function cpCurrentMD(){
if(!currentURL) {return promptErr('No history')};
setClipboardURL(currentURL,1);
}
/**
* Temp dep
*/
Expand Down Expand Up @@ -54,11 +74,13 @@ function makeName(filename) {
function setClipboardURL(rawURL, type) {
if (!rawURL) return;
let finalURL;
console.log('type=',type);
if (type === 0) {
finalURL = rawURL;
} else {
finalURL = "![](" + rawURL + ")";
}
currentURL = rawURL;
clipboard.writeText(finalURL);
}

Expand Down Expand Up @@ -116,7 +138,7 @@ function createWindow() {

configuration.initConfig();

win = new BrowserWindow({ width: 300, height: 400, alwaysOnTop: true, y: 80, x: 0, icon: __dirname + '/app/img/app-icon.ico' })
win = new BrowserWindow({ width: 300, height: 400, alwaysOnTop: false, y: 80, x: 0, icon: __dirname + '/app/img/app-icon.ico' })

win.setMenu(menu)

Expand All @@ -135,6 +157,7 @@ function createWindow() {
app.on('ready', createWindow)

app.on('window-all-closed', () => {
saveHistoryToJSON();

if (process.platform !== 'darwin') {
app.quit()
Expand Down Expand Up @@ -208,7 +231,8 @@ function uploadClipboard(){
fs.write(info.fd, img.toPNG());
fs.close(info.fd, function (err) {
console.log(info.path);
doUpload(info.path, makeName('clipboard'));
let newname = makeName('pasteshot')+"-" + moment().format()
doUpload(info.path, newname);
})
}
})
Expand All @@ -222,6 +246,8 @@ ipcMain.on('remove-bucket', removeBucket)
ipcMain.on('add-domain', addDomain)
ipcMain.on('remove-domain', removeDomain)
ipcMain.on('upload-clipboard', uploadClipboard)
ipcMain.on('cp-URL',cpCurrentURL);
ipcMain.on('cp-MD',cpCurrentMD);

const template = [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Picorz",
"version": "0.2.5",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"start": "electron .",
Expand Down

0 comments on commit ef9a96b

Please sign in to comment.