mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Add UI api
This commit is contained in:
@@ -498,6 +498,7 @@ let Network = {
|
||||
* @param url {string}
|
||||
* @param options {{method: string, headers: Object, body: any}}
|
||||
* @returns {Promise<{ok: boolean, status: number, statusText: string, headers: {}, arrayBuffer: (function(): Promise<ArrayBuffer>), text: (function(): Promise<string>), json: (function(): Promise<any>)}>}
|
||||
* @since 1.2.0
|
||||
*/
|
||||
async function fetch(url, options) {
|
||||
let method = 'GET';
|
||||
@@ -1203,3 +1204,45 @@ class Image {
|
||||
return new Image(key);
|
||||
}
|
||||
}
|
||||
|
||||
let UI = {
|
||||
/**
|
||||
* Show a message
|
||||
* @param message {string}
|
||||
*/
|
||||
showMessage: (message) => {
|
||||
sendMessage({
|
||||
method: 'UI',
|
||||
function: 'showMessage',
|
||||
message: message,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a dialog. Any action will close the dialog.
|
||||
* @param title {string}
|
||||
* @param content {string}
|
||||
* @param actions {{text:string, callback: () => void}[]}
|
||||
*/
|
||||
showDialog: (title, content, actions) => {
|
||||
sendMessage({
|
||||
method: 'UI',
|
||||
function: 'showDialog',
|
||||
title: title,
|
||||
content: content,
|
||||
actions: actions,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Open [url] in external browser
|
||||
* @param url {string}
|
||||
*/
|
||||
launchUrl: (url) => {
|
||||
sendMessage({
|
||||
method: 'UI',
|
||||
function: 'launchUrl',
|
||||
url: url,
|
||||
})
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user