Skip to content

Commit

Permalink
fix: mock some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jun 28, 2022
1 parent f9e1018 commit 30c5ade
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function createWindow(): BrowserWindow {
contextIsolation: false, // false if you want to run e2e test with Spectron
},
});
// 启动mock服务
mockServer.start(win as any);
proxyOpenExternal(win);
let loadPage = async () => {
const file: string =
Expand All @@ -69,8 +71,6 @@ function createWindow(): BrowserWindow {
UnitWorkerModule.setup({
view: win,
});
// 启动mock服务
await mockServer.start(win as any);
};
win.webContents.on('did-fail-load', (event, errorCode) => {
console.error('did-fail-load', errorCode);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ window.eo.storageRemote = (args) => {
};

window.eo.saveSettings = (settings) => {
console.log('window.eo.saveSettings', settings);
// console.log('window.eo.saveSettings', settings);
return ipcRenderer.sendSync('eo-sync', { action: 'saveSettings', data: { settings } });
};

Expand Down
4 changes: 2 additions & 2 deletions src/platform/node/mock-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class MockServer {
private mockUrl = '';

constructor() {
this.app = express();
this.app ??= express();
this.createProxyServer();
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export class MockServer {
// if (!protocolReg.test(req.url)) {
// match request type
const isMatchType = this.configuration.getModuleSettings<boolean>('eoapi-features.mock.matchType');
if (req.query.mockID || isMatchType) {
if (req.query.mockID || isMatchType !== false) {
this.view.webContents.send('getMockApiList', JSON.parse(jsonStringify(req)));
ipcMain.once('getMockApiList', (event, message) => {
console.log('getMockApiList message', message);
Expand Down
6 changes: 3 additions & 3 deletions src/workbench/browser/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ export class AppService {
this.ipcRenderer.on('getMockApiList', async (event, req = {}) => {
const sender = event.sender;
console.log('req', req);
const isEnabledMatchType = window.eo?.getModuleSettings?.('eoapi-features.mock.matchType');
const isEnabledMatchType = window.eo?.getModuleSettings?.('eoapi-features.mock.matchType') !== false;
// console.log('wo接收到了哇', event, message);
const { mockID } = req.query;
if (Number.isInteger(Number(mockID))) {
try {
const mock = await this.getMockByMockID(Number(mockID));
const apiData = await this.getApiData(Number(mock.apiDataID));
if (isEnabledMatchType) {
if (!mock && isEnabledMatchType) {
const result = await this.matchApiData(1, req);
return sender.send('getMockApiList', result);
} else {
mock.response = this.generateResponse(apiData.responseBody) || mock.response;
mock.response = mock?.response ?? this.generateResponse(apiData.responseBody);
}
sender.send('getMockApiList', mock);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class SettingComponent implements OnInit {
this.settings = this.localSettings = JSON.parse(localStorage.getItem('localSettings') || '{}');
// @ts-ignore
window.getConfiguration = this.remoteService.getConfiguration;
console.log('localSettings', this.localSettings);
// console.log('localSettings', this.localSettings);
// const featureList = window.eo.getFeature('configuration');
const modules = window.eo?.getModules() || new Map([]);
// const extensitonConfigurations = [...modules.values()].filter((n) => n.contributes?.configuration);
Expand Down

0 comments on commit 30c5ade

Please sign in to comment.