Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 378647f

Browse files
authored
docs: add content and fix problem (#27)
* docs: add content and fix problem * docs: some rewrite * docs: fix ci * docs: fis config step Signed-off-by: 浮心物语 <[email protected]> * docs: some changes - add update section - remove custom redis and mongodb in docker method * docs: rewrite update --------- Signed-off-by: 浮心物语 <[email protected]>
1 parent fa8533d commit 378647f

File tree

13 files changed

+283
-2
lines changed

13 files changed

+283
-2
lines changed

components/Icons/ArrowCircleUp.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { SVGProps } from 'react'
2+
3+
export function UilArrowCircleUp(props: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24" {...props}><path fill="currentColor" d="M12.71 8.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21l-3 3a1 1 0 0 0 1.42 1.42l1.29-1.3V15a1 1 0 0 0 2 0v-3.59l1.29 1.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42ZM12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2Zm0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8Z"></path></svg>
6+
)
7+
}

components/Icons/ExternalLinkAlt.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { SVGProps } from 'react';
2+
3+
export function UilExternalLinkAlt(props: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24" {...props}><path fill="currentColor" d="M18 10.82a1 1 0 0 0-1 1V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h7.18a1 1 0 0 0 0-2H5a3 3 0 0 0-3 3v11a3 3 0 0 0 3 3h11a3 3 0 0 0 3-3v-7.18a1 1 0 0 0-1-1Zm3.92-8.2a1 1 0 0 0-.54-.54A1 1 0 0 0 21 2h-6a1 1 0 0 0 0 2h3.59L8.29 14.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0L20 5.41V9a1 1 0 0 0 2 0V3a1 1 0 0 0-.08-.38Z"></path></svg>
6+
)
7+
}

pages/development/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"index": "前言",
3-
"frontend": "前端开发指南"
3+
"frontend": "前端开发指南",
4+
"admin": "后台单独部署"
45
}

pages/development/admin.mdx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# 后台单独部署
2+
3+
import { Callout } from 'nextra/components';
4+
5+
在正常情况下,你不需要单独部署后台,因为后台已经被打包到了后端中。
6+
7+
如果你有以下需求:
8+
9+
- 想使用其他域名作为后台地址
10+
- 想使用其他端口作为后台地址
11+
12+
那么你可以选择单独部署后台,或者你可以参考 [反向代理配置](/themes/kami#反向代理)
13+
14+
## 拉取源文件
15+
16+
```bash
17+
cd mx-space
18+
git clone https://github.com/mx-space/mx-admin.git --depth 1
19+
```
20+
21+
## 修改配置文件
22+
23+
进入到后台源码目录,找到 `.env.production` 文件,取消对应配置项的注释,然后修改为你的配置。
24+
25+
例如:
26+
27+
```txt
28+
VITE_APP_BASE_API=https://server.test.cn/api/v2
29+
VITE_APP_WEB_URL=https://www.test.cn
30+
VITE_APP_GATEWAY=https://server.test.cn
31+
# # VITE_APP_PUBLIC_URL=https://fastly.jsdelivr.net/gh/mx-space/admin-next@gh-pages/
32+
```
33+
34+
其他可以定义的配置在文件 `/src/configs.ts` 中。
35+
36+
## 构建
37+
38+
<Callout type="warning" emoji="⚠️">
39+
构建 mx-admin 需要的内存至少为 2 Gib,如果你服务器内存不足,你可以在本地构建成功后,将产物上传到服务器。
40+
41+
在 Windows 系统上,mx-admin 无法正常构建,你可以使用 WSL2 或者 Linux 系统。
42+
</Callout>
43+
44+
```bash
45+
pnpm i
46+
pnpm build
47+
```
48+
49+
## 部署产物
50+
51+
构建生成的产物在 dist 目录下,你可以直接把它们移动到你准备好的后台网站的根目录下。
52+
53+
假设你准备的后台网站域名是 `admin.test.cn`
54+
55+
网站根目录为 `/var/www/admin.test.cn/`
56+
57+
那么,你把 dist 目录下的所有文件移动到 `/var/www/admin.test.cn/` 目录下即可。
58+
59+
## 修改后端配置
60+
61+
编辑 Core 的 `.env` 文件,修改 `ALLOWED_ORIGINS` ,添加你的后台域名。
62+
63+
示例域名为 `admin.test.cn`
64+
65+
例如:
66+
67+
```txt
68+
# THIS ENV FILE EXAMPLE ONLY FOR DOCKER COMPOSE
69+
# SEE https://docs.docker.com/compose/environment-variables/#the-env-file
70+
JWT_SECRET=7294c34e0b28ad28 #此处填写一个长度不小于 16 个字符,不大于 32 个字符的字符串
71+
ALLOWED_ORIGINS=test.cn,www.test.cn,admin.test.cn
72+
```
73+
74+
然后重新启动 Core 即可:
75+
76+
```bash
77+
docker compose up -d
78+
```

pages/docs/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"docker": "Docker 部署",
99
"scripts": "预设脚本部署",
1010
"advanced": "进阶部署",
11+
"extra": "拓展内容",
1112
"community": "社区分享"
1213
}

