core: 自动语言识别

pull/211/head
undefined 3 years ago
parent 538be77e50
commit 761a885560

@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.36.4", "version": "2.36.5",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",

@ -527,6 +527,9 @@ export class Handler extends HandlerCommon {
this.session.scope = PERM.PERM_ALL.toString(); this.session.scope = PERM.PERM_ALL.toString();
this.user = await user.getById(domainId, this.session.uid, this.session.scope); this.user = await user.getById(domainId, this.session.uid, this.session.scope);
} }
if (!this.session._id && this.request.headers['accept-language'] && !this.request.headers['accept-language'].startsWith('zh')) {
this.session.viewLang = 'en';
}
if (this.user._id === 0 && this.session.viewLang) this.user.viewLang = this.session.viewLang; if (this.user._id === 0 && this.session.viewLang) this.user.viewLang = this.session.viewLang;
this.user.avatarUrl = avatar(this.user.avatar, 128); this.user.avatarUrl = avatar(this.user.avatar, 128);
this.csrfToken = this.getCsrfToken(this.session._id || String.random(32)); this.csrfToken = this.getCsrfToken(this.session._id || String.random(32));

Loading…
Cancel
Save