mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-12 09:32:49 +00:00
fix
This commit is contained in:
parent
17cad1b1ca
commit
338c43eea7
@ -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:', '') ||
|
||||||
|
''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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,17 +478,16 @@ export class BaseTranslateService {
|
|||||||
this.createLockFile('msg');
|
this.createLockFile('msg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成通用消息
|
* 生成通用消息
|
||||||
*/
|
*/
|
||||||
async genCommMsg(){
|
async genCommMsg() {
|
||||||
const file = path.join(this.basePath, 'comm', 'zh-cn.json');
|
const file = path.join(this.basePath, 'comm', 'zh-cn.json');
|
||||||
const scanPath = path.join(this.app.getBaseDir(), '..', 'src', 'modules');
|
const scanPath = path.join(this.app.getBaseDir(), '..', 'src', 'modules');
|
||||||
const messages = {};
|
const messages = {};
|
||||||
|
|
||||||
// 递归扫描目录
|
// 递归扫描目录
|
||||||
const scanDir = (dir: string) => {
|
const scanDir = (dir: string) => {
|
||||||
const files = fs.readdirSync(dir);
|
const files = fs.readdirSync(dir);
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const fullPath = path.join(dir, file);
|
const fullPath = path.join(dir, file);
|
||||||
@ -536,7 +540,7 @@ export class BaseTranslateService {
|
|||||||
await Promise.all(translatePromises);
|
await Promise.all(translatePromises);
|
||||||
this.createLockFile('comm');
|
this.createLockFile('comm');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用消息翻译
|
* 通用消息翻译
|
||||||
* @param text 文本
|
* @param text 文本
|
||||||
|
|||||||
@ -5,14 +5,16 @@ import { DemoI18nService } from '../../service/i18n';
|
|||||||
* 国际化
|
* 国际化
|
||||||
*/
|
*/
|
||||||
@CoolController({
|
@CoolController({
|
||||||
serviceApis: [{
|
serviceApis: [
|
||||||
method: 'en',
|
{
|
||||||
summary: '翻译成英文',
|
method: 'en',
|
||||||
},
|
summary: '翻译成英文',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
method: 'tw',
|
method: 'tw',
|
||||||
summary: '翻译成繁体',
|
summary: '翻译成繁体',
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
service: DemoI18nService,
|
service: DemoI18nService,
|
||||||
})
|
})
|
||||||
export class DemoI18nController extends BaseController {}
|
export class DemoI18nController extends BaseController {}
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user