Skip to content

Commit 935e806

Browse files
committed
feat: add vitepress for document (#25)
1 parent 2dd7982 commit 935e806

File tree

15 files changed

+1718
-755
lines changed

15 files changed

+1718
-755
lines changed

.github/workflows/github-page.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy Github Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'docs/**'
9+
jobs:
10+
page-deploy:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [10.x]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- name: Install
23+
run: |
24+
npm ci
25+
env:
26+
CI: true
27+
- name: Build Document
28+
run: |
29+
npm run build:docs
30+
- name: Deploy to GitHub Pages
31+
if: success()
32+
uses: crazy-max/ghaction-github-pages@v2
33+
with:
34+
target_branch: gh-pages
35+
build_dir: docs/.vitepress/dist
36+
jekyll: false
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This repository contains the starter template for using vue-next with the latest
44

55
*I started to learn electron & vue by the great project [electron-vue](https://github.com/SimulatedGREG/electron-vue). This project is also inspired from it.*
66

7+
You can see the document [here](https://ci010.github.io/electron-vue-next/index.html).
8+
79
## Features
810

911
- Electron 10
@@ -39,14 +41,10 @@ This repository contains the starter template for using vue-next with the latest
3941
Clone or fork this project to start.
4042
Once you have your project, and in the project folder:
4143

42-
```sh
44+
```shell
4345
# Install dependencies with linter
4446
npm install
4547

46-
# OR install dependencies without eslint
47-
npm install --no-optional
48-
```
49-
```sh
5048
# Will start vite server, rollup devserver, and electron to dev!
5149
npm run dev
5250

@@ -60,107 +58,3 @@ npm run build:dir
6058
npm run build:production
6159

6260
```
63-
64-
### Using NodeJS in Renderer
65-
66-
Due to the project is following the [security](https://www.electronjs.org/docs/tutorial/security) guideline. It does not allow the renderer to access node by default. You should use [Service](/src/main/services/Service.ts) to encapsulate your nodejs operation and use the hook `useService('NameOfService')` to use in renderer side.
67-
68-
### Config Your Project and Build
69-
70-
Once you install your project, you should change the package base info in [package.json](/package.json),
71-
and also the build information in [/scripts/build.base.config.js](/scripts/build.base.config.js)
72-
73-
#### assets, static resources, build resources... what's the difference?
74-
75-
The assets is only used by the renderer process (in-browser display), like picture or font. They are **bundled by vite/rollup**. You can directly `import` them in `.vue/.ts` files under renderer directory. The default assets are in [/src/renderer/assets](src/renderer/assets)
76-
77-
The static resources are the static files which main process wants to access (like read file content) in **runtime vie file system**. They might be the tray icon file, browser window icon file. The static folder is at [/static](static).
78-
79-
The build resources are used by `electron-builder` to build the installer. They can be your program icon of installer, or installer script. Default build icons are under [/build/icons](build/icons).
80-
81-
*Notice that your program icon can show up in multiple place! Don't mixup them!*
82-
- *In build icons, of course you want your program has correct icon.*
83-
- *In static directory, sometime you want your program has **tray** which require icon in static directory.*
84-
- *In assets, sometime you want to display your program icon inside a page. You need to place them in the assets!*
85-
86-
### Debug In VSCode
87-
88-
This is really simple. In vscode debug section, you will see three profiles:
89-
90-
1. Electron: Main (attach)
91-
2. Electron: Renderer (attach)
92-
3. Electron: Main & Renderer (attach)
93-
94-
The name should be clear. The first one attach to main and the second one attach to renderer (required vscode chrome debug extension).
95-
The third one is run the 1 and 2 at the same time.
96-
97-
You should first run `npm run dev` and start debugging by the vscode debug.
98-
99-
### Adding New Dependencies
100-
101-
If you adding new dependenceis, make sure if it using nodejs module, add it as `exclude` in the [/scripts/vite.config.js](/scripts/vite.config.js). Otherwise, the vite will complain about "I cannot optimize it!".
102-
103-
The raw javascript dependencies are okay for vite.
104-
105-
#### Native Dependencies
106-
107-
If you want to use the native dependencies, not only you should adding it to vite `exclude`, you should also take care about the electron-builder config.
108-
109-
For example, [7zip-min](https://github.com/onikienko/7zip-min):
110-
111-
Since it using the `7zip-bin` which carry binary for multiple platform, we need to correctly include them in config.
112-
Modify the electron-builder build script [/scripts/build.base.config.js](/scripts/build.base.config.js)
113-
114-
```js
115-
files: [
116-
"dist/electron/**/*",
117-
"!**/node_modules/**/*",
118-
"node_modules/7zip-bin/**/*"
119-
],
120-
asarUnpack: [
121-
"node_modules/7zip-bin/**/*"
122-
],
123-
```
124-
125-
Add them to `files` and `asarUnpack` to ensure the electron builder correctly pack & unpack them.
126-
127-
To optimize for multi-platform, you should also exclude them from `files` of each platform config [/scripts/build.config.js](/scripts/build.config.js)
128-
129-
```js
130-
mac: {
131-
// ... other mac configs
132-
files: [
133-
"node_modules/7zip-bin/**/*",
134-
"!node_modules/7zip-bin/linux/**",
135-
"!node_modules/7zip-bin/win/**"
136-
]
137-
},
138-
win: {
139-
// ... other win configs
140-
files: [
141-
"node_modules/7zip-bin/**/*",
142-
"!node_modules/7zip-bin/linux/**",
143-
"!node_modules/7zip-bin/mac/**"
144-
]
145-
},
146-
linux: {
147-
// ... other linux configs
148-
files: [
149-
"node_modules/7zip-bin/**/*",
150-
"!node_modules/7zip-bin/win/**",
151-
"!node_modules/7zip-bin/mac/**"
152-
]
153-
},
154-
```
155-
156-
### Release Process
157-
158-
The out-of-box github action will validate each your PR by eslint and run `npm run build`. It will not trigger electron-builder to build production assets.
159-
160-
For each push in master branch, it will build production assets for win/mac/linux platform and upload it as github action assets. It will also create a **pull request** to asking you to bump version and update the changelog.
161-
162-
It using the conventional-commit. If you want to auto-generate the changelog, you should follow the [conventional commit guideline](https://www.conventionalcommits.org/en/v1.0.0).
163-
164-
If the **bump version PR** is approved and merged to master, it will auto build and release to github release.
165-
166-
**If you want to disable this github action release process, just remove the [/.github/workflows/build.yml](/.github/workflows/build.yml) file.**

docs/.vitepress/config.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @type {import('vitepress').DefaultTheme.Config}
3+
*/
4+
const themeConfig = {
5+
search: {
6+
searchMaxSuggestions: 10,
7+
},
8+
sidebar: 'auto',
9+
repo: 'ci010/vue-electron-next',
10+
docsDir: 'docs',
11+
repoLabel: 'Github',
12+
lastUpdated: true,
13+
prevLink: true,
14+
nextLink: true,
15+
locales: {
16+
'/': {
17+
lang: 'en-US',
18+
title: 'vue-electron-next',
19+
description: 'vue hooks',
20+
label: 'English',
21+
selectText: 'Languages',
22+
},
23+
'/zh/': {
24+
lang: 'zh-CN',
25+
title: 'vue-electron-next',
26+
description: 'vue hooks',
27+
label: '中文',
28+
selectText: '语言',
29+
},
30+
},
31+
}
32+
33+
/**
34+
* @type {import('vitepress').UserConfig<import('vitepress').DefaultTheme.Config>}
35+
*/
36+
const config = {
37+
lang: 'en-US',
38+
themeConfig,
39+
base: '/electron-vue-next',
40+
title: 'Electron Vue Next',
41+
locales: {
42+
'/': {
43+
lang: 'en-US',
44+
title: 'vue-electron-next',
45+
description: 'vue hooks',
46+
label: 'English',
47+
selectText: 'Languages',
48+
},
49+
'/zh/': {
50+
lang: 'zh-CN',
51+
title: 'vue-electron-next',
52+
description: 'vue hooks',
53+
label: '中文',
54+
selectText: '语言',
55+
},
56+
},
57+
}
58+
59+
module.exports = config;

docs/.vitepress/theme/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.theme.no-sidebar aside {
2+
display: block;
3+
}

docs/.vitepress/theme/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import index from 'vitepress/dist/client/theme-default/index'
2+
import './index.css'
3+
4+
export default index

0 commit comments

Comments
 (0)