From 30ccb6edd59199b9038a196861d51517eb09782b Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 22 Apr 2021 20:52:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A2=98=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/question.ts | 48 ++++++++++++ src/api/questionPre.ts | 44 ----------- src/api/types.d.ts | 27 ------- src/router/modules/question.ts | 2 +- src/views/question/editor.vue | 112 ++++++++++++++------------- src/views/question/list.vue | 137 ++++++++++++++++++++++++++------- 6 files changed, 216 insertions(+), 154 deletions(-) create mode 100644 src/api/question.ts delete mode 100644 src/api/questionPre.ts diff --git a/src/api/question.ts b/src/api/question.ts new file mode 100644 index 0000000..2b43408 --- /dev/null +++ b/src/api/question.ts @@ -0,0 +1,48 @@ +import request from '@/utils/request' + +export interface IQuestionData { + _id?: string, + question: string, + a1: string, + a2?: string, + a3?: string, + a4?: string, + group?: string, + tag?: string, + quality: number +} + + +export const defaultQuestionData: IQuestionData = { + quality: 3, + a1: '', question: '' + +} + +export const getQuestions = (params: any) => + request({ + url: '/puzzles', + method: 'post', + params + }) + +export const getQuestion = (id: string, params: any) => + request({ + url: `/puzzle/${id}`, + method: 'get', + params + }) + + +export const saveQuestion = (data: any) => + request({ + url: `/puzzle/save`, + method: 'post', + data + }) + +export const deleteQuestion = (id: string) => + request({ + url: `/puzzle/${id}/delete`, + method: 'post' + }) diff --git a/src/api/questionPre.ts b/src/api/questionPre.ts deleted file mode 100644 index 59f3d17..0000000 --- a/src/api/questionPre.ts +++ /dev/null @@ -1,44 +0,0 @@ -import axios from 'axios' -import {IQuestionData } from '@/api/types' -export const defaultQuestionData: IQuestionData = { - option: [], - answer: '', attachment: '', parts: [], stars: 0, status: 0, type: 0, - id: '', - title: '', - tags: [] -} -/** - * 随机获取一个未处理的题目 - * @return {Promise} - */ -export async function randomOne() { - let url = '' - return axios.get(url, {}) - .then(res => { - return res.data - }) -} - -/** - * 更新一条记录 - * @param data - * @return {Promise} - */ -export async function updateOne(data: any) { - let url = '' - return axios.post(url, data) - .then(res => { - return res.data - }) -} - -/** - * 获取一个相关的列表 - */ -export async function queryList(str: string) { - let url = '' - return axios.post(url, {key: str}) - .then(res => { - return res.data - }) -} diff --git a/src/api/types.d.ts b/src/api/types.d.ts index d8f6f29..34c3097 100644 --- a/src/api/types.d.ts +++ b/src/api/types.d.ts @@ -14,33 +14,6 @@ export interface IArticleData { attachments: [] } -export interface IQuestionData { - id: string, - title: string, - /** - * 自动拆分的分词 - */ - parts?: string[], - tags: string[], - answer: string, - /** - * 混淆的答案 - */ - option: string[], - /** - * 题目类型 - * 0: 文字题 - * 1: 图文 - */ - type: number, - attachment?: string, - /** - * 评分 - */ - stars: number, - status: number, -} - export interface IShopData { _id?: string, name: string, diff --git a/src/router/modules/question.ts b/src/router/modules/question.ts index 72584f7..604cfac 100644 --- a/src/router/modules/question.ts +++ b/src/router/modules/question.ts @@ -21,7 +21,7 @@ const questionRoutes: RouteConfig = { } }, { - path: 'edit/:id(\\d+)', + path: 'edit/:id', component: () => import('@/views/question/editor.vue'), name: 'QuestionEditor', meta: { diff --git a/src/views/question/editor.vue b/src/views/question/editor.vue index d5b1b28..2e92deb 100644 --- a/src/views/question/editor.vue +++ b/src/views/question/editor.vue @@ -8,23 +8,20 @@ > + + 取消 + - Publish - - - Draft + 保存 +
@@ -35,7 +32,7 @@ prop="title" > @@ -66,11 +64,11 @@ class="postInfo-container-item" > @@ -84,7 +82,7 @@ label="混淆答案1:" > @@ -97,7 +95,7 @@ label="混淆答案2:" > @@ -110,7 +108,7 @@ label="混淆答案3:" > @@ -124,7 +122,6 @@