This commit is contained in:
COOL 2025-02-11 14:14:00 +08:00
parent 17cad1b1ca
commit 338c43eea7
6 changed files with 24 additions and 17 deletions

View File

@ -34,7 +34,8 @@ export class Utils {
const req = ctx.req; const req = ctx.req;
return ( return (
req.headers['x-forwarded-for'] || req.headers['x-forwarded-for'] ||
req.socket.remoteAddress.replace('::ffff:', '') req.socket.remoteAddress?.replace('::ffff:', '') ||
''
); );
} }

View File

@ -210,7 +210,12 @@ export class BaseTranslateService {
const commLockExists = this.checkLockFile('comm'); const commLockExists = this.checkLockFile('comm');
const dictLockExists = this.checkDictLockFile(); const dictLockExists = this.checkDictLockFile();
if (!menuLockExists || !msgLockExists || !dictLockExists || !commLockExists) { if (
!menuLockExists ||
!msgLockExists ||
!dictLockExists ||
!commLockExists
) {
const tasks = []; const tasks = [];
if (!msgLockExists) { if (!msgLockExists) {
tasks.push(this.genBaseMsg()); tasks.push(this.genBaseMsg());
@ -473,7 +478,6 @@ export class BaseTranslateService {
this.createLockFile('msg'); this.createLockFile('msg');
} }
/** /**
* *
*/ */

View File

@ -5,14 +5,16 @@ import { DemoI18nService } from '../../service/i18n';
* *
*/ */
@CoolController({ @CoolController({
serviceApis: [{ serviceApis: [
{
method: 'en', method: 'en',
summary: '翻译成英文', summary: '翻译成英文',
}, },
{ {
method: 'tw', method: 'tw',
summary: '翻译成繁体', summary: '翻译成繁体',
}], },
],
service: DemoI18nService, service: DemoI18nService,
}) })
export class DemoI18nController extends BaseController {} export class DemoI18nController extends BaseController {}

View File

@ -7,7 +7,7 @@ import { CoolCache } from '@cool-midway/core';
@Provide() @Provide()
export class DemoCacheService { export class DemoCacheService {
// 数据缓存5秒 // 数据缓存5秒
@CoolCache(5) @CoolCache(5000)
async get() { async get() {
console.log('执行方法'); console.log('执行方法');
return { return {

View File

@ -15,7 +15,7 @@ export class DemoI18nService {
async en() { async en() {
const value = this.translate.comm('一个很Cool的框架')['en']; const value = this.translate.comm('一个很Cool的框架')['en'];
console.log(value); console.log(value);
return value return value;
} }
/** /**
@ -24,6 +24,6 @@ export class DemoI18nService {
async tw() { async tw() {
const value = this.translate.comm('一个很Cool的框架')['zh-tw']; const value = this.translate.comm('一个很Cool的框架')['zh-tw'];
console.log(value); console.log(value);
return value return value;
} }
} }

View File

@ -185,11 +185,10 @@ export class UserLoginService extends BaseService {
if (wxInfo) { if (wxInfo) {
wxUserInfo.id = wxInfo.id; wxUserInfo.id = wxInfo.id;
} }
await this.userWxEntity.save({ return this.userWxEntity.save({
...wxUserInfo, ...wxUserInfo,
type, type,
}); });
return wxUserInfo;
} }
/** /**
@ -231,6 +230,7 @@ export class UserLoginService extends BaseService {
avatarUrl, avatarUrl,
gender: wxUserInfo.gender, gender: wxUserInfo.gender,
tenantId: userInfo['tenantId'], tenantId: userInfo['tenantId'],
loginType: wxUserInfo.type,
}; };
await this.userInfoEntity.insert(userInfo); await this.userInfoEntity.insert(userInfo);
} }