对话逻辑在办公室javascript API中关闭。 (Outlook加载项)

问题描述 投票:0回答:1

如何检查Outlook加载项中是否关闭了对话框?

关闭对话框后,我想清除浏览器的localstorage。

我正在使用Office.context.ui.displayDialogAsync来进行对话。

outlook office-js outlook-web-addins
1个回答
2
投票

在创建对话框时,需要获取对话框句柄,并添加一个对话框关闭的事件监听器:

export async function displayDialogAsync (dialogUrl: string): Promise<void> {
    return new Promise<void>(resolve => {

        const dialogClosed = async (_: any): Promise<void> => {
            // do whatever you need when the dialog is closed  
            resolve();
        };


        Office.context.ui.displayDialogAsync(url, dialogOptions, (result: Office.AsyncResult) => {
            dialog = result.value;
            dialog.addEventHandler(Office.EventType.DialogEventReceived, dialogClosed);
        });
    });
}
© www.soinside.com 2019 - 2024. All rights reserved.