李志伟 3 gadus atpakaļ
vecāks
revīzija
c96a5d1dd0

+ 3
- 1
babel.config.js Parādīt failu

@@ -1,7 +1,9 @@
1 1
 module.exports = {
2 2
   presets: [
3 3
     // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
4
-    '@vue/cli-plugin-babel/preset'
4
+    // '@vue/cli-plugin-babel/preset',
5
+    // 之前一直报错说core.js 把上面这句话改为下面的就可以了
6
+    ['@vue/cli-plugin-babel/preset', { useBuiltIns: 'entry' }]
5 7
   ],
6 8
   'env': {
7 9
     'development': {

+ 2
- 1
package.json Parādīt failu

@@ -14,9 +14,10 @@
14 14
     "test:ci": "npm run lint && npm run test:unit"
15 15
   },
16 16
   "dependencies": {
17
+    "ali-oss": "^6.16.0",
17 18
     "axios": "^0.18.1",
18 19
     "axios-retry": "^3.2.4",
19
-    "core-js": "3.6.5",
20
+    "core-js": "^2.6.12",
20 21
     "element-ui": "2.13.2",
21 22
     "js-cookie": "2.2.0",
22 23
     "js-md5": "^0.7.3",

+ 46
- 0
src/api/game.js Parādīt failu

@@ -0,0 +1,46 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+* 保存游戏
5
+* @param {*} data 
6
+* @returns 
7
+*/
8
+export const saveGame = (data) => request({
9
+  url: '/admin/game',
10
+  method: 'post',
11
+  data
12
+})
13
+
14
+/**
15
+ * 游戏列表
16
+ * @param {*} params 
17
+ * @returns 
18
+ */
19
+export const getGameList = (params) => request({
20
+  url: '/admin/game', params
21
+})
22
+
23
+/**
24
+ * 删除游戏
25
+ * @param {*} data 
26
+ * @returns 
27
+ */
28
+export const deleteGame = (id) => request({
29
+  url: `/admin/game/${id}`, method: 'delete'
30
+})
31
+/**
32
+ * 更新游戏
33
+ * @param {*} data 
34
+ * @returns 
35
+ */
36
+export const UpdateGame = (data, id) => request({
37
+  url: `/admin/game/${id}`, method: 'put', data
38
+})
39
+/**
40
+ * 查询游戏详情
41
+ * @param {*} params 
42
+ * @returns 
43
+ */
44
+export const getGameDetail = (id) => request({
45
+  url: `/admin/game/${id}`
46
+})

+ 60
- 0
src/api/oss.js Parādīt failu

@@ -0,0 +1,60 @@
1
+import OSS from 'ali-oss'
2
+import request from '@/utils/request'
3
+
4
+let client
5
+let stsInfo
6
+
7
+/**
8
+ * 获取 OSS-STS 临时凭证
9
+ * @returns
10
+ */
11
+export const getSTSToken = () => request({ url: '/admin/oss-sts' })
12
+
13
+/**
14
+ * 获取 OSS 客户端
15
+ * @returns
16
+ */
17
+export function getOSSClient() {
18
+  if (client) {
19
+    return Promise.resolve(client)
20
+  }
21
+
22
+  return getSTSToken().then((sts) => {
23
+    stsInfo = sts
24
+    client = new OSS({
25
+      accessKeyId: sts.data.accessKeyId,
26
+      accessKeySecret: sts.data.accessKeySecret,
27
+      stsToken: sts.data.stsToken,
28
+      bucket: sts.data.bucket,
29
+      endpoint: sts.data.endpoint,
30
+      refreshSTSTokenInterval: 25 * 60 * 1000, // 每25min刷新一次
31
+      refreshSTSToken: () => {
32
+        return getSTSToken().then((res) => {
33
+          return {
34
+            accessKeyId: res.accessKeyId,
35
+            accessKeySecret: res.accessKeySecret,
36
+            stsToken: res.stsToken
37
+          }
38
+        })
39
+      }
40
+    })
41
+
42
+    return client
43
+  })
44
+}
45
+
46
+/**
47
+ * 上传文件到 OSS
48
+ * @param {*} file
49
+ * @returns
50
+ */
51
+export function upload(file) {
52
+  return getOSSClient().then(() => {
53
+    const data = new FormData()
54
+    data.append('file', file)
55
+    const now = new Date()
56
+    const fileName = `${stsInfo.path}/${now.valueOf()}-${file.name}`
57
+
58
+    return client.put(fileName, file).then((res) => res.url)
59
+  })
60
+}

+ 24
- 16
src/api/question.js Parādīt failu

@@ -1,38 +1,46 @@
1 1
 import request from '@/utils/request'
2
-/**
3
- * 题库列表
4
- * @param {*} params 
5
- * @returns 
6
- */
7
-export const getQuestionList = (params) => request('/admin/question', { params })
8 2
 
9 3
 /**
10
-* 保存民宿
4
+* 保存应用
11 5
 * @param {*} data 
12 6
 * @returns 
13 7
 */
14
-export const saveQuestion = (data) =>request({
15
-  url: '/admin/question',
8
+export const saveApp = (data) => request({
9
+  url: '/admin/App',
16 10
   method: 'post',
17 11
   data
18 12
 })
19
- 
20 13
 
21 14
 /**
22
- * 删除民宿
15
+ * 应用列表
16
+ * @param {*} params 
17
+ * @returns 
18
+ */
19
+export const getAppList = (params) => request({
20
+  url: '/admin/App', params
21
+})
22
+
23
+/**
24
+ * 删除应用
23 25
  * @param {*} data 
24 26
  * @returns 
25 27
  */
26
-export const deleteQuestion = (id) => request(`/admin/question/${id}`, { method: 'delete' })
28
+export const deleteApp = (id) => request({
29
+  url: `/admin/App/${id}`, method: 'delete'
30
+})
27 31
 /**
28
- * 更新民宿
32
+ * 更新应用
29 33
  * @param {*} data 
30 34
  * @returns 
31 35
  */
32
-export const UpdateQuestion = (data, id) => request(`/admin/question/${id}`, { method: 'put', data })
36
+export const UpdateApp = (data, id) => request({
37
+  url: `/admin/App/${id}`, method: 'put', data
38
+})
33 39
 /**
34
- * 查询民宿详情
40
+ * 查询应用详情
35 41
  * @param {*} params 
36 42
  * @returns 
37 43
  */
38
-export const getQuestionDetail = (id) => request(`/admin/question/${id}`)
44
+export const getAppDetail = (id) => request({
45
+  url: `/admin/App/${id}`
46
+})

+ 52
- 44
src/components/CharacterResult/edit.vue Parādīt failu

@@ -1,21 +1,20 @@
1 1
 <template>
2 2
   <div style="padding: 20px">
3
-    实例详情
4 3
     <h2 style="text-align: center">
5
-      特征实例{{ this.resultId ? "编辑" : "添加" }}
4
+      特征实例{{ resultId ? "编辑" : "添加" }}
6 5
     </h2>
7 6
     <el-form ref="form" :model="form" label-width="150px" size="mini">
8 7
       <el-form-item label="实例名称:">
9 8
         <el-input
10 9
           v-model="form.name"
11 10
           placeholder="请输入实例名(必填)"
12
-        ></el-input>
11
+        />
13 12
       </el-form-item>
14 13
       <el-form-item label="特征库图标:">
15
-        <UploadImage />
14
+        <UploadImage :icon="form.thumb" @handleChange="handleChange" @handleDeleteIcon="handleDeleteIcon" />
16 15
       </el-form-item>
17 16
       <el-form-item label="实例描述:">
18
-        <el-input type="textarea" v-model="form.desc"></el-input>
17
+        <el-input v-model="form.desc" type="textarea" />
19 18
       </el-form-item>
20 19
 
21 20
       <el-form-item label="特征词:">
@@ -31,12 +30,12 @@
31 30
             :key="item.wordId"
32 31
             :label="item.word"
33 32
             :value="item.wordId"
34
-          >
35
-          </el-option>
33
+          />
36 34
         </el-select>
37 35
       </el-form-item>
38 36
       <el-form-item>
39 37
         <el-button type="primary" @click="onSubmit">确定</el-button>
38
+        <el-button @click="$router.go(-1)">返回</el-button>
40 39
       </el-form-item>
41 40
     </el-form>
42 41
   </div>
@@ -45,17 +44,20 @@
45 44
 import {
46 45
   saveCharacterResult,
47 46
   UpdateCharacterResult,
48
-  getCharacterResultDetail,
49
-} from "@/api/characterLib";
50
-import UploadImage from "@/components/UploadImage/index.vue";
47
+  getCharacterResultDetail
48
+} from '@/api/characterLib'
49
+import UploadImage from '@/components/UploadImage/index.vue'
51 50
 export default {
51
+  components: {
52
+    UploadImage
53
+  },
52 54
   props: {
53 55
     libId: String,
54 56
     resultId: String,
55 57
     wordList: {
56 58
       type: Array,
57
-      required: true,
58
-    },
59
+      required: true
60
+    }
59 61
   },
60 62
   data() {
61 63
     return {
@@ -64,63 +66,69 @@ export default {
64 66
         thumb: undefined,
65 67
         desc: undefined,
66 68
         libId: undefined,
67
-        wordList: [],
69
+        wordList: []
68 70
       },
69
-      nowList: [],
70
-    };
71
+      nowList: []
72
+    }
71 73
   },
72 74
   watch: {
73
-    resultId: function () {
75
+    resultId: function() {
74 76
       if (this.resultId) {
75
-        this.nowList = [];
77
+        this.nowList = []
76 78
         getCharacterResultDetail(this.resultId).then((res) => {
77
-          this.form = res.data;
78
-          let list = res.data.wordList;
79
+          this.form = res.data
80
+          const list = res.data.wordList
79 81
           list.map((item) => {
80
-            this.nowList.push(item.wordId);
81
-          });
82
-        });
82
+            this.nowList.push(item.wordId)
83
+          })
84
+        })
83 85
       } else {
84 86
         this.form = {
85 87
           name: undefined,
86 88
           thumb: undefined,
87 89
           desc: undefined,
88 90
           libId: undefined,
89
-          wordList: [],
90
-        };
91
-        this.nowList = [];
91
+          wordList: []
92
+        }
93
+        this.nowList = []
92 94
       }
93
-    },
95
+    }
94 96
   },
