Fix finder context menu in desktop mode and add error on link giletype

This commit is contained in:
cyber-dream 2023-05-11 04:56:56 +03:00
parent 8facac5d19
commit 1b3f17777e

View File

@ -153,9 +153,12 @@ class FinderWindow{
const html = await response.text()
args[2].innerHTML = html
this.fileView = new FileView(args[2].querySelector(".FileTileView"), (event) =>{
this.Click(event, true)
})
this.fileView = new FileView(
args[2].querySelector(".FileTileView"), (event) =>{this.Click(event)},
(event) => { this.RightClick(event) },
(event, draggedElem) => { this.DropEvent(event, draggedElem)},
() => { this.ReRenderDir() }
)
this.RenderDir(args[0])
return
}
@ -170,7 +173,6 @@ class FinderWindow{
let newWindow = WebDesktopEnvironment.CreateNewWindow(Finder.appId, 500, 350 )
newWindow.innerHTML = html
// console.log(this.ReRenderDir)
this.fileView = new FileView(
newWindow.querySelector(".FileTileView"),
(event) => { this.Click(event) },
@ -257,22 +259,24 @@ class FinderWindow{
Click(event){
let fileType = event.target.getAttribute("fileType")
let fileName = event.target.getAttribute("name")
const fileExtension = fileName.split(".")[fileName.split(".").length - 1] //FIXME
switch (fileType) {
case "directory":
if (fileExtension == "app"){
WebDesktopEnvironment.Open(`${this.CurPath}/${fileName}`, [])
} else{
WebDesktopEnvironment.Open(`/Applications/Finder.app`, [`${this.CurPath}/${fileName}`])
}
switch (true) {
case fileType == "objectlink":
WebDesktopEnvironment.Alert("Links not supported yet")
break
case "blog":
case fileType == "directory":
WebDesktopEnvironment.Open(`/Applications/Finder.app`, [`${this.CurPath}/${fileName}`])
break
case fileExtension == "blog":
WebDesktopEnvironment.Open("/Applications/BlogViewer.app", [`${this.CurPath}/${fileName}`])
break
case "jpeg":
case "png":
case fileExtension == "jpeg" | fileExtension == "png":
WebDesktopEnvironment.Open("img-viewer", [this.CurPath + "/" + fileName])
break;
case fileExtension == "app":
WebDesktopEnvironment.Open(`${this.CurPath}/${fileName}`, [])
break
default:
// console.log("Unsupported file type")
WebDesktopEnvironment.Alert("Unsupported file type")