Skip to content
代码片段 群组 项目
未验证 提交 472fc505 编辑于 作者: Michael Randers-Pehrson's avatar Michael Randers-Pehrson 提交者: GitHub
浏览文件

[Blazor][Fixes #20935] Adds an Environment parameter to...

[Blazor][Fixes #20935] Adds an Environment parameter to WebAssemblyStartOptions to provide or override the Environment value set by the host
上级 4b943417
No related branches found
No related tags found
无相关合并请求
文件被 .gitattributes 条目压制或文件的编码不受支持。
......@@ -66,8 +66,11 @@ async function boot(options?: Partial<WebAssemblyStartOptions>): Promise<void> {
);
});
// Get the custom environment setting if defined
const environment = options?.environment;
// Fetch the resources and prepare the Mono runtime
const bootConfigResult = await BootConfigResult.initAsync();
const bootConfigResult = await BootConfigResult.initAsync(environment);
const [resourceLoader] = await Promise.all([
WebAssemblyResourceLoader.initAsync(bootConfigResult.bootConfig, options || {}),
......
......@@ -2,7 +2,7 @@ export class BootConfigResult {
private constructor(public bootConfig: BootJsonData, public applicationEnvironment: string) {
}
static async initAsync(): Promise<BootConfigResult> {
static async initAsync(environment?: string): Promise<BootConfigResult> {
const bootConfigResponse = await fetch('_framework/blazor.boot.json', {
method: 'GET',
credentials: 'include',
......@@ -10,8 +10,8 @@ export class BootConfigResult {
});
// While we can expect an ASP.NET Core hosted application to include the environment, other
// hosts may not. Assume 'Production' in the absenc of any specified value.
const applicationEnvironment = bootConfigResponse.headers.get('Blazor-Environment') || 'Production';
// hosts may not. Assume 'Production' in the absence of any specified value.
const applicationEnvironment = environment || bootConfigResponse.headers.get('Blazor-Environment') || 'Production';
const bootConfig: BootJsonData = await bootConfigResponse.json();
return new BootConfigResult(bootConfig, applicationEnvironment);
......
......@@ -9,6 +9,11 @@ export interface WebAssemblyStartOptions {
* @returns A URI string or a Response promise to override the loading process, or null/undefined to allow the default loading behavior.
*/
loadBootResource(type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string) : string | Promise<Response> | null | undefined;
/**
* Override built-in environment setting on start.
*/
environment?: string;
}
// This type doesn't have to align with anything in BootConfig.
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册