1
1
# 进阶部署
2
2
3
- import { Callout } from ' nextra/components' ;
3
+ import { Callout } from ' nextra/components'
4
4
5
5
<Callout type = " error" >
6
6
在您进行进阶部署前,我们给予最后的警告:如果你** 不是开发者** ,或者** 不想折腾** ,请不要选择** 进阶部署** ,因为它需要你具备一定的开发能力。
7
7
8
8
由于自身技术原因导致的问题,我们将** 不会提供任何技术支持** 。情节严重者,我们将** 永久拉黑** 您的账号。
9
+
9
10
</Callout >
10
11
11
12
## 要求
@@ -14,7 +15,7 @@ import { Callout } from 'nextra/components';
14
15
- 已安装 [ Git] ( https://git-scm.com/downloads ) , [ PNPM] ( https://pnpm.io/installation ) , [ PM2] ( https://pm2.keymetrics.io/docs/usage/quick-start/ )
15
16
- 已安装 [ MongoDB] ( https://www.mongodb.com/try/download/community ) , [ Redis] ( https://redis.io/download ) 并正常运行
16
17
17
- import { Steps } from ' nextra/components' ;
18
+ import { Steps } from ' nextra/components'
18
19
19
20
<Steps >
20
21
### 1. 克隆并安装
@@ -34,14 +35,9 @@ pnpm bundle
34
35
35
36
### 3. 配置 ecosystem.config.js
36
37
37
- <Configurator
38
+ <Configurator
38
39
args = { [' --color' , ' --encrypt_enable' ]}
39
40
env = { {
40
- MX_ENCRYPT_KEY: {
41
- type: ' password' ,
42
- tip: ' 加密密钥,可选' ,
43
- default: null ,
44
- },
45
41
PORT: {
46
42
type: ' number' ,
47
43
tip: ' 服务端口,可选' ,
@@ -102,9 +98,6 @@ pm2 start ecosystem.config.js
102
98
103
99
</Steps >
104
100
105
-
106
-
107
-
108
101
import { useState , useEffect } from ' react' ;
109
102
import copy from ' copy-to-clipboard' ;
110
103
@@ -115,43 +108,44 @@ export const Configurator = ({ args, template, env }) => {
115
108
);
116
109
const [nowTemplate, setNowTemplate] = useState (template );
117
110
118
- const handleToggleArg = (arg ) => {
119
- if (selectedArgs .includes (arg )) {
120
- setSelectedArgs (selectedArgs .filter ((item ) => item !== arg ));
121
- } else {
122
- setSelectedArgs ([... selectedArgs , arg ]);
123
- }
124
- };
111
+ const handleToggleArg = (arg ) => {
112
+ if (selectedArgs .includes (arg )) {
113
+ setSelectedArgs (selectedArgs .filter ((item ) => item !== arg ));
114
+ } else {
115
+ setSelectedArgs ([... selectedArgs , arg ]);
116
+ }
117
+ };
125
118
126
- const handleChange = (index , value ) => {
127
- const updatedEnvValues = [... envValues ];
128
- updatedEnvValues [index ] = value ;
129
- setEnvValues (updatedEnvValues );
130
- };
119
+ const handleChange = (index , value ) => {
120
+ const updatedEnvValues = [... envValues ];
121
+ updatedEnvValues [index ] = value ;
122
+ setEnvValues (updatedEnvValues );
123
+ };
131
124
132
- const handleCopyToClipboard = () => {
133
- copy (updatedEnvTemplate );
134
- };
125
+ const handleCopyToClipboard = () => {
126
+ copy (updatedEnvTemplate );
127
+ };
135
128
136
- useEffect (() => {
137
- const updatedTemplate = nowTemplate .replace (
138
- / args:\s * '([^ '] * )'/ ,
139
- ` args: '${selectedArgs .join (' ' )}' `
140
- );
141
- const updatedEnvTemplate = updatedTemplate .replace (
142
- / env:\s * {([^ }] * )}/ ,
143
- ` env: {
129
+ useEffect (() => {
130
+ const updatedTemplate = nowTemplate .replace (
131
+ / args:\s * '([^ '] * )'/ ,
132
+ ` args: '${selectedArgs .join (' ' )}' `
133
+ );
134
+ const updatedEnvTemplate = updatedTemplate .replace (
135
+ / env:\s * {([^ }] * )}/ ,
136
+ ` env: {
144
137
${Object .keys (env )
145
138
.map ((key , index ) => ` ${key }: '${envValues [index ]}' ` )
146
139
.join (' , \n ' )}
147
140
} `
148
- );
149
- setNowTemplate (updatedEnvTemplate );
150
- }, [selectedArgs , envValues ]);
141
+ );
142
+ setNowTemplate (updatedEnvTemplate );
143
+ }, [selectedArgs , envValues ]);
151
144
152
- return (
153
- <div >
154
- <div className = " p-4 mt-2" >
145
+ return (
146
+
147
+ <div >
148
+ <div className = " p-4 mt-2" >
155
149
156
150
<div id = " config" className = " border rounded-lg overflow-hidden h-12 mb-4 dark:border-gray-700 " style = { {
157
151
height: " 66.4px" ,
@@ -259,5 +253,6 @@ export const Configurator = ({ args, template, env }) => {
259
253
复制
260
254
</button >
261
255
</div >
262
- );
256
+
257
+ );
263
258
};
0 commit comments