pages/docs/extra.mdx

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# 拓展内容
2+
3+
import { Callout } from 'nextra/components';
4+
5+
<Callout type="warning" emoji="⚠️">
6+
此部分内容是可选的,在正常情况,你不需要参考这部分内容。以下部分仅针对有特定需求的用户进行参考。
7+
</Callout>
8+
9+
## 配置其他 Redis 服务
10+
11+
如果你需要使用来自 (远端 / 非容器) 的 Redis 服务,你可以通过使用 `argv` 来动态传入对应的配置项。
12+
13+
支持传入如下值:
14+
15+
- `redis_host` Redis 服务地址,域名、IP 都可以
16+
- `redis_port` Redis 服务端口
17+
- `redis_password` Redis 服务密码
18+
19+
在默认情况下,我们认为这样已经足够了。
20+
21+
### 对于进阶部署
22+
23+
针对这种部署方式,我们可以修改 `ecosystem.config.js` 在 12 行,也就是 `script` 这一项,添加你需要传入的值,如下所示:
24+
25+
```diff
26+
const { cpus } = require('os')
27+
const { execSync } = require('child_process')
28+
const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).split(
29+
'\n',
30+
)[0]
31+
32+
const cpuLen = cpus().length
33+
module.exports = {
34+
apps: [
35+
{
36+
name: 'mx-server',
37+
- script: 'out/index.js,
38+
+ script: 'out/index.js --redis_host=远端地址 --redis_password=redis?passwd',
39+
autorestart: true,
40+
exec_mode: 'cluster',
41+
```
42+
43+
当你修改完成,你需要重新构建,并重启服务:
44+
45+
```bash
46+
pnpm bundle
47+
pnpm prod:pm2
48+
```
49+
50+
## 配置其他 MongoDB 服务
51+
52+
如果你需要使用来自 (远端 / 非容器) 的 MongoDB 服务,你可以通过使用 `argv` 来动态传入对应的配置项。
53+
54+
支持传入如下值:
55+
56+
- `collection_name` 数据库集合名字
57+
- `db_host` MongoDB 服务地址,域名、IP 都可以
58+
- `db_port` MongoDB 服务端口
59+
- `db_user` MongoDB 服务用户名
60+
- `db_password` MongoDB 服务密码
61+
62+
<Callout type="warning" emoji="⚠️">
63+
如果你需要使用密码登录,你不仅仅需要传入 password,还需要传入 user,建议你对数据库集合划分好用户权限
64+
</Callout>
65+
66+
### 对于进阶部署
67+
68+
和 Redis 一样,我们可以修改 `ecosystem.config.js` 在 12 行,也就是 `script` 这一项,添加你需要传入的值,如下所示:
69+
70+
```diff
71+
const { cpus } = require('os')
72+
const { execSync } = require('child_process')
73+
const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).split(
74+
'\n',
75+
)[0]
76+
77+
const cpuLen = cpus().length
78+
module.exports = {
79+
apps: [
80+
{
81+
name: 'mx-server',
82+
+ script: 'out/index.js --db_host=远端地址 --db_user=mongodb-test --db_password=db?passwd',
83+
autorestart: true,
84+
exec_mode: 'cluster',
85+
```
86+
87+
当你修改完成,你需要重新构建,并重启服务:
88+
89+
```bash
90+
pnpm bundle
91+
pnpm prod:pm2
92+
```

