docs: update documents category, add preload script document
This commit is contained in:
1 parent
f6fc0af4c2
commit
35e04a80e3
12 files changed
+49
-21
No files matched your search
Generated
+4
-4
@@ -10,7 +10,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vitepress": "^1.0.0-rc.20",
|
"vitepress": "^1.0.0-rc.20",
|
||||||
"vitepress-sidebar": "^1.17.0",
|
"vitepress-sidebar": "^1.18.0",
|
||||||
"vue": "^3.3.4"
|
"vue": "^3.3.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -1277,9 +1277,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vitepress-sidebar": {
|
"node_modules/vitepress-sidebar": {
|
||||||
"version": "1.17.0",
|
"version": "1.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/vitepress-sidebar/-/vitepress-sidebar-1.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/vitepress-sidebar/-/vitepress-sidebar-1.18.0.tgz",
|
||||||
"integrity": "sha512-/emot28rHICDkCeGbrEMQYe+lUErQ+NfOA33NPElhsq5Def72ifPYLb1UFj9YfuH9Pda4gnStzynUHF8jKnMuA==",
|
"integrity": "sha512-Ki9ZpNa0CUNr7kovAbAEJ5v4MEZi+dte8Bz3OxkQcjFqrOGfQGEoGATRgf9m6N741epLLB3PFdaUCN6ZH0zmhg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"gray-matter": "^4.0.3"
|
"gray-matter": "^4.0.3"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vitepress": "^1.0.0-rc.20",
|
"vitepress": "^1.0.0-rc.20",
|
||||||
"vitepress-sidebar": "^1.17.0",
|
"vitepress-sidebar": "^1.18.0",
|
||||||
"vue": "^3.3.4"
|
"vue": "^3.3.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,9 @@ export default {
|
|||||||
collapsed: false,
|
collapsed: false,
|
||||||
useTitleFromFileHeading: true,
|
useTitleFromFileHeading: true,
|
||||||
manualSortFileNameByPriority: [
|
manualSortFileNameByPriority: [
|
||||||
'getting-started.md',
|
'Installation and Build',
|
||||||
'build-configuration.md',
|
'Project Structures',
|
||||||
'project-structure.md',
|
'Electron How To'
|
||||||
'npm-scripts.md'
|
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }]
|
socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }]
|
||||||
|
|||||||
File renamed without changes.
@@ -0,0 +1,20 @@
|
|||||||
|
# Preload Script
|
||||||
|
|
||||||
|
The preload script in Electron.js is a secure area designed for communication between the main and renderer processes. It is typically used for **[IPC communication](https://www.electronjs.org/docs/latest/tutorial/ipc)**.
|
||||||
|
|
||||||
|
For more information, see the following articles https://www.electronjs.org/docs/latest/tutorial/tutorial-preload
|
||||||
|
|
||||||
|
For compatibility and security with the latest version of Electron, we do not recommend using the old `electron/remote` module. If you want to utilize system events or Node scripts, it is recommended to do so in the main process, not the renderer.
|
||||||
|
|
||||||
|
Vutron's preload script is located in the `src/preload` folder. To create a new IPC communication channel, add the channel name to the following variable to whitelist it for communication.
|
||||||
|
|
||||||
|
* `mainAvailChannels`: Send an event from main to renderer. (`window.mainApi.send('channelName'')`)
|
||||||
|
* `rendererAvailChannels`: Send an event from renderer to main. (`mainWindow.webContents.send('channelName')`)
|
||||||
|
|
||||||
|
When sending events from renderer to main, you access the `window.mainApi` object instead of `ipcRenderer.send`. The `mainApi` is the name you set in your Vutron template and can be changed.
|
||||||
|
|
||||||
|
Here are the supported functions for mainApi: (To change and modify this, you need to modify `exposeInMainWorld` in `src/preload/index.ts`).
|
||||||
|
|
||||||
|
* `send`: Send an event to main.
|
||||||
|
* `receive`: A listener to receive events sent by main.
|
||||||
|
* `invoke`: Functions that can send events to main and receive data asynchronously.
|
||||||
File renamed without changes.
+21
-12
@@ -11,26 +11,21 @@ $ npm run build:mac
|
|||||||
|
|
||||||
# For Linux (.rpm, .deb, .snap)
|
# For Linux (.rpm, .deb, .snap)
|
||||||
$ npm run build:linux
|
$ npm run build:linux
|
||||||
|
|
||||||
|
# All platform (.exe, .appx, .dmg, .rpm, .deb, .snap) - see below description
|
||||||
|
$ npm run build:all
|
||||||
```
|
```
|
||||||
|
|
||||||
The built packages can be found in `release/{version}` location.
|
The built packages can be found in `release/{version}` location.
|
||||||
|
|
||||||
## Build settings for projects that use Native Node modules
|
|
||||||
|
|
||||||
For projects that use the **Native Node Module**, add the following script to your `package.json`: When installing dependencies, `electron-builder` will take care of any modules that require rebuilding.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"scripts": {
|
|
||||||
"postinstall": "electron-builder install-app-deps"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information, please refer to the following article: https://webpack.electron.build/dependency-management#installing-native-node-modules
|
For more information, please refer to the following article: https://webpack.electron.build/dependency-management#installing-native-node-modules
|
||||||
|
|
||||||
## What do I need to do for a multi-platform build?
|
## What do I need to do for a multi-platform build?
|
||||||
|
|
||||||
|
To create a package for each OS, you must build it on the same OS. For example, a package for macOS must be built on a macOS machine.
|
||||||
|
|
||||||
|
However, you can build packages for Windows, macOS, and Linux all at once on one OS. However, this might require some preparation.
|
||||||
|
|
||||||
**macOS** is recommended if you want to build multiple platforms simultaneously on one platform. Because it can be configured with just a few very simple settings.
|
**macOS** is recommended if you want to build multiple platforms simultaneously on one platform. Because it can be configured with just a few very simple settings.
|
||||||
|
|
||||||
You can perform multi-platform builds at once with the following command. Alternatively, you can just do it for the OS you want via the individual build commands above.
|
You can perform multi-platform builds at once with the following command. Alternatively, you can just do it for the OS you want via the individual build commands above.
|
||||||
@@ -41,6 +36,8 @@ $ npm run build:all
|
|||||||
|
|
||||||
`Multipass` configuration may be required for Linux builds. Learn more about `Multipass` through the following link: https://multipass.run
|
`Multipass` configuration may be required for Linux builds. Learn more about `Multipass` through the following link: https://multipass.run
|
||||||
|
|
||||||
|
To learn more about multiplatform builds, see the following articles: https://www.electron.build/multi-platform-build
|
||||||
|
|
||||||
## Reduce bundle size by excluding development files
|
## Reduce bundle size by excluding development files
|
||||||
|
|
||||||
You can exclude files you don't need at build time by adding a file pattern to the files property of `buildAssets/builder/config.ts`. This will save bundle capacity.
|
You can exclude files you don't need at build time by adding a file pattern to the files property of `buildAssets/builder/config.ts`. This will save bundle capacity.
|
||||||
@@ -69,3 +66,15 @@ Below is an unnecessary `node_modules` file pattern that can further save bundle
|
|||||||
"!**/node_modules/json-schema/!(package.json|lib)"
|
"!**/node_modules/json-schema/!(package.json|lib)"
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Build settings for projects that use Native Node modules
|
||||||
|
|
||||||
|
For projects that use the **Native Node Module**, add the following script to your `package.json`: When installing dependencies, `electron-builder` will take care of any modules that require rebuilding.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "electron-builder install-app-deps"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user