Skip to content

Commit

Permalink
update elementui and electron, modify time
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzihaofzh committed Jul 20, 2018
1 parent 2213424 commit f2f6a87
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 48 deletions.
74 changes: 38 additions & 36 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
<meta charset="UTF-8">
</meta>
<title>Paper Arxiv</title>
<link rel="stylesheet" href="node_modules/element-ui/lib/theme-default/index.css">
<link rel="stylesheet" href="node_modules/element-ui/lib/theme-chalk/index.css">
</head>

<body style="overflow-y:hidden">
<div id="app">
<div style="float:right; width:180px;margin-bottom: 8px;">
<el-button icon="plus" @click="openPdfFile">添加</el-button>
<el-button icon="setting" @click="itemConfigFormVisible = true">配置</el-button>
<div style="float:right; width:210px; margin-bottom: 8px;">
<el-button icon="el-icon-plus" @click="openPdfFile">Add</el-button>
<el-button icon="el-icon-setting" @click="itemConfigFormVisible = true">Config</el-button>
</div>
<div style="margin-right: 200px;margin-bottom: 8px;">
<el-input placeholder="请输入查找内容(支持正则表达式" v-model="userInputSearchText" autofocus @change="searchContent">
<el-button slot="append" icon="search" @click="searchContent"></el-button>
<div style="margin-right: 220px;margin-bottom: 8px;">
<el-input placeholder="Please input query (support regular expressions" v-model="userInputSearchText" autofocus v-on:input="searchContent" style="width:100%" ref="searchBox">
<el-button slot="append" icon="el-icon-search" @click="searchContent"></el-button>
</el-input>
</div>



<el-dialog title="配置" :visible.sync="itemConfigFormVisible" :show-close=false size="large">
<el-dialog title="配置" :visible.sync="itemConfigFormVisible" :show-close=false width="80%">
<el-form :model="itemConfigFormData">
<el-form-item label="路径">
<el-input v-model="itemConfigFormData.libpath" type="textarea" autosize auto-complete="off" ></el-input>
Expand All @@ -34,76 +34,78 @@

</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="itemConfigFormVisible = false">取 消</el-button>
<el-button type="primary" @click="itemConfigFormDataUpdate" autofocus>确 定</el-button>
<el-button @click="itemConfigFormVisible = false">Cancel</el-button>
<el-button type="primary" @click="itemConfigFormDataUpdate" autofocus>OK</el-button>
</div>
</el-dialog>

<el-dialog title="编辑条目" :visible.sync="itemEditFormVisible" :show-close=false size="large">
<el-dialog title="Edit Item" :visible.sync="itemEditFormVisible" :show-close=false width="80%">
<el-form :model="itemEditFormData">
<el-form-item label="名称">
<el-form-item label="Name">
<el-input v-model="itemEditFormData.name" type="textarea" autosize auto-complete="off" :disabled="true"></el-input>
</el-form-item>
<el-form-item label="标题">
<el-form-item label="Title">
<el-input v-model="itemEditFormData.title" type="textarea" autosize auto-complete="off"></el-input>
</el-form-item>
<el-form-item label="期刊">
<el-form-item label="Journal">
<el-input v-model="itemEditFormData.journal" type="textarea" autosize auto-complete="off" @change="changNameByNewInfo"></el-input>
</el-form-item>
<el-form-item label="作者">
<el-form-item label="Authors">
<el-input v-model="itemEditFormData.authors" type="textarea" autosize auto-complete="off" @change="changNameByNewInfo"></el-input>
</el-form-item>
<el-form-item label="年份">
<el-form-item label="Year">
<el-input v-model="itemEditFormData.year" type="textarea" autosize auto-complete="off" @change="changNameByNewInfo"></el-input>
</el-form-item>
<el-form-item label="tags">
<el-input v-model="itemEditFormData.tags" type="textarea" autosize auto-complete="off"></el-input>
</el-form-item>
<el-form-item label="笔记">
<el-form-item label="Notes">
<el-input v-model="itemEditFormData.comment" type="textarea" autosize auto-complete="off"></el-input>
</el-form-item>

</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="itemEditFormVisible = false">取 消</el-button>
<el-button type="primary" @click="itemEditFormDataUpdate" autofocus>确 定</el-button>
<el-button type="danger" @click="deleteRowInfo()">Delete</el-button>
<el-button @click="itemEditFormVisible = false;itemEditFormDataCancel();">Cancel</el-button>
<el-button type="primary" @click="itemEditFormDataUpdate" autofocus>OK</el-button>
</div>
</el-dialog>

