mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-30 12:35:22 +08:00
This commit is contained in:
1 parent
eac5a659e6
commit
6b0332224f
10 files changed
+203
-22
No files matched your search
@@ -529,13 +529,20 @@ class NativeHost {
|
||||
}
|
||||
|
||||
async start(onFiles, onError) {
|
||||
this.bridge.on("ofdgo.files", values => onFiles(values.map(value => new NativeFile(value))));
|
||||
this.bridge.on("ofdgo.files", async values => {
|
||||
try { await onFiles(values.map(value => new NativeFile(value))); }
|
||||
catch (error) { onError(error); }
|
||||
});
|
||||
this.bridge.on("ofdgo.error", message => onError(new Error(message)));
|
||||
const title = document.querySelector("title");
|
||||
if (title) new MutationObserver(() => this.call("title", {title:document.title}).catch(onError)).observe(title, {childList:true});
|
||||
await this.call("ready", {});
|
||||
}
|
||||
|
||||
async discardFiles(files) {
|
||||
await Promise.all(files.filter(file => file.drop && file.nativeFile).map(file => this.call("drop.release", {file:file.nativeFile})));
|
||||
}
|
||||
|
||||
installFileInputs(onError) {
|
||||
document.addEventListener("click", async event => {
|
||||
const input = event.target;
|
||||
|
||||
Reference in new issue
Block a user