chore: upate

This commit is contained in:
草鞋没号
2020-08-31 09:50:57 +08:00
parent 278a3468d2
commit 79cd832cfc
11 changed files with 45 additions and 12 deletions

View File

@@ -15,11 +15,14 @@ function createWin() {
win = new BrowserWindow({
width: 1024,
height: 768,
webPreferences: {
nodeIntegration: true,
},
})
const URL = is_dev
? `http://localhost:${process.env.PORT}` // vite 启动的服务器地址
: `file://${join(__dirname, '../render/dist/index.html')}` // vite 构建后的静态文件地址
: `file://${join(__dirname, '../../dist/render/index.html')}` // vite 构建后的静态文件地址
win.loadURL(URL)
}

5
src/main/preload.js Normal file
View File

@@ -0,0 +1,5 @@
const { ipcRenderer } = require('electron')
window.stopLoading = function() {
ipcRenderer.send('stop-loading-main')
}

View File

@@ -3,7 +3,7 @@
<img style="height:200px;" src="./assets/electron.png" alt="Electron logo">
<img alt="Vue logo" src="./assets/logo.png" />
</div>
<HelloWorld msg="Hello Electron 9.0 + Vue 3.0 Vite" />
<HelloWorld msg="Hello Electron 9.0 + Vue 3.0 + Vite" />
</template>
<script>

View File

@@ -8,6 +8,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="/main.js"></script>
<script type="module" src="/main.ts"></script>
</body>
</html>

View File

@@ -1,5 +0,0 @@
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
createApp(App).mount('#app')

9
src/render/main.ts Normal file
View File

@@ -0,0 +1,9 @@
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
// vite 会编译 import 的形式;所以 electron 及 node.js 内置模块用 require 形式
const { ipcRenderer } = require('electron')
console.log(ipcRenderer)
createApp(App as any).mount('#app')

4
src/render/shims.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

4
src/render/source.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
declare const React: string
declare module '*.json'
declare module '*.png'
declare module '*.jpg'