小编Dav*_*lli的帖子

Web Worker in Angular Library

我正在开发一个执行强计算操作的角度库。所以我对实现 web worker 很感兴趣,以便有更好的用户体验,让复杂的操作在后台运行。

我的问题是,当我ng g web-worker使用 Angular CLI 8运行命令时,输出是Web Worker requires a project type of "application". 有人对如何继续在我的库中实现 Web Worker 有任何建议吗?

performance web-worker angular angular-library

10
推荐指数
1
解决办法
1423
查看次数

7
推荐指数
1
解决办法
5445
查看次数

HTTP拦截器发送相同的请求两次

我正在使用 HTTP 拦截器来向请求添加身份验证令牌,但是当 http 客户端触发请求时,该请求会被拦截并发送两次

这是我的 HttpClient 调用

  searchProd(query: string, limit?: number): Observable<Product[]> {
    let _limit = limit || 5;
    return this.http.get<Product[]>(`${API_CONST.HOST}/${API_CONST.PRODUCT}?search=${query}&limit=${_limit}`);
  }
Run Code Online (Sandbox Code Playgroud)

这是我的 app.module.ts

import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; 
import { TokenInterceptor } from './auth/token.interceptor';
....

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
  ],
  providers: [
    ApiService,
    AuthGuardService,
    SettingsService,
    {
      provide : HTTP_INTERCEPTORS,
      useClass : TokenInterceptor,
      multi : true
    }
  ],
  entryComponents: [ ... ],
  bootstrap: [ ... ]
})

Run Code Online (Sandbox Code Playgroud)

这是我的 token.interceptor.ts

import { Injectable } …
Run Code Online (Sandbox Code Playgroud)

rxjs angular-http-interceptors angular angular-httpclient

6
推荐指数
1
解决办法
4007
查看次数

受信任的 Web 活动在本地保存数据

我有一个 PWA,我将用户设置保存在本地存储上,并且我想通过 TWA 将此 PWA 部署在 Play 商店上。问题如下:

The host app doesn't have direct access to web content in a Trusted Web 
activity or any other kind of web state, like cookies and localStorage. 
Nevertheless, you can coordinate with the web content by passing data to and 
from the page in URLs (e.g. through query parameters, custom HTTP headers, and 
intent URIs.)
Run Code Online (Sandbox Code Playgroud)

根据谷歌的说法,我不明白如何在 PWA 上使用 TWA 保存客户端的用户设置。如果您能给我举一个例子,我将不胜感激。

local-storage progressive-web-apps trusted-web-activity

2
推荐指数
1
解决办法
1248
查看次数