mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 19:52:10 +08:00
window
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -23,6 +23,7 @@ const ipcApiRoute = {
|
||||
executeJS: 'controller.example.executeJS',
|
||||
loadViewContent: 'controller.example.loadViewContent',
|
||||
removeViewContent: 'controller.example.removeViewContent',
|
||||
createWindow: 'controller.example.createWindow',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user