95 97
   methods: {
96 98
     onSubmit() {
97 99
       this.form.wordList = this.wordList.filter((item) =>
98
-        this.nowList.some((v) => v == item.wordId)
99
-      );
100
-      this.form.libId = this.libId;
100
+        this.nowList.some((v) => v === item.wordId)
101
+      )
102
+      this.form.libId = this.libId
101 103
       if (this.form.name) {
102 104
         if (this.resultId) {
105
+          if (!this.form.thumb) {
106
+            this.form.thumb = ''
107
+          }
103 108
           UpdateCharacterResult(this.form, this.resultId).then((res) => {
104
-            this.$message("修改实例成功");
105
-            //告诉父页面实例表需要刷新并且关闭当前组件
106
-            this.$emit("handleRefresh", true);
107
-          });
109
+            this.$message('修改实例成功')
110
+            // 告诉父页面实例表需要刷新并且关闭当前组件
111
+            this.$emit('handleRefresh', true)
112
+          })
108 113
         } else {
109 114
           saveCharacterResult(this.form).then((res) => {
110
-            this.$message("添加实例成功");
111
-            //告诉父页面实例表需要刷新并且关闭当前组件
112
-            this.$emit("handleRefresh", true);
113
-          });
115
+            this.$message('添加实例成功')
116
+            // 告诉父页面实例表需要刷新并且关闭当前组件
117
+            this.$emit('handleRefresh', true)
118
+          })
114 119
         }
115 120
       } else {
116
-        this.$message("请输入实例名");
121
+        this.$message('请输入实例名')
117 122
       }
118 123
     },
119
-  },
120
-  components: {
121
-    UploadImage,
122
-  },
123
-};
124
+    handleChange(val) {
125
+      this.form.thumb = val
126
+    },
127
+    handleDeleteIcon() {
128
+      this.form.thumb = ''
129
+    }
130
+  }
131
+}
124 132
 </script>
125 133
 <style>
126
-</style>
134
+</style>

+ 45
- 46
src/components/CharacterResult/index.vue Parādīt failu

@@ -8,18 +8,17 @@
8 8
           style="width: 150px; margin-right: 20px"
9 9
         />
10 10
         创建时间:
11
-      <el-date-picker
12
-        v-model="daterange"
13
-        size="mini"
14
-        type="daterange"
15
-        range-separator="至"
16
-        start-placeholder="开始日期"
17
-        end-placeholder="结束日期"
18
-        value-format="yyyy-MM-dd"
19
-        @change="dateChange"
20
-        style="width:220px; margin-right: 20px"
21
-      >
22
-      </el-date-picker>
11
+        <el-date-picker
12
+          v-model="daterange"
13
+          size="mini"
14
+          type="daterange"
15
+          range-separator="至"
16
+          start-placeholder="开始日期"
17
+          end-placeholder="结束日期"
18
+          value-format="yyyy-MM-dd"
19
+          style="width:220px; margin-right: 20px"
20
+          @change="dateChange"
21
+        />
23 22
 
24 23
         <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
25 24
         <el-button size="mini" @click="onReset">重置</el-button>
@@ -50,7 +49,7 @@
50 49
             title="这个实例确定删除吗?"
51 50
             @onConfirm="handleDelete(scope.row)"
52 51
           >
53
-            <el-button type="text" slot="reference">删除</el-button>
52
+            <el-button slot="reference" type="text">删除</el-button>
54 53
           </el-popconfirm>
55 54
         </template>
56 55
       </el-table-column>
@@ -60,67 +59,67 @@
60 59
 <script>
61 60
 import {
62 61
   getCharacterResultList,
63
-  deleteCharacterResult,
64
-} from "@/api/characterLib";
62
+  deleteCharacterResult
63
+} from '@/api/characterLib'
65 64
 
66 65
 export default {
67 66
   props: {
68
-    libId: String,
67
+    libId: String
69 68
   },
70 69
   data() {
71 70
     return {
72
-      name: undefined,      
73
-      daterange:'',
71
+      name: undefined,
72
+      daterange: undefined,
74 73
       tableData: [],
75
-      endDate:undefined,
76
-      startDate:undefined
77
-    };
74
+      endDate: undefined,
75
+      startDate: undefined
76
+    }
78 77
   },
79 78
   watch: {
80
-    libId: function () {
81
-      this.onSearch();
82
-    },
79
+    libId: function() {
80
+      this.onSearch()
81
+    }
83 82
   },
84 83
   methods: {
85
-    //添加实例
84
+    // 添加实例
86 85
     handleAddRusult() {
87
-      this.$emit("handleAddRusult", true);
86
+      this.$emit('handleAddRusult', true)
88 87
     },
89 88
     handleEdit(row) {
90 89
       // 向外传送数据row.resultId
91
-      this.$emit("handleEdit", row.resultId);
90
+      this.$emit('handleEdit', row.resultId)
92 91
     },
93 92
     handleDelete(row) {
94 93
       deleteCharacterResult(row.resultId).then(() => {
95
-        this.$message("删除实例成功");
96
-        this.onSearch();
97
-        //关闭编辑实例页面防止编辑页面还没关闭就删除当前实例了
98
-        this.$emit("handleClose", true);
99
-      });
94
+        this.$message('删除实例成功')
95
+        this.onSearch()
96
+        // 关闭编辑实例页面防止编辑页面还没关闭就删除当前实例了
97
+        this.$emit('handleClose', true)
98
+      })
100 99
     },
