chengjie vor 6 Monaten
Ursprung
Commit
d6de3a8053

+ 10 - 2
app.json

@@ -8,9 +8,17 @@
8 8
   "window": {
9 9
     "backgroundTextStyle": "light",
10 10
     "navigationBarBackgroundColor": "#fff",
11
-    "navigationBarTitleText": "英语学习助手",
11
+    "navigationBarTitleText": "秒过英语-AI生文记单词",
12 12
     "navigationBarTextStyle": "black"
13 13
   },
14 14
   "style": "v2",
15
-  "sitemapLocation": "sitemap.json"
15
+  "sitemapLocation": "sitemap.json",
16
+  "permission": {
17
+    "scope.writePhotosAlbum": {
18
+      "desc": "保存PDF文件需要使用相册权限"
19
+    }
20
+  },
21
+  "setting": {
22
+    "urlCheck": false
23
+  }
16 24
 }

+ 125 - 307
pages/article_generator/article_generator.js

@@ -8,10 +8,11 @@ Page({
8 8
     selectedWords: [],
9 9
     difficulty: 0,
10 10
     difficulties: constant1.arrHardLevel,
11
+    articleStyles: constant1.arrArticleStyle,
12
+    articleStyle: '',
11 13
     generatedArticle: '',
12 14
     articleTranslation: '',
13 15
     generating: false,
14
-    generatingImage: false,
15 16
     Content:"",
16 17
   },
17 18
 
@@ -40,21 +41,43 @@ Page({
40 41
     });
41 42
   },
42 43
 
