Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Jan 31, 2024
1 parent 3311da7 commit ef1478e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 43 deletions.
77 changes: 36 additions & 41 deletions pages/docs/advanced.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 进阶部署

import { Callout } from 'nextra/components';
import { Callout } from 'nextra/components'

<Callout type="error">
在您进行进阶部署前,我们给予最后的警告:如果你**不是开发者**,或者**不想折腾**,请不要选择**进阶部署**,因为它需要你具备一定的开发能力。

由于自身技术原因导致的问题,我们将**不会提供任何技术支持**。情节严重者,我们将**永久拉黑**您的账号。

</Callout>

## 要求
Expand All @@ -14,7 +15,7 @@ import { Callout } from 'nextra/components';
- 已安装 [Git](https://git-scm.com/downloads), [PNPM](https://pnpm.io/installation), [PM2](https://pm2.keymetrics.io/docs/usage/quick-start/)
- 已安装 [MongoDB](https://www.mongodb.com/try/download/community), [Redis](https://redis.io/download) 并正常运行

import { Steps } from 'nextra/components';
import { Steps } from 'nextra/components'

<Steps>
### 1. 克隆并安装
Expand All @@ -34,14 +35,9 @@ pnpm bundle

### 3. 配置 ecosystem.config.js

<Configurator
<Configurator
args={['--color', '--encrypt_enable']}
env={{
MX_ENCRYPT_KEY: {
type: 'password',
tip: '加密密钥,可选',
default: null,
},
PORT: {
type: 'number',
tip: '服务端口,可选',
Expand Down Expand Up @@ -102,9 +98,6 @@ pm2 start ecosystem.config.js

</Steps>




import { useState, useEffect } from 'react';
import copy from 'copy-to-clipboard';

Expand All @@ -115,43 +108,44 @@ export const Configurator = ({ args, template, env }) => {
);
const [nowTemplate, setNowTemplate] = useState(template);

const handleToggleArg = (arg) => {
if (selectedArgs.includes(arg)) {
setSelectedArgs(selectedArgs.filter((item) => item !== arg));
} else {
setSelectedArgs([...selectedArgs, arg]);
}
};
const handleToggleArg = (arg) => {
if (selectedArgs.includes(arg)) {
setSelectedArgs(selectedArgs.filter((item) => item !== arg));
} else {
setSelectedArgs([...selectedArgs, arg]);
}
};

const handleChange = (index, value) => {
const updatedEnvValues = [...envValues];
updatedEnvValues[index] = value;
setEnvValues(updatedEnvValues);
};
const handleChange = (index, value) => {
const updatedEnvValues = [...envValues];
updatedEnvValues[index] = value;
setEnvValues(updatedEnvValues);
};

const handleCopyToClipboard = () => {
copy(updatedEnvTemplate);
};
const handleCopyToClipboard = () => {
copy(updatedEnvTemplate);
};

useEffect(() => {
const updatedTemplate = nowTemplate.replace(
/args:\s*'([^']*)'/,
`args: '${selectedArgs.join(' ')}'`
);
const updatedEnvTemplate = updatedTemplate.replace(
/env:\s*{([^}]*)}/,
`env: {
useEffect(() => {
const updatedTemplate = nowTemplate.replace(
/args:\s*'([^']*)'/,
`args: '${selectedArgs.join(' ')}'`
);
const updatedEnvTemplate = updatedTemplate.replace(
/env:\s*{([^}]*)}/,
`env: {
${Object.keys(env)
.map((key, index) => `${key}: '${envValues[index]}'`)
.join(', \n ')}
}`
);
setNowTemplate(updatedEnvTemplate);
}, [selectedArgs, envValues]);
);
setNowTemplate(updatedEnvTemplate);
}, [selectedArgs, envValues]);

return (
<div>
<div className="p-4 mt-2">
return (

<div>
<div className="p-4 mt-2">

<div id="config" className="border rounded-lg overflow-hidden h-12 mb-4 dark:border-gray-700 " style={{
height: "66.4px",
Expand Down Expand Up @@ -259,5 +253,6 @@ export const Configurator = ({ args, template, env }) => {
复制
</button>
</div>
);

);
};
7 changes: 5 additions & 2 deletions pages/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig'
- **`加密密钥`**:如果你不知道这是什么,那么不建议开启此功能,具体内容可参考 https://mx-space.js.org/usage/security.html

<Callout type="warning">
若开启加密,则需注意密钥长度**必须为 64
**,不然会在初始化时报错。注意这是**不可逆**的,务必保存自己的秘钥。所以并不是非常推荐使用,除非你真的需要加密,
若开启加密,则需注意密钥长度**必须为 64 位**,不然会在初始化时报错。注意这是**不可逆**的,务必保存自己的秘钥。所以并不是非常推荐使用,除非你真的需要加密
API Key.

密钥可以通过 `openssl rand -hex 32` 命令生成。请务必牢记。

</Callout>

### 启动 Core
Expand Down
12 changes: 12 additions & 0 deletions pages/usage/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ node index.js --encrypt_enable

可以通过附加 `--encrypt_key <key>` 来指定加密密钥,长度必须为 64 位。请牢记此密钥。或者通过环境变量 `MX_ENCRYPT_KEY` 也可以指定密钥。

<Callout type="warning">
若开启加密,则需注意密钥长度**必须为 64 位**,不然会在初始化时报错。注意这是**不可逆**的,务必保存自己的秘钥。
API Key.

</Callout>

密钥可以通过 `openssl rand -hex 32` 命令生成。请务必牢记。

::: info
`MX_ENCRYPT_KEY` `--encrypt_key` 不是必须的,默认取机器的 [machine-id](https://www.npmjs.com/package/node-machine-id)
:::
Expand All @@ -36,3 +44,7 @@ node index.js --encrypt_enable
cd core
tsx src/migration/helper/encrypt-configs.ts
```

## 疑难解答

如果出现 `Invalid key length`,请你确定是否开启了此功能,并且 key 的长度是否为 64 位长度。

0 comments on commit ef1478e

Please sign in to comment.