mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-08-26 23:11:18 +08:00
chore: upate
This commit is contained in:
@@ -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
5
src/main/preload.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
window.stopLoading = function() {
|
||||
ipcRenderer.send('stop-loading-main')
|
||||
}
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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
9
src/render/main.ts
Normal 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
4
src/render/shims.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module '*.vue' {
|
||||
import Vue from 'vue'
|
||||
export default Vue
|
||||
}
|
4
src/render/source.d.ts
vendored
Normal file
4
src/render/source.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const React: string
|
||||
declare module '*.json'
|
||||
declare module '*.png'
|
||||
declare module '*.jpg'
|
Reference in New Issue
Block a user