101 100
     onSearch() {
102
-      getCharacterResultList({ libId: this.libId, name: this.name ,startDate:this.startDate,endDate:this.endDate}).then(
101
+      getCharacterResultList({ libId: this.libId, name: this.name, startDate: this.startDate, endDate: this.endDate }).then(
103 102
         (res) => {
104
-          this.tableData = res.data.records;
103
+          this.tableData = res.data.records
105 104
         }
106
-      );
105
+      )
107 106
     },
108 107
     onReset() {
109
-      this.name = "";      
110
-      this.daterange = "";
111
-      this.startDate = "";
112
-      this.endDate = "";
113
-      this.onSearch();
108
+      this.name = ''
109
+      this.daterange = ''
110
+      this.startDate = ''
111
+      this.endDate = ''
112
+      this.onSearch()
114 113
     },
115
-    dateChange(val){
116
-      this.startDate=this.daterange[0]
117
-      this.endDate=this.daterange[1]
114
+    dateChange(val) {
115
+      this.startDate = this.daterange[0]
116
+      this.endDate = this.daterange[1]
118 117
     }
119
-  },
120
-};
118
+  }
119
+}
121 120
 </script>
122 121
 <style>
123 122
 .noshadowCard > .box-card {
124 123
   box-shadow: none;
125 124
 }
126
-</style>
125
+</style>

+ 0
- 0
src/components/Question/edit.vue Parādīt failu


+ 119
- 0
src/components/Question/index.vue Parādīt failu

@@ -0,0 +1,119 @@
1
+<template>
2
+  <div class="body">
3
+    <div class="noshadowCard">
4
+      <el-card class="box-card">
5
+        问题名称:<el-input
6
+          v-model="title"
7
+          size="mini"
8
+          style="width: 150px; margin-right: 20px"
9
+        />
10
+        创建时间:
11
+        <el-date-picker
12
+          v-model="daterange"
13
+          size="mini"
14
+          type="daterange"
15
+          range-separator="至"
16
+          start-placeholder="开始日期"
17
+          end-placeholder="结束日期"
18
+          value-format="yyyy-MM-dd"
19
+          style="width:220px; margin-right: 20px"
20
+          @change="dateChange"
21
+        />
22
+
23
+        <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
24
+        <el-button size="mini" @click="onReset">重置</el-button>
25
+        <el-button type="primary" size="mini" @click="handleAddRusult">添加问题</el-button>
26
+      </el-card>
27
+    </div>
28
+    <el-table stripe :data="tableData" border style="width: 100%">
29
+      <el-table-column prop="name" label="问题名称" />
30
+      <el-table-column prop="createDate" label="创建时间">
31
+        <template slot-scope="scope">{{
32
+          scope.row.createDate.substr(0, 10)
33
+        }}</template>
34
+      </el-table-column>
35
+      <el-table-column fixed="right" label="操作">
36
+        <template slot-scope="scope">
37
+          <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
38
+          <el-popconfirm
39
+            icon="el-icon-info"
40
+            icon-color="red"
41
+            title="确定删除这个问题吗?"
42
+            @onConfirm="handleDelete(scope.row)"
43
+          >
44
+            <el-button slot="reference" type="text">删除</el-button>
45
+          </el-popconfirm>
46
+        </template>
47
+      </el-table-column>
48
+    </el-table>
49
+  </div>
50
+</template>
51
+<script>
52
+import {
53
+  getCharacterResultList,
54
+  deleteCharacterResult
55
+} from '@/api/characterLib'
56
+
57
+export default {
58
+  props: {
59
+    gameId: String,
60
+    libId: String
61
+  },
62
+  data() {
63
+    return {
64
+      // 问题名称
65
+      title: undefined,
66
+      daterange: '',
67
+      tableData: [],
68
+      endDate: undefined,
69
+      startDate: undefined
70
+    }
71
+  },
72
+  watch: {
73
+    gameId: function() {
74
+      this.onSearch()
75
+    }
76
+  },
77
+  methods: {
78
+    // 添加实例
79
+    handleAddRusult() {
80
+      this.$emit('handleAddRusult', true)
81
+    },
82
+    handleEdit(row) {
83
+      // 向外传送数据row.resultId
84
+      this.$emit('handleEdit', row.resultId)
85
+    },
86
+    handleDelete(row) {
87
+      deleteCharacterResult(row.resultId).then(() => {
88
+        this.$message('删除实例成功')
89
+        this.onSearch()
90
+        // 关闭编辑实例页面防止编辑页面还没关闭就删除当前实例了
91
+        this.$emit('handleClose', true)
92
+      })
93
+    },
94
+    onSearch() {
95
+      getCharacterResultList({ libId: this.libId, name: this.name, startDate: this.startDate, endDate: this.endDate }).then(
96
+        (res) => {
97
+          this.tableData = res.data.records
98
+        }
99
+      )
100
+    },
101
+    onReset() {
102
+      this.name = ''
103
+      this.daterange = ''
104
+      this.startDate = ''
105
+      this.endDate = ''
106
+      this.onSearch()
107
+    },
108
+    dateChange(val) {
109
+      this.startDate = this.daterange[0]
110
+      this.endDate = this.daterange[1]
111
+    }
112
+  }
113
+}
114
+</script>
115
+<style>
116
+.noshadowCard > .box-card {
117
+  box-shadow: none;
118
+}
119
+</style>

+ 34
- 9
src/components/UploadImage/index.vue Parādīt failu

@@ -3,32 +3,57 @@
3 3
     <el-upload
4 4
       action="#"
5 5
       list-type="picture-card"
6
+      :file-list="fileList"
6 7
       :limit="1"
7 8
       :on-remove="handleRemove"
8 9
       :on-change="handleChange"
9 10
       :auto-upload="false"
11
+      @http-request="customUploadFile"
10 12
     >
11
-      <i class="el-icon-plus"></i>
13
+      <i class="el-icon-plus" />
12 14
     </el-upload>
13 15
   </div>
14 16
 </template>
15 17
 <script>
18
+import { uploadFile } from '@/utils/upload'
16 19
 export default {
20
+  props: {
21
+    icon: String
22
+  },
17 23
   data() {
18 24
     return {
19
-      dialogImageUrl: "",
25
+      dialogImageUrl: undefined,
20 26
       dialogVisible: false,
21
-    };
27
+      fileList: []
28
+    }
29
+  },
30
+  watch: {
31
+    icon() {
32
+      if (this.icon) {
33
+        this.fileList = [{ name: 'image', url: this.icon }]
34
+      } else {
35
+        this.fileList = []
36
+      }
37
+    }
22 38
   },
23 39
   methods: {
40
+    customUploadFile(val) {
41
+      uploadFile({ file: val, onSuccess: this.onSuccess, onError: this.onError })
42
+    },
43
+    onSuccess(url) {
44
+      this.$emit('handleChange', url)
45
+    },
46
+    onError(e) {
47
+    },
24 48
     handleRemove(file, fileList) {
25
-      console.log(file, fileList);
49
+      this.fileList = []
50
+      this.$emit('handleDeleteIcon', true)
26 51
     },
27 52
     handleChange(file, fileList) {
28
-      console.log(fileList[0].raw);
29
-    },
30
-  },
31
-};
53
+      this.customUploadFile(file.raw)
54
+    }
55
+  }
56
+}
32 57
 </script>
33 58
 <style>