44
+  onArticleStyleChange: function(e) {
45
+    this.setData({
46
+      articleStyle: e.detail.value
47
+    });
48
+    console.log('选择的文章类型:', e.detail.value);
49
+  },
50
+
43 51
   generateArticle: async function() {
44 52
     let that=this;
45
-    this.setData({ generating: true });
53
+
54
+    if (!this.data.articleStyle) {
55
+      wx.showToast({
56
+        title: '请选择文章类型',
57
+        icon: 'none'
58
+      });
59
+      return;
60
+    }
61
+
62
+    this.setData({ 
63
+      generating: true,
64
+      Content:"" 
65
+    });
46 66
 
47 67
     try {
48 68
       let url = common.Encrypt("GenerateArticle");
49
-      url="https://www.kylx365.com/apiData/"+url;
69
+      //url="https://www.kylx365.com/apiData/"+url;
70
+      url="http://localhost:3020/api/GenerateArticle";
50 71
       let words=that.data.wordList;
72
+      debugger;
51 73
       const cloudRes = await new Promise((resolve, reject) => {
52 74
         wx.request({
53 75
           url: url,
54 76
           method: "POST",
55 77
           data: {
56 78
             Words:JSON.stringify(words),
57
-            Level:that.data.difficulty
79
+            Level:that.data.difficulty,
80
+            Style:that.data.articleStyle
58 81
           },
59 82
           success: resolve,
60 83
           fail: reject,
@@ -102,317 +125,112 @@ Page({
102 125
     })
103 126
   },
104 127
 
105
-  generateImage: async function() {
106
-    const that = this;
107
-    this.setData({ generatingImage: true });
128
+  generateTestArticle:function(e){
129
+    this.setData({
130
+      Content:{
131
+        Title: "Sample Reading Article",
132
+        ArticleEnglishStr:"This is a <span>sample</span> article for testing the PDF generation functionality.It contains multiple paragraphs and some <span>bold text</span> to test formatting.The PDF should be generated with proper layout and styling.",
133
+        ArticleEnglish: [
134
+          "This is a <span>sample</span> article for testing the PDF generation functionality.",
135
+          "It contains multiple paragraphs and some <span>bold text</span> to test formatting.",
136
+          "The PDF should be generated with proper layout and styling."
137
+        ],
138
+        Question: [
139
+          {
140
+            QuestionEnglish: "What is the purpose of this article?",
141
+            OptionsEnglish: [
142
+              "A. To test PDF generation",
143
+              "B. To teach English",
144
+              "C. To demonstrate formatting",
145
+              "D. All of the above"
146
+            ]
147
+          },
148
+          {
149
+            QuestionEnglish: "What special formatting is used in this article?",
150
+            OptionsEnglish: [
151
+              "A. Italics",
152
+              "B. Bold text",
153
+              "C. Underline",
154
+              "D. Strikethrough"
155
+            ]
156
+          }
157
+        ]
158
+      },
159
+    })
160
+  },
161
+
162
+  //生成PDF文件
163
+  //访问服务器的GeneratePDF接口,提交this.data.Content数据,获得一个生成好的pdf文件,服务端的代码已经生成好
164
+  generatePDF: function(e) {
165
+    let that = this;
166
+    this.setData({ 
167
+      generatingPDF: true,
168
+    });
108 169
     
109
-    try {
110
-      const query = wx.createSelectorQuery();
111
-      query.select('#articleCanvas')
112
-        .fields({ node: true, size: true })
113
-        .exec((res) => {
114
-          const canvas = res[0].node;
115
-          const ctx = canvas.getContext('2d');
116
-          
117
-          // 基本设置
118
-          canvas.width = 595;
119
-          canvas.height = 842;
120
-          const margin = 40;
121
-          const lineHeight = 24;
122
-          const articleWidth = canvas.width - 2 * margin;
123
-          
124
-          // 计算内容高度的函数
125
-          const calculateHeight = () => {
126
-            let yPos = 40;
127
-            
128
-            // 标题高度
129
-            yPos += 40;
130
-            
131
-            // 文章高度
132
-            ctx.font = '16px Arial';
133
-            let articleText = that.data.Content.ArticleEnglish.join(" ");
134
-            articleText = articleText.replace(/<span[^>]*>(.*?)<\/span>/g, '###BOLD###$1###BOLD###');
135
-            const words = articleText.split(/\s+/);
136
-            
137
-            let lineWidth = 0;
138
-            words.forEach(word => {
139
-              if (!word) return;
140
-              
141
-              let wordToDraw = word.includes('###BOLD###') ? 
142
-                word.replace(/###BOLD###/g, '') : word;
143
-              
144
-              if (/[.,!?;:]$/.test(wordToDraw)) {
145
-                wordToDraw = wordToDraw.slice(0, -1);
146
-              }
147
-              
148
-              const spaceWidth = ctx.measureText(' ').width;
149
-              const wordWidth = ctx.measureText(wordToDraw).width;
150
-              const puncWidth = /[.,!?;:]$/.test(word) ? 
151
-                ctx.measureText(word.slice(-1)).width : 0;
152
-              
153
-              if (lineWidth + wordWidth + puncWidth + (lineWidth > 0 ? spaceWidth : 0) > articleWidth) {
154
-                yPos += lineHeight;
155
-                lineWidth = 0;
156
-              }
157
-              
158
-              lineWidth += wordWidth + puncWidth + (lineWidth > 0 ? spaceWidth : 0);
159
-            });
160
-            
161
-            yPos += lineHeight * 2;
162
-            
163
-            // 分隔线和问题标题高度
164
-            yPos += lineHeight * 2.5;
165
-            
166
-            // 问题高度
167
-            const questions = that.data.Content.Question;
168
-            questions.forEach(question => {
169
-              //debugger;
170
-              // 问题文本高度
171
-              const questionText = question.QuestionEnglish || '';
172
-              let textWidth = 0;
173
-              const words = questionText.split(' ');
174
-              words.forEach(word => {
175
-                const wordWidth = ctx.measureText(word + ' ').width;
176
-                if (textWidth + wordWidth > articleWidth) {
177
-                  yPos += lineHeight;
178
-                  textWidth = wordWidth;
179
-                } else {
180
-                  textWidth += wordWidth;
181
-                }
182
-              });
183
-              yPos += lineHeight;
184
-              
185
-              // 选项高度
186
-              if (question.OptionsEnglish && Array.isArray(question.OptionsEnglish)) {
187
-                question.OptionsEnglish.forEach(option => {
188
-                  if (!option) return;
189
-                  textWidth = 20; // 选项缩进
190
-                  const words = option.split(' ');
191
-                  words.forEach(word => {
192
-                    const wordWidth = ctx.measureText(word + ' ').width;
193
-                    if (textWidth + wordWidth > articleWidth) {
194
-                      yPos += lineHeight;
195
-                      textWidth = 20 + wordWidth;
196
-                    } else {
197
-                      textWidth += wordWidth;
198
-                    }
199
-                  });
200
-                  yPos += lineHeight;
201
-                });
202
-              }
203
-              
204
-              yPos += lineHeight / 2;
205
-            });
206
-            
207
-            return yPos + margin;
208
-          };
209
-          
210
-          // 计算所需高度
211
-          const requiredHeight = calculateHeight();
212
-          canvas.height = Math.max(842, requiredHeight);
213
-          
214
-          // 绘制背景
215
-          ctx.fillStyle = '#ffffff';
216
-          ctx.fillRect(0, 0, canvas.width, canvas.height);
217
-          ctx.fillStyle = '#000000';
218
-          ctx.textBaseline = 'top';
219
-          
220
-          // 绘制标题
221
-          let yPos = 40;
222
-          ctx.font = 'bold 20px Arial';
223
-          const title = that.data.Content.Title || "English Reading Practice";
224
-          const titleWidth = ctx.measureText(title).width;
225
-          ctx.fillText(title, (canvas.width - titleWidth) / 2, yPos);
226
-          yPos += 40;
227
-          
228
-          // 绘制文章
229
-          ctx.font = '16px Arial';
230
-          let articleText = that.data.Content.ArticleEnglish.join(" ");
231
-          articleText = articleText.replace(/<span[^>]*>(.*?)<\/span>/g, '###BOLD###$1###BOLD###');
232
-          const words = articleText.split(/\s+/);
233
-          
234
-          let xPos = margin;
235
-          let lineWidth = 0;
236
-          
237
-          words.forEach(word => {
238
-            if (!word) return;
239
-            
240
-            // 处理加粗和标点
241
-            let isBold = word.includes('###BOLD###');
242
-            let wordToDraw = isBold ? word.replace(/###BOLD###/g, '') : word;
243
-            let punctuation = '';
244
-            
245
-            if (/[.,!?;:]$/.test(wordToDraw)) {
246
-              punctuation = wordToDraw.slice(-1);
247
-              wordToDraw = wordToDraw.slice(0, -1);
248
-            }
249
-            
250
-            // 设置字体
251
-            ctx.font = isBold ? 'bold 16px Arial' : '16px Arial';
252
-            
253
-            // 计算宽度
254
-            const spaceWidth = ctx.measureText(' ').width;
255
-            const wordWidth = ctx.measureText(wordToDraw).width;
256
-            const puncWidth = punctuation ? ctx.measureText(punctuation).width : 0;
257
-            const totalWidth = wordWidth + puncWidth;
258
-            
259
-            // 检查换行
260
-            if (lineWidth + totalWidth + (lineWidth > 0 ? spaceWidth : 0) > articleWidth) {
261
-              xPos = margin;
262
-              yPos += lineHeight;
263
-              lineWidth = 0;
264
-            }
265
-            
266
-            // 添加空格
267
-            if (lineWidth > 0) {
268
-              xPos += spaceWidth;
269
-              lineWidth += spaceWidth;
270
-            }
271
-            
272
-            // 绘制单词
273
-            ctx.fillText(wordToDraw, xPos, yPos);
274
-            
275
-            // 绘制标点
276
-            if (punctuation) {
277
-              ctx.font = '16px Arial';
278
-              ctx.fillText(punctuation, xPos + wordWidth, yPos);
279
-            }
280
-            
281
-            xPos += totalWidth;
282
-            lineWidth += totalWidth;
283
-          });
284
-          
285
-          // 添加分隔线
286
-          yPos += lineHeight * 2;
287
-          ctx.beginPath();
288
-          ctx.moveTo(margin, yPos);
289
-          ctx.lineTo(canvas.width - margin, yPos);
290
-          ctx.stroke();
291
-          yPos += lineHeight;
292
-          
293
-          // 绘制问题标题
294
-          ctx.font = 'bold 16px Arial';
295
-          ctx.fillText("Reading Comprehension Questions:", margin, yPos);
296
-          yPos += lineHeight * 1.5;
297
-          
298
-          // 绘制问题
299
-          const questions = that.data.Content.Question;          
300
-          questions.forEach((question, index) => {
301
-            // 绘制问题
302
-            ctx.font = 'bold 16px Arial';
303
-            const questionText = `${index + 1}. ${question.QuestionEnglish || ''}`;
304
-            const words = questionText.split(' ');
305
-            let line = '';
306
-            let testLine = '';
307
-            
308
-            words.forEach(word => {
309
-              testLine = line + (line ? ' ' : '') + word;
310
-              if (ctx.measureText(testLine).width > articleWidth) {
311
-                ctx.fillText(line, margin, yPos);
312
-                yPos += lineHeight;
313
-                line = word;
314
-              } else {
315
-                line = testLine;
316
-              }
317
-            });
318
-            if (line) {
319
-              ctx.fillText(line, margin, yPos);
320
-              yPos += lineHeight;
321
-            }
322
-            
323
-            // 绘制选项
324
-            ctx.font = '16px Arial';
325
-            if (question.OptionsEnglish && Array.isArray(question.OptionsEnglish)) {
326
-              question.OptionsEnglish.forEach((option, optIndex) => {
327
-                if (!option) return;
328
-                
329
-                const optionText = `${option}`;
330
-                const optionWords = optionText.split(' ');
331
-                line = '';
332
-                testLine = '';
333
-                
334
-                optionWords.forEach(word => {
335
-                  testLine = line + (line ? ' ' : '') + word;
336
-                  if (ctx.measureText(testLine).width > articleWidth - 20) {
337
-                    ctx.fillText(line, margin + 20, yPos);
338
-                    yPos += lineHeight;
339
-                    line = word;
340
-                  } else {
341
-                    line = testLine;
342
-                  }
343
-                });
344
-                if (line) {
345
-                  ctx.fillText(line, margin + 20, yPos);
346
-                  yPos += lineHeight;
347
-                }
348
-              });
349
-            }
350
-            
351
-            yPos += lineHeight / 2;
352
-          });
170
+    let url = common.Encrypt("GeneratePDF");
171
+    url = "https://www.kylx365.com/apiData/" + url;
172
+    //url="http://localhost:3020/api/GeneratePDF";
173
+    wx.request({
174
+      url: url,
175
+      method: "POST",
176
+      data: {
177
+        Content: that.data.Content
178
+      },
179
+      responseType: 'arraybuffer',  // 确保响应类型为arraybuffer
180
+      success: function(res) {
181
+        // 将arraybuffer转为临时文件
182
+        const fsm = wx.getFileSystemManager();
183
+        const tempFilePath = `${wx.env.USER_DATA_PATH}/temp_${Date.now()}.pdf`;
184
+        
185
+        try {
186
+          fsm.writeFileSync(
187
+            tempFilePath,
188
+            res.data,
189
+            'binary'
190
+          );
191
+
192
+          // 直接使用临时文件路径,不再尝试永久保存
193
+          console.log('文件已生成:', tempFilePath);
353 194
           
354
-          // 保存图片
355
-          wx.canvasToTempFilePath({
356
-            canvas: canvas,
357
-            width: canvas.width,
358
-            height: canvas.height,
359
-            destWidth: canvas.width * 2,
360
-            destHeight: canvas.height * 2,
361
-            fileType: 'jpg',
362
-            quality: 0.9,
363
-            success(res) {
364
-              wx.saveImageToPhotosAlbum({
365
-                filePath: res.tempFilePath,
366
-                success() {
367
-                  wx.showToast({
368
-                    title: '图片已保存到相册',
369
-                    icon: 'success',
370
-                    duration: 2000
371
-                  });
372
-                  that.setData({ generatingImage: false });
373
-                },
374
-                fail(err) {
375
-                  console.error('保存图片失败:', err);
376
-                  if (err.errMsg.indexOf('auth deny') >= 0 || err.errMsg.indexOf('authorize') >= 0) {
377
-                    wx.showModal({
378
-                      title: '提示',
379
-                      content: '需要您授权保存图片到相册',
380
-                      showCancel: false,
381
-                      success() {
382
-                        wx.openSetting({
383
-                          success(res) {
384
-                            console.log('设置结果', res);
385
-                          }
386
-                        });
387
-                      }
388
-                    });
389
-                  } else {
390
-                    wx.showToast({
391
-                      title: '保存图片失败',
392
-                      icon: 'none'
393
-                    });
394
-                  }
395
-                  that.setData({ generatingImage: false });
396
-                }
195
+          // 打开PDF文件预览
196
+          wx.openDocument({
197
+            filePath: tempFilePath,
198
+            fileType: 'pdf',
199
+            showMenu: true,  // 显示右上角菜单,可以分享
200
+            success: function() {
201
+              console.log('打开文档成功');
202
+              wx.showToast({
203
+                title: 'PDF生成成功',
204
+                icon: 'success'
397 205
               });
398 206
             },
399
-            fail(err) {
400
-              console.error('生成图片失败:', err);
207
+            fail: function(error) {
208
+              console.error('打开文档失败:', error);
401 209
               wx.showToast({
402
-                title: '生成图片失败',
210
+                title: '打开文件失败',
403 211
                 icon: 'none'
404 212
               });
405
-              that.setData({ generatingImage: false });
406 213
             }
407 214
           });
215
+        } catch (error) {
216
+          console.error('写入文件失败:', error);
217
+          wx.showToast({
218
+            title: '写入文件失败',
219
+            icon: 'none'
220
+          });
221
+        }
222
+      },
223
+      fail: function(err) {
224
+        console.error('请求GeneratePDF接口失败:', err);
225
+        wx.showToast({
226
+          title: '网络错误,请稍候重试',
227
+          icon: 'none'
408 228
         });
409
-    } catch (error) {
410
-      console.error('生成图片过程出错:', error);
411
-      wx.showToast({
412
-        title: '生成图片失败',
413
-        icon: 'none'
414
-      });
415
-      this.setData({ generatingImage: false });
416
-    }
417
-  }
229
+      },
230
+      complete: function() {
231
+        that.setData({ generatingPDF: false });
232
+      }
233
+    });
234
+  },
235
+
418 236
 });

+ 35 - 7
pages/article_generator/article_generator.wxml

@@ -26,6 +26,25 @@
26 26
     </radio-group>
27 27
   </view>
28 28
 
29
+  <!-- 文章类型选择区域 -->
30
+  <view class="section">
31
+    <view class="section-title">选择文章类型</view>
32
+    <radio-group class="two-column-layout" bindchange="onArticleStyleChange">
33
+      <block wx:for="{{articleStyles}}" wx:key="index" wx:for-item="category">
34
+        <view class="style-category">{{category.Name}}</view>
35
+        <view class="style-options-container">
36
+          <label class="style-option" 
37
+            wx:for="{{category.List}}" 
38
+            wx:key="Name"
39
+            wx:for-item="style">
40
+            <radio value="{{style.Name}}" checked="{{articleStyle === style.Name}}"/>
41
+            <text>{{style.Name}}</text>
42
+          </label>
43
+        </view>
44
+      </block>
45
+    </radio-group>
46
+  </view>
47
+
29 48
   <!-- 生成按钮 -->
30 49
   <view class="section">
31 50
     <button 
@@ -35,6 +54,13 @@
35 54
       loading="{{generating}}">
36 55
       生成文章
37 56
     </button>
57
+
58
+    <button 
59
+      class="generate-btn" 
60
+      type="primary" 
61
+      bindtap="generateTestArticle">
62
+      测试文章(非AI生成)
63
+    </button>
38 64
   </view>
39 65
 
40 66
   <!-- 生成的文章区域 -->
@@ -62,14 +88,16 @@
62 88
         答案:<view class="Answer1" wx:for="{{Content.Question}}" wx:key="index">({{index+1}}) {{item.Answer}}</view>
63 89
       </view>
64 90
     </view>
65
-    <!-- 生成图片按钮 -->
91
+    <!-- 生成图片和PDF按钮 -->
66 92
     <view class="section" wx:if="{{Content}}">
67
-      <button 
68
-        class="generate-image-btn" 
69
-        bindtap="generateImage"
70
-        loading="{{generatingImage}}">
71
-        生成练习图片
72
-      </button>
93
+      <view class="button-group">
94
+        <button 
95
+          class="generate-image-btn" 
96
+          bindtap="generatePDF"
97
+          loading="{{generatingPDF}}">
98
+          生成PDF文件
99
+        </button>
100
+      </view>
73 101
     </view>
74 102
   </block>
75 103
 

+ 81 - 3
pages/article_generator/article_generator.wxss

@@ -59,16 +59,39 @@
59 59
 .difficulty-group {
60 60
   display: flex;
61 61
   flex-direction: column;
62
-  gap: 20rpx;
63 62
   width: 650rpx;
64 63
 }
65 64
 
65
+.two-column-layout {
66
+  display: flex;
67
+  flex-direction: column;
68
+  width: 100%;
69
+}
70
+
71
+.style-options-container {
72
+  display: flex;
73
+  flex-wrap: wrap;
74
+  width: 100%;
75
+  gap: 10rpx;
76
+}
77
+
66 78
 .difficulty-item {
67 79
   display: flex;
68 80
   align-items: center;
69 81
   gap: 10rpx;
70 82
   font-size: 28rpx;
71 83
   color: #333;
84
+  width: calc(50% - 10rpx);
85
+  box-sizing: border-box;
86
+  padding: 10rpx;
87
+}
88
+
89
+.style-option{
90
+  font-size:28rpx;
91
+}
92
+
93
+.full-width {
94
+  width: 100% !important;
72 95
 }
73 96
 
74 97
 /* 生成按钮样式 */
@@ -146,9 +169,64 @@
146 169
   visibility: hidden;
147 170
 }
148 171
 
172
+/* 按钮组样式 */
173
+.button-group {
174
+  display: flex;
175
+  justify-content: space-between;
176
+  gap: 20rpx;
177
+  width: 100%;
178
+  padding: 0 20rpx;
179
+  box-sizing: border-box;
180
+}
181
+
149 182
 .generate-image-btn {
150
-  width: 80% !important;
151
-  margin: 30rpx auto !important;
183
+  flex: 1;
184
+  margin: 30rpx 0 !important;
152 185
   background-color: #1890ff;
153 186
   color: #fff;
187
+  font-size: 36rpx;
188
+  padding: 0 10rpx;
189
+  line-height: 80rpx;
190
+}
191
+
192
+/* 文章类型选择样式 */
193
+.style-category {
194
+  width: 100%;
195
+  font-size: 28rpx;
196
+  color: #666;
197
+  padding: 10rpx 0;
198
+  margin-top: 20rpx;
199
+  margin-bottom: 10rpx;
200
+  font-weight: bold;
201
+  border-bottom: 1rpx solid #eee;
202
+}
203
+
204
+.difficulty-group radio-group {
205
+  display: flex;
206
+  flex-wrap: wrap;
207
+  width: 100%;
208
+}
209
+
210
+.difficulty-item {
211
+  width: 50%;
212
+  box-sizing: border-box;
213
+  padding: 10rpx;
214
+}
215
+
216
+.difficulty-item radio {
217
+  transform: scale(0.8);
218
+}
219
+
220
+.difficulty-item text {
221
+  font-size: 28rpx;
222
+  color: #333;
223
+}
224
+
225
+/* 难度选择保持单列 */
226
+.difficulty-select radio-group {
227
+  flex-direction: column;
228
+}
229
+
230
+.difficulty-select .difficulty-item {
231
+  width: 100%;
154 232
 }

+ 7 - 2
pages/index/index.js

@@ -5,8 +5,7 @@ const app = getApp();
5 5
 
6 6
 Page({
7 7
   data: {
8
-    //Words:"apple\rblue\rred\rgreen\rbanana\rfish\rtable\rboy\rgirl"
9
-    Words:"go\r\ndo\r\nbe\r\ngood\r\nking\r\nriver\r\nfire\r\ndragon"
8
+    Words:""
10 9
   },
11 10
   onLoad: function (options) {
12 11
     var that = this;
@@ -42,6 +41,12 @@ Page({
42 41
       url: url,
43 42
     });
44 43
   },
44
+  getTest:function(){
45
+    this.setData({
46
+      Words:"go\r\ndo\r\nbe\r\ngood\r\nking\r\nriver\r\nfire\r\ndragon"
47
+    });
48
+  },
49
+
45 50
   onShareAppMessage: function () {
46 51
     return {
47 52
       title: app.globalData.ShareTitle,

+ 3 - 0
pages/index/index.wxml

@@ -4,6 +4,9 @@
4 4
   <button class="feature-btn" bindtap="goto" data-url="../ocr/ocr">
5 5
     <view class="feature-name">拍照识别获得单词</view>
6 6
   </button>
7
+  <button class="feature-btn" bindtap="getTest">
8
+    <view class="feature-name">测试使用单词</view>
9
+  </button>
7 10
   
8 11
   <button class="footer feature-btn btn-retake" bindtap="goto" data-url="../article_generator/article_generator">
9 12
       <view class="feature-name">生成文章</view>

+ 57 - 12
utils/constant.js

@@ -1,15 +1,60 @@
1 1
 module.exports = {
2 2
   arrHardLevel: [{
3
-    Level:0,
4
-    Name:"小学生难度"
5
-  },{
6
-    Level:1,
7
-    Name:"初中生难度"
8
-   },{
9
-    Level:2,
10
-    Name:"高中生难度"
11
-   },{
12
-    Level:3,
13
-    Name:"大学生难度"
14
-   }],
3
+    Level: 0,
4
+    Name: "小学生难度"
5
+  }, {
6
+    Level: 1,
7
+    Name: "初中生难度"
8
+  }, {
9
+    Level: 2,
10
+    Name: "高中生难度"
11
+  }, {
12
+    Level: 3,
13
+    Name: "大学生难度"
14
+  }],
15
+  arrArticleStyle: [{
16
+      Name: "童话类",
17
+      List: [{
18
+        Name: "童话故事"
19
+      }, {
20
+        Name: "寓言故事"
21
+      }, {
22
+        Name: "科幻/奇幻故事"
23
+      }]
24
+    },
25
+    {
26
+      Name: "生活类",
27
+      List: [{
28
+        Name: "校园文化"
29
+      }, {
30
+        Name: "家庭故事"
31
+      }, {
32
+        Name: "节日与文化"
33
+      }, {
34
+        Name: "旅行见闻"
35
+      }]
36
+    },
37
+    {
38
+      Name: "自然与科学",
39
+      List: [{
40
+        Name: "动物故事"
41
+      }, {
42
+        Name: "环保主题"
43
+      }, {
44
+        Name: "科普短文"
45
+      }]
46
+    },
47
+    {
48
+      Name: "情感与哲理",
49
+      List: [{
50
+        Name: "友情与分享"
51
+      }, {
52
+        Name: "成长烦恼"
53
+      }, {
54
+        Name: "人生哲理"
55
+      }, {
56
+        Name: "励志故事"
57
+      }]
58
+    },
59
+  ]
15 60
 }