|
9 | 9 | <el-icon><EditPen /></el-icon> |
10 | 10 | {{ item.content }} |
11 | 11 | </div> |
| 12 | + <div v-else-if="item.type === 'html_rander'" :innerHTML="item.content"></div> |
12 | 13 | <MdPreview |
13 | 14 | v-else |
14 | 15 | noIconfont |
@@ -60,7 +61,7 @@ const md_view_list = computed(() => { |
60 | 61 | return md_img_list[Math.floor(index / 2)] |
61 | 62 | } |
62 | 63 | }) |
63 | | - return split_quick_question(result) |
| 64 | + return split_html_rander(split_quick_question(result)) |
64 | 65 | }) |
65 | 66 | const split_quick_question = (result: Array<string>) => { |
66 | 67 | return result |
@@ -95,6 +96,40 @@ const split_quick_question_ = (source: string) => { |
95 | 96 | }) |
96 | 97 | return result |
97 | 98 | } |
| 99 | +const split_html_rander = (result: Array<any>) => { |
| 100 | + return result |
| 101 | + .map((item) => split_html_rander_(item.content, item.type)) |
| 102 | + .reduce((x: any, y: any) => { |
| 103 | + return [...x, ...y] |
| 104 | + }, []) |
| 105 | +} |
| 106 | +
|
| 107 | +const split_html_rander_ = (source: string, type: string) => { |
| 108 | + const temp_md_quick_question_list = source.match(/<html_rander>[\d\D]*?<\/html_rander>/g) |
| 109 | + const md_quick_question_list = temp_md_quick_question_list |
| 110 | + ? temp_md_quick_question_list.filter((i) => i) |
| 111 | + : [] |
| 112 | + const split_quick_question_value = source |
| 113 | + .split(/<html_rander>[\d\D]*?<\/html_rander>/g) |
| 114 | + .filter((item) => item !== undefined) |
| 115 | + .filter((item) => !md_quick_question_list?.includes(item)) |
| 116 | + const result = Array.from( |
| 117 | + { length: md_quick_question_list.length + split_quick_question_value.length }, |
| 118 | + (v, i) => i |
| 119 | + ).map((index) => { |
| 120 | + if (index % 2 == 0) { |
| 121 | + return { type: type, content: split_quick_question_value[Math.floor(index / 2)] } |
| 122 | + } else { |
| 123 | + return { |
| 124 | + type: 'html_rander', |
| 125 | + content: md_quick_question_list[Math.floor(index / 2)] |
| 126 | + .replace('<html_rander>', '') |
| 127 | + .replace('</html_rander>', '') |
| 128 | + } |
| 129 | + } |
| 130 | + }) |
| 131 | + return result |
| 132 | +} |
98 | 133 | </script> |
99 | 134 | <style lang="scss" scoped> |
100 | 135 | .problem-button { |
|
0 commit comments