34 59
 .uploadClass .el-upload--picture-card {
@@ -40,4 +65,4 @@ export default {
40 65
   width: 100px;
41 66
   height: 100px;
42 67
 }
43
-</style> 
68
+</style>

+ 16
- 15
src/router/index.js Parādīt failu

@@ -58,7 +58,7 @@ export const constantRoutes = [
58 58
       {
59 59
         path: 'questionList/edit',
60 60
         name: '编辑题目',
61
-        component: () => import('@/views/questionList/edit'),
61
+        component: () => import('@/views/questionList/edit')
62 62
         // meta: { title: '编辑题目', icon: 'form' }
63 63
       }]
64 64
   },
@@ -71,21 +71,16 @@ export const constantRoutes = [
71 71
     children: [
72 72
       {
73 73
         path: 'characterLibManage',
74
-        name: '特征库列表',
74
+        name: 'characterLibList',
75 75
         component: () => import('@/views/characterLibManage/index'),
76 76
         meta: { title: '特征库列表', icon: 'form' }
77 77
       },
78 78
       {
79
-        path: 'characterLibManage/add',
80
-        name: '新增特征库',
81
-        component: () => import('@/views/characterLibManage/add'),
82
-        // meta: { title: '新增特征库', icon: 'form' }
83
-      },
84
-      {
79
+        hidden: true,
85 80
         path: 'characterLibManage/edit',
86
-        name: '编辑特征库',
81
+        name: 'characterLibEdit',
87 82
         component: () => import('@/views/characterLibManage/edit'),
88
-        // meta: { title: '编辑特征库', icon: 'form' }
83
+        meta: { title: '编辑特征库', icon: 'form' }
89 84
       }
90 85
     ]
91 86
   },
@@ -102,7 +97,13 @@ export const constantRoutes = [
102 97
         component: () => import('@/views/gameManage/index'),
103 98
         meta: { title: '游戏列表', icon: 'form' }
104 99
       },
105
-      
100
+      {
101
+        hidden: true,
102
+        path: 'gameManage/edit',
103
+        name: 'gameEdit',
104
+        component: () => import('@/views/gameManage/edit'),
105
+        meta: { title: '编辑游戏', icon: 'form' }
106
+      }
106 107
     ]
107 108
   },
108 109
   {
@@ -118,16 +119,18 @@ export const constantRoutes = [
118 119
         meta: { title: '应用列表', icon: 'form' }
119 120
       },
120 121
       {
122
+        hidden: true,
121 123
         path: 'appManage/add',
122 124
         name: '新增应用',
123 125
         component: () => import('@/views/appManage/add'),
124
-        // meta: { title: '新增应用', icon: 'form' }
126
+        meta: { title: '新增应用', icon: 'form' }
125 127
       },
126 128
       {
129
+        hidden: true,
127 130
         path: 'appManage/edit',
128 131
         name: '编辑应用',
129 132
         component: () => import('@/views/appManage/edit'),
130
-        // meta: { title: '编辑应用', icon: 'form' }
133
+        meta: { title: '编辑应用', icon: 'form' }
131 134
       }
132 135
     ]
133 136
   },
@@ -144,8 +147,6 @@ export const constantRoutes = [
144 147
     hidden: true
145 148
   },
146 149
 
