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
@@ -26,7 +26,6 @@ export default class ElasticSearchService extends Service {
|
||||
client: Client;
|
||||
|
||||
constructor(ctx: Context, private config: ReturnType<typeof ElasticSearchService.Config>) {
|
||||
console.log('elastic-search', config);
|
||||
super(ctx, 'elastic-search');
|
||||
this.client = new Client({ node: config.url });
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"jquery.easing": "^1.4.1",
|
||||
"jquery.transit": "^0.9.12",
|
||||
"matchmedia-polyfill": "^0.3.2",
|
||||
"md-editor-rt": "^5.4.3",
|
||||
"md-editor-rt": "^5.4.4",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
"moment": "^2.30.1",
|
||||
"monaco-editor": "0.52.2",
|
||||
|
||||
Reference in new issue
Block a user