This commit is contained in:
gaoshuaixing
2022-02-21 18:35:39 +08:00
parent 2a1b3fd071
commit 3c4d524257
3 changed files with 26 additions and 3 deletions

View File

@@ -182,6 +182,28 @@ class ExampleController extends Controller {
this.app.electron.mainWindow.removeBrowserView(browserViewObj);
return true
}
/**
* 打开新窗口
*/
createWindow (args) {
let content = null;
if (args.type == 'html') {
content = path.join('file://', electronApp.getAppPath(), args.content)
} else {
content = args.content;
}
let winObj = new BrowserWindow({
x: 10,
y: 10,
width: 980,
height: 650
})
winObj.loadURL(content);
return winObj.id
}
}
module.exports = ExampleController;

View File

@@ -23,6 +23,7 @@ const ipcApiRoute = {
executeJS: 'controller.example.executeJS',
loadViewContent: 'controller.example.loadViewContent',
removeViewContent: 'controller.example.removeViewContent',
createWindow: 'controller.example.createWindow',
}
/**

View File

@@ -23,6 +23,7 @@
</div>
</template>
<script>
import { ipcApiRoute } from '@/api/main'
export default {
data() {
@@ -34,15 +35,14 @@ export default {
},
{
type: 'html',
content: '/asset/view_example.html'
content: '/public/html/view_example.html'
},
],
};
},
methods: {
createWindow (index) {
const self = this;
self.$ipcCallMain('example.createWindow', this.views[index]).then(r => {
this.$ipcCallMain(ipcApiRoute.createWindow, this.views[index]).then(r => {
console.log(r);
})
},