147
-    
148
-
149 150
   {
150 151
     path: 'external-link',
151 152
     component: Layout,

+ 0
- 1
src/store/index.js Parādīt failu

@@ -5,7 +5,6 @@ import app from './modules/app'
5 5
 import settings from './modules/settings'
6 6
 import user from './modules/user'
7 7
 
8
-
9 8
 Vue.use(Vuex)
10 9
 
11 10
 const store = new Vuex.Store({

+ 11
- 12
src/store/modules/user.js Parādīt failu

@@ -1,26 +1,26 @@
1
-import { login} from '@/api/user'
2
-import { getToken, setToken, removeToken,setUserId } from '@/utils/auth'
1
+import { login } from '@/api/user'
2
+import { getToken, setToken, removeToken, setUserId } from '@/utils/auth'
3 3
 import { resetRouter } from '@/router'
4 4
 
5 5
 const getDefaultState = () => {
6 6
   return {
7
-    token: getToken(),
7
+    token: getToken()
8 8
   }
9 9
 }
10 10
 
11 11
 const state = getDefaultState()
12 12
 
13
-//定义Mutations
13
+// 定义Mutations
14 14
 const mutations = {
15 15
   RESET_STATE: (state) => {
16 16
     Object.assign(state, getDefaultState())
17 17
   },
18 18
   SET_TOKEN: (state, token) => {
19 19
     state.token = token
20
-  },
20
+  }
21 21
 }
22
-//在actions里面增加一个才可以在页面加 
23
-//this.$store.dispatch('user/login', this.loginForm)调用api里面的方法
22
+// 在actions里面增加一个才可以在页面加
23
+// this.$store.dispatch('user/login', this.loginForm)调用api里面的方法
24 24
 const actions = {
25 25
   // user login
26 26
   login({ commit }, userInfo) {
@@ -38,14 +38,13 @@ const actions = {
38 38
     })
39 39
   },
40 40
 
41
-
42 41
   // user logout
43 42
   logout({ commit, state }) {
44 43
     return new Promise((resolve, reject) => {
45
-        removeToken() // must remove  token  first
46
-        resetRouter()
47
-        commit('RESET_STATE')
48
-        resolve()
44
+      removeToken() // must remove  token  first
45
+      resetRouter()
46
+      commit('RESET_STATE')
47
+      resolve()
49 48
     })
50 49
   },
51 50
 

+ 3
- 6
src/utils/request.js Parādīt failu

@@ -1,8 +1,7 @@
1 1
 import axios from 'axios'
2
-import { MessageBox, Message } from 'element-ui'
2
+import { Message } from 'element-ui'
3 3
 import store from '@/store'
4
-import { getToken,getUserId } from '@/utils/auth'
5
- 
4
+import { getToken, getUserId } from '@/utils/auth'
6 5
 
7 6
 // create an axios instance
8 7
 const service = axios.create({
@@ -22,7 +21,6 @@ service.interceptors.request.use(
22 21
       // please modify it according to the actual situation
23 22
       config.headers['X-Authorization-JWT'] = getToken()
24 23
       config.headers['x-userid'] = getUserId()
25
-
26 24
     }
27 25
     return config
28 26
   },
@@ -46,7 +44,6 @@ service.interceptors.response.use(
46 44
    * You can also judge the status by HTTP Status Code
47 45
    */
48 46
   response => {
49
-
50 47
     const res = response.data
51 48
     // if the custom code is not 20000, it is judged as an error.
52 49
     if (res.code !== 1000) {
@@ -54,7 +51,7 @@ service.interceptors.response.use(
54 51
         message: res.message || 'Error',
55 52
         type: 'error',
56 53
         duration: 5 * 1000
57
-      })      
54
+      })
58 55
       return Promise.reject(new Error(res.message || 'Error'))
59 56
     } else {
60 57
       return res

+ 17
- 0
src/utils/upload.js Parādīt failu

@@ -0,0 +1,17 @@
1
+import { upload } from '@/api/oss'
2
+
3
+/**
4
+ * 获取 OSS 客户端
5
+ * @returns
6
+ */
7
+export function uploadFile({ file, onSuccess, onError }) {
8
+  upload(file).then((url) => {
9
+    onSuccess(url, file)
10
+  }).catch((e) => {
11
+    onError(e)
12
+  })
13
+
14
+  return {
15
+    abort: () => {}
16
+  }
17
+}

+ 0
- 94
src/views/characterLibManage/add.vue Parādīt failu

@@ -1,94 +0,0 @@
1
-<template>
2
-  <div class="body_edit">
3
-    <h2 style="text-align: center">特征库新增</h2>
4
-    <el-row :gutter="20">
5
-      <el-col :span="15">
6
-        <el-form
7
-          ref="form"
8
-          :model="characterLib"
9
-          label-width="150px"
10
-          size="mini"
11
-        >
12
-          <el-form-item label="特征库名称:">
13
-            <el-input v-model="characterLib.name"></el-input>
14
-          </el-form-item>
15
-          <el-form-item label="特征库图标:">
16
-            <UploadImage />
17
-          </el-form-item>
18
-          <el-form-item label="特征库描述:">
19
-            <el-input type="textarea" v-model="characterLib.remark"></el-input>
20
-          </el-form-item>
21
-
22
-          <el-form-item class="editBottomItem">
23
-            <el-button type="primary" @click="onSubmit">添加</el-button>
24
-            <el-button @click="onCancel">取消</el-button>
25
-          </el-form-item>
26
-        </el-form>
27
-      </el-col>
28
-      <el-col :span="5">
29
-        特征词列表
30
-        <TagComponents
31
-          :value="characterLib.wordList"
32
-          @handleDelete="handleDelete"
33
-          @handleAdd="handleAdd"
34
-        />
35
-      </el-col>
36
-    </el-row>
37
-  </div>
38
-</template>
39
-<script>
40
-import { saveCharacterLib } from "@/api/characterLib";
41
-import UploadImage from "@/components/UploadImage/index.vue";
42
-import TagComponents from "@/components/TagComponents/index.vue";
43
-export default {
44
-  data() {
45
-    return {
46
-      characterLib: {
47
-        name: undefined,
48
-        icon: undefined,
49
-        remark: undefined,
50
-        wordList: [],
51
-      },
52
-    };
53
-  },
54
-
55
-  methods: {
56
-    onCancel() {
57
-      this.$router.go(-1);
58
-    },
59
-    onSubmit() {
60
-      saveCharacterLib(this.characterLib).then((res) => {
61
-        this.$message("保存成功");
62
-        this.$router.go(-1);
63
-      });
64
-    },
65
-    handleDelete(val) {
66
-      this.characterLib.wordList.map((item) => {
67
-        if (item.word === val) {
68
-          this.characterLib.wordList.splice(
69
-            this.characterLib.wordList.indexOf(item),
70
-            1
71
-          );
72
-        }
73
-      });
74
-    },
75
-    handleAdd(val) {
76
-      this.characterLib.wordList.push({
77
-        libId: undefined,
78
-        word: val,
79
-        wordId: undefined,
80
-      });
81
-    },
82
-  },
83
-  components: {
84
-    UploadImage,
85
-    TagComponents,
86
-  },
87
-};
88
-</script>
89
-<style>
90
-.editBottomItem > div {
91
-  margin: 0 !important;
92
-  text-align: center;
93
-}
94
-</style>

+ 101
- 73
src/views/characterLibManage/edit.vue Parādīt failu

@@ -1,9 +1,9 @@
1 1
 <template>
2
-  <div style="padding: 20px">
2
+  <div style="padding: 20px; font-size: 14px">
3 3
     <el-tabs v-model="activeName">
4 4
       <el-tab-pane label="特征库" name="characterLib">
5 5
         <el-row :gutter="20">
6
-          <el-col :span="12">
6
+          <el-col :span="13">
7 7
             <el-form
8 8
               ref="form"
9 9
               :model="characterLib"
@@ -11,24 +11,21 @@
11 11
               size="mini"
12 12
             >
13 13
               <el-form-item label="特征库名称:">
14
-                <el-input v-model="characterLib.name"></el-input>
14
+                <el-input v-model="characterLib.name" />
15 15
               </el-form-item>
16 16
               <el-form-item label="特征库图标:">
17
-                <UploadImage />
17
+                <UploadImage :icon="characterLib.icon" @handleChange="handleChange" @handleDeleteIcon="handleDeleteIcon" />
18 18
               </el-form-item>
19 19
               <el-form-item label="特征库描述:">
20
-                <el-input
21
-                  type="textarea"
22
-                  v-model="characterLib.remark"
23
-                ></el-input>
20
+                <el-input v-model="characterLib.remark" type="textarea" />
24 21
               </el-form-item>
25
-              <el-form-item class="editBottomItem" >
22
+              <el-form-item class="editBottomItem">
26 23
                 <el-button type="primary" @click="onEdit">修改</el-button>
27 24
                 <el-button @click="onCancel">取消</el-button>
28 25
               </el-form-item>
29 26
             </el-form>
30 27
           </el-col>
31
-          <el-col :span="12">
28
+          <el-col :span="11">
32 29
             特征词列表
33 30
             <TagComponents
34 31
               :value="characterLib.wordList"
@@ -38,22 +35,22 @@
38 35
           </el-col>
39 36
         </el-row>
40 37
       </el-tab-pane>
41
-      <el-tab-pane label="特征实例" name="characterResult">
38
+      <el-tab-pane label="特征实例" name="characterResult" :disabled="libId ? false : true">
42 39
         <el-row :gutter="20" style="padding-top: 20px">
43
-          <el-col :span="12">
40
+          <el-col :span="13">
44 41
             <CharacterResult
45
-              :libId="characterLib.libId"
46 42
               ref="CharacterResult"
43
+              :lib-id="characterLib.libId"
47 44
               @handleEdit="handleEdit"
48 45
               @handleClose="handleClose"
49 46
               @handleAddRusult="resultId = undefined"
50 47
             />
51 48
           </el-col>
52
-          <el-col :span="12">
49
+          <el-col :span="11">
53 50
             <CharacterResultEdit
54
-              :resultId="resultId"
55
-              :libId="characterLib.libId"
56
-              :wordList="this.characterLib.wordList"
51
+              :result-id="resultId"
52
+              :lib-id="characterLib.libId"
53
+              :word-list="characterLib.wordList"
57 54
               @handleRefresh="handleRefresh"
58 55
             />
59 56
           </el-col>
@@ -63,14 +60,20 @@
63 60
   </div>
64 61
 </template>
65 62
 <script>
66
-import { UpdateCharacterLib, getCharacterLibDetail } from "@/api/characterLib";
67
-import { deleteCharacterWord, saveCharacterWord } from "@/api/characterWord";
68
-import UploadImage from "@/components/UploadImage/index.vue";
69
-import CharacterResult from "@/components/CharacterResult/index.vue";
70
-import CharacterResultEdit from "@/components/CharacterResult/edit.vue";
71
-import TagComponents from "@/components/TagComponents/index.vue";
63
+import { UpdateCharacterLib, getCharacterLibDetail, saveCharacterLib } from '@/api/characterLib'
64
+import { deleteCharacterWord, saveCharacterWord } from '@/api/characterWord'
65
+import UploadImage from '@/components/UploadImage/index.vue'
66
+import CharacterResult from '@/components/CharacterResult/index.vue'
67
+import CharacterResultEdit from '@/components/CharacterResult/edit.vue'
68
+import TagComponents from '@/components/TagComponents/index.vue'
72 69
 
73 70
 export default {
71
+  components: {
72
+    UploadImage,
73
+    CharacterResult,
74
+    CharacterResultEdit,
75
+    TagComponents
76
+  },
74 77
   data() {
75 78
     return {
76 79
       characterLib: {
@@ -78,35 +81,74 @@ export default {
78 81
         name: undefined,
79 82
         icon: undefined,
80 83
         remark: undefined,
81
-        wordList: [],
84
+        wordList: []
82 85
       },
83 86
       resultId: undefined,
84
-      activeName: "characterLib",
85
-    };
87
+      libId: undefined,
88
+      activeName: 'characterLib'
89
+    }
90
+  },
91
+  watch: {
92
+    '$route.query.id'() {
93
+      if (this.$route?.query.id) {
94
+        this.libId = this.$route.query.id
95
+        getCharacterLibDetail(this.$route.query.id).then((res) => {
96
+          this.characterLib = res.data
97
+        })
98
+      }
99
+    }
100
+  },
101
+  // 进入页面执行的方法
102
+  mounted: function() {
103
+    if (this.$route?.query.id) {
104
+      this.libId = this.$route.query.id
105
+      getCharacterLibDetail(this.$route.query.id).then((res) => {
106
+        this.characterLib = res.data
107
+      })
108
+    }
86 109
   },
87 110
 
88 111
   methods: {
89
-    //上方实例库的方法
112
+    // 上方实例库的方法
90 113
     onCancel() {
91
-      this.$router.go(-1);
114
+      this.$router.go(-1)
92 115
     },
93 116
     onEdit() {
94
-      UpdateCharacterLib(this.characterLib, this.characterLib.libId).then(
95
-        (res) => {
96
-          this.$message("修改成功");
97
-        }
98
-      );
117
+      if (this.libId) {
118
+        UpdateCharacterLib(this.characterLib, this.characterLib.libId).then(
119
+          (res) => {
120
+            this.$message('修改成功')
121
+          }
122
+        )
123
+      } else {
124
+        saveCharacterLib(this.characterLib, this.characterLib.libId).then(
125
+          (res) => {
126
+            this.$message('添加成功')
127
+            this.$router.replace({
128
+              name: 'characterLibEdit',
129
+              query: { id: res.data.libId }
130
+            })
131
+          }
132
+        )
133
+      }
99 134
     },
100
-
101
-    //特征词列表的方法
135
+    // 添加图片
136
+    handleChange(val) {
137
+      this.characterLib.icon = val
138
+    },
139
+    // 删除图片
140
+    handleDeleteIcon() {
141
+      this.characterLib.icon = ''
142
+    },
143
+    // 特征词列表的方法
102 144
     handleDelete(val) {
103 145
       if (this.characterLib.libId) {
104
-        let nowWordId = undefined;
146
+        let nowWordId
105 147
         this.characterLib.wordList.map((item) => {
106 148
           if (item.word === val) {
107
-            nowWordId = item.wordId;
149
+            nowWordId = item.wordId
108 150
           }
109
-        });
151
+        })
110 152
         // 调用删除接口
111 153
         deleteCharacterWord(nowWordId).then(() => {
112 154
           this.characterLib.wordList.map((item) => {
@@ -114,10 +156,10 @@ export default {
114 156
               this.characterLib.wordList.splice(
115 157
                 this.characterLib.wordList.indexOf(item),
116 158
                 1
117
-              );
159
+              )
118 160
             }
119
-          });
120
-        });
161
+          })
162
+        })
121 163
       } else {
122 164
         // 直接删除当前项
123 165
         this.characterLib.wordList.map((item) => {
@@ -125,9 +167,9 @@ export default {
125 167
             this.characterLib.wordList.splice(
126 168
               this.characterLib.wordList.indexOf(item),
127 169
               1
128
-            );
170
+            )
129 171
           }
130
-        });
172
+        })
131 173
       }
