javascript - microsoft office javascript API中messageRead和messageWrite模式的逻辑?
问题描述
目前正在开发基于 JavaScript 的 Outlook 插件。加载项启动时,我想以读写模式打开不同的对话框。
如何检查加载项是否处于消息读取或写入模式?
清单.xml
<!-- Message Read -->
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
<OfficeTab id="TabDefault">
<!-- Up to 6 Groups added per Tab -->
<Group id="msgReadGroup">
<Label resid="groupLabel" />
<!-- Launch the add-in : task pane button -->
<Control xsi:type="Button" id="msgReadOpenPaneButton">
<Label resid="paneReadButtonLabel" />
<Supertip>
<Title resid="paneReadSuperTipTitle" />
<Description resid="paneReadSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16" />
<bt:Image size="32" resid="icon32" />
<bt:Image size="80" resid="icon80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="messageReadTaskPaneUrl" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
<!-- Message Compose -->
<ExtensionPoint xsi:type="MessageComposeCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgComposeCmdGroup">
<Label resid="groupLabel"/>
<Control xsi:type="Button" id="msgComposeIndex">
<Label resid="indexLabel"/>
<Supertip>
<Title resid="indexTitle"/>
<Description resid="insertGistDesc"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16"/>
<bt:Image size="32" resid="icon32"/>
<bt:Image size="80" resid="icon80"/>
<bt:Image size="80" resid="paksign"/>
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="index-file" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
解决方案
我们建议使用不同的 SourceLocation URL,或在 URL 中添加查询参数,以区分不同的模式(即...index.html?mode=MessageRead
)。
在您的示例清单中,这意味着对messageReadTaskPaneUrl
和index-file
URL 使用不同的 URL 或查询参数。
虽然可以检查是否定义了 API 来尝试确定模式,但我们不建议这样做,因为将来可能会添加 API。例如,Office.context.mailbox.item.from
最初仅在 API 要求集 1.0(和undefined
Compose 模式)中以读取模式定义。但是当在需求集 1.7Office.context.mailbox.item.from.getAsync
中添加到 Compose 模式时,情况发生了变化。
推荐阅读
- arrays - 为什么这个程序不遵循矩阵规则?
- data-science - 如何在测试集上估算缺失值?
- swift - 一起使用 queryEqual 和 queryEnding?
- python - 来自 URL 的 Python Socket GET 请求格式不正确?
- python - 如何将非线性 cmap 围绕 RdYlGn 居中?
- apache-spark - K8s 上的 Spark:执行程序节点永远挂起
- java - Quarkus Qute 无法解析模板
- javascript - 在 Sequelize-CLI 中仅恢复两个迁移之一?
- java - 在两个活动之间划分片段是否更好,比如在 MainActivity 和另一个活动之间:(性能)?
- c++ - 当我将一个指针分配给另一个指针时会发生什么?