minor improvement on GUI API

This commit is contained in:
lxsang 2021-03-15 11:01:57 +01:00
parent de5878c349
commit 9a12e9176f
3 changed files with 58 additions and 43 deletions

View File

@ -317,7 +317,8 @@ namespace OS {
return; return;
} }
if (it.type === "app" && it.app) { if (it.type === "app" && it.app) {
return launch(it.app, []); launch(it.app, []);
return;
} }
if (it.type === "app") { if (it.type === "app") {
return announcer.osinfo( return announcer.osinfo(
@ -331,7 +332,8 @@ namespace OS {
); );
} }
if (apps.length === 1) { if (apps.length === 1) {
return launch(apps[0].app, [it]); launch(apps[0].app, [it]);
return;
} }
const list = apps.map((e) => ({ const list = apps.map((e) => ({
text: e.app, text: e.app,
@ -364,7 +366,7 @@ namespace OS {
"This method is used for developing only, please use the launch method instead" "This method is used for developing only, please use the launch method instead"
); );
unloadApp(app); unloadApp(app);
return launch(app, args); launch(app, args);
} }
/** /**
@ -529,32 +531,37 @@ namespace OS {
* @param {string} app application class name * @param {string} app application class name
* @param {AppArgumentsType[]} args application arguments * @param {AppArgumentsType[]} args application arguments
*/ */
export function launch(app: string, args: AppArgumentsType[]): void { export function launch(app: string, args: AppArgumentsType[]): Promise<OS.PM.ProcessType> {
return new Promise((resolve, reject) => {
if (!application[app]) { if (!application[app]) {
// first load it // first load it
loadApp(app) loadApp(app)
.then((a) => .then((a) => {
{ if (!application[app]) {
if (!application[app]){ const e = API.throwe(__("Application not found"));
return announcer.oserror( announcer.oserror(
__("{0} is not an application", app), __("{0} is not an application", app),
API.throwe(__("Application not found")) e);
); return reject(e);
} }
PM.createProcess( PM.createProcess(
app, app,
application[app], application[app],
args args
).catch((e) => ).catch((e) => {
announcer.osfail( announcer.osfail(
__("Unable to launch: {0}", app), __("Unable to launch: {0}", app),
e e
) );
) return reject(e);
}
).then((p: PM.ProcessType) => resolve(p));
} }
) )
.catch((e) => .catch((e) => {
announcer.osfail(__("Unable to launch: {0}", app), e) announcer.osfail(__("Unable to launch: {0}", app), e);
reject(e);
}
); );
} else { } else {
// now launch it // now launch it
@ -563,16 +570,22 @@ namespace OS {
app, app,
application[app], application[app],
args args
).catch((e: Error) => ).catch((e: Error) => {
announcer.osfail(__("Unable to launch: {0}", app), e) announcer.osfail(__("Unable to launch: {0}", app), e);
return reject(e);
}
); );
} else { } else {
const e = API.throwe(__("Application not found"));
announcer.osfail( announcer.osfail(
__("Unable to find: {0}", app), __("Unable to find: {0}", app),
API.throwe("Application not found") e
); );
return reject(e);
} }
} }
});
} }
/** /**
@ -703,7 +716,7 @@ namespace OS {
var handle = function (e: HTMLElement) { var handle = function (e: HTMLElement) {
if (e.contextmenuHandle) { if (e.contextmenuHandle) {
const m = $("#contextmenu")[0] as tag.MenuTag; const m = $("#contextmenu")[0] as tag.MenuTag;
m.onmenuselect = () => {}; m.onmenuselect = () => { };
return e.contextmenuHandle(event, m); return e.contextmenuHandle(event, m);
} else { } else {
const p = $(e).parent().get(0); const p = $(e).parent().get(0);
@ -747,7 +760,7 @@ namespace OS {
fnk += "SHIFT"; fnk += "SHIFT";
} }
if ( fnk == "") { if (fnk == "") {
return; return;
} }
fnk = `fn_${fnk.hash()}`; fnk = `fn_${fnk.hash()}`;
@ -908,7 +921,7 @@ namespace OS {
fnk += "SHIFT"; fnk += "SHIFT";
} }
if ( fnk == "") { if (fnk == "") {
return; return;
} }
fnk = `fn_${fnk.hash()}`; fnk = `fn_${fnk.hash()}`;

2
src/libs/jquery-3.6.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -140,7 +140,7 @@ namespace OS {
* @memberof PushNotification * @memberof PushNotification
*/ */
private showLogReport(): void { private showLogReport(): void {
return this._gui.launch("Syslog", []); this._gui.launch("Syslog", []);
} }
/** /**