|
|
@@ -183,7 +183,7 @@ export async function GenerateArticle(ctx) {
|
|
183
|
183
|
if (result === 0) {
|
|
184
|
184
|
const params = ctx.request.body;
|
|
185
|
185
|
const words = params.Words;
|
|
186
|
|
- const articleStyle = params.ArticleStyle;
|
|
|
186
|
+ let articleStyle = params.ArticleStyle;
|
|
187
|
187
|
|
|
188
|
188
|
//文章类型
|
|
189
|
189
|
const ARTICLE_STYLE={
|
|
|
@@ -234,8 +234,13 @@ export async function GenerateArticle(ctx) {
|
|
234
|
234
|
|
|
235
|
235
|
content = content.replace("[难度]",LEVEL[Number(params.Level)].Content);
|
|
236
|
236
|
|
|
237
|
|
- if (articleStyle=="任意")
|
|
238
|
|
- articleStyle=stringUtils.Random(0,ARTICLE_STYLE.length-1);
|
|
|
237
|
+ if (articleStyle=="任意") {
|
|
|
238
|
+ // 获取ARTICLE_STYLE对象的所有键(文章类型)
|
|
|
239
|
+ const articleTypes = Object.keys(ARTICLE_STYLE);
|
|
|
240
|
+ // 随机选择一个文章类型
|
|
|
241
|
+ const randomIndex = stringUtils.Random(0, articleTypes.length-1);
|
|
|
242
|
+ articleStyle = articleTypes[randomIndex];
|
|
|
243
|
+ }
|
|
239
|
244
|
content = content.replace("[类型]",ARTICLE_STYLE[articleStyle]);
|
|
240
|
245
|
|
|
241
|
246
|
|