Qwe is born
This commit is contained in:
22
lib/platforms/browser.js
Normal file
22
lib/platforms/browser.js
Normal 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)
|
||||
}
|
||||
}
|
||||
33
lib/platforms/neutralino.js
Normal file
33
lib/platforms/neutralino.js
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user