Skip to content

Commit

Permalink
[add] 修增記憶檔案排序的功能
Browse files Browse the repository at this point in the history
[fix] 修復網路路徑內的檔案無法開啟的問題
  • Loading branch information
hbl917070 committed Feb 24, 2022
1 parent 262d805 commit c48a2ed
Show file tree
Hide file tree
Showing 14 changed files with 308 additions and 194 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tiefsee4
> Tiefsee是圖片檢視軟體。 4.0.0版全面改寫架構,程式UI界面全部以HTML、css、JavaScript渲染,可實現半透明視窗與AERO毛玻璃視窗。目前程式還在測試階段,功能尚未齊全到足以取代Tiefsee 3.0.2
目前版本:Tiefsee 4.0.0-beta.8
目前版本:Tiefsee 4.0.0-beta.9
[下載測試版](https://github.com/hbl917070/tiefsee4/releases)

- 專案類型:C# WinForm(net 4.8.0)
Expand Down
2 changes: 1 addition & 1 deletion Tiefsee/Tiefsee/QuickRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static bool Check(string[] args) {
//偵測是否可用
String uri = $"http://127.0.0.1:{port}/api/check";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Timeout = 30;
request.Timeout = 300;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
using (Stream stream = response.GetResponseStream()) {
/*using (StreamReader reader = new StreamReader(stream)) {
Expand Down
Binary file modified Tiefsee/Tiefsee/bin/output/Tiefsee.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions Tiefsee/Tiefsee/bin/output/www/js/BaseWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class BaseWindow {
_dropPath = decodeURIComponent(temp_dropPath);
if (_dropPath.indexOf("file:///") === 0) {
_dropPath = _dropPath.substr(8);
} else if (_dropPath.indexOf("file://") === 0) {
_dropPath = _dropPath.substr(5);
}
break;
}
Expand Down
3 changes: 3 additions & 0 deletions Tiefsee/Tiefsee/bin/output/www/js/Lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const _Lib = class {
console.log(hex);
return fileExt;
}
static pathToURL(path) {
return "file:///" + encodeURIComponent(path).replace(/[%]3A/g, ":").replace(/[%]2F/g, "/").replace(/[%]5C/g, "/");
}
};
let Lib = _Lib;
Lib.GetFileName = (path) => {
Expand Down
70 changes: 22 additions & 48 deletions Tiefsee/Tiefsee/bin/output/www/js/MainWindow/FileLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ class FileLoad {
constructor(M) {
var arWaitingFile = [];
var flag;
var sortType = FileSortType.name;
var groupType = "img";
var fileLoadType;
this.getArray = () => {
this.getWaitingFile = () => {
return arWaitingFile;
};
this.setWaitingFile = (ar) => {
arWaitingFile = ar;
};
this.getFlag = () => {
return flag;
};
this.setFlag = (n) => {
flag = n;
};
this.loadFile = loadFile;
this.loadFiles = loadFiles;
this.next = next;
Expand All @@ -38,13 +46,15 @@ class FileLoad {
this.getFileLoadType = getFileLoadType;
this.deleteMsg = deleteMsg;
this.renameMsg = renameMsg;
this.setSort = setSort;
this.updateTitle = updateTitle;
function loadFiles(_0) {
return __async(this, arguments, function* (dirPath, arName = []) {
fileLoadType = FileLoadType.userDefined;
arWaitingFile = yield WV_Directory.GetFiles2(dirPath, arName);
let path = arWaitingFile[0];
arWaitingFile = yield sort(sortType);
M.fileSort.sortType = M.fileSort.getFileSortType(dirPath);
M.fileSort.setFileSortMenu(M.fileSort.sortType);
arWaitingFile = yield M.fileSort.sort(arWaitingFile, M.fileSort.sortType);
flag = 0;
for (let i = 0; i < arWaitingFile.length; i++) {
if (arWaitingFile[i] == path) {
Expand All @@ -61,19 +71,23 @@ class FileLoad {
arWaitingFile = [];
if ((yield WV_Directory.Exists(path)) === true) {
arWaitingFile = yield WV_Directory.GetFiles(path, "*.*");
arWaitingFile = yield sort(sortType);
M.fileSort.sortType = M.fileSort.getFileSortType(path);
M.fileSort.setFileSortMenu(M.fileSort.sortType);
arWaitingFile = yield M.fileSort.sort(arWaitingFile, M.fileSort.sortType);
groupType = GroupType.img;
arWaitingFile = yield filter();
} else if ((yield WV_File.Exists(path)) === true) {
let p = yield WV_Path.GetDirectoryName(path);
arWaitingFile = yield WV_Directory.GetFiles(p, "*.*");
let dirPath = yield WV_Path.GetDirectoryName(path);
arWaitingFile = yield WV_Directory.GetFiles(dirPath, "*.*");
let fileInfo2 = yield Lib.GetFileInfo2(path);
groupType = fileToGroupType(fileInfo2);
arWaitingFile = yield filter();
if (arWaitingFile.indexOf(path) === -1) {
arWaitingFile.splice(0, 0, path);
}
arWaitingFile = yield sort(sortType);
M.fileSort.sortType = M.fileSort.getFileSortType(dirPath);
M.fileSort.setFileSortMenu(M.fileSort.sortType);
arWaitingFile = yield M.fileSort.sort(arWaitingFile, M.fileSort.sortType);
}
flag = 0;
for (let i = 0; i < arWaitingFile.length; i++) {
Expand Down Expand Up @@ -206,23 +220,6 @@ class FileLoad {
return ar;
});
}
function sort(_type) {
return __async(this, null, function* () {
if (_type === FileSortType.name) {
return yield WV_System.Sort(arWaitingFile, "name");
}
if (_type === FileSortType.nameDesc) {
return yield WV_System.Sort(arWaitingFile, "nameDesc");
}
if (_type === FileSortType.lastWriteTime) {
return yield WV_System.Sort(arWaitingFile, "lastWriteTime");
}
if (_type === FileSortType.lastWriteTimeDesc) {
return yield WV_System.Sort(arWaitingFile, "lastWriteTimeDesc");
}
return [];
});
}
function deleteMsg() {
return __async(this, null, function* () {
let path = getFilePath();
Expand Down Expand Up @@ -287,33 +284,10 @@ class FileLoad {
msg.domInput.setSelectionRange(0, len);
});
}
function setSort(type) {
return __async(this, null, function* () {
sortType = type;
let path = getFilePath();
let ar = yield sort(sortType);
flag = 0;
for (let i = 0; i < ar.length; i++) {
if (ar[i] == path) {
flag = i;
break;
}
}
arWaitingFile = ar;
updateTitle();
});
}
}
}
var FileLoadType = /* @__PURE__ */ ((FileLoadType2) => {
FileLoadType2[FileLoadType2["dir"] = 0] = "dir";
FileLoadType2[FileLoadType2["userDefined"] = 1] = "userDefined";
return FileLoadType2;
})(FileLoadType || {});
var FileSortType = /* @__PURE__ */ ((FileSortType2) => {
FileSortType2[FileSortType2["name"] = 0] = "name";
FileSortType2[FileSortType2["nameDesc"] = 1] = "nameDesc";
FileSortType2[FileSortType2["lastWriteTime"] = 2] = "lastWriteTime";
FileSortType2[FileSortType2["lastWriteTimeDesc"] = 3] = "lastWriteTimeDesc";
return FileSortType2;
})(FileSortType || {});
2 changes: 1 addition & 1 deletion Tiefsee/Tiefsee/bin/output/www/js/MainWindow/FileShow.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FileShow {
if (M.fileLoad.getGroupType() === GroupType.unknown) {
imgurl = yield WV_Image.GetFileIcon(_path, 256);
} else {
imgurl = _path + `?LastWriteTimeUtc=${fileInfo2.LastWriteTimeUtc}`;
imgurl = Lib.pathToURL(_path) + `?LastWriteTimeUtc=${fileInfo2.LastWriteTimeUtc}`;
}
tieefseeview.setLoading(true);
yield tieefseeview.preload(imgurl);
Expand Down
95 changes: 78 additions & 17 deletions Tiefsee/Tiefsee/bin/output/www/js/MainWindow/FileSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,111 @@ class FileSort {
this.dom_dirSort_lastWriteTime = document.getElementById("menuitem-dirSort-lastWriteTime");
this.dom_dirSort_lastWriteTimeDesc = document.getElementById("menuitem-dirSort-lastWriteTimeDesc");
this.yesSvgTxt = "";
this.defaultFileSort = FileSortType.name;
this.defaultDirSort = FileSortType.name;
this.sortType = FileSortType.name;
this.M = _M;
this.init();
}
init() {
return __async(this, null, function* () {
this.yesSvgTxt = SvgList["yes.svg"];
this.dom_fileSort_name.addEventListener("click", () => {
this.setFileSortMenu(FileSortType.name);
this.updateSort(FileSortType.name);
});
this.dom_fileSort_nameDesc.addEventListener("click", () => {
this.setFileSortMenu(FileSortType.nameDesc);
this.updateSort(FileSortType.nameDesc);
});
this.dom_fileSort_lastWriteTime.addEventListener("click", () => {
this.setFileSortMenu(FileSortType.lastWriteTime);
this.updateSort(FileSortType.lastWriteTime);
});
this.dom_fileSort_lastWriteTimeDesc.addEventListener("click", () => {
this.setFileSortMenu(FileSortType.lastWriteTimeDesc);
this.updateSort(FileSortType.lastWriteTimeDesc);
});
});
}
setFileSortMenu(_type) {
updateSort(_sortType) {
return __async(this, null, function* () {
this.sortType = _sortType;
let path = this.M.fileLoad.getFilePath();
let dirPath = yield WV_Path.GetDirectoryName(path);
this.setFileSortType(dirPath, this.sortType);
let ar = yield this.sort(this.M.fileLoad.getWaitingFile(), this.sortType);
this.M.fileLoad.setFlag(0);
for (let i = 0; i < ar.length; i++) {
if (ar[i] == path) {
this.M.fileLoad.setFlag(i);
break;
}
}
this.M.fileLoad.setWaitingFile(ar);
this.M.fileLoad.updateTitle();
this.setFileSortMenu(_sortType);
});
}
setFileSortMenu(_sortType) {
this.dom_fileSort_name.getElementsByClassName("menu-hor-icon")[0].innerHTML = "";
this.dom_fileSort_nameDesc.getElementsByClassName("menu-hor-icon")[0].innerHTML = "";
this.dom_fileSort_lastWriteTime.getElementsByClassName("menu-hor-icon")[0].innerHTML = "";
this.dom_fileSort_lastWriteTimeDesc.getElementsByClassName("menu-hor-icon")[0].innerHTML = "";
if (_type === FileSortType.name) {
if (_sortType === FileSortType.name) {
this.dom_fileSort_name.getElementsByClassName("menu-hor-icon")[0].innerHTML = this.yesSvgTxt;
this.M.fileLoad.setSort(FileSortType.name);
this.M.menu.close();
}
if (_type === FileSortType.nameDesc) {
if (_sortType === FileSortType.nameDesc) {
this.dom_fileSort_nameDesc.getElementsByClassName("menu-hor-icon")[0].innerHTML = this.yesSvgTxt;
this.M.fileLoad.setSort(FileSortType.nameDesc);
this.M.menu.close();
}
if (_type === FileSortType.lastWriteTime) {
if (_sortType === FileSortType.lastWriteTime) {
this.dom_fileSort_lastWriteTime.getElementsByClassName("menu-hor-icon")[0].innerHTML = this.yesSvgTxt;
this.M.fileLoad.setSort(FileSortType.lastWriteTime);
this.M.menu.close();
}
if (_type === FileSortType.lastWriteTimeDesc) {
if (_sortType === FileSortType.lastWriteTimeDesc) {
this.dom_fileSort_lastWriteTimeDesc.getElementsByClassName("menu-hor-icon")[0].innerHTML = this.yesSvgTxt;
this.M.fileLoad.setSort(FileSortType.lastWriteTimeDesc);
this.M.menu.close();
}
this.M.menu.close();
}
sort(arWaitingFile, _type) {
return __async(this, null, function* () {
if (_type === FileSortType.name) {
return yield WV_System.Sort(arWaitingFile, "name");
}
if (_type === FileSortType.nameDesc) {
return yield WV_System.Sort(arWaitingFile, "nameDesc");
}
if (_type === FileSortType.lastWriteTime) {
return yield WV_System.Sort(arWaitingFile, "lastWriteTime");
}
if (_type === FileSortType.lastWriteTimeDesc) {
return yield WV_System.Sort(arWaitingFile, "lastWriteTimeDesc");
}
return [];
});
}
setFileSortType(dirPath, _sortType) {
let t = window.localStorage.getItem("sortFile");
let json = {};
if (t !== null) {
json = JSON.parse(t);
}
json[dirPath] = _sortType;
window.localStorage.setItem("sortFile", JSON.stringify(json));
console.log(`\u8A2D\u5B9A\uFF1A${dirPath} + ${_sortType}`);
}
getFileSortType(dirPath) {
let t = window.localStorage.getItem("sortFile");
if (t === null) {
t = "{}";
}
let json = JSON.parse(t);
let _sortType = json[dirPath];
if (_sortType !== void 0) {
return _sortType;
} else {
return this.defaultFileSort;
}
}
}
var FileSortType = {
name: "name",
nameDesc: "nameDesc",
lastWriteTime: "lastWriteTime",
lastWriteTimeDesc: "lastWriteTimeDesc"
};
7 changes: 4 additions & 3 deletions Tiefsee/Tiefsee/bin/output/www/ts/BaseWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ class BaseWindow {
let _dropPath: string = "";
for (let i = 0; i < 100; i++) {


if (temp_dropPath !== "") {
_dropPath = temp_dropPath;
_dropPath = decodeURIComponent(temp_dropPath)
if (_dropPath.indexOf("file:///") === 0) {
if (_dropPath.indexOf("file:///") === 0) {//一般檔案
_dropPath = _dropPath.substr(8);
}
} else if (_dropPath.indexOf("file://") === 0) {//網路路徑,例如 \\Desktop-abc\AA
_dropPath = _dropPath.substr(5);
}
break;
}
await sleep(10);
Expand Down
13 changes: 13 additions & 0 deletions Tiefsee/Tiefsee/bin/output/www/ts/Lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ class Lib {
return fileExt;
}


/**
* 路徑 轉 URL
* @param path
* @returns
*/
public static pathToURL(path: string): string {
return "file:///" + encodeURIComponent(path)
.replace(/[%]3A/g, ":")
.replace(/[%]2F/g, "/")
.replace(/[%]5C/g, "/");
}

}


Expand Down
Loading

0 comments on commit c48a2ed

Please sign in to comment.