Skip to content

Commit

Permalink
fix: import project path error
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Oct 2, 2022
1 parent 174b38f commit d307eb8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class ExportApiComponent implements OnInit {
featureMap = window.eo?.getFeature('apimanage.export');
constructor(
private storage: StorageService,
private workspaceService: WorkspaceService,
private projectService: ProjectService,
public extensionService: ExtensionService
) {}
Expand Down Expand Up @@ -59,7 +58,7 @@ export class ExportApiComponent implements OnInit {
* @param callback
*/
private exportEoapi(callback) {
const params = [this.workspaceService.currentWorkspaceID, this.projectService.currentProjectID];
const params = [this.projectService.currentProjectID];
this.storage.run('projectExport', params, (result: StorageRes) => {
if (result.status === StorageResStatus.success) {
result.data.version = packageJson.version;
Expand All @@ -83,7 +82,7 @@ export class ExportApiComponent implements OnInit {
const filename = feature.filename || null;
const module: ModuleInfo = window.eo.loadFeatureModule(this.currentExtension);
if (action && filename && module && module[action] && typeof module[action] === 'function') {
const params = [this.workspaceService.currentWorkspaceID, this.projectService.currentProjectID];
const params = [this.projectService.currentProjectID];
this.storage.run('projectExport', params, (result: StorageRes) => {
if (result.status === StorageResStatus.success) {
result.data.version = packageJson.version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StorageService } from 'eo/workbench/browser/src/app/shared/services/sto
import { StorageRes, StorageResStatus } from 'eo/workbench/browser/src/app/shared/services/storage/index.model';
import { ExtensionService } from 'eo/workbench/browser/src/app/pages/extension/extension.service';
import { Router } from '@angular/router';
import { ProjectService } from 'eo/workbench/browser/src/app/shared/services/project/project.service';

// const optionList = [
// {
Expand Down Expand Up @@ -55,7 +56,8 @@ export class ImportApiComponent implements OnInit {
private router: Router,
private storage: StorageService,
private eoMessage: EoMessageService,
public extensionService: ExtensionService
public extensionService: ExtensionService,
private projectService: ProjectService
) {}
ngOnInit(): void {
this.featureMap?.forEach((data: FeatureType, key: string) => {
Expand Down Expand Up @@ -111,9 +113,10 @@ export class ImportApiComponent implements OnInit {
}
return obj;
};
this.storage.run('projectImport', [1, decycle(data)], (result: StorageRes) => {
const params = [this.projectService.currentProjectID, decycle(data)];
this.storage.run('projectImport', params, (result: StorageRes) => {
if (result.status === StorageResStatus.success) {
this.router.navigate(['home/api']);
this.router.navigate(['home/api']);
}
});
callback(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ProjectService } from 'eo/workbench/browser/src/app/shared/services/pro
const protocolReg = new RegExp('^(http|https)://');

const interceptorPaths = ['/api_data', '/group', '/api_test_history', '/mock', '/environment'];
const needWorkspaceIDPrefixPaths = ['/project'];

// implements StorageInterface
@Injectable()
Expand All @@ -25,11 +26,15 @@ export class BaseUrlInterceptor extends SettingService implements HttpIntercepto
const { url = '' } = this.getConfiguration('eoapi-common.remoteServer') || {};
const token = StorageUtil.get('accessToken') || '';

const targetUrl = interceptorPaths.find((n) => req.url.startsWith(n));
if (targetUrl) {
let targetUrl;
if ((targetUrl = interceptorPaths.find((n) => req.url.startsWith(n)))) {
req = req.clone({
url: req.url.replace(targetUrl, `${this.apiPrefix}/${targetUrl}`),
});
} else if ((targetUrl = needWorkspaceIDPrefixPaths.find((n) => req.url.startsWith(n)))) {
req = req.clone({
url: req.url.replace(targetUrl, `/${this.workspaceService.currentWorkspaceID}/${targetUrl}`),
});
}
req = req.clone({
url: uniqueSlash(protocolReg.test(req.url) ? req.url : url + req.url),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class HttpStorage implements StorageInterface {
projectBulkRemove: (uuids: Array<number | string>) => Observable<object>;
projectLoad: (uuid: number | string) => Observable<object>;
projectBulkLoad: (uuids: Array<number | string>) => Observable<object>;
projectExport(workspaceID, projectID) {
return this.http.get(`/${workspaceID}/project/${projectID}/export`) as Observable<object>;
projectExport(projectID) {
return this.http.get(`/project/${projectID}/export`) as Observable<object>;
}
// Environment
environmentCreate(item: Environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export interface StorageInterface {
projectBulkRemove: (uuids: Array<number | string>) => Observable<object>;
projectLoad: (uuid: number | string) => Observable<object>;
projectBulkLoad: (uuids: Array<number | string>) => Observable<object>;
projectExport: (workspaceID?, projectID?) => Observable<object>;
projectExport: (projectID?) => Observable<object>;
// Environment
environmentCreate: (item: Environment) => Observable<object>;
environmentUpdate: (item: Environment, uuid: number | string) => Observable<object>;
Expand Down

0 comments on commit d307eb8

Please sign in to comment.