Skip to content

Commit

Permalink
Merge pull request #25 from caoxiemeihao/v0.4.4
Browse files Browse the repository at this point in the history
V0.4.4
  • Loading branch information
caoxiemeihao authored Mar 29, 2023
2 parents 99e3a8d + 1b41694 commit 49efcd6
Show file tree
Hide file tree
Showing 9 changed files with 964 additions and 2,781 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.4 (2023-03-29)

- 57f06ec docs: v0.4.4 (#21, #24)
- 00dbfd7 feat: support customize default behavior

## 0.4.3 (2023-03-29)

- 12d8c58 refactor: cleanup
Expand Down
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ That's it! You can now use Electron in your Nuxt app ✨

## Electron Options

> This is based on the `vite-electron-plugin`, see the **[Documents](https://github.com/electron-vite/vite-electron-plugin#configuration)** for more detailed options
Here is the default `electron` options

```ts
Expand All @@ -79,20 +77,38 @@ export default defineNuxtConfig({
})
```

Use Node.js in Renderer process
Full types definition

> This is based on the `vite-electron-plugin`, see the **[Documents](https://github.com/electron-vite/vite-electron-plugin#configuration)** for more detailed options
```ts
export default defineNuxtConfig({
modules: [
'nuxt-electron',
],
electron: {
/**
* @see https://github.com/electron-vite/vite-plugin-electron-renderer
*/
renderer: {},
},
})
import type { Configuration } from 'vite-electron-plugin'

export interface ElectronOptions extends Partial<Configuration> {
/**
* @see https://github.com/electron-vite/vite-plugin-electron-renderer
*/
renderer?: Parameters<typeof import('vite-plugin-electron-renderer').default>[0]
/**
* nuxt-electron will modify some options by default
*
* ```js
* export default defineNuxtConfig({
* ssr: false,
* app: {
* buildAssetsDir: '/',
* baseURL: './',
* },
* runtimeConfig: {
* app: {
* baseURL: './',
* },
* },
* })
* ```
*/
disableDefaultOptions?: boolean
}
```

## Recommend Structure
Expand Down Expand Up @@ -122,6 +138,8 @@ Let's use the official [nuxt-starter-v3](https://codeload.github.com/nuxt/starte
## Notes
By default, we force the App to run in SPA mode since we don't need SSR for desktop apps

If you want to fully customize the default behavior, you can disable it by `disableDefaultOptions`

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/nuxt-electron/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/nuxt-electron
Expand Down
11 changes: 11 additions & 0 deletions examples/quick-start/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
<NuxtWelcome />
</div>
</template>

<script setup>
import { onMounted } from 'vue'
import { ipcRenderer } from 'electron'
import fs from 'node:fs'
onMounted(() => {
console.log('ipcRenderer:',ipcRenderer)
console.log('fs:', fs)
})
</script>
4 changes: 4 additions & 0 deletions examples/quick-start/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function bootstrap() {
win = new BrowserWindow({
webPreferences: {
preload,
nodeIntegrationInWorker: true,
contextIsolation: false,
nodeIntegration: true,
webSecurity: false,
},
})

Expand Down
9 changes: 9 additions & 0 deletions examples/quick-start/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ export default defineNuxtConfig({
modules: [
'nuxt-electron',
],
electron: {
renderer: {},
},
vite: {
build: {
// https://github.com/electron-vite/vite-plugin-electron-renderer/blob/v0.13.13/src/index.ts#L57
cssCodeSplit: true,
},
},
})
4 changes: 2 additions & 2 deletions examples/quick-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"dependencies": {},
"devDependencies": {
"electron": "^21.3.0",
"electron": "^23.1.1",
"electron-builder": "^23.6.0",
"nuxt": "^3.0.0",
"nuxt": "^3.2.2",
"nuxt-electron": "workspace:*"
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-electron",
"version": "0.4.3",
"version": "0.4.4",
"description": "Nuxt Integration with Electron",
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -38,13 +38,13 @@
}
},
"devDependencies": {
"@types/node": "^18.13.0",
"esbuild": "^0.17.8",
"nuxt": "^3.2.0",
"@types/node": "^18.15.11",
"esbuild": "^0.17.14",
"nuxt": "^3.2.2",
"typescript": "^4.9.5",
"vite": "^4.1.1",
"vite-electron-plugin": "^0.7.4",
"vite-plugin-electron-renderer": "^0.12.1"
"vite": "^4.1.4",
"vite-electron-plugin": "latest",
"vite-plugin-electron-renderer": "latest"
},
"files": [
"electron-env.d.ts",
Expand Down
Loading

0 comments on commit 49efcd6

Please sign in to comment.