I有一个角(18.2) +电子(26)应用,该应用需要伸缩,而在网络上运行时不需要此。
在标准app.config.ts中,我只是将下面的extron用于电子
provideRouter: (routes, withHashLocation())
如何使这种动态化,以便在不添加电子时不会添加删除?
检查角网站是否在电子下运行的唯一方法是以下语句,当加载app.config.ts时,它感觉不可能访问。
this.windowReference.api && this.windowReference.api.isElectron
app.config.ts
)有条件地分配它:
const isElectron = this.windowReference?.api?.isElectron;
const routerProviders = isElectron ? provideRouter(routes, withHashLocation()) : provideRouter(routes);
export const appConfig: ApplicationConfig = {
providers: [routerProviders]
};