132 174
     },
133 175
     handleAdd(val) {
@@ -135,55 +177,41 @@ export default {
135 177
         saveCharacterWord({
136 178
           libId: this.characterLib.libId,
137 179
           word: val,
138
-          wordId: undefined,
180
+          wordId: undefined
139 181
         }).then((res) => {
140
-          this.characterLib.wordList.push(res.data);
141
-        });
182
+          this.characterLib.wordList.push(res.data)
183
+        })
142 184
       } else {
143 185
         this.characterLib.wordList.push({
144 186
           libId: this.characterLib.libId,
145 187
           word: val,
146
-          wordId: undefined,
147
-        });
188
+          wordId: undefined
189
+        })
148 190
       }
149 191
     },
150 192
 
151
-    //实例列表的方法
152
-    //添加实例
193
+    // 实例列表的方法
194
+    // 添加实例
153 195
     handleAddRusult() {
154
-      this.resultId = undefined;
196
+      this.resultId = undefined
155 197
     },
156 198
     handleEdit(val) {
157
-      this.resultId = val;
199
+      this.resultId = val
158 200
     },
159 201
 
160
-    //实例编辑页面调用实例列表的刷新方法 兄弟组件调用方法
202
+    // 实例编辑页面调用实例列表的刷新方法 兄弟组件调用方法
161 203
     handleRefresh() {
162
-      this.$refs.CharacterResult.onSearch();
204
+      this.$refs.CharacterResult.onSearch()
163 205
     },
164 206
     handleClose() {
165
-      this.resultId = undefined;
166
-    },
167
-  },
168
-  //进入页面执行的方法
169
-  mounted: function () {
170
-    if (this.$route?.query.id) {
171
-      getCharacterLibDetail(this.$route.query.id).then((res) => {
172
-        this.characterLib = res.data;
173
-      });
207
+      this.resultId = undefined
174 208
     }
175
-  },
176
-  components: {
177
-    UploadImage,
178
-    CharacterResult,
179
-    CharacterResultEdit,
180
-    TagComponents,
181
-  },
182
-};
209
+  }
210
+}
183 211
 </script>
184 212
 <style>
185
-.editBottomItem>div{
213
+.editBottomItem > div {
186 214
   margin: 0 !important;
187 215
   text-align: center;
188 216
 }
189
-</style>
217
+</style>

+ 36
- 36
src/views/characterLibManage/index.vue Parādīt failu

@@ -1,27 +1,27 @@
1 1
 <template>
2
-  <div class="body">
2
+  <div class="body" style="font-size:14px">
3 3
     <el-card class="box-card">
4 4
       特征库名称:<el-input
5 5
         v-model="name"
6
-        size="medium"
6
+        size="mini"
7 7
         style="width: 200px; margin-right: 20px"
8 8
       />
9 9
       创建时间:
10 10
       <el-date-picker
11 11
         v-model="daterange"
12
+        size="mini"
12 13
         type="daterange"
13 14
         range-separator="至"
14 15
         start-placeholder="开始日期"
15 16
         end-placeholder="结束日期"
16 17
         value-format="yyyy-MM-dd"
17
-        @change="dateChange"
18 18
         style="margin-right: 20px"
19
-      >
20
-      </el-date-picker>
19
+        @change="dateChange"
20
+      />
21 21
 
22
-      <el-button type="primary" @click="onSearch">查询</el-button>
23
-      <el-button @click="onReset">重置</el-button>
24
-      <el-button type="primary" @click="handleAdd">添加特征库</el-button>
22
+      <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
23
+      <el-button size="mini" @click="onReset">重置</el-button>
24
+      <el-button type="primary" size="mini" @click="handleAdd">添加特征库</el-button>
25 25
     </el-card>
26 26
     <el-table stripe :data="tableData" border style="width: 100%">
27 27
       <el-table-column prop="name" label="特征库名称" />
@@ -44,7 +44,7 @@
44 44
             title="这个特征库确定删除吗?"
45 45
             @onConfirm="handleDelete(scope.row)"
46 46
           >
47
-            <el-button type="text" slot="reference">删除</el-button>
47
+            <el-button slot="reference" type="text">删除</el-button>
48 48
           </el-popconfirm>
49 49
         </template>
50 50
       </el-table-column>
@@ -52,58 +52,58 @@
52 52
   </div>
53 53
 </template>
54 54
 <script>
55
-import { getCharacterLibList, deleteCharacterLib } from "@/api/characterLib";
55
+import { getCharacterLibList, deleteCharacterLib } from '@/api/characterLib'
56 56
 
57 57
 export default {
58 58
   data() {
59 59
     return {
60 60
       name: undefined,
61
-      daterange: "",
61
+      daterange: '',
62 62
       tableData: [],
63 63
       endDate: undefined,
64
-      startDate: undefined,
65
-    };
64
+      startDate: undefined
65
+    }
66
+  },
67
+  mounted() {
68
+    this.onSearch()
66 69
   },
67 70
   methods: {
68 71
     handleAdd() {
69
-      this.$router.push({ path: "characterLibManage/add" });
72
+      this.$router.push({ name: 'characterLibEdit' })
70 73
     },
71 74
     handleEdit(row) {
72 75
       this.$router.push({
73
-        path: "characterLibManage/edit",
74
-        query: { id: row.libId },
75
-      });
76
+        name: 'characterLibEdit',
77
+        query: { id: row.libId }
78
+      })
76 79
     },
