6565 <el-divider class =" divider" >Memery</el-divider >
6666 <div class =" tool-content" >{{memery}} MB</div >
6767 </el-card >
68+ <el-card shadow =" never" class =" margin-top" >
69+ <div class =" margin-bottom" >
70+ <i class =" el-icon-collection-tag" />
71+ Tags
72+ <div v-if =" showTag" @click =" showTag = false" id =" tag-button" ><i class =" el-icon-arrow-up" />Hide tags</div >
73+ <div v-if =" !showTag" @click =" showTag = true" id =" tag-button" ><i class =" el-icon-arrow-down" />Show tags</div >
74+ </div >
75+ <div class =" tags" v-if =" showTag" >
76+ <SegmentTag
77+ v-for =" item in rendertags"
78+ :key =" item.content"
79+ :border_color =" item.color"
80+ :content =" item.content"
81+ >
82+ </SegmentTag >
83+ </div >
84+ </el-card >
6885 </div >
6986 </div >
7087 </div >
7592import timeFormat from ' ./../../methods/time' ;
7693import apiurl from ' ./../../apiurl' ;
7794import MarkdownContainer from ' ./../lib/MarkdownContainer.vue' ;
95+ import SegmentTag from ' ./../lib/tag.vue' ;
7896
7997export default {
8098 name: ' ProblemView' ,
@@ -90,10 +108,29 @@ export default {
90108 time: ' -' ,
91109 memery: ' -' ,
92110 timeAdd: ' Unknown' ,
93- problemLoading: true
111+ tags: [],
112+ rendertags: [],
113+ problemLoading: true ,
114+ showTag: false
94115 };
95116 },
96117 methods: {
118+ render_tags () {
119+ for (let i = 0 ; i < this .tags .length ; i += 1 ) {
120+ this .$axios
121+ .get (apiurl (' /problem/tag/' + this .tags [i]))
122+ .then (res => {
123+ let data = res .data ;
124+ this .rendertags .push ({
125+ color: data .res .color ,
126+ content: data .res .content
127+ });
128+ })
129+ .catch (() => {
130+
131+ });
132+ }
133+ },
97134 loadproblem () {
98135 this .$axios
99136 .get (apiurl (' /problem/' + String (this .$route .params .id )))
@@ -107,7 +144,9 @@ export default {
107144 this .time = data .time_limit ;
108145 this .hidden = ! data .enabled ;
109146 this .timeAdd = timeFormat (data .date_added );
147+ this .tags = data .tags ;
110148 this .problemLoading = false ;
149+ this .render_tags ();
111150 })
112151 .catch (err => {
113152 if (err .request .status === 404 ) {
@@ -127,7 +166,8 @@ export default {
127166 this .loadproblem ();
128167 },
129168 components: {
130- MarkdownContainer
169+ MarkdownContainer,
170+ SegmentTag
131171 }
132172};
133173 </script >
@@ -146,6 +186,10 @@ export default {
146186 margin-top : 20px ;
147187}
148188
189+ .margin-bottom {
190+ margin-bottom : 15px ;
191+ }
192+
149193@media only screen and (max-width : 700px ) {
150194 #pannel {
151195 z-index : 1000 ;
@@ -193,11 +237,13 @@ export default {
193237 border : 1px solid #e4e7ed ;
194238}
195239
196- #full-screen-button {
240+ #full-screen-button ,
241+ #tag-button {
197242 float : right ;
198243}
199244
200- #full-screen-button :hover {
245+ #full-screen-button :hover ,
246+ #tag-button :hover {
201247 cursor : pointer ;
202248}
203249
0 commit comments