<el-table id="el-main-table" :data="tableData" border height="100%" style="height:400px; width: 100%" :default-sort="{prop: 'updateTime', order: 'descending'}">
<el-table-column type="expand">
<template scope="table">
<el-button size="small" @click="editRowInfo(table.row)">编辑</el-button>
<el-button size="small" type="danger" @click="deleteRowInfo(table.row)">删除</el-button>
<el-table id="el-main-table" :data="tableData" border height="100%" style=" width: 100%" :default-sort="{prop: 'updateTime', order: 'descending'}" @cell-dblclick="onCellDBClick">
<!--<el-table-column type="expand">
<template slot-scope="table">
<el-button size="small" @click="editRowInfo(table.row)">Edit</el-button>
<el-button size="small" type="danger" @click="deleteRowInfo(table.row)">Delete</el-button>
</template>
</el-table-column>
<el-table-column prop="name" label="名称" sortable>
<template scope="table">
</el-table-column>-->
<el-table-column prop="name" label="Name" sortable>
<template slot-scope="table">
<p v-html="table.row.name" @click="openPdfFileWithSystemTool(table.row.name)" style="color:#72ACE3; cursor:pointer"></p>
</template>
</el-table-column>
<el-table-column prop="title" label="标题" sortable>
<template scope="table">
<el-table-column prop="title" label="Title" sortable>
<template slot-scope="table">
<p v-html="table.row.title"></p>
</template>
</el-table-column>
<el-table-column prop="authors" label="作者" sortable>
<template scope="table">
<el-table-column prop="authors" label="Authors" sortable>
<template slot-scope="table">
<p v-html="table.row.authors" style="white-space: pre-line"></p>
<!--<el-input type="textarea" autosize v-model="table.row.authors" > </el-input>-->
</template>
</el-table-column>
<el-table-column prop="tags" label="tags" sortable>
<template scope="table">
<template slot-scope="table">
<p v-html="table.row.tags"></p>
</template>
</el-table-column>
<el-table-column prop="comment" label="笔记" > <!--show-overflow-tooltip-->
<template scope="table">
<el-table-column prop="comment" label="Notes" > <!--show-overflow-tooltip-->
<template slot-scope="table">
<p v-html="table.row.comment"></p>
</template>
</el-table-column>
<el-table-column prop="updateTime" label="更新时间" sortable>
<template scope="table">
<el-table-column prop="updateTime" label="Update Time" sortable>
<template slot-scope="table">
<p v-html="table.row.updateTime"></p>
</template>
</el-table-column>
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PaperArxiv",
"version": "0.0.1",
"version": "0.0.2",
"description": "A paper management tool",
"main": "main.js",
"scripts": {
Expand All @@ -24,7 +24,7 @@
"author": "Maple",
"license": "MIT",
"devDependencies": {
"electron": "~1.7.9",
"electron": "~1.8.7",
"electron-rebuild": "^1.6.0",
"electron-packager": "9.0.0",
"electron-installer-debian": "0.5.2",
Expand All @@ -34,9 +34,9 @@
"ava": "0.22.0"
},
"dependencies": {
"better-sqlite3": "3.3.0",
"better-sqlite3": "4.1.2",
"child_process": "1.0.2",
"element-ui": "1.4.12",
"element-ui": "2.0.11",
"home-dir": "1.0.0",
"path": "0.12.7",
"vue": "2.5.2",
Expand Down
14 changes: 13 additions & 1 deletion src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ function DBManager(ctx) {
};
};

_exteactTags = function(tableData, key){
var tags = tableData.map(x => x[key].split(","));
tags = Array.prototype.concat.apply([], tags);
tags = tags.map(x => x.trim()).filter(x => x.length > 0);
var counts = {};
for (var i = 0; i < tags.length; i++) {
counts[tags[i]] = counts[tags[i]] ? counts[tags[i]] + 1 : 1;
}
return counts;
}
this.loadFullData = dbwrapper(function() {
if(typeof(this.db) !== undefined)ctx.tableData = this.db.prepare("SELECT * FROM docInfoTable").all();
//ctx.tagCounts = _exteactTags(ctx.tableData, "tags");
//ctx.journalCounts = _exteactTags(ctx.tableData, "journal");
});
_insertItem = dbwrapper(function(itemInfo, srcPath, dstPath){
keys = Object.keys(itemInfo);
Expand Down Expand Up @@ -54,7 +66,7 @@ function DBManager(ctx) {
});
this.updateItemInfo = function(oriName){
var d = new Date()
ctx.ctor.itemEditFormData.updateTime = d.toISOString().slice(0, 10) + ' ' + d.toTimeString().slice(0, 8);
ctx.ctor.itemEditFormData.updateTime = d.toLocaleDateString().replace(/\//g,'-').slice(0, 10) + ' ' + d.toTimeString().slice(0, 8);
ctx.itemEditFormDataStandard = utils.deepcopy(ctx.ctor.itemEditFormData);
var findItemId = 0;
for(;findItemId < ctx.tableData.length && ctx.tableData[findItemId].name !== oriName; ++findItemId);
Expand Down
2 changes: 1 addition & 1 deletion src/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function extractFromPdfFile(filePath, ctx) {
pdfInfo.name = ([pdfInfo.year, pdfInfo.journal, authors[0].replace(/[\%\/\<\>\^\|\?\&\#\*\\\:\" \n]/g, '')].join('-') + '.pdf').replace(/[\%\/\<\>\^\|\?\&\#\*\\\:\" ]/g, '');
pdfInfo.authors = authors.map(x => x.trim()).join('\n')
var d = new Date()
pdfInfo.addTime = d.toISOString().slice(0, 10) + ' ' + d.toTimeString().slice(0, 8);
pdfInfo.addTime = d.toLocaleDateString().replace(/\//g,'-').slice(0, 10) + ' ' + d.toTimeString().slice(0, 8);
pdfInfo.updateTime = pdfInfo.addTime;
pdfInfo.content = child_process.execSync('pdftohtml -q -xml -i -stdout -fontfullname "' + filePath + '"', {env:{PATH: process.env.PATH + ':/usr/local/bin'}}).toString().replace(/<\/?[^>]+(>|$)/g, "").split('\n').filter(x => x.length > 10).join('\n');
pdfInfo.tags = "";
Expand Down
26 changes: 20 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ var ItemEdit = {
itemEditFormVisible: false,
itemConfigFormVisible: false,
tableData: utils.partialCopyArray(ctx.tableData, ctx.showKeys),
userInputSearchText: ""
userInputSearchText: "",
}
},
methods: {
openPdfFile: function() {
fileManager.loadFile(this.ctx);
this.$refs.searchBox.focus();
},
itemEditFormDataUpdate: function() {
this.itemEditFormVisible = false;
Expand All @@ -48,6 +49,10 @@ var ItemEdit = {
ctx.dbManager.InsertItemInfo();
}
this.searchContent();
this.$refs.searchBox.focus();
},
itemEditFormDataCancel: function(){
this.$refs.searchBox.focus();
},
itemConfigFormDataUpdate: function(){
var config = utils.stringToConfig(this.itemConfigFormData, ctx);
Expand All @@ -57,14 +62,15 @@ var ItemEdit = {
this.itemConfigFormVisible = false;
this.itemConfigFormData = utils.configToString(ctx.configSettings);
location.reload(true);
this.$refs.searchBox.focus();
},
changNameByNewInfo: function() {
this.itemEditFormData.name = ([this.itemEditFormData.year, this.itemEditFormData.journal, this.itemEditFormData.authors.split('\n')[0]].join('-') + ".pdf").replace(/[\%\/\<\>\^\|\?\&\#\*\\\:\" ]/g, '');
},
openPdfFileWithSystemTool: function(val){
shell.openItem(path.join(this.ctx.configSettings.libpath, val.replace(/<\/?[^>]+(>|$)/g, "")));
},
searchContent: function(){
searchContent: function(value){
if(this.userInputSearchText.length == 0){
ctx.ctor.tableData = utils.partialCopyArray(ctx.tableData, ctx.showKeys);
}else{
Expand All @@ -78,13 +84,19 @@ var ItemEdit = {
if(findItem.length !== 1){ctx.error('数据库中找不到该文件,请重启程序!');return;};
ctx.ctor.itemEditFormData = utils.deepcopy(findItem[0]);
},
deleteRowInfo: function(row){
this.$confirm('确认删除记录' + row.name.replace(/<\/?[^>]+(>|$)/g, "") + '?')
deleteRowInfo: function(){
name = ctx.ctor.itemEditFormData.name;
this.itemEditFormVisible = false;
this.$confirm('Confirm to delete record ' + name.replace(/<\/?[^>]+(>|$)/g, "") + '?')
.then(_ => {
ctx.dbManager.deleteItemInfo(row.name.replace(/<\/?[^>]+(>|$)/g, ""));
ctx.dbManager.deleteItemInfo(name.replace(/<\/?[^>]+(>|$)/g, ""));
this.searchContent();
this.$refs.searchBox.focus();
})
.catch(_ => {})
},
onCellDBClick: function(row, column, cell, event){
this.editRowInfo(row);
}
}
}
Expand All @@ -100,7 +112,9 @@ function updateWindowSize(){
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
document.getElementById('el-main-table').setAttribute("style","height:" + (height - 60).toString() + "px");
}
updateWindowSize();

window.addEventListener('resize', function (e){
updateWindowSize();
}, true);

updateWindowSize();

0 comments on commit f2f6a87

Please sign in to comment.