我正在尝试使用Dialog API从加载项中调用其他域URL。
它在Word Online中运行良好,但在Word桌面中却出现错误:“域不受信任”。
我已将域添加到清单中的AppDomains
数组,但我仍然收到此错误:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<!-- BeginBasicSettings: Add-in metadata, used for all versions of Office unless override provided -->
<!--IMPORTANT! Id must be unique for your add-in, if you clone this manifest ensure that you change this id to your own GUID -->
<Id>28da4ead-1448-449a-aa31-c08193eca9c2</Id>
<!--Version. Updates from the store only get triggered if there is a version change -->
<Version>1.0.0.0</Version>
<ProviderName>Acrowit, Inc. DBA WittyParrot</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various placed of the Office UI such as the add-ins dialog -->
<DisplayName DefaultValue="P365-DEV" />
<Description DefaultValue="P365-DEV"/>
<!--Icon for your add-in. Used on installation screens and the add-ins dialog -->
<IconUrl DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_32px.png" />
<HighResolutionIconUrl DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_128px.png" />
<SupportUrl DefaultValue="http://support.parrot365.com/support/home" />
<!--BeginTaskpaneMode integration. Office 2013 and any client that doesn't understand commands will use this section.
This section will also be used if there are no VersionOverrides -->
<Hosts>
<Host Name="Document" />
</Hosts>
<AppDomains>
<AppDomain>https://dev2.wittyparrot.com:3001</AppDomain>
</AppDomains>
<DefaultSettings>
<SourceLocation DefaultValue="https://p365.wittyparrot.com:3000?source=msoffice" />
</DefaultSettings>
<!--EndTaskpaneMode integration -->
<Permissions>ReadWriteDocument</Permissions>
<!--BeginAddinCommandsMode integration-->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<!-- Optional, override the description of the Add-in -->
<Description resid="residToolTip" />
<!--Required, hosts node. Each host can have a different set of commands -->
<Hosts>
<!--Specific host. Workbook=Excel, Document=Word, Presentation=PowerPoint -->
<Host xsi:type="Document">
<!-- Form factor. Currenly only DesktopFormFactor is supported. We will add TabletFormFactor and PhoneFormFactor in the future-->
<DesktopFormFactor>
<!--GetStarted information used on the callout that appears when installing the add-in.
Ensure you have build 16.0.6769 or above for GetStarted section to work-->
<GetStarted>
<!--Title of the Getting Started callout. resid points to a ShortString resource -->
<Title resid="Witty.GetStarted.Title"/>
<!--Description of the Getting Started callout. resid points to a LongString resource -->
<Description resid="Witty.GetStarted.Description"/>
<!--Not used right now but you need to provide a valid resource. We will add code in the future to consume this URL.
resid points to a Url resource -->
<LearnMoreUrl resid="Witty.GetStarted.LearnMoreUrl"/>
</GetStarted>
<FunctionFile resid="residDesktopFuncUrl" />
<!--PrimaryCommandSurface==Main Office Ribbon-->
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<OfficeTab id="TabHome">
<!--Group. Ensure you provide a unique id. Recommendation for any IDs is to namespace using your companyname-->
<Group id="Witty.Citations.Group1Id1">
<!--Label for your group. resid must point to a ShortString resource -->
<Label resid="residLabel4" />
<!--Icons. Required sizes 16,31,80, optional 20, 24, 40, 48, 64. Strongly recommended to provide all sizes for great UX -->
<!--Use PNG icons and remember that all URLs on the resources section must use HTTPS -->
<Icon>
<bt:Image size="16" resid="icon1_16x16" />
<bt:Image size="32" resid="icon1_32x32" />
<bt:Image size="80" resid="icon1_80x80" />
</Icon>
<!--Control. It can be of type "Button" or "Menu" -->
<Control xsi:type="Button" id="Button3Id1">
<!--Label for your button. resid must point to a ShortString resource -->
<Label resid="residLabel3" />
<Supertip>
<!--ToolTip title. resid must point to a ShortString resource -->
<Title resid="residLabel" />
<!--ToolTip description. resid must point to a LongString resource -->
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon1_16x16" />
<bt:Image size="32" resid="icon3_32x32" />
<bt:Image size="80" resid="icon1_80x80" />
</Icon>
<!--This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFuncion or ShowTaskpane-->
<Action xsi:type="ShowTaskpane">
<!--Provide a url resource id for the location that will be displayed on the taskpane -->
<SourceLocation resid="residUnitConverterUrl" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="icon1_16x16" DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_16px.png">
</bt:Image>
<bt:Image id="icon1_32x32" DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_32px.png">
</bt:Image>
<bt:Image id="icon1_80x80" DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_80px.png">
</bt:Image>
<bt:Image id="icon2_32x32" DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_32px.png">
</bt:Image>
<bt:Image id="icon3_32x32" DefaultValue="https://p365.wittyparrot.com:3000/resources/assets/images/parrot365/word_icons/p365_word_32px.png">
</bt:Image>
</bt:Images>
<bt:Urls>
<bt:Url id="residDesktopFuncUrl" DefaultValue="https://p365.wittyparrot.com:3000?source=msoffice">
</bt:Url>
<bt:Url id="residUnitConverterUrl" DefaultValue="https://p365.wittyparrot.com:3000?source=msoffice">
</bt:Url>
<!--LearnMore URL currently not used -->
<bt:Url id="Witty.GetStarted.LearnMoreUrl" DefaultValue="https://p365.wittyparrot.com:3000">
</bt:Url>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="residLabel" DefaultValue="Launch Widget">
</bt:String>
<bt:String id="residLabel3" DefaultValue="Parrot365">
</bt:String>
<bt:String id="residLabel4" DefaultValue=" ">
</bt:String>
<bt:String id="Witty.GetStarted.Title" DefaultValue="Parrot365 Document Assembler Loaded Successfully">
</bt:String>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="residToolTip" DefaultValue="Instantly assemble proposals, contracts, legal docs using pre-created reusable content and templates.">
</bt:String>
<bt:String id="Witty.GetStarted.Description" DefaultValue="Instantly assemble proposals, contracts, legal docs using pre-created reusable content and templates.">
</bt:String>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
答案 0 :(得分:2)
您无法使用Dialog API直接打开远程URI。来自documentation:
传递给displayDialogAsync方法的页面,控制器方法或其他资源必须与主机页面位于同一个域中。
要打开远程URI,您需要首先使用同一域内的URI(即加载项的本地)打开对话框。这需要是标准的Office加载项页面,它都引用office.js
并定义Office.initialize
方法。打开此页面后,您可以重定向到清单中AppDomains
阵列中列出的任何远程域。
另请注意,您需要初始化才能完成,因此您的重定向需要在初始化后触发:
Office.initialize = function () {
window.location = "https://dev2.wittyparrot.com:3001";
};