123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import Vue from "vue";
- import Vuex from "vuex";
- Vue.use(Vuex);
- const examHomeModule = {
- namespaced: true,
- state: { faceCheckModalOpen: false },
- mutations: {
- toggleFaceCheckModal(state, open) {
- if (open === undefined) {
- state.faceCheckModalOpen = !state.faceCheckModalOpen;
- } else {
- state.faceCheckModalOpen = open;
- }
- }
- },
- actions: {},
- getters: {}
- };
- const examingHomeModule = {
- namespaced: true,
- state: {
- exam: null,
- paperStruct: null,
- examQuestionList: null,
- questionFilterType: "ALL",
- snapNow: false,
- snapProcessingCount: 0,
- shouldSubmitPaper: false
- },
- mutations: {
- toggleSnapNow(state) {
- state.snapNow = !state.snapNow;
- if (state.snapNow) {
- state.snapProcessingCount = state.snapProcessingCount + 1;
- }
- },
- decreaseSnapCount(state) {
- state.snapProcessingCount = state.snapProcessingCount - 1;
- },
- updateExamState(state, payload) {
- state = Object.assign(state, payload);
- },
- updateExamResult(state, payload) {
- state = Object.assign(state, { examResult: payload });
- },
- updateQuestionFilter(state, type) {
- state.questionFilterType = type;
- },
- updateExamQuestion(
- state,
- { order, studentAnswer, isSign, audioPlayTimes, getQuestionContent }
- ) {
- const examQuestionList = state.examQuestionList.map(eq => {
- // console.log(eq.order, order);
- if (eq.order == order) {
- return Object.assign(
- {},
- eq,
- getQuestionContent === undefined && { dirty: true }, // 仅设置getQuestionContent时,不更新dirty
- studentAnswer !== undefined && { studentAnswer },
- audioPlayTimes !== undefined && { audioPlayTimes },
- isSign !== undefined && { isSign },
- getQuestionContent !== undefined && { getQuestionContent }
- );
- }
- return eq;
- });
- state = Object.assign(state, { examQuestionList });
- },
- resetExamQuestionDirty(state) {
- const examQuestionList = state.examQuestionList.map(eq => {
- return Object.assign({}, eq, { dirty: false });
- });
- state = Object.assign(state, { examQuestionList });
- },
- setShouldSubmitPaper(state) {
- state.shouldSubmitPaper = !state.shouldSubmitPaper;
- }
- },
- actions: {},
- getters: {
- examShouldShowAnswer(state) {
- if (state.exam && state.exam.practiceType === "IN_PRACTICE") {
- return true;
- }
- return false;
- }
- }
- };
- const userStr = window.localStorage.getItem("user-for-reload");
- const initUser = userStr ? JSON.parse(userStr) : {};
- export default new Vuex.Store({
- state: {
- user: initUser
- },
- mutations: {
- updateUser(state, payload) {
- state = Object.assign(state, { user: payload });
- }
- },
- actions: {},
- modules: {
- examHomeModule,
- examingHomeModule
- }
- });
|