77 80
     handleDelete(row) {
78 81
       deleteCharacterLib(row.libId).then(() => {
79
-        this.onSearch();
80
-      });
82
+        this.onSearch()
83
+      })
81 84
     },
82 85
     onSearch() {
83 86
       getCharacterLibList({
84 87
         name: this.name,
85 88
         startDate: this.startDate,
86
-        endDate: this.endDate,
89
+        endDate: this.endDate
87 90
       }).then((res) => {
88
-        this.tableData = res.data.records;
89
-      });
91
+        this.tableData = res.data.records
92
+      })
90 93
     },
91 94
     onReset() {
92
-      this.name = "";
93
-      this.daterange = "";
94
-      this.startDate = "";
95
-      this.endDate = "";
96
-      this.onSearch();
95
+      this.name = ''
96
+      this.daterange = ''
97
+      this.startDate = ''
98
+      this.endDate = ''
99
+      this.onSearch()
97 100
     },
98 101
     dateChange(val) {
99
-      this.startDate = this.daterange[0];
100
-      this.endDate = this.daterange[1];
101
-    },
102
-  },
103
-  mounted() {
104
-    this.onSearch();
105
-  },
106
-};
102
+      this.startDate = this.daterange[0]
103
+      this.endDate = this.daterange[1]
104
+    }
105
+  }
106
+}
107 107
 </script>
108 108
 <style>
109
-</style>
109
+</style>

+ 126
- 0
src/views/gameManage/edit.vue Parādīt failu

@@ -0,0 +1,126 @@
1
+<template>
2
+  <div class="body_edit">
3
+    <el-tabs v-model="activeName">
4
+      <el-tab-pane label="游戏详情" name="game">
5
+        <h2 style="text-align: center">游戏{{ gameId ? "编辑" : "新增" }}</h2>
6
+        <el-form ref="form" :model="gameForm" label-width="150px" size="mini">
7
+          <el-form-item label="游戏名称:">
8
+            <el-input v-model="gameForm.title" />
9
+          </el-form-item>
10
+          <el-form-item label="游戏图标:">
11
+            <UploadImage :icon="gameForm.gameImage" @handleChange="handleChange" @handleDeleteIcon="handleDeleteIcon" />
12
+          </el-form-item>
13
+          <el-form-item label="特征库名称:">
14
+            <el-select
15
+              v-model="gameForm.libId"
16
+              filterable
17
+              default-first-option
18
+              placeholder="请选择"
19
+              style="width: 200px; margin-right: 20px"
20
+              :disabled="gameId ? true : false"
21
+            >
22
+              <el-option
23
+                v-for="item in libList"
24
+                :key="item.libId"
25
+                :label="item.name"
26
+                :value="item.libId"
27
+              />
28
+            </el-select>
29
+          </el-form-item>
30
+
31
+          <el-form-item class="editBottomItem">
32
+            <el-button type="primary" @click="onSubmit">保存</el-button>
33
+            <el-button @click="onCancel">取消</el-button>
34
+          </el-form-item>
35
+        </el-form>
36
+      </el-tab-pane>
37
+      <el-tab-pane
38
+        label="游戏题库"
39
+        name="question"
40
+        :disabled="gameId ? false : true"
41
+      >
42
+        问题列表
43
+      </el-tab-pane>
44
+    </el-tabs>
45
+  </div>
46
+</template>
47
+<script>
48
+import { saveGame, UpdateGame, getGameDetail } from '@/api/game'
49
+import { getCharacterLibList } from '@/api/characterLib'
50
+import UploadImage from '@/components/UploadImage/index.vue'
51
+export default {
52
+  components: {
53
+    UploadImage
54
+  },
55
+  data() {
56
+    return {
57
+      gameForm: {
58
+        title: undefined,
59
+        gameImage: undefined,
60
+        libId: undefined
61
+      },
62
+      libList: [],
63
+      gameId: undefined,
64
+      activeName: 'game'
65
+    }
66
+  },
67
+  watch: {
68
+    '$route.query.id'(val) {
69
+      this.gameId = val
70
+      getGameDetail(val).then((res) => {
71
+        this.gameForm = res.data
72
+      })
73
+    }
74
+  },
75
+  mounted() {
76
+    if (this.$route?.query.id) {
77
+      this.gameId = this.$route.query.id
78
+      getGameDetail(this.$route.query.id).then((res) => {
79
+        this.gameForm = res.data
80
+      })
81
+    }
82
+    getCharacterLibList().then((res) => {
83
+      const list = res.data.records
84
+      list.map((item) => {
85
+        this.libList.push({ libId: item.libId, name: item.name })
86
+      })
87
+    })
88
+  },
89
+  methods: {
90
+    onCancel() {
91
+      this.$router.go(-1)
92
+    },
93
+    onSubmit() {
94
+      if (this.gameId) {
95
+        if (!this.gameForm.gameImage) {
96
+          this.gameForm.gameImage = ''
97
+        }
98
+        UpdateGame(this.gameForm, this.gameId).then((res) => {
99
+          this.$message('修改成功')
100
+          this.$router.go(-1)
101
+        })
102
+      } else {
103
+        saveGame(this.gameForm).then((res) => {
104
+          this.$message('保存成功')
105
+          this.$router.replace({
106
+            name: 'gameEdit',
107
+            query: { id: res.data.gameId }
108
+          })
109
+        })
110
+      }
111
+    },
112
+    handleChange(val) {
113
+      this.gameForm.gameImage = val
114
+    },
115
+    handleDeleteIcon() {
116
+      this.gameForm.gameImage = ''
117
+    }
118
+  }
119
+}
120
+</script>
121
+<style>
122
+.editBottomItem > div {
123
+  margin: 0 !important;
124
+  text-align: center;
125
+}
126
+</style>

+ 131
- 2
src/views/gameManage/index.vue Parādīt failu

@@ -1,7 +1,136 @@
1 1
 <template>
