mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-10 16:12:50 +00:00
fix
This commit is contained in:
parent
17cad1b1ca
commit
338c43eea7
@ -34,7 +34,8 @@ export class Utils {
|
||||
const req = ctx.req;
|
||||
return (
|
||||
req.headers['x-forwarded-for'] ||
|
||||
req.socket.remoteAddress.replace('::ffff:', '')
|
||||
req.socket.remoteAddress?.replace('::ffff:', '') ||
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,12 @@ export class BaseTranslateService {
|
||||
const commLockExists = this.checkLockFile('comm');
|
||||
const dictLockExists = this.checkDictLockFile();
|
||||
|
||||
if (!menuLockExists || !msgLockExists || !dictLockExists || !commLockExists) {
|
||||
if (
|
||||
!menuLockExists ||
|
||||
!msgLockExists ||
|
||||
!dictLockExists ||
|
||||
!commLockExists
|
||||
) {
|
||||
const tasks = [];
|
||||
if (!msgLockExists) {
|
||||
tasks.push(this.genBaseMsg());
|
||||
@ -473,17 +478,16 @@ export class BaseTranslateService {
|
||||
this.createLockFile('msg');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成通用消息
|
||||
*/
|
||||
async genCommMsg(){
|
||||
async genCommMsg() {
|
||||
const file = path.join(this.basePath, 'comm', 'zh-cn.json');
|
||||
const scanPath = path.join(this.app.getBaseDir(), '..', 'src', 'modules');
|
||||
const messages = {};
|
||||
|
||||
// 递归扫描目录
|
||||
const scanDir = (dir: string) => {
|
||||
// 递归扫描目录
|
||||
const scanDir = (dir: string) => {
|
||||
const files = fs.readdirSync(dir);
|
||||
for (const file of files) {
|
||||
const fullPath = path.join(dir, file);
|
||||
@ -536,7 +540,7 @@ export class BaseTranslateService {
|
||||
await Promise.all(translatePromises);
|
||||
this.createLockFile('comm');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通用消息翻译
|
||||
* @param text 文本
|
||||
|
||||
@ -5,14 +5,16 @@ import { DemoI18nService } from '../../service/i18n';
|
||||
* 国际化
|
||||
*/
|
||||
@CoolController({
|
||||
serviceApis: [{
|
||||
method: 'en',
|
||||
summary: '翻译成英文',
|
||||
},
|
||||
serviceApis: [
|
||||
{
|
||||
method: 'en',
|
||||
summary: '翻译成英文',
|
||||
},
|
||||
{
|
||||
method: 'tw',
|
||||
summary: '翻译成繁体',
|
||||
}],
|
||||
},
|
||||
],
|
||||
service: DemoI18nService,
|
||||
})
|
||||
export class DemoI18nController extends BaseController {}
|
||||
|
||||
@ -7,7 +7,7 @@ import { CoolCache } from '@cool-midway/core';
|
||||
@Provide()
|
||||
export class DemoCacheService {
|
||||
// 数据缓存5秒
|
||||
@CoolCache(5)
|
||||
@CoolCache(5000)
|
||||
async get() {
|
||||
console.log('执行方法');
|
||||
return {
|
||||
|
||||
@ -15,7 +15,7 @@ export class DemoI18nService {
|
||||
async en() {
|
||||
const value = this.translate.comm('一个很Cool的框架')['en'];
|
||||
console.log(value);
|
||||
return value
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -24,6 +24,6 @@ export class DemoI18nService {
|
||||
async tw() {
|
||||
const value = this.translate.comm('一个很Cool的框架')['zh-tw'];
|
||||
console.log(value);
|
||||
return value
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,11 +185,10 @@ export class UserLoginService extends BaseService {
|
||||
if (wxInfo) {
|
||||
wxUserInfo.id = wxInfo.id;
|
||||
}
|
||||
await this.userWxEntity.save({
|
||||
return this.userWxEntity.save({
|
||||
...wxUserInfo,
|
||||
type,
|
||||
});
|
||||
return wxUserInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,6 +230,7 @@ export class UserLoginService extends BaseService {
|
||||
avatarUrl,
|
||||
gender: wxUserInfo.gender,
|
||||
tenantId: userInfo['tenantId'],
|
||||
loginType: wxUserInfo.type,
|
||||
};
|
||||
await this.userInfoEntity.insert(userInfo);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user