Skip to content

Commit 1b5612a

Browse files
authored
Merge pull request #87 from segment-oj/change-api-url-ztl
change in api
2 parents d92de37 + 9d1a559 commit 1b5612a

File tree

3 files changed

+78
-13
lines changed

3 files changed

+78
-13
lines changed

src/components/problem/list.vue

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,44 @@ export default {
111111
this.$store.commit('setDisplayTag', {
112112
val: val
113113
});
114+
},
115+
limit(val) {
116+
this.set_column(val);
114117
}
115118
},
116119
methods: {
120+
get_list_lenth() {
121+
this.$axios
122+
.get(apiurl('/problem/list/count'))
123+
.then(response => {
124+
let data = response.data;
125+
this.data_count = data.res;
126+
})
127+
.catch(err => {
128+
this.$SegmentMessage.error(this, '[Problem List] Get List Length Failed');
129+
console.log(err);
130+
});
131+
},
132+
get_column() {
133+
if (this.$store.state.user.userid === null) {
134+
return;
135+
}
136+
this.$axios
137+
.get(apiurl('/account/' + this.$store.state.user.userid))
138+
.then(res => {
139+
let data = res.data.res;
140+
this.limit = data.list_column;
141+
});
142+
},
143+
set_column(x) {
144+
if (this.$store.state.user.userid === null) {
145+
return;
146+
}
147+
this.$axios
148+
.patch(apiurl('/account/' + this.$store.state.user.userid), {
149+
list_column: x
150+
});
151+
},
117152
process(x) {
118153
let color = '';
119154
if (x.score === 100) {
@@ -149,16 +184,8 @@ export default {
149184
JumpToProblem
150185
},
151186
mounted() {
152-
this.$axios
153-
.get(apiurl('/problem/list/count'))
154-
.then(response => {
155-
let data = response.data;
156-
this.data_count = data.res;
157-
})
158-
.catch(err => {
159-
this.$SegmentMessage.error(this, '[Problem List] Get List Length Failed');
160-
console.log(err);
161-
});
187+
this.get_list_lenth();
188+
this.get_column();
162189
}
163190
};
164191
</script>

src/components/user/content.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ export default {
172172
this.username = data.username;
173173
this.userid = data.id;
174174
this.email = data.email;
175-
this.introduction = data.introduction;
176175
this.solved = data.solved;
177176
this.submit = data.submit_time;
178177
this.timeJoin = timeFormat(data.date_joined);
@@ -194,6 +193,18 @@ export default {
194193
if (this.$store.state.user.isStaff || this.userid == String(this.$store.state.user.userid)) {
195194
this.ismine = true;
196195
}
196+
this.$axios
197+
.get(apiurl('/account/' + this.$route.params.id + '/introduction'))
198+
.then(detail => {
199+
this.introduction = detail.data.res.introduction;
200+
})
201+
.catch(err => {
202+
if(err.request.status === 404) {
203+
this.$SegmentMessage.error(this, 'User does not exist');
204+
} else {
205+
this.$SegmentMessage.error(this, 'Unkown error');
206+
}
207+
});
197208
this.userLoading = false;
198209
})
199210
.catch(err => {

src/components/user/edit.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export default {
123123
if (this.isMine || this.isRootMe || this.isStaffMe) {
124124
this.username = data.username;
125125
this.email = data.email;
126-
this.introduction = data.introduction;
127126
this.isStaff = data.is_staff;
128127
this.isRoot = data.is_superuser;
129128
this.isActive = data.is_active;
@@ -139,13 +138,26 @@ export default {
139138
this.$SegmentMessage.error(this, 'Unkown error');
140139
}
141140
});
141+
this.$axios
142+
.get(apiurl('/account/' + this.$route.params.id + '/introduction'))
143+
.then(res => {
144+
let data = res.data.res;
145+
this.introduction = data.introduction;
146+
})
147+
.catch(err => {
148+
if(err.request.status === 404) {
149+
this.$SegmentMessage.error(this, 'User does not exist');
150+
} else {
151+
this.$SegmentMessage.error(this, 'Unkown error');
152+
}
153+
this.userLoading = false;
154+
});
142155
},
143156
submit() {
144157
this.buttonLoading = true;
145158
this.$axios
146159
.patch(apiurl('/account/' + this.$route.params.id), {
147160
username: this.username,
148-
introduction: this.introduction,
149161
is_staff: this.isStaff,
150162
is_superuser: this.isRoot,
151163
is_active: this.isActive,
@@ -163,6 +175,21 @@ export default {
163175
lang: this.lang
164176
});
165177
}
178+
this.$axios
179+
.patch(apiurl('/account/' + this.$route.params.id + '/introduction'), {
180+
introduction: this.introduction,
181+
})
182+
.then(() => {
183+
this.buttonLoading = false;
184+
})
185+
.catch(err => {
186+
if(err.request.status === 404) {
187+
this.$SegmentMessage.error(this, 'User does not exist');
188+
} else {
189+
this.$SegmentMessage.error(this, 'Unkown error');
190+
}
191+
this.userLoading = false;
192+
});
166193
})
167194
.catch(err => {
168195
this.buttonLoading = false;

0 commit comments

Comments
 (0)