2
-<div>游戏列表</div>
2
+  <div class="body" style="font-size:14px">
3
+    <el-card class="box-card">
4
+      游戏名称:<el-input
5
+        v-model="title"
6
+        size="mini"
7
+        style="width: 200px; margin-right: 20px"
8
+      />
9
+      特征库名称:
10
+      <el-select
11
+        v-model="libId"
12
+        size="mini"
13
+        filterable
14
+        default-first-option
15
+        placeholder="请选择"
16
+        style="width: 200px; margin-right: 20px"
17
+      >
18
+        <el-option
19
+          v-for="item in libList"
20
+          :key="item.libId"
21
+          :label="item.name"
22
+          :value="item.libId"
23
+        />
24
+      </el-select>
25
+      创建时间:
26
+      <el-date-picker
27
+        v-model="daterange"
28
+        size="mini"
29
+        type="daterange"
30
+        range-separator="至"
31
+        start-placeholder="开始日期"
32
+        end-placeholder="结束日期"
33
+        value-format="yyyy-MM-dd"
34
+        style="margin-right: 20px"
35
+        @change="dateChange"
36
+      />
37
+      <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
38
+      <el-button size="mini" @click="onReset">重置</el-button>
39
+      <el-button type="primary" size="mini" @click="handleAdd">添加游戏</el-button>
40
+    </el-card>
41
+    <el-table stripe :data="tableData" border style="width: 100%">
42
+      <el-table-column prop="title" label="游戏名称" />
43
+      <el-table-column prop="gameImage" label="游戏图标">
44
+        <template slot-scope="scope">
45
+          <el-image :src="scope.row.gameImage" style="width: 100px; height: 100px" />
46
+        </template>
47
+      </el-table-column>
48
+      <el-table-column prop="libName" label="特征库名称" />
49
+      <el-table-column prop="createDate" label="创建时间">
50
+        <template slot-scope="scope">{{
51
+          scope.row.createDate.substr(0, 10)
52
+        }}</template>
53
+      </el-table-column>
54
+      <el-table-column fixed="right" label="操作">
55
+        <template slot-scope="scope">
56
+          <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
57
+          <el-popconfirm
58
+            icon="el-icon-info"
59
+            icon-color="red"
60
+            title="确定删除这个游戏吗?"
61
+            @onConfirm="handleDelete(scope.row)"
62
+          >
63
+            <el-button slot="reference" type="text">删除</el-button>
64
+          </el-popconfirm>
65
+        </template>
66
+      </el-table-column>
67
+    </el-table>
68
+  </div>
3 69
 </template>
4 70
 <script>
71
+import { getCharacterLibList } from '@/api/characterLib'
72
+import { getGameList, deleteGame } from '@/api/game'
73
+
74
+export default {
75
+  data() {
76
+    return {
77
+      libId: undefined,
78
+      title: undefined,
79
+      daterange: undefined,
80
+      tableData: [],
81
+      endDate: undefined,
82
+      startDate: undefined,
83
+      libList: []
84
+    }
85
+  },
86
+  mounted() {
87
+    this.onSearch()
88
+    getCharacterLibList().then((res) => {
89
+      const list = res.data.records
90
+      list.map((item) => {
91
+        this.libList.push({ libId: item.libId, name: item.name })
92
+      })
93
+    })
94
+  },
95
+  methods: {
96
+    handleAdd() {
97
+      this.$router.push({ name: 'gameEdit' })
98
+    },
99
+    handleEdit(row) {
100
+      this.$router.push({
101
+        name: 'gameEdit',
102
+        query: { id: row.gameId }
103
+      })
104
+    },
105
+    handleDelete(row) {
106
+      deleteGame(row.gameId).then(() => {
107
+        this.onSearch()
108
+      })
109
+    },
110
+    onSearch() {
111
+      getGameList({
112
+        title: this.title,
113
+        libId: this.libId,
114
+        startDate: this.startDate,
115
+        endDate: this.endDate
116
+      }).then((res) => {
117
+        this.tableData = res.data.records
118
+      })
119
+    },
120
+    onReset() {
121
+      this.title = undefined
122
+      this.libId = undefined
123
+      this.daterange = undefined
124
+      this.startDate = undefined
125
+      this.endDate = undefined
126
+      this.onSearch()
127
+    },
128
+    dateChange(val) {
129
+      this.startDate = this.daterange[0]
130
+      this.endDate = this.daterange[1]
131
+    }
132
+  }
133
+}
5 134
 </script>
6 135
 <style>
7
-</style>
136
+</style>

+ 38
- 39
src/views/questionList/edit.vue Parādīt failu

@@ -3,13 +3,13 @@
3 3
     <h2 style="text-align: center">题目编辑</h2>
4 4
     <el-form ref="form" :model="form" label-width="150px" size="mini">
5 5
       <el-form-item label="题目:">
6
-        <el-input type="textarea" v-model="form.title"></el-input>
6
+        <el-input v-model="form.title" type="textarea" />
7 7
       </el-form-item>
8 8
       <el-form-item label="题目类型:">
9 9
         <el-select v-model="form.optType" placeholder="请选择">
10
-          <el-option label="单选题" value="1"></el-option>
11
-          <el-option label="多选题" value="2"></el-option>
12
-          <el-option label="判断题" value="3"></el-option>
10
+          <el-option label="单选题" value="1" />
11
+          <el-option label="多选题" value="2" />
12
+          <el-option label="判断题" value="3" />
13 13
         </el-select>
14 14
       </el-form-item>
15 15
       <el-form-item label="答案:">
@@ -38,8 +38,7 @@
38 38
             :key="item.option"
39 39
             :label="item.option"
40 40
             :value="item.option"
41
-          >
42
-          </el-option>
41
+          />
43 42
         </el-select>
44 43
       </el-form-item>
45 44
       <el-form-item>
@@ -50,63 +49,63 @@
50 49
   </div>
51 50
 </template>
52 51
 <script>
53
-import AddAnswer from "@/components/AddAnswer/index.vue";
54
-import { saveQuestion } from "@/api/question";
52
+import AddAnswer from '@/components/AddAnswer/index.vue'
53
+import { saveQuestion } from '@/api/question'
55 54
 export default {
55
+  components: {
56
+    AddAnswer
57
+  },
56 58
   data() {
57 59
     return {
58 60
       form: {
59
-        title: "",
60
-        optType: "",
61
+        title: undefined,
62
+        optType: undefined,
61 63
         answerList: [],
62
-        option: "",
64
+        option: undefined
63 65
       },
64
-      rightList: undefined,
65
-    };
66
+      rightList: undefined
67
+    }
68
+  },
69
+  // 进入页面执行的方法
70
+  mounted: function() {
71
+    if (this.$route?.query.row) {
72
+      this.form.title = this.$route.query.row.title
73
+      this.form.optType = this.$route.query.row.optType
74
+    }
66 75
   },
67 76
 
68 77
   methods: {
69
-    //添加答案按钮事件
78
+    // 添加答案按钮事件
70 79
     onAddAnswer() {
71 80
       this.form.answerList.push({
72
-        answerId: "",
73
-        questionId: "",
74
-        contentType: "",
75
-        content: "",
76
-      });
81
+        answerId: undefined,
82
+        questionId: undefined,
83
+        contentType: undefined,
84
+        content: undefined
85
+      })
77 86
     },
78 87
     onCancel() {
79
-      this.$router.go(-1);
88
+      this.$router.go(-1)
80 89
     },
81 90
     onSubmit() {
82
-      this.form.option = this.rightList.toString();
91
+      this.form.option = this.rightList.toString()
83 92
       saveQuestion(this.form).then((res) => {
84
-        console.log(res);
85
-      });
93
+        console.log(res)
94
+      })
86 95
     },
87 96
     handleChange(answer) {
88
-      const index = this.form.answerList.indexOf(answer);
89
-      this.$set(this.form.answerList, index, answer);
97
+      const index = this.form.answerList.indexOf(answer)
98
+      this.$set(this.form.answerList, index, answer)
90 99
     },
91 100
     handleDelete(answer) {
92
-      this.form.answerList.splice(this.form.answerList.indexOf(answer), 1);
93
-    },
94
-  },
95
-  //进入页面执行的方法
96
-  mounted: function () {
97
-    if (this.$route?.query.row) {
98
-      this.form.title = this.$route.query.row.title;
99
-      this.form.optType = this.$route.query.row.optType;
101
+      this.form.answerList.splice(this.form.answerList.indexOf(answer), 1)
100 102
     }
101
-  },
102
-  components: {
103
-    AddAnswer,
104
-  },
105
-};
103
+  }
104
+}
106 105
 </script>
107 106
 <style>
108 107
 .body_edit {
109 108
   padding: 20px;
110 109
   width: 1000px;
111 110
 }
112
-</style>
111
+</style>

+ 1074
- 636
yarn.lock
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu