diff --git a/src/api/questionPre.ts b/src/api/questionPre.ts new file mode 100644 index 0000000..59f3d17 --- /dev/null +++ b/src/api/questionPre.ts @@ -0,0 +1,44 @@ +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 875cdeb..04b8bca 100644 --- a/src/api/types.d.ts +++ b/src/api/types.d.ts @@ -13,3 +13,30 @@ export interface IArticleData { type: string 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, +} diff --git a/src/lang/en.ts b/src/lang/en.ts index 6aa90e3..7bdff4f 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -72,6 +72,8 @@ export default { marketing_points: 'Points Setting', question: 'Question Set', question_list: 'Question List', + question_prepare: 'Question Edit', + createQuestion: 'Create Question', shop: 'Shop Setting', game_setting: 'Game Setting' }, diff --git a/src/lang/zh.ts b/src/lang/zh.ts index d650d61..ccdbc3e 100644 --- a/src/lang/zh.ts +++ b/src/lang/zh.ts @@ -71,7 +71,9 @@ export default { marketing_promo: '优惠码设置', marketing_points: '积分设置', question: '题库管理', - question_list: '列表', + question_list: '题目列表', + question_prepare: '题目编辑', + createQuestion: '创建题目', shop: '店铺设置', game_setting: '游戏设置' }, diff --git a/src/router/modules/question.ts b/src/router/modules/question.ts index aba993f..1fefcd3 100644 --- a/src/router/modules/question.ts +++ b/src/router/modules/question.ts @@ -10,6 +10,26 @@ const questionRoutes: RouteConfig = { alwaysShow: true }, children: [ + { + path: 'create', + component: () => import(/* webpackChunkName: "example-create" */ '@/views/question/editor.vue'), + name: 'CreateQuestion', + meta: { + title: 'createQuestion', + icon: 'edit' + } + }, + { + path: 'edit/:id(\\d+)', + component: () => import('@/views/question/editor.vue'), + name: 'QuestionEditor', + meta: { + title: 'question_prepare', + permissions: ['question:read'], + elicon: 'el-icon-arrow-right', + hidden: true + } + }, { path: 'list', component: () => import('@/views/question/list.vue'), @@ -17,7 +37,7 @@ const questionRoutes: RouteConfig = { meta: { title: 'question_list', permissions: ['question:read'], - elicon: 'el-icon-arrow-right' + elicon: 'el-icon-arrow-right', } }, ] diff --git a/src/settings.ts b/src/settings.ts index 2255537..dcce3c6 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -12,7 +12,7 @@ interface ISettings { // You can customize below settings :) const settings: ISettings = { - title: 'Vue Typescript Admin', + title: '管理后台', showSettings: true, showTagsView: true, fixedHeader: false, diff --git a/src/views/question/editor.vue b/src/views/question/editor.vue new file mode 100644 index 0000000..d5b1b28 --- /dev/null +++ b/src/views/question/editor.vue @@ -0,0 +1,287 @@ + + + + + + diff --git a/src/views/question/list.vue b/src/views/question/list.vue index e69de29..fad9776 100644 --- a/src/views/question/list.vue +++ b/src/views/question/list.vue @@ -0,0 +1,135 @@ + + + + +