界面语言切换功能,修复nav异常

This commit is contained in:
masnn committed 2020-06-10 23:20:36 +08:00
1 parent 7e7dee4074
commit 0923d6e72b
16 files changed
+53 -36

No files matched your search

+2 -2
View File
@@ -21,9 +21,9 @@ class DomainRankHandler extends Handler {
udocs = await Promise.all(udocs);
const path = [
['Hydro', '/'],
['domain_rank', null],
['ranking', null],
];
this.response.template = 'domain_rank.html';
this.response.template = 'ranking.html';
this.response.body = {
udocs, upcount, ucount, page, path,
};
+3 -2
View File
@@ -56,9 +56,10 @@ class SystemScriptHandler extends SystemHandler {
this.response.body.path.push(['manage_script', null]);
}
async post({ id, args }) {
async post({ id, args = '{}' }) {
args = JSON.parse(args);
// TODO Do not use console.log
await global.Hydro.script[id].run(JSON.parse(args), console.log);
await global.Hydro.script[id].run(args, console.log);
this.back();
}
}
+5 -2
View File
@@ -1,6 +1,7 @@
const { PERM_JUDGE } = require('../permission');
const { PERM_JUDGE, PERM_LOGGEDIN } = require('../permission');
const file = require('../model/file');
const user = require('../model/user');
const db = require('../service/db');
const { Route, Handler } = require('../service/server');
@@ -47,7 +48,9 @@ class StatusUpdateHandler extends Handler {
class SwitchLanguageHandler extends Handler {
async get({ lang }) {
this.session.language = lang;
if (this.user.hasPerm(PERM_LOGGEDIN)) await user.setById(this.user._id, { viewLang: lang });
else this.session.viewLang = lang;
this.back();
}
}
+3 -8
View File
@@ -138,8 +138,7 @@ class UserLostPassWithCodeHandler extends Handler {
class UserDetailHandler extends Handler {
async get({ domainId, uid }) {
const isSelfProfile = this.user._id === uid;
const udoc = await user.getById(domainId, uid);
if (!udoc) throw new UserNotFoundError(uid);
const udoc = await user.getById(domainId, uid, true);
const sdoc = await token.getMostRecentSessionByUid(uid);
this.response.template = 'user_detail.html';
this.response.body = { isSelfProfile, udoc, sdoc };
@@ -151,12 +150,8 @@ class UserSearchHandler extends Handler {
let udocs;
if (exactMatch) udocs = [];
else udocs = await user.getPrefixList(q, 20);
try {
const udoc = await user.getById(domainId, parseInt(q));
if (udoc) udocs.push(udoc);
} catch (e) {
/* Ignore */
}
const udoc = await user.getById(domainId, parseInt(q));
if (udoc) udocs.push(udoc);
for (const i in udocs) {
if (udocs[i].gravatar) {
udocs[i].gravatar_url = misc.gravatar(udocs[i].gravatar);