File tree Expand file tree Collapse file tree
oj/views/problem/problemSolving Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<template >
2- <codemirror
3- v-model =" currentValue"
4- :options =" options"
5- ref =" editor"
6- ></codemirror >
2+ <div class =" admin-code-mirror" >
3+ <codemirror
4+ v-model =" currentValue"
5+ :options =" options"
6+ ref =" editor"
7+ ></codemirror >
8+ </div >
79</template >
810<script >
911// import { codemirror } from 'vue-codemirror-lite'
@@ -65,8 +67,8 @@ export default {
6567}
6668 </script >
6769
68- <style >
69- .CodeMirror {
70+ <style scoped >
71+ .admin-code-mirror /deep/ . CodeMirror {
7072 height : auto !important ;
7173 font-family : " Courier New" , Courier , monospace !important ;
7274 font-size : 14px ;
@@ -75,30 +77,30 @@ export default {
7577 color : #334155 !important ;
7678}
7779
78- .CodeMirror-scroll {
80+ .admin-code-mirror /deep/ . CodeMirror-scroll {
7981 height : 300px ;
8082 overflow-y : auto !important ;
8183}
8284
83- .CodeMirror-lines {
85+ .admin-code-mirror /deep/ . CodeMirror-lines {
8486 padding : 8px 0 !important ;
8587}
8688
87- .CodeMirror-gutters {
89+ .admin-code-mirror /deep/ . CodeMirror-gutters {
8890 background-color : #f8fafc !important ;
8991 border-right : 1px solid #e2e8f0 !important ;
9092 padding-right : 5px ;
9193}
9294
93- .CodeMirror-linenumber {
95+ .admin-code-mirror /deep/ . CodeMirror-linenumber {
9496 color : #94a3b8 !important ;
9597}
9698
97- .CodeMirror-activeline-background {
99+ .admin-code-mirror /deep/ . CodeMirror-activeline-background {
98100 background : #f1f5f9 !important ;
99101}
100102
101- .CodeMirror-selected {
103+ .admin-code-mirror /deep/ . CodeMirror-selected {
102104 background : #cbd5e1 !important ;
103105}
104106 </style >
Original file line number Diff line number Diff line change @@ -747,6 +747,7 @@ export default {
747747 data .spj_code = " "
748748 }
749749 data .spj_language = data .spj_language || " C"
750+ this .template = {}
750751 this .problem = data
751752 this .testCaseUploaded = true
752753 })
@@ -778,7 +779,7 @@ export default {
778779 if (this .template [langName] === undefined ) {
779780 if (this .problem .template [langName] === undefined ) {
780781 data[langName] = {
781- checked: isSelected ,
782+ checked: false ,
782783 code: langConfig .config .template ,
783784 mode: langConfig .content_type ,
784785 }
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ export default {
136136 submitting: false ,
137137 code: " " ,
138138 language: " C++" ,
139+ codePerLanguage: {},
139140 languages: {
140141 type: Array ,
141142 default : () => {
@@ -276,11 +277,22 @@ export default {
276277 event .returnValue = " "
277278 },
278279 changeLanguage (newLang ) {
279- if (this .problem .template [newLang]) {
280- if (this .code .trim () === " " ) {
281- this .code = this .problem .template [newLang]
282- }
280+ // 현재 작성 중인 코드 저장
281+ this .codePerLanguage [this .language ] = this .code
282+
283+ // 변경 언어로 작성된 코드가 존재 하는 경우
284+ if (this .codePerLanguage [newLang] !== undefined ) {
285+ this .code = this .codePerLanguage [newLang]
286+ }
287+ // 변경 언어로 작성된 코드가 존재하지 않음 + 변경언어 template 존재하는 경우
288+ else if (this .problem .template && this .problem .template [newLang]) {
289+ this .code = this .problem .template [newLang]
283290 }
291+ // 변경 언어로 작성된 코드가 존재하지 않음 + 변경언어 template 존재하지 않는 경우
292+ else {
293+ this .code = " "
294+ }
295+
284296 this .language = newLang
285297 this .$refs .myCm .onLangChange (newLang)
286298 },
Original file line number Diff line number Diff line change 77 <div
88 style =" display : flex ; justify-content : space-between ; align-items : center "
99 >
10- <Tooltip :content =" ' 언어 선택' " placement="bottom ">
10+ <Tooltip :content =" ' 언어 선택' " placement="top ">
1111 <Dropdown @on-click =" changeLanguage " trigger="click" class="dropdown">
1212 <span
1313 style =" font-size : 13px ; padding-right : 3px ; font-weight : 450 "
You can’t perform that action at this time.
0 commit comments