fix: geoip模块dts异常及prepublish.sh不调用的问题

This commit is contained in:
undefined committed 2020-09-05 21:13:29 +08:00
1 parent a1aeb521fe
commit 02c1866963
5 files changed
+10 -7

No files matched your search

+3 -2
View File
@@ -1,4 +1,5 @@
import 'hydrooj';
import 'hydrooj/src/lib/i18n';
import fs from 'fs';
import path from 'path';
import { Reader } from 'maxmind';
@@ -14,9 +15,9 @@ export interface Result {
display: string
}
export function lookup(ip: string, locale: string) {
export function lookup(ip: string, locale: string): Result {
const res: any = reader.get(ip);
if (!res) return {};
if (!res) return { display: 'Unknown address'.translate(locale) };
const ret: Result = { display: '' };
if (res.location) ret.location = res.location;
if (res.continent) ret.continent = res.continent.names[locale] || res.continent.names.en;