-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
136 lines (119 loc) · 3.73 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
app 数据结构的定义
整体对象是一个json db 里面暂时只存一个json
{
objectName:"forder",
objectValue:[
{
forderName:"ff",
items:[
{
src:"",
text:"",
time:"",
lastTime:"",
}
],
},{
forderName:"bobi",
items:[
{
src:"",
text:"",
time:"",
lastTime:"",
}
],
},
],
}
*/
// const { remote, ipcRenderer } = window.require("electron");
// const fs = require("fs");
// const sizeOf = require("image-size");
// ipcRenderer.on("selected-directory", function(event, path) {
// console.log(path);
// const name = path[0].slice(path[0].lastIndexOf("/") + 1);
// console.log(name);
// });
// function domo(){
// ///////////////////////////////////
// ipcRenderer.on("selected-directory", function(event, path) {
// console.log(path);
// const name = path[0].slice(path[0].lastIndexOf("/") + 1);
// $(".typeForlder").append(' <div class="type">' + name + "</div>");
// console.log(name);
// var items = UI.getFileList(name);
// for (e in items) {
// $(".itemList").append(
// ' <div class="item"><img src="' +
// e.path +
// "/" +
// e.filename +
// '"/> </div>'
// );
// }
// // 遍历获取路径下的资源
// console.log(items);
// db.find({ objName: "folder" }, function(err, data) {
// console.log("查看全局文件夹");
// var forderValue = data[0].objValue;
// var firstTime = null;
// console.log(data[0], forderValue.hasOwnProperty(name));
// if (forderValue.hasOwnProperty(name)) {
// console.log("再次打开这个文件夹");
// firstTime = forderValue[name].firstTime;
// console.log(firstTime);
// }
// forderValue[name] = {
// firstTime: firstTime || Date.now(),
// lasrTime: Date.now(),
// items: items
// };
// console.log("新的值");
// forderValue = JSON.parse(JSON.stringify(forderValue)); // nedb 的bug 不能使用原对象需要 深拷贝
// console.log(forderValue);
// db.update(
// { objName: "folder" },
// { $set: { objValue: forderValue } },
// { multi: true },
// function(err, data) {
// console.log("更新的情况");
// console.log(data);
// db.find({ objName: "folder" }, function(err, data) {
// console.log(data[0]);
// });
// }
// );
// console.log(forderValue);
// });
// });
// }
// //////////////////////////////////
// function readFileList(path, filesList) {
// var files = fs.readdirSync(path);
// console.log(files);
// files.forEach(function(itm, index) {
// var stat = fs.statSync(path + "/" + itm);
// if (stat.isDirectory()) {
// readFileList(path + "/" + itm + "/", filesList);
// } else {
// var obj = {}; //定义一个对象存放文件的路径和名字
// obj.path = path; //路径
// obj.filename = itm; //名字
// var suffix = itm.substr(itm.length - 4).toLowerCase();
// if (
// suffix === ".png" ||
// suffix === ".png" ||
// suffix === ".ico" ||
// suffix === ".jpg"
// ) {
// var dimensions = sizeOf(obj.path + "/" + obj.filename);
// obj.width = dimensions.width;
// obj.height = dimensions.height;
// obj.type = "img";
// filesList.push(obj);
// }
// }
// });
// }