-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: survey vuex to pinia * feat: fix ts type-check * feat: fix lint error
- Loading branch information
1 parent
023a9e5
commit 3d1bdae
Showing
6 changed files
with
96 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { isMobile } from '../utils/index' | ||
// import { isMobile } from '../utils/index' | ||
|
||
export default { | ||
surveyPath: '', | ||
// surveyPath: '', | ||
questionData: null, | ||
isMobile: isMobile(), | ||
// isMobile: isMobile(), | ||
errorInfo: { | ||
errorType: '', | ||
errorMsg: '' | ||
}, | ||
enterTime: null, | ||
// enterTime: null, | ||
questionSeq: [], // 题目的顺序,因为可能会有分页的情况,所以是一个二维数组[[qid1, qid2], [qid3,qid4]] | ||
voteMap: {}, | ||
encryptInfo: null, | ||
// encryptInfo: null, | ||
ruleEngine: null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
// 问卷相关的Pinia Store | ||
// 问卷相关的Pinia Store | ||
import { defineStore } from 'pinia' | ||
import { ref } from 'vue' | ||
import { isMobile as isInMobile } from '@/render/utils/index' | ||
import { getEncryptInfo as getEncryptInfoApi } from '@/render/api/survey' | ||
|
||
/** | ||
* CODE_MAP不从management引入,在dev阶段,会导致B端 router被加载,进而导致C端路由被添加 baseUrl: /management | ||
*/ | ||
const CODE_MAP = { | ||
SUCCESS: 200, | ||
ERROR: 500, | ||
NO_AUTH: 403 | ||
} | ||
export const useSurveyStore = defineStore('survey', () => { | ||
const surveyPath = ref(''); | ||
const isMobile = ref(isInMobile()) | ||
const enterTime = ref(0) | ||
const encryptInfo = ref(null) | ||
|
||
const setSurveyPath = ( data) => { | ||
surveyPath.value = data | ||
} | ||
|
||
const setEnterTime = () => { | ||
enterTime.value = Date.now() | ||
} | ||
|
||
const getEncryptInfo = async() => { | ||
try { | ||
const res = await getEncryptInfoApi() | ||
if (res.code === CODE_MAP.SUCCESS) { | ||
encryptInfo.value = res.data | ||
} | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
} | ||
|
||
return { | ||
surveyPath, | ||
isMobile, | ||
enterTime, | ||
encryptInfo, | ||
|
||
setSurveyPath, | ||
setEnterTime, | ||
getEncryptInfo | ||
} | ||
}) |