chengjie 4 maanden geleden
bovenliggende
commit
976785f4fc
3 gewijzigde bestanden met toevoegingen van 678 en 10 verwijderingen
  1. 660 0
      public/mg/yjbdc_articles.html
  2. 1 0
      src/api/yjbdc/routes.js
  3. 17 10
      src/api/yjbdc/yjbdcController.js

+ 660 - 0
public/mg/yjbdc_articles.html

@@ -0,0 +1,660 @@
1
+<!DOCTYPE html>
2
+<html>
3
+
4
+<head>
5
+    <meta charset="UTF-8">
6
+    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
7
+    <title>YJBDC文章维护</title>
8
+    <script src="https://kylx365-1253256735.file.myqcloud.com/js/jquery-1.10.2.min.js"></script>
9
+    <script src="https://kylx365-1253256735.file.myqcloud.com/js/vue.min.js"></script>
10
+    <style>
11
+        .main00 {
12
+            width: 100%;
13
+            height: 100vh;
14
+            min-height: 600px;
15
+            background: white;
16
+            display: flex;
17
+            flex-direction: column;
18
+            overflow: hidden;
19
+        }
20
+
21
+        .ListTop {
22
+            width: 100%;
23
+            height: 60px;
24
+            background: white;
25
+            border-bottom: 1px solid #EEEEEE;
26
+            justify-content: flex-start;
27
+            flex-shrink: 0;
28
+        }
29
+
30
+        .ListTop3 {
31
+            margin-left: 40px;
32
+            height: 50px;
33
+            align-items: center;
34
+        }
35
+
36
+        .title {
37
+            font-size: 24px;
38
+            color: #333333;
39
+            font-weight: bold;
40
+        }
41
+
42
+        .main0 {
43
+            width: 100%;
44
+            background: white;
45
+            flex: 1;
46
+            min-height: 0;
47
+            overflow: hidden;
48
+            display: flex;
49
+            position: relative;
50
+            align-items: flex-start;
51
+        }
52
+
53
+        .search-panel {
54
+            width: 400px;
55
+            border-right: 1px solid #EEEEEE;
56
+            background: #F9F9F9;
57
+            display: flex;
58
+            flex-direction: column;
59
+            height: 100%;
60
+            position: relative;
61
+            flex-shrink: 0;
62
+        }
63
+
64
+        .search-box {
65
+            padding: 15px;
66
+            border-bottom: 1px solid #EEEEEE;
67
+            background: white;
68
+            width: 100%;
69
+            justify-content: center;
70
+        }
71
+
72
+        .search-input {
73
+            width: 200px;
74
+            height: 32px;
75
+            padding: 0 32px 0 12px;
76
+            border: 1px solid #DDDDDD;
77
+            border-radius: 4px;
78
+            font-size: 14px;
79
+            color: #333333;
80
+        }
81
+
82
+        .search-input:focus {
83
+            border-color: #4A90E2;
84
+            outline: none;
85
+        }
86
+
87
+        .btn33 {
88
+            width: 32px;
89
+            height: 32px;
90
+            margin-left: 8px;
91
+            border-radius: 4px;
92
+            background: #F5F5F5;
93
+            cursor: pointer;
94
+            justify-content: center;
95
+            align-items: center;
96
+        }
97
+
98
+        .btn33:hover {
99
+            background: #EEEEEE;
100
+        }
101
+
102
+        .json-editor {
103
+            width: calc(100% - 400px);
104
+            padding: 20px;
105
+            overflow-y: auto;
106
+            height: calc(100% - 60px);
107
+        }
108
+
109
+        .json-node {
110
+            margin: 5px 0;
111
+            padding: 5px;
112
+            font-family: monospace;
113
+        }
114
+
115
+        .json-key {
116
+            color: #881391;
117
+            margin-right: 5px;
118
+        }
119
+
120
+        .json-string {
121
+            color: #268BD2;
122
+        }
123
+
124
+        .json-number {
125
+            color: #859900;
126
+        }
127
+
128
+        .json-boolean {
129
+            color: #CB4B16;
130
+        }
131
+
132
+        .json-null {
133
+            color: #93A1A1;
134
+        }
135
+
136
+        .editable {
137
+            cursor: pointer;
138
+        }
139
+
140
+        .editable:hover {
141
+            background-color: #f0f0f0;
142
+        }
143
+
144
+        .json-editor-input {
145
+            width: 100%;
146
+            padding: 4px;
147
+            font-family: monospace;
148
+            border: 1px solid #4A90E2;
149
+            border-radius: 4px;
150
+        }
151
+
152
+        .btn-group {
153
+            position: fixed;
154
+            bottom: 20px;
155
+            right: 20px;
156
+            text-align: right;
157
+            padding: 20px;
158
+            background: white;
159
+            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
160
+            border-radius: 4px;
161
+        }
162
+
163
+        .btn {
164
+            min-width: 30px;
165
+            height: 36px;
166
+            padding: 0 16px;
167
+            margin-left: 12px;
168
+            border: none;
169
+            border-radius: 4px;
170
+            cursor: pointer;
171
+            font-size: 14px;
172
+            transition: all 0.3s;
173
+        }
174
+
175
+        .btn-primary {
176
+            background: #4A90E2;
177
+            color: white;
178
+        }
179
+
180
+        .btn-primary:hover {
181
+            background: #357ABD;
182
+        }
183
+
184
+        .btn-default {
185
+            background: white;
186
+            border: 1px solid #DDDDDD;
187
+            color: #666666;
188
+        }
189
+
190
+        .btn-default:hover {
191
+            background: #F5F5F5;
192
+            border-color: #CCCCCC;
193
+        }
194
+
195
+        .toast {
196
+            position: fixed;
197
+            top: 20px;
198
+            left: 50%;
199
+            transform: translateX(-50%);
200
+            padding: 12px 24px;
201
+            background: rgba(0, 0, 0, 0.7);
202
+            color: white;
203
+            border-radius: 4px;
204
+            z-index: 9999;
205
+            opacity: 0;
206
+            transition: opacity 0.3s;
207
+        }
208
+
209
+        .toast.show {
210
+            opacity: 1;
211
+        }
212
+
213
+        .toast.success {
214
+            background: #4CAF50;
215
+        }
216
+
217
+        .toast.error {
218
+            background: #F44336;
219
+        }
220
+
221
+        .toast.info {
222
+            background: #2196F3;
223
+        }
224
+
225
+        /* Loading样式 */
226
+        .loading-overlay {
227
+            position: absolute;
228
+            top: 0;
229
+            left: 0;
230
+            width: 100%;
231
+            height: 100%;
232
+            background-color: rgba(255, 255, 255, 0.7);
233
+            display: flex;
234
+            justify-content: center;
235
+            align-items: center;
236
+            z-index: 100;
237
+        }
238
+
239
+        .loading-spinner {
240
+            width: 50px;
241
+            height: 50px;
242
+            border: 5px solid #f3f3f3;
243
+            border-top: 5px solid #4A90E2;
244
+            border-radius: 50%;
245
+            animation: spin 1s linear infinite;
246
+        }
247
+
248
+        @keyframes spin {
249
+            0% { transform: rotate(0deg); }
250
+            100% { transform: rotate(360deg); }
251
+        }
252
+
253
+        .clear-btn {
254
+            position: absolute;
255
+            right: 12px;
256
+            top: 50%;
257
+            transform: translateY(-50%);
258
+            width: 16px;
259
+            height: 16px;
260
+            background-color: #999;
261
+            border-radius: 50%;
262
+            display: flex;
263
+            align-items: center;
264
+            justify-content: center;
265
+            cursor: pointer;
266
+            transition: background-color 0.2s;
267
+        }
268
+
269
+        .clear-btn:hover {
270
+            background-color: #666;
271
+        }
272
+
273
+        .clear-x {
274
+            position: relative;
275
+            width: 8px;
276
+            height: 8px;
277
+        }
278
+
279
+        .clear-x:before,
280
+        .clear-x:after {
281
+            content: '';
282
+            position: absolute;
283
+            width: 8px;
284
+            height: 2px;
285
+            background-color: white;
286
+            top: 3px;
287
+            left: 0;
288
+        }
289
+
290
+        .clear-x:before {
291
+            transform: rotate(45deg);
292
+        }
293
+
294
+        .clear-x:after {
295
+            transform: rotate(-45deg);
296
+        }
297
+
298
+        .FlexRow {
299
+            display: flex;
300
+            flex-direction: row;
301
+        }
302
+
303
+        .FlexColumn {
304
+            display: flex;
305
+            flex-direction: column;
306
+        }
307
+    </style>
308
+</head>
309
+
310
+<body class="container FlexRow">
311
+    <div id="app" class="main00 FlexColumn">
312
+        <div class="ListTop FlexRow">
313
+            <div class="ListTop3 FlexRow">
314
+                <div class="title">YJBDC文章维护</div>
315
+            </div>
316
+        </div>
317
+        <div class="main0 FlexRow">
318
+            <!-- 左侧搜索面板 -->
319
+            <div class="search-panel" style="position: relative;">
320
+                <div v-if="isSearchLoading" class="loading-overlay">
321
+                    <div class="loading-spinner"></div>
322
+                </div>
323
+                <div class="search-box FlexRow">
324
+                    <div style="position: relative;">
325
+                        <input type="text" class="search-input" v-model="searchText" @keyup.enter="searchArticles"
326
+                            placeholder="输入用户ID搜索...">
327
+                        <div class="clear-btn" v-show="searchText" @click="clearSearch">
328
+                            <span class="clear-x"></span>
329
+                        </div>
330
+                    </div>
331
+                    <div class="btn33 FlexRow" @click="searchArticles">
332
+                        <img title="搜索" alt="搜索"
333
+                            src="https://kylx365-1253256735.file.myqcloud.com/web/universalpic_search_gray_30x30.png"
334
+                            style="width: 20px; height: 20px;" />
335
+                    </div>
336
+                </div>
337
+                <!-- 搜索结果列表 -->
338
+                <div class="search-results" style="flex: 1; overflow-y: auto; padding: 10px;">
339
+                    <div v-if="articles && articles.length > 0" 
340
+                         v-for="(article, index) in articles" 
341
+                         :key="index"
342
+                         @click="selectArticle(article)"
343
+                         style="padding: 10px; margin: 5px 0; background: white; border-radius: 4px; cursor: pointer; transition: background-color 0.2s;"
344
+                         :style="{ backgroundColor: selectedArticle === article ? '#e6f3ff' : 'white' }"
345
+                         class="search-result-item">
346
+                        <div style="font-weight: bold;">文章ID: {{ article.ID }}</div>
347
+                        <div style="font-size: 12px; color: #666; margin-top: 4px;">
348
+                            创建时间: {{ article.CreateTime }}
349
+                        </div>
350
+                        <div style="font-size: 12px; color: #666;">
351
+                            标题: {{ article.ArticleStart }}
352
+                        </div>
353
+                        <div style="font-size: 12px; color: #666;">
354
+                            字数: {{ article.words }}
355
+                        </div>
356
+                    </div>
357
+                    <div v-else-if="articles && articles.length === 0" 
358
+                         style="text-align: center; color: #999; padding: 20px;">
359
+                        未找到相关文章
360
+                    </div>
361
+                </div>
362
+            </div>
363
+
364
+            <!-- 右侧文章内容编辑器 -->
365
+            <div class="json-editor" v-if="selectedArticle" style="position: relative;">
366
+                <div v-if="isDetailLoading" class="loading-overlay">
367
+                    <div class="loading-spinner"></div>
368
+                </div>
369
+                <div class="json-node">
370
+                    <span class="json-key">文章ID:</span>
371
+                    <span class="json-number">{{ selectedArticle.ID }}</span>
372
+                </div>
373
+                <div class="json-node">
374
+                    <span class="json-key">是否精选:</span>
375
+                    <span class="json-number editable" @dblclick="editValue(selectedArticle, 'IsFine', 'IsFine')">
376
+                        <template v-if="editingKey === 'IsFine'">
377
+                            <input type="number" class="json-editor-input" v-model.number="selectedArticle.IsFine"
378
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
379
+                        </template>
380
+                        <template v-else>
381
+                            {{ selectedArticle.IsFine }}
382
+                        </template>
383
+                    </span>
384
+                </div>
385
+                <div class="json-node">
386
+                    <span class="json-key">文章英文标题:</span>
387
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'ArticleTitle', 'ArticleTitle')">
388
+                        <template v-if="editingKey === 'ArticleTitle'">
389
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleTitle"
390
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
391
+                        </template>
392
+                        <template v-else>
393
+                            "{{ selectedArticle.ArticleTitle }}"
394
+                        </template>
395
+                    </span>
396
+                </div>
397
+                <div class="json-node">
398
+                    <span class="json-key">文章中文标题:</span>
399
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'ArticleTitleCHN', 'ArticleTitleCHN')">
400
+                        <template v-if="editingKey === 'ArticleTitleCHN'">
401
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleTitleCHN"
402
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
403
+                        </template>
404
+                        <template v-else>
405
+                            "{{ selectedArticle.ArticleTitleCHN }}"
406
+                        </template>
407
+                    </span>
408
+                </div>
409
+                <div class="json-node">
410
+                    <span class="json-key">文章图片名称:</span>
411
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'ArticleImage', 'ArticleImage')">
412
+                        <template v-if="editingKey === 'ArticleImage'">
413
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleImage"
414
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
415
+                        </template>
416
+                        <template v-else>
417
+                            "{{ selectedArticle.ArticleImage }}"
418
+                        </template>
419
+                    </span>
420
+                </div>
421
+                <div class="json-node">
422
+                    <span class="json-key">创建时间:</span>
423
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'CreateTime', 'CreateTime')">
424
+                        <template v-if="editingKey === 'CreateTime'">
425
+                            <input type="text" disabled="true" class="json-editor-input" v-model="selectedArticle.CreateTime"
426
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
427
+                        </template>
428
+                        <template v-else>
429
+                            "{{ selectedArticle.CreateTime }}"
430
+                        </template>
431
+                    </span>
432
+                </div>
433
+                <div class="json-node">
434
+                    <span class="json-key">英语文章:</span>
435
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'ArticleStart', 'ArticleStart')">
436
+                        <template v-if="editingKey === 'ArticleStart'">
437
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleStart"
438
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
439
+                        </template>
440
+                        <template v-else>
441
+                            "{{ selectedArticle.ArticleStart }}"
442
+                        </template>
443
+                    </span>
444
+                </div>
445
+               
446
+                <div class="json-node">
447
+                    <span class="json-key">用户ID:</span>
448
+                    <span class="json-number editable" @dblclick="editValue(selectedArticle, 'UserID', 'UserID')">
449
+                        <template v-if="editingKey === 'UserID'">
450
+                            <input type="number" class="json-editor-input" v-model.number="selectedArticle.UserID"
451
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
452
+                        </template>
453
+                        <template v-else>
454
+                            {{ selectedArticle.UserID }}
455
+                        </template>
456
+                    </span>
457
+                </div>
458
+                <div class="json-node">
459
+                    <span class="json-key">生成秒数:</span>
460
+                    <span class="json-number editable" @dblclick="editValue(selectedArticle, 'GenerateTime', 'GenerateTime')">
461
+                        <template v-if="editingKey === 'GenerateTime'">
462
+                            <input type="number" class="json-editor-input" v-model.number="selectedArticle.GenerateTime"
463
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
464
+                        </template>
465
+                        <template v-else>
466
+                            {{ selectedArticle.GenerateTime }}
467
+                        </template>
468
+                    </span>
469
+                </div>
470
+                <div class="json-node">
471
+                    <span class="json-key">使用AI模型:</span>
472
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'AIProvider', 'AIProvider')">
473
+                        <template v-if="editingKey === 'AIProvider'">
474
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.AIProvider"
475
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
476
+                        </template>
477
+                        <template v-else>
478
+                            "{{ selectedArticle.AIProvider }}"
479
+                        </template>
480
+                    </span>
481
+                </div>
482
+                <div class="json-node">
483
+                    <span class="json-key">提示语:</span>
484
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'BuildStr', 'BuildStr')">
485
+                        <template v-if="editingKey === 'BuildStr'">
486
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.BuildStr"
487
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
488
+                        </template>
489
+                        <template v-else>
490
+                            "{{ selectedArticle.BuildStr }}"
491
+                        </template>
492
+                    </span>
493
+                </div>
494
+                <div class="json-node">
495
+                    <span class="json-key">单词表:</span>
496
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'Words', 'Words')">
497
+                        <template v-if="editingKey === 'Words'">
498
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.Words"
499
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
500
+                        </template>
501
+                        <template v-else>
502
+                            "{{ selectedArticle.Words }}"
503
+                        </template>
504
+                    </span>
505
+                </div>
506
+                <div class="json-node">
507
+                    <span class="json-key">文章难度:</span>
508
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'Level', 'Level')">
509
+                        <template v-if="editingKey === 'Level'">
510
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.Level"
511
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
512
+                        </template>
513
+                        <template v-else>
514
+                            "{{ selectedArticle.Level }}"
515
+                        </template>
516
+                    </span>
517
+                </div>
518
+                <div class="json-node">
519
+                    <span class="json-key">文章类型:</span>
520
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'ArticleStyle', 'ArticleStyle')">
521
+                        <template v-if="editingKey === 'ArticleStyle'">
522
+                            <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleStyle"
523
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
524
+                        </template>
525
+                        <template v-else>
526
+                            "{{ selectedArticle.ArticleStyle }}"
527
+                        </template>
528
+                    </span>
529
+                </div>
530
+                <div class="json-node">
531
+                    <span class="json-key">用户阅读数:</span>
532
+                    <span class="json-number editable" @dblclick="editValue(selectedArticle, 'ReadCount', 'ReadCount')">
533
+                        <template v-if="editingKey === 'ReadCount'">
534
+                            <input type="number" class="json-editor-input" v-model.number="selectedArticle.ReadCount"
535
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
536
+                        </template>
537
+                        <template v-else>
538
+                            {{ selectedArticle.ReadCount }}
539
+                        </template>
540
+                    </span>
541
+                </div>
542
+                
543
+                <div class="json-node">
544
+                    <span class="json-key">JSON结果:</span>
545
+                    <span class="json-string editable" @dblclick="editValue(selectedArticle, 'JSONString', 'JSONString')">
546
+                        <template v-if="editingKey === 'JSONString'">
547
+                            <textarea class="json-editor-input" v-model="selectedArticle.JSONString"
548
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus></textarea>
549
+                        </template>
550
+                        <template v-else>
551
+                            "{{ selectedArticle.JSONString }}"
552
+                        </template>
553
+                    </span>
554
+                </div>
555
+                <div class="json-node">
556
+                    <span class="json-key">是否删除:</span>
557
+                    <span class="json-number editable" @dblclick="editValue(selectedArticle, 'Flag', 'Flag')">
558
+                        <template v-if="editingKey === 'Flag'">
559
+                            <input type="number" class="json-editor-input" v-model.number="selectedArticle.Flag"
560
+                                @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
561
+                        </template>
562
+                        <template v-else>
563
+                            {{ selectedArticle.Flag }}
564
+                        </template>
565
+                    </span>
566
+                </div>
567
+                <div class="btn-group">
568
+                    <button class="btn btn-primary" @click="saveArticle">保存</button>
569
+                    <button class="btn btn-default" @click="cancelEdit">取消</button>
570
+                </div>
571
+            </div>
572
+        </div>
573
+    </div>
574
+
575
+    <script>
576
+        new Vue({
577
+            el: '#app',
578
+            data: {
579
+                searchText: '',
580
+                articles: [],
581
+                selectedArticle: null,
582
+                isSearchLoading: false,
583
+                isDetailLoading: false,
584
+                editingKey: null
585
+            },
586
+            methods: {
587
+                searchArticles() {
588
+                    if (!this.searchText) return;
589
+                    this.isSearchLoading = true;
590
+                    $.ajax({
591
+                        url: `api/GetYJBDCArticleList?UserID=${this.searchText}&PageCount=100`,
592
+                        method: 'GET',
593
+                        success: (data) => {
594
+                            this.articles = data.result;
595
+                            this.isSearchLoading = false;
596
+                        },
597
+                        error: () => {
598
+                            this.isSearchLoading = false;
599
+                        }
600
+                    });
601
+                },
602
+                selectArticle(article) {
603
+                    this.isDetailLoading = true;
604
+                    this.selectedArticle = null;
605
+                    $.ajax({
606
+                        url: `api/GetYJBDCArticleList?UserID=${this.searchText}&ID=${article.ID}`,
607
+                        method: 'GET',
608
+                        success: (data) => {
609
+                            this.selectedArticle = data.result[0];
610
+                            this.isDetailLoading = false;
611
+                        },
612
+                        error: () => {
613
+                            this.isDetailLoading = false;
614
+                        }
615
+                    });
616
+                },
617
+                clearSearch() {
618
+                    this.searchText = '';
619
+                    this.articles = [];
620
+                    this.selectedArticle = null;
621
+                },
622
+                editValue(obj, key, editingKey) {
623
+                    this.editingKey = editingKey;
624
+                },
625
+                finishEdit() {
626
+                    this.editingKey = null;
627
+                },
628
+                saveArticle() {
629
+                    if (!this.selectedArticle) return;
630
+                    this.isDetailLoading = true;
631
+                    $.ajax({
632
+                        url: 'api/UpdateYJBDCArticle',
633
+                        method: 'POST',
634
+                        data: this.selectedArticle,
635
+                        success: () => {
636
+                            this.isDetailLoading = false;
637
+                            alert('保存成功');
638
+                        },
639
+                        error: () => {
640
+                            this.isDetailLoading = false;
641
+                            alert('保存失败');
642
+                        }
643
+                    });
644
+                },
645
+                cancelEdit() {
646
+                    this.selectedArticle = null;
647
+                }
648
+            },
649
+            directives: {
650
+                focus: {
651
+                    inserted(el) {
652
+                        el.focus();
653
+                    }
654
+                }
655
+            }
656
+        });
657
+    </script>
658
+</body>
659
+
660
+</html>