pages/docs/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import { UimDocker } from '@components/Icons/Docker';
2323
import { UilPaintTool } from '@components/Icons/PaintTool';
2424
import { UimStar } from '@components/Icons/Star';
2525
import { FluentPeopleCommunity } from '@components/Icons/PeopleCommunity';
26+
import { UilExternalLinkAlt } from '@components/Icons/ExternalLinkAlt';
2627

2728
<Cards num={2}>
2829
<Card arrow title="Docker 部署 (推荐)" href="/docs/docker" icon={<UimDocker />} />
2930
<Card arrow title="预设脚本部署" href="/docs/scripts" icon={<UilPaintTool />} />
3031
<Card arrow title="进阶部署" href="/docs/advanced" icon={<UimStar />} />
3132
<Card arrow title="社区部署教程" href="/docs/community" icon={<FluentPeopleCommunity />} />
33+
<Card arrow title="拓展内容" href="/docs/extra" icon={<UilExternalLinkAlt />} />
3234
</Cards>
3335

3436
还有更多部署方式吗?欢迎您向文档提交 [Pull Request](https://github.com/mx-space/docs/pulls) 以分享您的部署方式。按上方**后端部署文档**完成你的部署后,你可以通过下面的方式继续部署 Mix Space **前端** *(为什么分开部署?请查看 [一些你需要知道的事情](#一些你需要知道的事情)*

pages/themes/kami.mdx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,59 @@ server {
181181

182182
</Steps>
183183

184+
## 更新
185+
186+
分为对 Kami 进行魔改和未魔改两种情况。
187+
188+
### 未魔改
189+
190+
<Callout emoji="💡">
191+
该方法适合于对 Kami 源代码没有做改动的用户。
192+
</Callout>
193+
194+
直接在 `kami` 文件夹下执行 `git pull origin master`
195+
196+
```bash
197+
cd ~/mx-space/kami
198+
git pull origin master
199+
```
200+
201+
安装依赖、构建、启动前端:
202+
203+
```bash
204+
pnpm i
205+
pnpm build
206+
pm2 start
207+
```
208+
209+
<Callout type="warning" emoji="⚠️">
210+
你应该理解的是,即便是你没有对 Kami 进行任何魔改,仍有可能出现代码不能自动合并的问题,对于这种情况,建议参考下面的已魔改部分完成升级。
211+
</Callout>
212+
213+
### 已魔改
214+
215+
<Callout emoji="💡">
216+
此方法适用于对前端魔改后的升级,我们认为你修改了 'kami/src' 里面的源代码,这样的话,容易出现合并冲突,建议手动替换。
217+
</Callout>
218+
219+
`kami` 文件夹改为任意名字,例如修改为 `kami.d`,然后拉取 kami 前端仓库,更新到稳定版本:
220+
221+
```bash
222+
cd ~/mx-space
223+
git clone https://github.com/mx-space/kami.git --depth=1
224+
cd kami && git fetch --tags && git checkout $(git rev-list --tags --max-count=1)
225+
```
226+
227+
然后将更新前之前配置时修改过的文件,如在 `kami.d` 中的 `.env``public` 文件夹复制到 `kami`,将你的修改的部分依次修改替换完成。
228+
229+
安装依赖、构建、启动前端:
230+
231+
```bash
232+
pnpm i
233+
pnpm build
234+
pm2 start
235+
```
236+
184237
<style global jsx>{`
185238
.nextra-content pre {
186239
max-height: 50vh;

pages/themes/shiro/index.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig';
236236

237237
进入 Vercel 部署此项目的仪表盘,点击上方的 Storage,进入设置页面,点击左侧的 Projects,将链接的项目取消链接,接着点击左侧的 Settings,点击右侧的 Delete Edge Config 按钮,即可完成删除。
238238

239+
## 更新
240+
241+
按照文档的部署方法使用 Vercel 托管的话,只需要在自己 Fork 的项目上 Sync Fork 即可(如图)。如果自己有魔改某些内容的话不要点击 Discard Changes,会把自己的魔改搞没了。
242+
243+
![](https://pan.vinua.cn/f/GRefM/0.png)
244+
239245
<style global jsx>{`
240246
.nextra-cards img {
241247
border-radius: 50%;

pages/usage/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"xlog": "xLog 集成",
1010
"search": "Algolia Search",
1111
"backup": "备份与回滚",
12+
"update": "更新 Mx-Space",
1213
"-- community": {
1314
"type": "separator",
1415
"title": "社区使用指南"

0 commit comments

Comments
 (0)