Skip to content

Commit

Permalink
feat: add workbench mask
Browse files Browse the repository at this point in the history
  • Loading branch information
everright committed Apr 20, 2022
1 parent 9df818f commit 1aeed32
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
17 changes: 15 additions & 2 deletions src/app/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,21 @@ try {
} else if (arg.action === 'autoResize') {
resize(arg.data.sideWidth);
} else if (arg.action === 'openModal') {
console.log('openModal');
subView.mainView.view.webContents.send('connect-main', { action: 'openModal' });
const background = arg.data.background || '#00000073';
subView.mainView.view.webContents.executeJavaScript(`
var mask = document.querySelector('#mask');
if (mask) {
mask.style.background = '${background}';
mask.style.display = 'block';
}
`);
} else if (arg.action === 'closeModal') {
subView.mainView.view.webContents.executeJavaScript(`
var mask = document.querySelector('#mask');
if (mask) {
mask.style.display = 'none';
}
`);
} else {
returnValue = 'Invalid data';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export class ModalService {
{
label: '取消',
onClick: () =>{
window.eo.closeModal();
modal.destroy();
}
},
],
};
Object.assign(modalOpts, inOpts);
const modal = this.modalService.create(modalOpts);
window.eo.openModal();
modal.afterOpen.subscribe(() => window.eo.openModal());
modal.afterClose.subscribe(() => window.eo.closeModal());
return modal;
}
}
5 changes: 3 additions & 2 deletions src/platform/electron-browser/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ if (apiAccessRules.includes('hook')) {
window.eo.tempApi = (params) => {
return ipcRenderer.sendSync('eo-sync', params);
};
window.eo.openModal = () => {
return ipcRenderer.sendSync('eo-sync', { action: 'openModal' });
window.eo.openModal = (background) => {
background = background || '#00000073';
return ipcRenderer.sendSync('eo-sync', { action: 'openModal', data: { background: background } });
};
window.eo.closeModal = () => {
return ipcRenderer.sendSync('eo-sync', { action: 'closeModal' });
Expand Down
10 changes: 10 additions & 0 deletions src/workbench/browser/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@
</div>
</div>
</eo-root>
<div id="mask"></div>
</body>
<style>
#mask {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 99999;
display: none;
}
.loading_container {
position: absolute;
top: 40%;
Expand Down

0 comments on commit 1aeed32

Please sign in to comment.