+ 1 - 0
src/api/yjbdc/routes.js

@@ -13,5 +13,6 @@ router.get('/api/BuildYJBDCQRCode',yjbdcController.BuildYJBDCQRCode);
13 13
 router.get('/api/DeleteYJBDCArticleList',yjbdcController.DeleteYJBDCArticleList);
14 14
 router.get('/api/UpdateYJBDCArticleReadCount',yjbdcController.UpdateYJBDCArticleReadCount);
15 15
 router.get('/api/getMiaoguoTodayAllWords',yjbdcController.getMiaoguoTodayAllWords);
16
+router.get('/yjbdc_article_admin',yjbdcController.YJBDC_Articles_Admin);
16 17
 
17 18
 export default router;

+ 17 - 10
src/api/yjbdc/yjbdcController.js

@@ -1,5 +1,6 @@
1 1
 import moment from 'moment';
2 2
 import fs from 'fs';
3
+import { promises as fsPromises } from 'fs';
3 4
 import commonModel from '../../model/commonModel.js';
4 5
 import config from '../../config/index.js';
5 6
 import _ from 'lodash';
@@ -281,7 +282,7 @@ export async function GenerateArticle(ctx) {
281 282
                 
282 283
                 // 尝试解析JSON以获取ArticleStart
283 284
                 const jsonObj2 = JSON.parse(result2);
284
-                param2.ArticleStart = jsonObj2.ArticleEnglish && jsonObj2.ArticleEnglish.length > 0 ? jsonObj2.ArticleEnglish[0] : "No content available";
285
+                param2.ArticleStart = jsonObj2.ArticleEnglish && jsonObj2.ArticleEnglish.length > 0 ? jsonObj2.ArticleEnglish.join("\r\n") : "No content available";
285 286
                 
286 287
                 // 去除JSON字符串中的所有换行符(\r\n, \n, \r)
287 288
                 param2.JSONString=JSON.stringify(result2.replace(/[\r\n]+/g, ''));
@@ -399,16 +400,16 @@ export async function GetYJBDCArticleList(ctx) {
399 400
     if (result === 0) {
400 401
 
401 402
         result = await yjbdc.GetYJBDCArticleList(param);
402
-        if (param.ID==0){
403
-            let menuConfig=constantClass.GetYJBDCGenerateConfig();
404
-            for(let i=0;i<result.length;i++){
405
-                let item=result[i];
406
-                item.CreateTime=moment(item.CreateTime).format("YYYY年MM月DD日 HH:mm");
407
-                //debugger;
408
-                item.LevelStr=menuConfig.Level[item.Level].Name;
409
-            }
403
+        
404
+        let menuConfig=constantClass.GetYJBDCGenerateConfig();
405
+        for(let i=0;i<result.length;i++){
406
+            let item=result[i];
407
+            item.CreateTime=moment(item.CreateTime).format("YYYY年MM月DD日 HH:mm");
408
+            //debugger;
409
+            item.LevelStr=menuConfig.Level[item.Level].Name;
410 410
         }
411 411
         
412
+        
412 413
         globalCache.set(url, result, config.BufferMemoryTime);
413 414
         console.log("缓存"+config.BufferMemoryTime+"秒");
414 415
     }
@@ -1053,4 +1054,10 @@ export async function BuildYJBDCQRCode(ctx) {
1053 1054
             error: error.message 
1054 1055
         };
1055 1056
     }
1056
-}
1057
+}
1058
+
1059
+export async function YJBDC_Articles_Admin(ctx) {
1060
+    console.log("yjbdc_articles");
1061
+    const data = await fsPromises.readFile("./public/mg/yjbdc_articles.html");
1062
+    ctx.body = data.toString();
1063
+};