mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
8 files changed
+38
-30
No files matched your search
@@ -119,6 +119,8 @@ export async function apply(ctx: Context) {
|
||||
server.addLayer('base', baseLayer);
|
||||
server.addLayer('user', userLayer);
|
||||
|
||||
let cachedTranslate = null;
|
||||
|
||||
server.handlerMixin({
|
||||
url(name: string, ...kwargsList: Record<string, any>[]) {
|
||||
if (name === '#') return '#';
|
||||
@@ -159,10 +161,11 @@ export async function apply(ctx: Context) {
|
||||
translate(str: string) {
|
||||
if (!str) return '';
|
||||
const lang = this.user?.viewLang || this.session?.viewLang;
|
||||
const res = lang
|
||||
? ctx.i18n.translate(str.toString(), [lang, ...this.context.acceptsLanguages()])
|
||||
: ctx.i18n.translate(str.toString(), [...this.context.acceptsLanguages(), system.get('server.language')]);
|
||||
return res;
|
||||
const langs = lang
|
||||
? [lang, ...this.context.acceptsLanguages()]
|
||||
: [...this.context.acceptsLanguages(), system.get('server.language')];
|
||||
cachedTranslate ||= ctx.i18n.translate;
|
||||
return cachedTranslate(str.toString(), langs);
|
||||
},
|
||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string | number) {
|
||||
return db.paginate(cursor, page, typeof key === 'number' ? key : (this.ctx.setting.get(`pagination.${key}`) || 20));
|
||||
|
||||
@@ -710,7 +710,7 @@ export const coreScripts: MigrationScript[] = [
|
||||
{ $or: [{ _join: { $exists: false } }, { _join: { $eq: null } }, { '_join.method': domain.JOIN_METHOD_NONE }] },
|
||||
{ $set: { _join: { method: domain.JOIN_METHOD_ALL, role: 'default', expire: null }, _migratedJoin: true } },
|
||||
);
|
||||
const domainUser = await domain.coll.find({ domainId: 'system', join: true }, onPrimary)
|
||||
const domainUser = await domain.collUser.find({ domainId: 'system', join: true }, onPrimary)
|
||||
.project({ uid: 1 }).toArray();
|
||||
const otherUsers = await user.coll.find({ _id: { $gt: 1, $nin: domainUser.map((u) => u.uid) } }, onPrimary)
|
||||
.project({ _id: 1 }).toArray();
|
||||
|
||||
Reference in new issue
Block a user