本文整理汇总了TypeScript中common/actions.actions.modalResponse方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.modalResponse方法的具体用法?TypeScript actions.modalResponse怎么用?TypeScript actions.modalResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.modalResponse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
client.on(messages.ExternalUploadsAreBad, async () => {
const modalRes = await promisedModal(
store,
modalWidgets.naked.make({
window: "root",
title: "Dragons be thar",
message:
"You've chosen to install an external upload. Those are supported poorly.",
detail:
"There's a chance it won't install at all.\n\nAlso, we won't be able to check for updates.",
bigButtons: [
{
label: "Install it anyway",
tags: [{ label: "Consequences be damned" }],
icon: "fire",
action: actions.modalResponse({}),
},
"nevermind",
],
widgetParams: null,
})
);
if (!modalRes) {
return { whatever: false };
}
// ahh damn.
return { whatever: true };
});
示例2: async
onError: async (e, log) => {
const response = await promisedModal(
store,
modals.showError.make({
wind: "root",
title: ["prompt.uninstall_error.title"],
message: ["prompt.uninstall_error.message"],
buttons: [
{
label: ["prompt.action.ok"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: { rawError: e, log },
})
);
if (!response) {
// modal was closed
return;
}
logger.info(`Should remove entry anyway, performing hard uninstall`);
try {
await mcall(messages.UninstallPerform, { caveId, hard: true });
store.dispatch(actions.uninstallEnded({}));
} catch (e) {
logger.error(`Well, even hard uninstall didn't work: ${e.stack}`);
}
},
示例3: async
client.on(messages.PrereqsFailed, async ({ errorStack, error }) => {
closePrereqsModal();
const { title } = game;
let errorMessage = error;
errorMessage = errorMessage.split("\n")[0];
let log = "(empty)\n";
if (logger.customOut && logger.customOut.toString) {
log = logger.customOut.toString();
}
const res = await promisedModal(
store,
modalWidgets.showError.make({
window: "root",
title: ["game.install.could_not_launch", { title }],
message: [
"game.install.could_not_launch.message",
{ title, errorMessage },
],
detail: ["game.install.could_not_launch.detail"],
widgetParams: {
game,
rawError: { stack: errorStack },
log,
},
buttons: [
{
label: ["prompt.action.continue"],
action: actions.modalResponse({
continue: true,
}),
},
"cancel",
],
})
);
if (res) {
return { continue: true };
}
return { continue: false };
});
示例4: async
watcher.on(actions.quit, async (store, action) => {
const { tasks } = store.getState().tasks;
let runningGameIds: number[] = [];
for (const taskId of Object.keys(tasks)) {
const task = tasks[taskId];
if (task.name === "launch") {
runningGameIds.push(task.gameId);
}
}
if (runningGameIds.length > 0) {
const res = await promisedModal(
store,
modals.confirmQuit.make({
wind: "root",
title: ["prompt.confirm_quit.title"],
message: ["prompt.confirm_quit.message"],
buttons: [
{
label: ["prompt.action.quit_and_close_all"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: {
gameIds: runningGameIds,
},
})
);
if (!res) {
store.dispatch(actions.cancelQuit({}));
return;
}
}
store.dispatch(actions.performQuit({}));
});
示例5: async
onError: async (e, log) => {
const response = await promisedModal(
store,
modalWidgets.showError.make({
window: "root",
title: ["prompt.uninstall_error.title"],
message: ["prompt.uninstall_error.message"],
buttons: [
{
label: ["prompt.action.ok"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: { rawError: e, log },
})
);
if (!response) {
// modal was closed
return;
}
},
示例6: async
async ({ params }) => {
const res = await promisedModal(
store,
modalWidgets.naked.make({
window: "root",
title: ["preferences.scan_install_locations.confirm_import"],
message: ["preferences.scan_install_locations.message"],
detail: names.map(n => ` * ${n}`).join("\n") + "\n",
widgetParams: null,
buttons: [
{
label: [
"preferences.scan_install_locations.import_items",
{ numItems: params.numItems },
],
icon: "install",
action: actions.modalResponse({}),
},
"cancel",
],
})
);
return { confirm: !!res };
}
示例7: async
convo.on(messages.AcceptLicense, async ({ text }) => {
const res = await promisedModal(
store,
modals.naked.make({
wind: "root",
title: ["prompt.sla.title"],
message: ["prompt.sla.message"],
detail: text,
widgetParams: {} as any,
buttons: [
{
label: ["prompt.sla.accept"],
action: actions.modalResponse({}),
},
"cancel",
],
})
);
if (res) {
return { accept: true };
}
return { accept: false };
});
示例8: async
watcher.on(actions.removeInstallLocation, async (store, action) => {
const { id } = action.payload;
const { installLocation } = await call(messages.InstallLocationsGetByID, {
id,
});
if (!installLocation) {
return;
}
if (installLocation.sizeInfo!.installedSize > 0) {
store.dispatch(
actions.openModal(
modalWidgets.naked.make({
window: "root",
title: ["prompt.install_location_not_empty.title"],
message: ["prompt.install_location_not_empty.message"],
detail: ["prompt.install_location_not_empty.detail"],
buttons: [
{
label: ["prompt.install_location_not_empty.show_contents"],
action: actions.navigateToInstallLocation({
window: "root",
installLocation,
}),
},
"cancel",
],
widgetParams: null,
})
)
);
return;
}
{
const res = await promisedModal(
store,
modalWidgets.naked.make({
window: "root",
title: ["prompt.install_location_remove.title"],
message: ["prompt.install_location_remove.message"],
detail: [
"prompt.install_location_remove.detail",
{
location: installLocation.path,
},
],
buttons: [
{
label: ["prompt.action.confirm_removal"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: null,
})
);
if (!res) {
// modal was closed
return;
}
await call(messages.InstallLocationsRemove, { id });
store.dispatch(actions.installLocationsChanged({}));
}
});
示例9: async
watcher.on(actions.removeInstallLocation, async (store, action) => {
const { id } = action.payload;
const { installLocations } = await mcall(messages.InstallLocationsList, {});
if (installLocations.length <= 1) {
// refuse to remove the last one
return;
}
const { installLocation } = await mcall(messages.InstallLocationsGetByID, {
id,
});
if (!installLocation) {
return;
}
{
const res = await promisedModal(
store,
modals.naked.make({
wind: "root",
title: ["prompt.install_location_remove.title"],
message: ["prompt.install_location_remove.message"],
detail: [
"prompt.install_location_remove.detail",
{
location: installLocation.path,
},
],
buttons: [
{
label: ["prompt.action.confirm_removal"],
action: actions.modalResponse({}),
},
"cancel",
],
widgetParams: null,
})
);
if (!res) {
// modal was closed
return;
}
const logger = recordingLogger(mainLogger);
try {
await mcall(messages.InstallLocationsRemove, { id }, convo => {
hookLogging(convo, logger);
});
store.dispatch(actions.installLocationsChanged({}));
} catch (e) {
store.dispatch(
actions.openModal(
modals.showError.make({
wind: "root",
title: _("prompt.show_error.generic_message"),
message: t(store.getState().i18n, formatError(e)),
widgetParams: {
rawError: e,
log: logger.getLog(),
forceDetails: true,
},
buttons: ["ok"],
})
)
);
}
}
});