Autostart list from backend
This commit is contained in:
parent
a921646f4c
commit
e6138cba1e
@ -40,26 +40,32 @@ class FinderWindow{
|
||||
fileView = undefined
|
||||
windowElem = undefined
|
||||
|
||||
async Init(args, runContext){
|
||||
if (args[1] === "-desktop"){
|
||||
//todo pass div id, not div in args[]
|
||||
async Init(args, appContext){
|
||||
if (args[1] == "--desktop"){
|
||||
let desktopNode = document.body.querySelector(`#${args[2]}`)
|
||||
if (desktopNode == null){
|
||||
WebDesktopEnvironment.Alert("Desktop node not found")
|
||||
return
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({
|
||||
isMobile: WebDesktopEnvironment.isMobile,
|
||||
path: args[0]
|
||||
})
|
||||
const response = await fetch(`/app/${Finder.AppId}/renderDesktop?` + params,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify(runContext)
|
||||
body: JSON.stringify(appContext)
|
||||
})
|
||||
if (response.status != 200){
|
||||
console.log(response.status)
|
||||
WebDesktopEnvironment.Alert("Error in render desktop") //TODO
|
||||
return
|
||||
}
|
||||
const html = await response.text()
|
||||
args[2].innerHTML = html
|
||||
desktopNode.innerHTML = html
|
||||
|
||||
this.fileView = new FileView(
|
||||
args[2].querySelector(".FileTileView"), (event) =>{this.Click(event)},
|
||||
desktopNode.querySelector(".FileTileView"), (event) =>{this.Click(event)},
|
||||
(event) => { this.RightClick(event) },
|
||||
(event, draggedElem) => { this.DropEvent(event, draggedElem)},
|
||||
() => { this.ReRenderDir() }
|
||||
@ -71,7 +77,7 @@ class FinderWindow{
|
||||
const response = await fetch(`/app/${Finder.AppId}/render?` + params,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify(runContext)
|
||||
body: JSON.stringify(appContext)
|
||||
})
|
||||
if (response.status != 200){
|
||||
const error = await response.json()
|
||||
|
@ -34,9 +34,35 @@ class WebDesktopEnvironment{
|
||||
}
|
||||
|
||||
async loadWDE(){
|
||||
let autoStart = document.body.querySelector("wde-autostart")
|
||||
if (autoStart == null){
|
||||
WebDesktopEnvironment.Alert("Error in loading DE")
|
||||
return
|
||||
}
|
||||
for (const child of autoStart.children) {
|
||||
if (child.nodeName != "APP") continue
|
||||
let appPath = child.getAttribute("app-path")
|
||||
if (appPath == null) continue
|
||||
|
||||
let args = []
|
||||
let argsRaw = child.querySelector("args")
|
||||
if (argsRaw == null) continue
|
||||
|
||||
for (const argRaw of argsRaw.children) {
|
||||
let arg = argRaw.getAttribute("string")
|
||||
if (arg == null) continue
|
||||
args.push(arg)
|
||||
}
|
||||
|
||||
// console.log(appPath, args)
|
||||
await WebDesktopEnvironment.Open(appPath, args)
|
||||
}
|
||||
|
||||
autoStart.remove()
|
||||
|
||||
// await WebDesktopEnvironment.load2('/Applications/Finder.app', [ "desktop", document.querySelector('#desktop-layer')]) //FIXME
|
||||
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/.desktop", "-desktop", document.querySelector('#desktop-layer')])
|
||||
await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/Blogs",])
|
||||
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/Blogs",])
|
||||
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user",])
|
||||
// await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home",])
|
||||
// WebDesktopEnvironment.Open('/Applications/AboutMe.app', [])
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/errormessage"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/routewde"
|
||||
"personalwebsite/wde"
|
||||
"personalwebsite/webfilesystem"
|
||||
"time"
|
||||
@ -54,7 +53,7 @@ func PrivateRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.W
|
||||
|
||||
wdeGroup := systemGroup.Group("wde")
|
||||
{
|
||||
routewde.PublicRoutes(wdeGroup, webde)
|
||||
wde.PublicRoutes(wdeGroup, webde)
|
||||
}
|
||||
|
||||
fsGroup := systemGroup.Group("fs")
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"path"
|
||||
"personalwebsite/apps"
|
||||
"personalwebsite/libs"
|
||||
"personalwebsite/routewde"
|
||||
|
||||
"personalwebsite/wde"
|
||||
"personalwebsite/webfilesystem"
|
||||
|
||||
@ -45,7 +45,7 @@ func PublicRoutes(port string, webfs *webfilesystem.WebFileSystem, webde *wde.WD
|
||||
|
||||
wdeGroup := systemGroup.Group("wde")
|
||||
{
|
||||
routewde.PublicRoutes(wdeGroup, webde)
|
||||
wde.PublicRoutes(wdeGroup, webde)
|
||||
}
|
||||
|
||||
systemGroup.GET("/loadApp", func(ctx *gin.Context) {
|
||||
|
@ -1,14 +1,13 @@
|
||||
package routewde
|
||||
package wde
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"personalwebsite/wde"
|
||||
|
||||
"github.com/gin-contrib/location"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func PublicRoutes(route *gin.RouterGroup, wde *wde.WDE) {
|
||||
func PublicRoutes(route *gin.RouterGroup, wde *WDE) {
|
||||
route.GET("/getbasicwindow", func(ctx *gin.Context) { //TODO Rename to renderGenericWindowFrame
|
||||
ctx.HTML(http.StatusOK, "basic-window.html", nil)
|
||||
})
|
Loading…
Reference in New Issue
Block a user