本文整理汇总了TypeScript中main/reactors/modals.promisedModal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript promisedModal函数的具体用法?TypeScript promisedModal怎么用?TypeScript promisedModal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了promisedModal函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
watcher.on(actions.clearBrowsingDataRequest, async (store, action) => {
const { wind } = action.payload;
const response = await promisedModal(
store,
modals.clearBrowsingData.make({
wind,
title: ["preferences.advanced.clear_browsing_data"],
message: "",
buttons: [
{
label: ["prompt.clear_browsing_data.clear"],
id: "modal-clear-data",
action: "widgetResponse",
},
"cancel",
],
widgetParams: {},
})
);
if (!response) {
// modal was closed
return;
}
store.dispatch(
actions.clearBrowsingData({
cache: response.cache,
cookies: response.cookies,
})
);
});
开发者ID:itchio,项目名称:itch,代码行数:32,代码来源:clear-browsing-data.ts
示例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}`);
}
},
开发者ID:itchio,项目名称:itch,代码行数:31,代码来源:queue-cave-uninstall.ts
示例3: pickManifestAction
export async function pickManifestAction(
store: Store,
manifestActions: Action[],
game: Game
): Promise<number> {
const buttons: ModalButtonSpec[] = [];
const bigButtons: ModalButtonSpec[] = [];
for (let index = 0; index < manifestActions.length; index++) {
const action = manifestActions[index];
if (!action.name) {
throw new Error(`in manifest, action ${index} is missing a name`);
}
const icon = action.icon || defaultManifestIcons[action.name] || "star";
bigButtons.push({
label: [`action.name.${action.name}`, { defaultValue: action.name }],
action: modals.pickManifestAction.action({ index }),
icon,
className: `action-${action.name}`,
});
}
buttons.push("cancel");
const response = await promisedModal(
store,
modals.pickManifestAction.make({
wind: "root",
title: game.title,
stillCoverUrl: game.stillCoverUrl,
coverUrl: game.coverUrl,
message: "",
bigButtons,
buttons,
widgetParams: {},
})
);
if (response) {
return response.index;
}
// as per butlerd spec, negative index means abort launch
return -1;
}
开发者ID:itchio,项目名称:itch,代码行数:47,代码来源:pick-manifest-action.ts
示例4: performInstallQueue
async function performInstallQueue({
store,
game,
uploadId,
}: PerformInstallQueueOpts) {
await promisedModal(
store,
modals.planInstall.make({
wind: "root",
title: game.title,
widgetParams: {
game,
uploadId,
},
buttons: [],
})
);
}
开发者ID:itchio,项目名称:itch,代码行数:18,代码来源:queue-game.ts
示例5: async
async ({ cave, upload, builds }) => {
const response = await promisedModal(
store,
modals.switchVersionCave.make({
wind: "root",
title: ["prompt.revert.title", { title: cave.game.title }],
message: "",
widgetParams: { cave, upload, builds },
buttons: ["cancel"],
})
);
if (!response) {
// modal was closed
return { index: -1 };
}
return { index: response.index };
}
开发者ID:itchio,项目名称:itch,代码行数:19,代码来源:switch-version-cave.ts
示例6: async
convo.on(messages.PrereqsFailed, async ({ errorStack, error }) => {
closePrereqsModal();
const { title } = game;
let errorMessage = error;
errorMessage = errorMessage.split("\n")[0];
let log = logger.getLog();
const res = await promisedModal(
store,
modals.showError.make({
wind: "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 };
});
开发者ID:itchio,项目名称:itch,代码行数:42,代码来源:perform-launch.ts
示例7: 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({}));
});
开发者ID:itchio,项目名称:itch,代码行数:38,代码来源:winds.ts
示例8: async
client.on(messages.ProfileRequestTOTP, async () => {
logger.info(`Showing TOTP`);
const modalRes = await promisedModal(
store,
modals.twoFactorInput.make({
wind: "root",
title: ["login.two_factor.title"],
message: "",
widgetParams: {
username,
},
})
);
if (modalRes) {
logger.info(`TOTP answered`);
return { code: modalRes.totpCode };
} else {
// abort
logger.info(`TOTP cancelled`);
return { code: null };
}
});
开发者ID:itchio,项目名称:itch,代码行数:23,代码来源:login.ts
注:本文中的main/reactors/modals.promisedModal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论