core: fix import-syzoj (#61)

Co-authored-by: Macesuted <macesuted@qq.com>
pull/64/head
Macesuted 4 years ago committed by GitHub
parent 193b0dfa9d
commit 9cfdbe3aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -132,11 +132,14 @@ class ProblemImportSYZOJHandler extends Handler {
protocol: string, host: string, pid: string | number,
wait = false,
) {
let tagsOfLocale = this.user.viewLang || this.session.viewLang;
if (tagsOfLocale === 'en') tagsOfLocale = 'en_US';
else tagsOfLocale = 'zh_CN';
const result = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/getProblem`)
.send({
displayId: +pid,
localizedContentsOfAllLocales: true,
tagsOfLocale: this.user.viewLang || this.session.viewLang,
tagsOfLocale,
samples: true,
testData: true,
additionalFiles: true,
@ -154,7 +157,10 @@ class ProblemImportSYZOJHandler extends Handler {
delete section.sampleId;
}
}
content[c.locale] = sections;
let locale = c.locale;
if (locale === 'en_US') locale = 'en';
else if (locale === 'zh_CN') locale = 'zh';
content[locale] = sections;
}
const tags = result.body.tagsOfLocale.map((node) => node.name);
const title = [

Loading…
Cancel
Save