Skip to content

Commit

Permalink
feat: load local module
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Aug 5, 2022
1 parent a63d94a commit 0ca0f54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/platform/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ window.eo.loadFeatureModule = (moduleID) => {
if (!featureModules.has(moduleID)) {
try {
const module = window.eo.getModule(moduleID);
window.eo._currentExtensionID=moduleID;
const _module = window.require(module.baseDir);
console.log('featureModules module', module);
window.eo._currentExtensionID = moduleID;
const _module = require(module.baseDir);
featureModules.set(moduleID, _module);
} catch (e) {
console.log(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class ImportApiComponent implements OnInit {
{
const { key } = this.supportList.at(0);
this.currentExtension = key || '';
console.log('this.currentExtension', this.currentExtension);
}
}
uploadChange(data) {
Expand All @@ -68,7 +69,7 @@ export class ImportApiComponent implements OnInit {
// * this.currentExtension is extension's key, like 'eoapi-import-openapi'
const feature = this.featureMap.get(this.currentExtension);
const action = feature.action || null;
const module = window.eo.loadFeatureModule(this.currentExtension);
const module = await window.eo.loadFeatureModule(this.currentExtension);
const { name, content } = this.uploadData;
const [data, err] = module[action](content);
if (err) {
Expand Down

0 comments on commit 0ca0f54

Please sign in to comment.