Skip to content

Commit 8038095

Browse files
authored
Merge pull request #81 from segment-oj/fix-bugs
Fix bugs
2 parents cd3af58 + 527184d commit 8038095

File tree

8 files changed

+47
-29
lines changed

8 files changed

+47
-29
lines changed

src/assets/code_mirror/tomorrow.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
}
5656

5757
.CodeMirror-gutters {
58-
background: #f9f9f9;
58+
background: #fcfcfc;
5959
border-right: none;
6060
}
6161

src/components/lib/tag.vue renamed to src/components/lib/problemTag.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<span class="segment-tag" :style="style">
2+
<span class="tag" :style="style">
33
<i :v-if="icon" :class="'el-icon-' + icon_detail"></i>{{content}}
44
</span>
55
</template>
66

77
<script>
88
export default {
9-
name: 'SegmentTag',
9+
name: 'ProblemTag',
1010
props: {
1111
content: {
1212
type: String,
@@ -55,7 +55,7 @@ export default {
5555
</script>
5656

5757
<style scoped>
58-
.segment-tag {
58+
.tag {
5959
display: inline-block;
6060
padding: 0 10px;
6161
font-size: 12px;

src/components/problem/content.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,14 @@
7878
</div>
7979
</div>
8080
<div class="tags" v-if="showTag">
81-
<SegmentTag
81+
<ProblemTag
8282
v-for="item in rendertags"
8383
:key="item.content"
8484
color="#fff"
8585
:border_color="item.color"
8686
:background_color="item.color"
8787
:content="item.content"
88-
>
89-
</SegmentTag>
88+
/>
9089
</div>
9190
</el-card>
9291
</div>
@@ -100,7 +99,7 @@
10099
import timeFormat from './../../methods/time';
101100
import apiurl from './../../apiurl';
102101
import MarkdownContainer from './../lib/MarkdownContainer.vue';
103-
import SegmentTag from './../lib/tag.vue';
102+
import ProblemTag from './../lib/problemTag.vue';
104103
105104
export default {
106105
name: 'ProblemView',
@@ -174,7 +173,7 @@ export default {
174173
},
175174
components: {
176175
MarkdownContainer,
177-
SegmentTag
176+
ProblemTag
178177
}
179178
};
180179
</script>

src/components/problem/edit.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</el-row>
3232
</el-card>
3333
<el-card class="item">
34-
<el-button type="primary" @click="submit" :loading="buttonLoading">Submit</el-button>
34+
<el-button type="primary" @click="submit">Submit</el-button>
3535
<el-button @click="back();">Back</el-button>
3636
<ConfirmDelete
3737
buttonName="Delete"
@@ -93,7 +93,10 @@
9393
</el-row>
9494
</el-card>
9595
<el-card v-loading="contentLoading" class="item">
96-
<div slot="header" class="clearfix"><i class="el-icon-document" /> Content</div>
96+
<div slot="header" class="clearfix">
97+
<i class="el-icon-document" />
98+
Content
99+
</div>
97100
<MarkdownEditor v-model="mdContent" />
98101
</el-card>
99102
</div>
@@ -111,7 +114,6 @@ export default {
111114
title: '',
112115
mdContent: 'Loading...',
113116
contentLoading: true,
114-
buttonLoading: false,
115117
time: 'Unknown',
116118
memery: 'Unknown',
117119
disable: false,
@@ -137,15 +139,19 @@ export default {
137139
this.contentLoading = false;
138140
})
139141
.catch(err => {
140-
this.$SegmentMessage.error(this, 'Problem loading error');
141-
console.log(err);
142+
if (err.request.status === 404) {
143+
this.$SegmentMessage.error(this, 'Problem not found');
144+
} else if (err.request.status === 403) {
145+
this.$SegmentMessage.error(this, 'Permission denied');
146+
} else {
147+
this.$SegmentMessage.error(this, 'Unkown error');
148+
}
142149
});
143150
},
144151
back() {
145152
this.$router.push('/problem/' + this.$route.params.id);
146153
},
147154
submit() {
148-
this.buttonLoading = true;
149155
this.$axios
150156
.patch(apiurl('/problem/' + this.$route.params.id), {
151157
title: this.title,
@@ -156,7 +162,6 @@ export default {
156162
enabled: !this.disable
157163
})
158164
.then(() => {
159-
this.buttonLoading = false;
160165
this.$SegmentMessage.success(this, 'Your changes have been submitted');
161166
})
162167
.catch(err => {
@@ -167,7 +172,6 @@ export default {
167172
} else {
168173
this.$SegmentMessage.error(this, 'Unkown error');
169174
}
170-
this.buttonLoading = false;
171175
});
172176
},
173177
delete() {

src/components/problem/list.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
v-model="limit"
2121
:step="10"
2222
:min="10"
23-
@change="refresh"
2423
style="margin-top: 10px;"
2524
/>
2625
</el-col>
@@ -119,12 +118,6 @@ export default {
119118
x.tag = (<listTag tags={ x.tags }></listTag>);
120119
121120
return x;
122-
},
123-
refresh() {
124-
// this.alive = false;
125-
// this.$nextTick(() => {
126-
// this.alive = true;
127-
// });
128121
}
129122
},
130123
components: {

src/components/problem/listTag.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div>
33
<div v-if="$store.state.tags.displayTags">
4-
<SegmentTag
4+
<ProblemTag
55
v-for="item in this.rendertags"
66
:key="item.content"
77
color="#fff"
8-
height="22"
8+
:height="22"
99
:border_color="item.color"
1010
:background_color="item.color"
1111
:content="item.content"
@@ -15,7 +15,7 @@
1515
</template>
1616

1717
<script>
18-
import SegmentTag from './../lib/tag.vue';
18+
import ProblemTag from './../lib/problemTag.vue';
1919
import apiurl from './../../apiurl';
2020
import AWaitLock from './../../methods/lock';
2121
@@ -74,7 +74,7 @@ export default {
7474
this.loadTag();
7575
},
7676
components: {
77-
SegmentTag,
77+
ProblemTag
7878
},
7979
};
8080
</script>

src/components/user/content.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ export default {
176176
this.solved = data.solved;
177177
this.submit = data.submit_time;
178178
this.timeJoin = timeFormat(data.date_joined);
179-
this.lastLogin = timeFormat(data.last_login);
179+
if (data.last_login == null) {
180+
this.lastLogin = 'Never';
181+
} else {
182+
this.lastLogin = timeFormat(data.last_login);
183+
}
180184
this.isRoot = data.is_superuser;
181185
this.isStaff = data.is_staff;
182186
this.isActive = data.is_active;

src/components/user/edit.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ export default {
129129
this.isActive = data.is_active;
130130
this.lang = String(data.lang);
131131
}
132+
})
133+
.catch(err => {
134+
if (err.request.status === 404) {
135+
this.$SegmentMessage.error(this, 'User not found');
136+
} else if (err.request.status === 403) {
137+
this.$SegmentMessage.error(this, 'Permission denied');
138+
} else {
139+
this.$SegmentMessage.error(this, 'Unkown error');
140+
}
132141
});
133142
},
134143
submit() {
@@ -154,6 +163,15 @@ export default {
154163
lang: this.lang
155164
});
156165
}
166+
})
167+
.catch(err => {
168+
if (err.request.status === 404) {
169+
this.$SegmentMessage.error(this, 'User not found');
170+
} else if (err.request.status === 403) {
171+
this.$SegmentMessage.error(this, 'Permission denied');
172+
} else {
173+
this.$SegmentMessage.error(this, 'Unkown error');
174+
}
157175
});
158176
}
159177
},

0 commit comments

Comments
 (0)