mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
界面语言切换功能,修复nav异常
This commit is contained in:
1 parent
7e7dee4074
commit
0923d6e72b
16 files changed
+53
-36
No files matched your search
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user