Skip to content

Commit

Permalink
feat: test exstension-push-eolink, it works
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed May 11, 2022
1 parent d7d085f commit 047a5fd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 46 deletions.
5 changes: 4 additions & 1 deletion src/platform/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ window.eo.saveSettings = (settings) => {
};

window.eo.saveModuleSettings = (moduleID, settings) => {
return ipcRenderer.sendSync('eo-sync', { action: 'saveModuleSettings', data: { moduleID: moduleID, settings: settings } });
return ipcRenderer.sendSync('eo-sync', {
action: 'saveModuleSettings',
data: { moduleID: moduleID, settings: settings },
});
};

window.eo.deleteModuleSettings = (moduleID) => {
Expand Down
24 changes: 0 additions & 24 deletions src/workbench/browser/src/app/shared/components/sync-api/push.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<nz-radio-group [(ngModel)]="exportType">
<nz-radio-group [(ngModel)]="pushType">
<label *ngFor="let item of supportList" nz-radio-button [nzValue]="item.key">{{item.title}}</label>
</nz-radio-group>
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
import { Component, OnInit } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { StorageHandleResult, StorageHandleStatus } from '../../../../../../../platform/browser/IndexedDB';
import { StorageService } from '../../services/storage';
import packageJson from '../../../../../../../../package.json';

@Component({
selector: 'eo-sync-api',
templateUrl: './sync-api.component.html',
styleUrls: ['./sync-api.component.scss'],
})
export class SyncApiComponent implements OnInit {
exportType: string = 'eolink';
pushType: '';
supportList: any[] = [];
featureList = window.eo.getFeature('apimanager.sync');
constructor(private modalRef: NzModalRef, private storage: StorageService) {}

ngOnInit(): void {
const extensionList = window.eo.getModules();
this.supportList = Object.values([...extensionList])
.map((it) => it[1])
.filter((it) => it.moduleType === 'feature')
.filter((it) => it.features['apimanager.sync'])
.map((it: any) => ({
key: it.moduleName,
image: it.logo,
title: it.features['apimanager.sync'].label,
}));
this.featureList?.forEach((feature: object, key: string) => {
this.supportList.push({
key: key,
image: feature['icon'],
title: feature['label'],
});
});
}
async submit() {
console.log('sync');
// const res = await sync_to_remote(
// { a: 1 },
// {
// projectId: 'ZXXhzTG756db7e34a8d7c803f001edf1a1c545bcbf27719',
// SecretKey: 'SgAZ5Lk60f776c1a235a3c3e62543c3793c36d6cc511db9',
// }
// );
// console.log(res);
const feature = this.featureList.get(this.pushType);
const action = feature.action || null;
const module = window.eo.loadFeatureModule(this.pushType);
if (module && module[action] && typeof module[action] === 'function') {
this.storage.run('projectExport', [], async (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
result.data.version = packageJson.version;
try {
const output = await module[action](result.data, {
projectId: 'ZXXhzTG756db7e34a8d7c803f001edf1a1c545bcbf27719',
SecretKey: 'SgAZ5Lk60f776c1a235a3c3e62543c3793c36d6cc511db9',
});
console.log(output);
} catch (e) {
console.log(e);
}
}
});
}
}
}

0 comments on commit 047a5fd

Please sign in to comment.