mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-24 15:14:01 +08:00
Feat: i18n develop for remote_service
This commit is contained in:
parent
e76dafb74a
commit
253497593e
@ -44,33 +44,34 @@ export default class RemoteService {
|
||||
// 连接远程服务
|
||||
public connect(connectOpts?: SocketIOClient.ConnectOpts) {
|
||||
if (connectOpts) this.config.connectOpts = connectOpts;
|
||||
|
||||
if (this.available) {
|
||||
logger.info(`[${this.uuid}] 用户发起重连已可用状态的远程服务,正在重置连接通道`);
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
// 防止重复注册事件
|
||||
if (this.socket && this.socket.hasListeners("connect")) {
|
||||
logger.info(`[${this.uuid}] 用户发起重复连接请求,现进行重置连接配置`);
|
||||
return this.refreshReconnect();
|
||||
}
|
||||
|
||||
// 开始正式连接远程Socket程序
|
||||
let addr = `ws://${this.config.ip}:${this.config.port}`;
|
||||
if (this.config.ip.indexOf("wss://") === 0 || this.config.ip.indexOf("ws://") === 0) {
|
||||
addr = `${this.config.ip}:${this.config.port}`;
|
||||
}
|
||||
logger.info(`[${this.uuid}] 面板正在尝试连接远程服务 ${addr}`);
|
||||
const daemonInfo = `[${this.uuid}] [${addr}]`;
|
||||
|
||||
if (this.available) {
|
||||
logger.info(`${$t("daemonInfo.resetConnect")}:${daemonInfo}`);
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
// 防止重复注册事件
|
||||
if (this.socket && this.socket.hasListeners("connect")) {
|
||||
logger.info(`${$t("daemonInfo.replaceConnect")}:${daemonInfo}`);
|
||||
return this.refreshReconnect();
|
||||
}
|
||||
|
||||
logger.info(`${$t("daemonInfo.tryConnect")}:${daemonInfo}`);
|
||||
this.socket = io.connect(addr, connectOpts);
|
||||
|
||||
// 注册内置事件
|
||||
this.socket.on("connect", async () => {
|
||||
logger.info(`远程服务 [${this.uuid}] [${this.config.ip}:${this.config.port}] 已连接`);
|
||||
logger.info($t("daemonInfo.connect", { v: daemonInfo }));
|
||||
await this.onConnect();
|
||||
});
|
||||
this.socket.on("disconnect", async () => {
|
||||
logger.info(`远程服务 [${this.uuid}] [${this.config.ip}:${this.config.port}] 已断开`);
|
||||
logger.info($t("daemonInfo.disconnect", { v: daemonInfo }));
|
||||
await this.onDisconnect();
|
||||
});
|
||||
this.socket.on("connect_error", async (error: string) => {
|
||||
|
@ -47,7 +47,7 @@ export default {
|
||||
off: "管理员已限制全部用户使用文件管理功能"
|
||||
},
|
||||
schedule: {
|
||||
invaildName: "非法的计划任务名"
|
||||
invalidName: "非法的计划任务名"
|
||||
},
|
||||
login: {
|
||||
ban: "身份验证次数过多,您的 IP 地址已被锁定 10 分钟",
|
||||
@ -63,7 +63,10 @@ export default {
|
||||
authSuccess: "远程节点 {{v}} 验证成功",
|
||||
authFailure: "远程节点 {{v}} 验证失败",
|
||||
authError: "远程节点 {{v}} 验证错误",
|
||||
closed: "主动断开远程节点 {{v}} "
|
||||
closed: "主动断开远程节点 {{v}} ",
|
||||
resetConnect: "用户发起重连已可用状态的远程节点,正在重置连接通道",
|
||||
replaceConnect: "用户发起重复连接请求,现进行重置连接配置",
|
||||
tryConnect: "正在尝试连接远程节点"
|
||||
}
|
||||
};
|
||||
// import { $t } from "../../i18n";
|
||||
|
@ -84,7 +84,7 @@ router.post(
|
||||
// 计划任务名需要文件名格式检查
|
||||
const name = String(task.name);
|
||||
FILENAME_BLACKLIST.forEach((ch) => {
|
||||
if (name.includes(ch)) throw new Error($t("router.schedule.invaildName"));
|
||||
if (name.includes(ch)) throw new Error($t("router.schedule.invalidName"));
|
||||
});
|
||||
|
||||
ctx.body = await new RemoteRequest(RemoteServiceSubsystem.getInstance(serviceUuid)).request(
|
||||
|
Loading…
Reference in New Issue
Block a user