From 5e53f2ac7ec0bff943b6e51ea185d125fc07333b Mon Sep 17 00:00:00 2001 From: buqiyuan <1743369777@qq.com> Date: Tue, 28 Jun 2022 11:53:35 +0800 Subject: [PATCH] fix: remote source for web --- .../setting/common/data-storage.component.ts | 2 +- .../services/storage/http/lib/baseUrl.service.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts b/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts index fac1d5ed7..f7ff29119 100644 --- a/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts +++ b/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts @@ -18,7 +18,7 @@ import { NzMessageService } from 'ng-zorro-antd/message';

Localhost: Store the data locally. You can only use the product on the current computer.

Remote Server: Store data on a remote server to facilitate cross device use of the product. - Learn more... + Learn more...

diff --git a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts index 7254917be..9185e3b8a 100644 --- a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts +++ b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts @@ -1,13 +1,14 @@ -import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { filter, map, Observable } from "rxjs"; +import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service'; +import { filter, map, Observable } from 'rxjs'; const protocolReg = new RegExp('^(http|https)://'); // implements StorageInterface @Injectable() -export class BaseUrlInterceptor implements HttpInterceptor { +export class BaseUrlInterceptor extends RemoteService implements HttpInterceptor { intercept(req: HttpRequest, next: HttpHandler): Observable> { - const { url = '', token = '' } = window.eo?.getModuleSettings?.('eoapi-common.remoteServer') || {}; + const { url = '', token = '' } = this.getConfiguration('eoapi-common.remoteServer') || {}; req = req.clone({ url: protocolReg.test(req.url) ? req.url : url + req.url, headers: req.headers.append('x-api-key', token), @@ -18,4 +19,4 @@ export class BaseUrlInterceptor implements HttpInterceptor { map((event: HttpResponse) => event.clone({ body: { status: 200, data: event.body.data } })) ); } -} \ No newline at end of file +}