Qwe is born

This commit is contained in:
2023-12-24 22:49:54 -05:00
parent 4879f5a7cf
commit eb0077c849
20 changed files with 512 additions and 354 deletions

22
lib/platforms/browser.js Normal file
View File

@@ -0,0 +1,22 @@
function Platform() {
this.save = async (path, data) => {
localStorage.setItem(path, data)
}
this.open = (path) => {
return localStorage.getItem(path)
}
this.readdir = (path) => {
return Object.keys(localStorage)
.filter(key => key.startsWith(path))
}
this.createWindow = url => {
return window.open(url ?? 'about:blank', '_blank')
}
this.createInstance = url => {
return window.open(url ?? this.location)
}
}

View File

@@ -0,0 +1,33 @@
export default {
async access(path) {
try {
await Neutralino.filesystem.getStats(path)
return
} catch(err) {
if(err.name = 'NE_FS_NOPATHE') {
return false
} else {
throw err
}
}
},
dirname(path) {
let index = path.lastIndexOf('/')
return index === -1 ? '' : path.slice(0, index)
},
filename(path) {
let index = path.lastIndexOf('/')
return index === -1 ? path : path.slice(index + 1)
},
ext(path) {
let filename = this.filename(path)
let index = filename.lastIndexOf('.')
return index === -1 ? '' : path.slice(index + 1)
}
}