@zykjcommon/questions 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +3 -0
- package/.env +7 -0
- package/.env.buildTest +9 -0
- package/.env.development +9 -0
- package/.env.production +13 -0
- package/.env.test +12 -0
- package/@types/global.d.ts +33 -0
- package/@types/shims-vue.d.ts +6 -0
- package/@types/shims-vuex.d.ts +15 -0
- package/auto-imports.d.ts +6 -0
- package/babel.config.js +5 -0
- package/components.d.ts +23 -0
- package/design/App.vue +60 -0
- package/design/main.js +23 -0
- package/design/views/dialog/contentDialog.vue +18 -0
- package/design/views/dialog/contentDialog2.vue +18 -0
- package/design/views/dialog/contentDialog3.vue +19 -0
- package/design/views/exam/analysis.vue +208 -0
- package/design/views/exam/exam.vue +355 -0
- package/design/views/home/illustrate.vue +45 -0
- package/design/views/home/login.vue +43 -0
- package/design/vueMapper.js +8 -0
- package/design/vueMapperTree.js +2 -0
- package/dist/demo.html +1 -0
- package/dist/zykjcommon-questions.common.js +12817 -0
- package/dist/zykjcommon-questions.css +1 -0
- package/dist/zykjcommon-questions.umd.js +12836 -0
- package/dist/zykjcommon-questions.umd.min.js +18 -0
- package/index.js +10 -0
- package/package.json +61 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +19 -0
- package/public/static/js/jquery.html2json.js +169 -0
- package/public/static/js/jquery.json2html.js +137 -0
- package/public/static/js/jquery.min.js +2 -0
- package/public/static/js/json2html.js +447 -0
- package/readme +8 -0
- package/src/App.vue +37 -0
- package/src/assets/img/afei.jpg +0 -0
- package/src/assets/img/audio-ico.gif +0 -0
- package/src/assets/img/audio-ico.png +0 -0
- package/src/assets/img/bc-type-bg.png +0 -0
- package/src/assets/img/big-close.png +0 -0
- package/src/assets/img/big-next.png +0 -0
- package/src/assets/img/big-pre.png +0 -0
- package/src/assets/img/book-bg.png +0 -0
- package/src/assets/img/checkbox-cur.png +0 -0
- package/src/assets/img/checkbox.png +0 -0
- package/src/assets/img/cpp-bg.png +0 -0
- package/src/assets/img/deer-logo.png +0 -0
- package/src/assets/img/header-bg-2.png +0 -0
- package/src/assets/img/header-bg.png +0 -0
- package/src/assets/img/illustrate-bg.png +0 -0
- package/src/assets/img/loading.gif +0 -0
- package/src/assets/img/login-bg.png +0 -0
- package/src/assets/img/login-box-bg.png +0 -0
- package/src/assets/img/login-box-logo.png +0 -0
- package/src/assets/img/logo.png +0 -0
- package/src/assets/img/logoByText.png +0 -0
- package/src/assets/img/py-bg.png +0 -0
- package/src/assets/img/pygame-bg.png +0 -0
- package/src/assets/img/radio-cur.png +0 -0
- package/src/assets/img/radio.png +0 -0
- package/src/assets/img/return-top-hover.png +0 -0
- package/src/assets/img/return-top.png +0 -0
- package/src/assets/img/sb3-bg.png +0 -0
- package/src/assets/img/star-ico.png +0 -0
- package/src/assets/img/tab-mark.png +0 -0
- package/src/assets/img/video-play-btn.png +0 -0
- package/src/assets/js/arms.js +16 -0
- package/src/assets/js/bus.js +14 -0
- package/src/assets/js/fun.js +883 -0
- package/src/assets/js/helper.js +575 -0
- package/src/assets/js/http.js +219 -0
- package/src/assets/js/md5.js +260 -0
- package/src/assets/js/rem.js +33 -0
- package/src/assets/js/validation.js +216 -0
- package/src/assets/js/zykjcommon-questions.umd.min.js +18 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/scss/dialog/dialog.scss +144 -0
- package/src/assets/scss/exam/exam.scss +256 -0
- package/src/assets/scss/home/home.scss +222 -0
- package/src/assets/scss/index.scss +80 -0
- package/src/assets/scss/questions/index.scss +345 -0
- package/src/common/const.ts +15 -0
- package/src/components/common/ContentDialog.vue +172 -0
- package/src/components/common/IframeComponent.vue +101 -0
- package/src/components/common/Loading.vue +45 -0
- package/src/components/common/MediaLooker.vue +171 -0
- package/src/components/common/TextAreaEditor.vue +121 -0
- package/src/components/exam/QuestionCard.vue +494 -0
- package/src/components/exam/QuestionHeader.vue +87 -0
- package/src/components/exam/TimeCounter.vue +107 -0
- package/src/components/questions/QuestionReader.js +20 -0
- package/src/components/questions/Question_SingleChoice.vue +208 -0
- package/src/components/questions/buildEntry.js +12 -0
- package/src/components/questions/developmentEntry.js +11 -0
- package/src/components/questions/mixin.js +64 -0
- package/src/main.ts +176 -0
- package/src/router/exam.ts +50 -0
- package/src/router/index.ts +33 -0
- package/src/store/exam.ts +199 -0
- package/src/store/index.ts +22 -0
- package/src/types/common/index.ts +4 -0
- package/src/types/exam/exam.ts +10 -0
- package/src/views/exam/Analysis.vue +516 -0
- package/src/views/exam/Default.vue +28 -0
- package/src/views/exam/Exam.vue +594 -0
- package/src/views/exam/ReviewPaper.vue +178 -0
- package/src/views/exam/ReviewQuestion.vue +167 -0
- package/tasks/vueMapper.js +37 -0
- package/tasks/vueMapperTree.js +42 -0
- package/tsconfig.json +46 -0
- package/tslint.json +19 -0
- package/vue.config.js +107 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="exam">
|
|
3
|
+
<QuestionHeader :resData="responsiveObj.resData"></QuestionHeader>
|
|
4
|
+
<div class="content-outter">
|
|
5
|
+
<div class="content">
|
|
6
|
+
<div class="content-left">
|
|
7
|
+
<div class="return-top" v-returnTop></div>
|
|
8
|
+
<div class="intro">
|
|
9
|
+
<div class="intro-tit">测评说明:</div>
|
|
10
|
+
<div class="intro-txt">-</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="question-main">
|
|
13
|
+
<ul class="question-list">
|
|
14
|
+
<li v-for="(item,index) in responsiveObj.questionList" :id="'question'+ index">
|
|
15
|
+
<component :is="item.questionComponent"
|
|
16
|
+
:mode="'review'"
|
|
17
|
+
:questionInfo="item"
|
|
18
|
+
:key="'question'+ index"
|
|
19
|
+
:ref="'question'+ index"/>
|
|
20
|
+
</li>
|
|
21
|
+
</ul>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="content-right">
|
|
25
|
+
<!-- {{responsiveObj.questionList}}-->
|
|
26
|
+
<QuestionCard v-model:questionList="responsiveObj.questionList"></QuestionCard>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
import {defineComponent, ref, toRefs, reactive, watch, computed, onMounted, getCurrentInstance, onUnmounted} from 'vue'
|
|
35
|
+
// import QuestionReader from '@src/components/questions/QuestionReader.js'
|
|
36
|
+
import QuestionCard from '@src/components/exam/QuestionCard.vue'
|
|
37
|
+
import TimeCounter from '@src/components/exam/TimeCounter.vue'
|
|
38
|
+
import QuestionHeader from '@src/components/exam/QuestionHeader.vue'
|
|
39
|
+
import {createNamespacedHelpers} from 'vuex-composition-helpers';
|
|
40
|
+
import {useRouter,useRoute} from 'vue-router'
|
|
41
|
+
import fun from "@/assets/js/fun";
|
|
42
|
+
import bus from "@/assets/js/bus";
|
|
43
|
+
import {questionMapper} from '@src/common/const.ts'
|
|
44
|
+
|
|
45
|
+
interface dataInterface{
|
|
46
|
+
warnVisible:boolean,
|
|
47
|
+
autoSubmitTimer:any,
|
|
48
|
+
routeName:string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface responsiveData{
|
|
52
|
+
questionList:Array<any>,
|
|
53
|
+
resData:any
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
export default defineComponent({
|
|
58
|
+
components: {
|
|
59
|
+
// ...QuestionReader,
|
|
60
|
+
QuestionCard,
|
|
61
|
+
QuestionHeader,
|
|
62
|
+
TimeCounter
|
|
63
|
+
},
|
|
64
|
+
setup(props,context) {
|
|
65
|
+
const {useState, useActions,useMutations} = createNamespacedHelpers('exam'); // specific module name
|
|
66
|
+
const {getExamPaperActions,resetExamActions} = useActions(['getExamPaperActions','resetExamActions'])
|
|
67
|
+
const {setExamPaperInfo} = useMutations(['setExamPaperInfo'])
|
|
68
|
+
let route = useRoute()
|
|
69
|
+
//不需要响应式或者写死的数据放里面
|
|
70
|
+
let data:dataInterface = reactive({
|
|
71
|
+
autoSubmitTimer:null,
|
|
72
|
+
warnVisible:false,
|
|
73
|
+
routeName:route.name as string
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
//需要响应式放里面
|
|
77
|
+
let responsiveObj:{value:responsiveData} = ref({
|
|
78
|
+
questionList:[],
|
|
79
|
+
resData:{}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
window.addEventListener('message',messageEvent)
|
|
84
|
+
fun.postMessageByType('reviewReady')
|
|
85
|
+
|
|
86
|
+
onMounted(()=>{
|
|
87
|
+
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
onUnmounted(()=>{
|
|
91
|
+
removeIframeEvents()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function parseQuestionListItem(question_list:Array<any>,parentIndex:any = undefined){
|
|
96
|
+
question_list.forEach((item:any,index:number)=>{
|
|
97
|
+
item.questionComponent = questionMapper[item.question_type]
|
|
98
|
+
// item.questionIndex = index + 1
|
|
99
|
+
if(parentIndex === undefined){
|
|
100
|
+
item.questionIndex = index + 1
|
|
101
|
+
}else{
|
|
102
|
+
item.questionIndex = (parentIndex + 1) + '-' + (index + 1)
|
|
103
|
+
item.questionIndex2 = index + 1
|
|
104
|
+
}
|
|
105
|
+
item.answerMap = null
|
|
106
|
+
let question_type = item.question_type
|
|
107
|
+
if(question_type == 3){
|
|
108
|
+
//判断题手动构造选项数组
|
|
109
|
+
item.exam_options_data = [
|
|
110
|
+
{
|
|
111
|
+
index:1,data:{
|
|
112
|
+
name:'正确'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
index:2,data:{
|
|
117
|
+
name:'错误'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}else{
|
|
122
|
+
if(item.exam_options_data && item.exam_options_data.length){
|
|
123
|
+
item.exam_options_data.forEach((subItem:any,subIndex:number)=>{
|
|
124
|
+
subItem.enIndex = fun.indexToEnIndex(subIndex+1)
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//转化富文本
|
|
130
|
+
try{
|
|
131
|
+
item.htmlContent = $.json2html({}, JSON.parse(item.content));
|
|
132
|
+
}catch(e){
|
|
133
|
+
item.htmlContent = item.content
|
|
134
|
+
console.log('json2html转化出错:', e);
|
|
135
|
+
}
|
|
136
|
+
//如果是阅读题要递归解析
|
|
137
|
+
if(item.sub_questions && item.sub_questions.length){
|
|
138
|
+
parseQuestionListItem(item.sub_questions,index)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
})
|
|
142
|
+
// console.log(question_list,33333);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function messageEvent(data:any){
|
|
146
|
+
if(typeof(data.data)==='string'){
|
|
147
|
+
try {
|
|
148
|
+
let obj = JSON.parse(data.data)
|
|
149
|
+
if(obj.type === 'getPaperReviewData'){
|
|
150
|
+
responsiveObj.value.resData = obj.data
|
|
151
|
+
responsiveObj.value.resData.remain_second = responsiveObj.value.resData.remain_second * 1000
|
|
152
|
+
let {questionList} = obj.data
|
|
153
|
+
parseQuestionListItem(questionList)
|
|
154
|
+
responsiveObj.value.questionList = questionList
|
|
155
|
+
setExamPaperInfo(responsiveObj.value.resData.user_id)
|
|
156
|
+
// console.log(questionList,12345);
|
|
157
|
+
}
|
|
158
|
+
} catch(e) {
|
|
159
|
+
let res = data.data
|
|
160
|
+
// console.log(res,88888);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function removeIframeEvents(){
|
|
165
|
+
window.removeEventListener('message',messageEvent)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
...toRefs(data),
|
|
171
|
+
responsiveObj
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
</script>
|
|
176
|
+
<style lang="scss" scoped>
|
|
177
|
+
|
|
178
|
+
</style>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="exam">
|
|
3
|
+
<div class="content-outter">
|
|
4
|
+
<div class="content">
|
|
5
|
+
<div class="content-left" style="width: 100%">
|
|
6
|
+
<div class="question-main">
|
|
7
|
+
<ul class="question-list">
|
|
8
|
+
<li v-for="(item,index) in responsiveObj.questionList" :id="'question'+ index">
|
|
9
|
+
<component :is="item.questionComponent"
|
|
10
|
+
:mode="'review'"
|
|
11
|
+
:questionInfo="item"
|
|
12
|
+
:key="'question'+ index"
|
|
13
|
+
:ref="'question'+ index"/>
|
|
14
|
+
</li>
|
|
15
|
+
</ul>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import {defineComponent, ref, toRefs, reactive, watch, computed, onMounted, getCurrentInstance, onUnmounted} from 'vue'
|
|
25
|
+
// import QuestionReader from '@src/components/questions/QuestionReader.js'
|
|
26
|
+
import QuestionCard from '@src/components/exam/QuestionCard.vue'
|
|
27
|
+
import TimeCounter from '@src/components/exam/TimeCounter.vue'
|
|
28
|
+
import {createNamespacedHelpers} from 'vuex-composition-helpers';
|
|
29
|
+
import {useRouter,useRoute} from 'vue-router'
|
|
30
|
+
import fun from "@/assets/js/fun";
|
|
31
|
+
import bus from "@/assets/js/bus";
|
|
32
|
+
import {questionMapper} from '@src/common/const.ts'
|
|
33
|
+
|
|
34
|
+
interface dataInterface{
|
|
35
|
+
warnVisible:boolean,
|
|
36
|
+
enterCode:boolean,
|
|
37
|
+
autoSubmitTimer:any,
|
|
38
|
+
routeName:string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface responsiveData{
|
|
42
|
+
questionList:Array<any>,
|
|
43
|
+
resData:any
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export default defineComponent({
|
|
48
|
+
components: {
|
|
49
|
+
// ...QuestionReader,
|
|
50
|
+
QuestionCard,
|
|
51
|
+
TimeCounter
|
|
52
|
+
},
|
|
53
|
+
setup(props,context) {
|
|
54
|
+
const {useState, useActions,useMutations} = createNamespacedHelpers('exam'); // specific module name
|
|
55
|
+
const {getExamPaperActions,resetExamActions} = useActions(['getExamPaperActions','resetExamActions'])
|
|
56
|
+
const {setExamPaperInfo} = useMutations(['setExamPaperInfo'])
|
|
57
|
+
let route = useRoute()
|
|
58
|
+
//不需要响应式或者写死的数据放里面
|
|
59
|
+
let data:dataInterface = reactive({
|
|
60
|
+
autoSubmitTimer:null,
|
|
61
|
+
warnVisible:false,
|
|
62
|
+
enterCode:false,
|
|
63
|
+
routeName:route.name as string
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
//需要响应式放里面
|
|
67
|
+
let responsiveObj:{value:responsiveData} = ref({
|
|
68
|
+
questionList:[],
|
|
69
|
+
resData:{}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
window.addEventListener('message',messageEvent)
|
|
74
|
+
onMounted(()=>{
|
|
75
|
+
bus.$on('enterCode',(bol)=>{
|
|
76
|
+
data.enterCode = bol as boolean
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
onUnmounted(()=>{
|
|
81
|
+
removeIframeEvents()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function parseQuestionListItem(question_list:Array<any>,parentIndex:any = undefined){
|
|
86
|
+
question_list.forEach((item:any,index:number)=>{
|
|
87
|
+
item.questionComponent = questionMapper[item.question_type]
|
|
88
|
+
// item.questionIndex = index + 1
|
|
89
|
+
if(parentIndex === undefined){
|
|
90
|
+
item.questionIndex = index + 1
|
|
91
|
+
}else{
|
|
92
|
+
item.questionIndex = (parentIndex + 1) + '-' + (index + 1)
|
|
93
|
+
item.questionIndex2 = index + 1
|
|
94
|
+
}
|
|
95
|
+
item.answerMap = null
|
|
96
|
+
let question_type = item.question_type
|
|
97
|
+
if(question_type == 3){
|
|
98
|
+
//判断题手动构造选项数组
|
|
99
|
+
item.exam_options_data = [
|
|
100
|
+
{
|
|
101
|
+
index:1,data:{
|
|
102
|
+
name:'正确'
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
index:2,data:{
|
|
107
|
+
name:'错误'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}else{
|
|
112
|
+
if(item.exam_options_data && item.exam_options_data.length){
|
|
113
|
+
item.exam_options_data.forEach((subItem:any,subIndex:number)=>{
|
|
114
|
+
subItem.enIndex = fun.indexToEnIndex(subIndex+1)
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//转化富文本
|
|
120
|
+
try{
|
|
121
|
+
item.htmlContent = $.json2html({}, JSON.parse(item.content));
|
|
122
|
+
}catch(e){
|
|
123
|
+
item.htmlContent = item.content;
|
|
124
|
+
console.log('json2html转化出错:', e);
|
|
125
|
+
}
|
|
126
|
+
//如果是阅读题要递归解析
|
|
127
|
+
if(item.sub_questions && item.sub_questions.length){
|
|
128
|
+
parseQuestionListItem(item.sub_questions,index)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
})
|
|
132
|
+
// console.log(question_list,33333);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function messageEvent(data:any){
|
|
136
|
+
if(typeof(data.data)==='string'){
|
|
137
|
+
try {
|
|
138
|
+
let obj = JSON.parse(data.data)
|
|
139
|
+
if(obj.type === 'getQuestionReviewData'){
|
|
140
|
+
responsiveObj.value.resData = obj.data
|
|
141
|
+
let {questionList} = obj.data
|
|
142
|
+
parseQuestionListItem(questionList)
|
|
143
|
+
responsiveObj.value.questionList = questionList
|
|
144
|
+
setExamPaperInfo(responsiveObj.value.resData.user_id)
|
|
145
|
+
// console.log(questionList,12345);
|
|
146
|
+
}
|
|
147
|
+
} catch(e) {
|
|
148
|
+
let res = data.data
|
|
149
|
+
// console.log(res,88888);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function removeIframeEvents(){
|
|
154
|
+
window.removeEventListener('message',messageEvent)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
...toRefs(data),
|
|
160
|
+
responsiveObj
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
</script>
|
|
165
|
+
<style lang="scss" scoped>
|
|
166
|
+
|
|
167
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Allen Liu on 2021/6/5.
|
|
3
|
+
*/
|
|
4
|
+
let fs = require('fs')
|
|
5
|
+
let path = require('path')
|
|
6
|
+
function resolvePath(p){
|
|
7
|
+
let result = path.resolve(__dirname,p)
|
|
8
|
+
return result
|
|
9
|
+
}
|
|
10
|
+
let dirs = fs.readdirSync(resolvePath('../design/views'))
|
|
11
|
+
let result = ''
|
|
12
|
+
let vueRouterNameStrs = ''
|
|
13
|
+
dirs.forEach((dir)=>{
|
|
14
|
+
let subDirStr = resolvePath(`../design/views/${dir}`)
|
|
15
|
+
let data = fs.statSync(subDirStr)
|
|
16
|
+
let isDirectory = data.isDirectory()
|
|
17
|
+
if(isDirectory){
|
|
18
|
+
let subDirs = fs.readdirSync(subDirStr)
|
|
19
|
+
subDirs = subDirs.map((item)=>{
|
|
20
|
+
//去除xx.vue
|
|
21
|
+
let i = item.split('.')[0]
|
|
22
|
+
return i
|
|
23
|
+
})
|
|
24
|
+
subDirs.forEach((subDir,index)=>{
|
|
25
|
+
let vueRouterName = `${dir}_${subDir}`
|
|
26
|
+
let resultItem = `import ${vueRouterName} from './views/${dir}/${subDir}.vue';\r\n`
|
|
27
|
+
result += resultItem
|
|
28
|
+
vueRouterNameStrs += vueRouterName + `,`
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
// console.log(data.isDirectory());
|
|
32
|
+
})
|
|
33
|
+
result += `export default {${vueRouterNameStrs} }`
|
|
34
|
+
fs.writeFile(resolvePath('../design/vueMapper.js'),result,function(){
|
|
35
|
+
console.log('生成vueMapper成功!!!');
|
|
36
|
+
})
|
|
37
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Allen Liu on 2021/6/5.
|
|
3
|
+
*/
|
|
4
|
+
let fs = require('fs')
|
|
5
|
+
let path = require('path')
|
|
6
|
+
function resolvePath(p){
|
|
7
|
+
let result = path.resolve(__dirname,p)
|
|
8
|
+
return result
|
|
9
|
+
}
|
|
10
|
+
let dirs = fs.readdirSync(resolvePath('../design/views'))
|
|
11
|
+
let result = 'let treeData = '
|
|
12
|
+
let arr = []
|
|
13
|
+
dirs.forEach((dir)=>{
|
|
14
|
+
let subDirStr = resolvePath(`../design/views/${dir}`)
|
|
15
|
+
let data = fs.statSync(subDirStr)
|
|
16
|
+
let isDirectory = data.isDirectory()
|
|
17
|
+
if(isDirectory){
|
|
18
|
+
let dataItem = {label:dir, children:[]}
|
|
19
|
+
let subDirs = fs.readdirSync(subDirStr)
|
|
20
|
+
subDirs = subDirs.map((item)=>{
|
|
21
|
+
//去除xx.vue
|
|
22
|
+
let i = item.split('.')[0]
|
|
23
|
+
return i
|
|
24
|
+
})
|
|
25
|
+
subDirs.forEach((subDir,index)=>{
|
|
26
|
+
let vueRouterName = `${dir}_${subDir}`
|
|
27
|
+
dataItem.children.push({
|
|
28
|
+
label:subDir,
|
|
29
|
+
name:vueRouterName
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
arr.push(dataItem)
|
|
33
|
+
}
|
|
34
|
+
// console.log(data.isDirectory());
|
|
35
|
+
})
|
|
36
|
+
result += JSON.stringify(arr) + `\r\n`
|
|
37
|
+
result += `export default treeData`
|
|
38
|
+
fs.writeFile(resolvePath('../design/vueMapperTree.js'),result,function(){
|
|
39
|
+
console.log('生成vueMapperTree成功!!!');
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"importHelpers": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"baseUrl": ".",
|
|
15
|
+
"types": [
|
|
16
|
+
"webpack-env",
|
|
17
|
+
"node"
|
|
18
|
+
],
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": [
|
|
21
|
+
"src/*","@types/*"
|
|
22
|
+
],
|
|
23
|
+
//加了@src/的解析后 import xx from '@src/xxx'才不会找不到
|
|
24
|
+
"@src/*": [
|
|
25
|
+
"src/*","@types/*"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"lib": [
|
|
29
|
+
"esnext",
|
|
30
|
+
"dom",
|
|
31
|
+
"dom.iterable",
|
|
32
|
+
"scripthost"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"include": [
|
|
36
|
+
"@types/**/*.ts",
|
|
37
|
+
"src/**/*.ts",
|
|
38
|
+
"src/**/*.tsx",
|
|
39
|
+
"src/**/*.vue",
|
|
40
|
+
"tests/**/*.ts",
|
|
41
|
+
"tests/**/*.tsx"
|
|
42
|
+
],
|
|
43
|
+
"exclude": [
|
|
44
|
+
"node_modules"
|
|
45
|
+
]
|
|
46
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"defaultSeverity": "none",
|
|
3
|
+
"extends": [
|
|
4
|
+
"tslint:recommended"
|
|
5
|
+
],
|
|
6
|
+
"linterOptions": {
|
|
7
|
+
"exclude": [
|
|
8
|
+
"node_modules/**"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"rules": {
|
|
12
|
+
"indent": [true, "spaces", 2],
|
|
13
|
+
"interface-name": false,
|
|
14
|
+
"no-consecutive-blank-lines": false,
|
|
15
|
+
"object-literal-sort-keys": false,
|
|
16
|
+
"ordered-imports": false,
|
|
17
|
+
"quotemark": [true, "single"]
|
|
18
|
+
}
|
|
19
|
+
}
|
package/vue.config.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
let argv = require('yargs').argv
|
|
3
|
+
const isProduction = (process.env.NODE_ENV === 'production');
|
|
4
|
+
function resolve(dir) {
|
|
5
|
+
return path.join(__dirname, dir)
|
|
6
|
+
}
|
|
7
|
+
let version = require('./package.json').version;
|
|
8
|
+
process.env.VUE_APP_VERSION = version;
|
|
9
|
+
// console.log(process.env.NODE_ENV,33);
|
|
10
|
+
|
|
11
|
+
const webpack = require('webpack');
|
|
12
|
+
const AutoImport = require('unplugin-auto-import/dist/webpack.js')
|
|
13
|
+
const Components = require('unplugin-vue-components/dist/webpack.js')
|
|
14
|
+
// const elementPlugin = require('unplugin-element-plus/dist/webpack.js')
|
|
15
|
+
const {ElementPlusResolver} = require('unplugin-vue-components/dist/resolvers.js')
|
|
16
|
+
|
|
17
|
+
//design需要用到elementui src暂时用不到
|
|
18
|
+
let elementUiPlugins = []
|
|
19
|
+
if(argv.design){
|
|
20
|
+
elementUiPlugins = [
|
|
21
|
+
AutoImport({
|
|
22
|
+
resolvers: [ElementPlusResolver()],
|
|
23
|
+
}),
|
|
24
|
+
Components({
|
|
25
|
+
resolvers: [ElementPlusResolver()],
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
module.exports = {
|
|
30
|
+
// lintOnSave: 'warning',
|
|
31
|
+
productionSourceMap:!(!argv.mode && isProduction),
|
|
32
|
+
lintOnSave: !isProduction,
|
|
33
|
+
//里面是真正的webpack配置
|
|
34
|
+
configureWebpack: {
|
|
35
|
+
resolveLoader: {
|
|
36
|
+
mainFields: ['main'],
|
|
37
|
+
modules: [path.resolve(__dirname, "loaders")]
|
|
38
|
+
},
|
|
39
|
+
module: {
|
|
40
|
+
rules: [
|
|
41
|
+
/*{
|
|
42
|
+
test: /py-bg\.png$/,
|
|
43
|
+
type:'asset',
|
|
44
|
+
parser:{
|
|
45
|
+
dataUrlCondition:{
|
|
46
|
+
//小于这个数会被转成base64
|
|
47
|
+
maxSize: 2*1024
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}*/
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
plugins: [
|
|
54
|
+
new webpack.DefinePlugin({
|
|
55
|
+
isDev: true
|
|
56
|
+
}),
|
|
57
|
+
...elementUiPlugins
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
chainWebpack: (config) => {
|
|
61
|
+
config.externals({jquery: 'jQuery'});
|
|
62
|
+
if (argv.design) {
|
|
63
|
+
config.entry('app').clear().add('./design/main.js')
|
|
64
|
+
config.devServer.set('port', '8088');
|
|
65
|
+
}
|
|
66
|
+
config.resolve.alias
|
|
67
|
+
.set('@src', path.resolve('./src'))
|
|
68
|
+
|
|
69
|
+
/*config.module
|
|
70
|
+
.rule('images')
|
|
71
|
+
// .rule('min-image')
|
|
72
|
+
.use('image-webpack-loader')
|
|
73
|
+
.loader('image-webpack-loader')
|
|
74
|
+
.options({
|
|
75
|
+
disable:true,
|
|
76
|
+
mozjpeg: {
|
|
77
|
+
progressive: true,
|
|
78
|
+
quality: 50
|
|
79
|
+
},
|
|
80
|
+
optipng: {
|
|
81
|
+
enabled: true
|
|
82
|
+
},
|
|
83
|
+
pngquant: {
|
|
84
|
+
quality: [0.5, 0.65],
|
|
85
|
+
speed: 4
|
|
86
|
+
},
|
|
87
|
+
gifsicle: {
|
|
88
|
+
interlaced: false
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
.end()*/
|
|
92
|
+
},
|
|
93
|
+
publicPath: process.env.BASE_URL ? process.env.BASE_URL : '/',
|
|
94
|
+
assetsDir: 'static',
|
|
95
|
+
devServer:{
|
|
96
|
+
proxy:{
|
|
97
|
+
'/education':{
|
|
98
|
+
target:'https://pre-api.thedeer.cn/'
|
|
99
|
+
// target:'http://193.168.251.23:22397/'
|
|
100
|
+
},
|
|
101
|
+
'/event':{
|
|
102
|
+
// target:'https://pre-api.thedeer.cn/'
|
|
103
|
+
target:'http://193.168.251.189:22397/'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|