Browse Source

修复一些问题

zhusiqing 5 years ago
parent
commit
5cdb5c6556
2 changed files with 9 additions and 3 deletions
  1. 5 2
      server.js
  2. 4 1
      src/views/Review.vue

+ 5 - 2
server.js

@@ -161,9 +161,12 @@ router.post('/words', ctx => {
   ctx.body = body
 })
 router.get('/reviews', ctx => {
-  console.log(ctx.url)
   const buf = fs.readFileSync(reviewDataPath)
-  const list = buf.toString().split(',')
+  const text = buf.toString()
+  let list = []
+  if (text) {
+    list = text.split(',')
+  }
   ctx.body = { success: true, list }
 })
 router.post('/reviews', ctx => {

+ 4 - 1
src/views/Review.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="review">
-    <ul>
+    <ul v-if="list.length">
       <li v-for="(word, i) in list" :key="i">
         <label>
           <input type="checkbox" :value="word" @change="(e) => { onChange(e, word) }">
@@ -8,6 +8,9 @@
         </label>
       </li>
     </ul>
+    <ul v-else>
+      <li>暂无数据</li>
+    </ul>
     <p><span>选中的词:</span>{{checkedList.join(',')}}</p>
     <button class="review-button" :class="{ disabled: disabled }" :disabled="disabled" @click.prevent="onAddWords">添加新词</button>
   </div>