中英文切换
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
} from '../../api/device.ts';
|
||||
|
||||
import envConfig from '../../../env';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../../i18n';
|
||||
|
||||
export default class DeviceController {
|
||||
constructor(userInfo, messageApi) {
|
||||
@@ -175,7 +175,7 @@ export default class DeviceController {
|
||||
this.connectedDeviceSn = sn;
|
||||
|
||||
if (!this.hasControlRight) {
|
||||
this.messageApi.warning('其他端正在控制');
|
||||
this.messageApi.warning(i18n.t('devices.fixed2OthersControlFixed2'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ export default class DeviceController {
|
||||
await this.getControl(sn);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.messageApi.error('权限校验失败');
|
||||
this.messageApi.error(i18n.t('devices.failedFixed22'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ export default class DeviceController {
|
||||
requestControl() {
|
||||
if (this.isRequestControl) return;
|
||||
if (!this.hasControlRight) {
|
||||
this.messageApi.warning('无控制权限');
|
||||
this.messageApi.warning(i18n.t('devices.noneControl'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ export default class DeviceController {
|
||||
|
||||
this.messageApi.loading({
|
||||
key: 'control',
|
||||
content: '请求控制中...',
|
||||
content: i18n.t('devices.control2'),
|
||||
duration: 0,
|
||||
});
|
||||
|
||||
@@ -228,7 +228,7 @@ export default class DeviceController {
|
||||
this.isRequestControl = false;
|
||||
this.onRequestControlStatusChange?.(false);
|
||||
this.messageApi.destroy('control');
|
||||
this.messageApi.error('控制请求超时');
|
||||
this.messageApi.error(i18n.t('devices.fixed2ControlFixed2'));
|
||||
this.clearControlTimeout();
|
||||
|
||||
}, 20000);
|
||||
@@ -280,12 +280,12 @@ export default class DeviceController {
|
||||
if (msg.success === false || msg?.respond?.switchResult === false) {
|
||||
this.isControlled = false;
|
||||
this.onControlStatusChange?.(false);
|
||||
this.messageApi.error({ key: 'control', content: msg.message || '控制失败' });
|
||||
this.messageApi.error({ key: 'control', content: msg.message || i18n.t('devices.controlFailed') });
|
||||
return;
|
||||
}
|
||||
this.isControlled = true;
|
||||
this.onControlStatusChange?.(true);
|
||||
this.messageApi.success({ key: 'control', content: '控制成功' });
|
||||
this.messageApi.success({ key: 'control', content: i18n.t('devices.fixed2ControlFixed2SuccessFixed2') });
|
||||
break;
|
||||
}
|
||||
case "device_task_change": {
|
||||
@@ -310,8 +310,8 @@ export default class DeviceController {
|
||||
|
||||
this.requestDeviceId = msg.deviceId;
|
||||
this.onPermissionRequest?.({
|
||||
title: '权限请求',
|
||||
content: `${msg.platform} 请求控制设备`,
|
||||
title: i18n.t('devices.s2'),
|
||||
content: i18n.t('devices.platformRequestControl', { platform: msg.platform }),
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -322,10 +322,10 @@ export default class DeviceController {
|
||||
if (isSecure) return;
|
||||
const type = obstacle?.type;
|
||||
const distance = (obstacle?.distance || 0).toFixed(2);
|
||||
const types = { 0: t('constants.locationUnknown'), 1: '人', 2: '车辆', 3: '围栏', 4: '坑洞', 5: '草丛' };
|
||||
const types = { 0: i18n.t('constants.locationUnknown'), 1: i18n.t('devices.obstaclePerson'), 2: i18n.t('devices.obstacleVehicle'), 3: i18n.t('devices.obstacleFence'), 4: i18n.t('devices.obstaclePothole'), 5: i18n.t('devices.obstacleGrass') };
|
||||
this.messageApi.warning({
|
||||
key: 'obstacle-warning',
|
||||
content: `检测到 ${types[type] ?? '未知物'},距离 ${distance}m`,
|
||||
content: i18n.t('devices.obstacleDetectedReport', { obstacle: types[type] ?? i18n.t('devices.unknownObject'), distance }),
|
||||
duration: 3,
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user