Refactor: i18n key text

This commit is contained in:
unitwk 2023-09-06 11:53:01 +08:00
parent dbd2a672db
commit 095911201b
53 changed files with 474 additions and 460 deletions

View File

@ -41,7 +41,7 @@ if (fs.existsSync(LOCAL_PRESET_LANG_PATH)) {
logger.info(`LANGUAGE: ${lang}`);
i18next.changeLanguage(lang);
}
logger.info($t("app.welcome"));
logger.info($t("TXT_CODE_app.welcome"));
import * as router from "./service/router";
import * as koa from "./service/http";
@ -63,7 +63,7 @@ koaApp.on("error", (error) => {
const httpServer = http.createServer(koaApp.callback());
httpServer.on("error", (err) => {
logger.error($t("app.httpSetupError"));
logger.error($t("TXT_CODE_app.httpSetupError"));
logger.error(err);
process.exit(1);
});
@ -88,15 +88,15 @@ initDependent();
// Initialize application instance system
try {
InstanceSubsystem.loadInstances();
logger.info($t("app.instanceLoad", { n: InstanceSubsystem.getInstances().length }));
logger.info($t("TXT_CODE_app.instanceLoad", { n: InstanceSubsystem.getInstances().length }));
} catch (err) {
logger.error($t("app.instanceLoadError"), err);
logger.error($t("TXT_CODE_app.instanceLoadError"), err);
process.exit(-1);
}
// Initialize Websocket server
io.on("connection", (socket: Socket) => {
logger.info($t("app.sessionConnect", { ip: socket.handshake.address, uuid: socket.id }));
logger.info($t("TXT_CODE_app.sessionConnect", { ip: socket.handshake.address, uuid: socket.id }));
protocol.addGlobalSocket(socket);
router.navigation(socket);
@ -104,7 +104,9 @@ io.on("connection", (socket: Socket) => {
socket.on("disconnect", () => {
protocol.delGlobalSocket(socket);
for (const name of socket.eventNames()) socket.removeAllListeners(name);
logger.info($t("app.sessionDisconnect", { ip: socket.handshake.address, uuid: socket.id }));
logger.info(
$t("TXT_CODE_app.sessionDisconnect", { ip: socket.handshake.address, uuid: socket.id })
);
});
});
@ -117,13 +119,13 @@ process.on("unhandledRejection", (reason, p) => {
});
logger.info("----------------------------");
logger.info($t("app.started"));
logger.info($t("app.doc"));
logger.info($t("app.addr", { port: config.port }));
logger.info($t("app.configPathTip", { path: "" }));
logger.info($t("app.password", { key: config.key }));
logger.info($t("app.passwordTip"));
logger.info($t("app.exitTip"));
logger.info($t("TXT_CODE_app.started"));
logger.info($t("TXT_CODE_app.doc"));
logger.info($t("TXT_CODE_app.addr", { port: config.port }));
logger.info($t("TXT_CODE_app.configPathTip", { path: "" }));
logger.info($t("TXT_CODE_app.password", { key: config.key }));
logger.info($t("TXT_CODE_app.passwordTip"));
logger.info($t("TXT_CODE_app.exitTip"));
logger.info("----------------------------");
console.log("");

View File

@ -100,7 +100,7 @@ export async function decompress(
async function _7zipCompress(zipPath: string, files: string[]) {
const cmd = `7z.exe a ${zipPath} ${files.join(" ")}`.split(" ");
console.log($t("common._7zip"), `${cmd.join(" ")}`);
console.log($t("TXT_CODE_common._7zip"), `${cmd.join(" ")}`);
return new Promise((resolve, reject) => {
const p = cmd.splice(1);
const process = child_process.spawn(cmd[0], [...p], {
@ -117,7 +117,7 @@ async function _7zipCompress(zipPath: string, files: string[]) {
async function _7zipDecompress(sourceZip: string, destDir: string) {
// ./7z.exe x archive.zip -oD:\7-Zip
const cmd = `7z.exe x ${sourceZip} -o${destDir}`.split(" ");
console.log($t("common._7unzip"), `${cmd.join(" ")}`);
console.log($t("TXT_CODE_common._7unzip"), `${cmd.join(" ")}`);
return new Promise((resolve, reject) => {
const process = child_process.spawn(cmd[0], [cmd[1], cmd[2], cmd[3]], {
cwd: "./7zip/"

View File

@ -108,12 +108,12 @@ export function killProcess(pid: string | number, process: ChildProcess, signal?
try {
if (os.platform() === "win32") {
execSync(`taskkill /PID ${pid} /T /F`);
console.log($t("common.killProcess", { pid: pid }));
console.log($t("TXT_CODE_common.killProcess", { pid: pid }));
return true;
}
if (os.platform() === "linux") {
execSync(`kill -s 9 ${pid}`);
console.log($t("common.killProcess", { pid: pid }));
console.log($t("TXT_CODE_common.killProcess", { pid: pid }));
return true;
}
} catch (err) {

View File

@ -26,7 +26,8 @@ class StorageSubsystem {
public store(category: string, uuid: string, object: any) {
const dirPath = path.join(StorageSubsystem.STIRAGE_DATA_PATH, category);
if (!fs.existsSync(dirPath)) fs.mkdirsSync(dirPath);
if (!this.checkFileName(uuid)) throw new Error($t("common.uuidIrregular", { uuid: uuid }));
if (!this.checkFileName(uuid))
throw new Error($t("TXT_CODE_common.uuidIrregular", { uuid: uuid }));
const filePath = path.join(dirPath, `${uuid}.json`);
const data = JSON.stringify(object, null, 4);
fs.writeFileSync(filePath, data, { encoding: "utf-8" });
@ -57,7 +58,8 @@ class StorageSubsystem {
public load(category: string, classz: any, uuid: string) {
const dirPath = path.join(StorageSubsystem.STIRAGE_DATA_PATH, category);
if (!fs.existsSync(dirPath)) fs.mkdirsSync(dirPath);
if (!this.checkFileName(uuid)) throw new Error($t("common.uuidIrregular", { uuid: uuid }));
if (!this.checkFileName(uuid))
throw new Error($t("TXT_CODE_common.uuidIrregular", { uuid: uuid }));
const filePath = path.join(dirPath, `${uuid}.json`);
if (!fs.existsSync(filePath)) return null;
const data = fs.readFileSync(filePath, { encoding: "utf-8" });

View File

@ -40,7 +40,7 @@ export function commandStringToArray(cmd: string) {
const ch = cmd[index];
if (ch === '"') return index;
}
throw new Error($t("command.quotes"));
throw new Error($t("TXT_CODE_command.quotes"));
}
_analyze();

View File

@ -92,9 +92,9 @@ export default class DockerStartCommand extends InstanceCommand {
async exec(instance: Instance, source = "Unknown") {
if (!instance.config.cwd || !instance.config.ie || !instance.config.oe)
return instance.failure(new StartupDockerProcessError($t("instance.dirEmpty")));
return instance.failure(new StartupDockerProcessError($t("TXT_CODE_instance.dirEmpty")));
if (!fs.existsSync(instance.absoluteCwdPath()))
return instance.failure(new StartupDockerProcessError($t("instance.dirNoE")));
return instance.failure(new StartupDockerProcessError($t("TXT_CODE_instance.dirNoE")));
// command parsing
const commandList = commandStringToArray(instance.config.startCommand);
@ -168,7 +168,7 @@ export default class DockerStartCommand extends InstanceCommand {
if (instance.config.docker.cpusetCpus) {
const arr = instance.config.docker.cpusetCpus.split(",");
arr.forEach((v) => {
if (isNaN(Number(v))) throw new Error($t("instance.invalidCpu", { v }));
if (isNaN(Number(v))) throw new Error($t("TXT_CODE_instance.invalidCpu", { v }));
});
cpusetCpus = instance.config.docker.cpusetCpus;
// Note: check
@ -177,7 +177,7 @@ export default class DockerStartCommand extends InstanceCommand {
// container name check
let containerName = instance.config.docker.containerName;
if (containerName && (containerName.length > 64 || containerName.length < 2)) {
throw new Error($t("instance.invalidContainerName", { v: containerName }));
throw new Error($t("TXT_CODE_instance.invalidContainerName", { v: containerName }));
}
// output startup log
@ -242,7 +242,9 @@ export default class DockerStartCommand extends InstanceCommand {
instance.started(processAdapter);
logger.info(
$t("instance.successful", { v: `${instance.config.nickname} ${instance.instanceUuid}` })
$t("TXT_CODE_instance.successful", {
v: `${instance.config.nickname} ${instance.instanceUuid}`
})
);
}
}

View File

@ -12,7 +12,7 @@ export default class GeneralSendCommand extends InstanceCommand {
async exec(instance: Instance, buf?: any): Promise<any> {
// The server shutdown command needs to send a command, but before the server shutdown command is executed, the status will be set to the shutdown state.
// So here the command can only be executed by whether the process exists or not
if (!instance.process) instance.failure(new Error($t("command.instanceNotOpen")));
if (!instance.process) instance.failure(new Error($t("TXT_CODE_command.instanceNotOpen")));
instance.process.write(encode(buf, instance.config.oe));
if (instance.config.crlf === 2) return instance.process.write("\r\n");

View File

@ -9,7 +9,7 @@ export default class GeneralRestartCommand extends InstanceCommand {
async exec(instance: Instance) {
try {
instance.println("INFO", $t("restart.start"));
instance.println("INFO", $t("TXT_CODE_restart.start"));
await instance.execPreset("stop");
instance.setLock(true);
const startCount = instance.startCount;
@ -18,16 +18,16 @@ export default class GeneralRestartCommand extends InstanceCommand {
const task = setInterval(async () => {
try {
if (startCount !== instance.startCount) {
throw new Error($t("restart.error1"));
throw new Error($t("TXT_CODE_restart.error1"));
}
if (
instance.status() !== Instance.STATUS_STOPPING &&
instance.status() !== Instance.STATUS_STOP
) {
throw new Error($t("restart.error2"));
throw new Error($t("TXT_CODE_restart.error2"));
}
if (instance.status() === Instance.STATUS_STOP) {
instance.println("INFO", $t("restart.restarting"));
instance.println("INFO", $t("TXT_CODE_restart.restarting"));
await instance.execPreset("start");
instance.setLock(false);
clearInterval(task);

View File

@ -72,23 +72,23 @@ export default class GeneralStartCommand extends InstanceCommand {
!instance.config.ie ||
!instance.config.oe
)
return instance.failure(new StartupError($t("general_start.instanceConfigErr")));
return instance.failure(new StartupError($t("TXT_CODE_general_start.instanceConfigErr")));
if (!fs.existsSync(instance.absoluteCwdPath()))
return instance.failure(new StartupError($t("general_start.cwdPathNotExist")));
return instance.failure(new StartupError($t("TXT_CODE_general_start.cwdPathNotExist")));
// command parsing
const commandList = commandStringToArray(instance.config.startCommand);
const commandExeFile = commandList[0];
const commandParameters = commandList.slice(1);
if (commandList.length === 0) {
return instance.failure(new StartupError($t("general_start.cmdEmpty")));
return instance.failure(new StartupError($t("TXT_CODE_general_start.cmdEmpty")));
}
logger.info("----------------");
logger.info($t("general_start.startInstance", { source: source }));
logger.info($t("general_start.instanceUuid", { uuid: instance.instanceUuid }));
logger.info($t("general_start.startCmd", { cmdList: JSON.stringify(commandList) }));
logger.info($t("general_start.cwd", { cwd: instance.config.cwd }));
logger.info($t("TXT_CODE_general_start.startInstance", { source: source }));
logger.info($t("TXT_CODE_general_start.instanceUuid", { uuid: instance.instanceUuid }));
logger.info($t("TXT_CODE_general_start.startCmd", { cmdList: JSON.stringify(commandList) }));
logger.info($t("TXT_CODE_general_start.cwd", { cwd: instance.config.cwd }));
logger.info("----------------");
// create child process
@ -103,13 +103,13 @@ export default class GeneralStartCommand extends InstanceCommand {
if (!process || !process.pid) {
instance.println(
"ERROR",
$t("general_start.pidErr", {
$t("TXT_CODE_general_start.pidErr", {
startCommand: instance.config.startCommand,
commandExeFile: commandExeFile,
commandParameters: JSON.stringify(commandParameters)
})
);
throw new StartupError($t("general_start.startErr"));
throw new StartupError($t("TXT_CODE_general_start.startErr"));
}
// create process adapter
@ -118,8 +118,11 @@ export default class GeneralStartCommand extends InstanceCommand {
// generate open event
instance.started(processAdapter);
logger.info(
$t("general_start.startSuccess", { instanceUuid: instance.instanceUuid, pid: process.pid })
$t("TXT_CODE_general_start.startSuccess", {
instanceUuid: instance.instanceUuid,
pid: process.pid
})
);
instance.println("INFO", $t("general_start.startOrdinaryTerminal"));
instance.println("INFO", $t("TXT_CODE_general_start.startOrdinaryTerminal"));
}
}

View File

@ -11,7 +11,7 @@ export default class GeneralStopCommand extends InstanceCommand {
async exec(instance: Instance) {
const stopCommand = instance.config.stopCommand;
if (instance.status() === Instance.STATUS_STOP || !instance.process)
return instance.failure(new Error($t("general_stop.notRunning")));
return instance.failure(new Error($t("TXT_CODE_general_stop.notRunning")));
instance.status(Instance.STATUS_STOPPING);
@ -24,7 +24,7 @@ export default class GeneralStopCommand extends InstanceCommand {
}
}
instance.println("INFO", $t("general_stop.execCmd", { stopCommand }));
instance.println("INFO", $t("TXT_CODE_general_stop.execCmd", { stopCommand }));
const cacheStartCount = instance.startCount;
// If the instance is still in the stopped state after 10 minutes, restore the state
@ -33,7 +33,7 @@ export default class GeneralStopCommand extends InstanceCommand {
instance.status() === Instance.STATUS_STOPPING &&
instance.startCount === cacheStartCount
) {
instance.println("ERROR", $t("general_stop.stopErr"));
instance.println("ERROR", $t("TXT_CODE_general_stop.stopErr"));
instance.status(Instance.STATUS_RUNNING);
}
}, 1000 * 60 * 10);

View File

@ -22,15 +22,17 @@ export default class GeneralUpdateCommand extends InstanceCommand {
async exec(instance: Instance) {
if (instance.status() !== Instance.STATUS_STOP)
return instance.failure(new Error($t("general_update.statusErr_notStop")));
return instance.failure(new Error($t("TXT_CODE_general_update.statusErr_notStop")));
if (instance.asynchronousTask !== null)
return instance.failure(new Error($t("general_update.statusErr_otherProgress")));
return instance.failure(new Error($t("TXT_CODE_general_update.statusErr_otherProgress")));
try {
instance.setLock(true);
let updateCommand = instance.config.updateCommand;
updateCommand = updateCommand.replace(/\$\{mcsm_workspace\}/gm, instance.config.cwd);
logger.info($t("general_update.readyUpdate", { instanceUuid: instance.instanceUuid }));
logger.info($t("general_update.updateCmd", { instanceUuid: instance.instanceUuid }));
logger.info(
$t("TXT_CODE_general_update.readyUpdate", { instanceUuid: instance.instanceUuid })
);
logger.info($t("TXT_CODE_general_update.updateCmd", { instanceUuid: instance.instanceUuid }));
logger.info(updateCommand);
// command parsing
@ -38,7 +40,7 @@ export default class GeneralUpdateCommand extends InstanceCommand {
const commandExeFile = commandList[0];
const commnadParameters = commandList.slice(1);
if (commandList.length === 0) {
return instance.failure(new Error($t("general_update.cmdFormatErr")));
return instance.failure(new Error($t("TXT_CODE_general_update.cmdFormatErr")));
}
// start the update command
@ -49,7 +51,10 @@ export default class GeneralUpdateCommand extends InstanceCommand {
});
if (!process || !process.pid) {
this.stopped(instance);
return instance.println($t("general_update.err"), $t("general_update.updateFailed"));
return instance.println(
$t("TXT_CODE_general_update.err"),
$t("TXT_CODE_general_update.updateFailed")
);
}
// process & pid
@ -69,24 +74,38 @@ export default class GeneralUpdateCommand extends InstanceCommand {
process.on("exit", (code) => {
this.stopped(instance);
if (code === 0) {
instance.println($t("general_update.update"), $t("general_update.updateSuccess"));
instance.println(
$t("TXT_CODE_general_update.update"),
$t("TXT_CODE_general_update.updateSuccess")
);
} else {
instance.println($t("general_update.update"), $t("general_update.updateErr"));
instance.println(
$t("TXT_CODE_general_update.update"),
$t("TXT_CODE_general_update.updateErr")
);
}
});
} catch (err) {
this.stopped(instance);
instance.println($t("general_update.update"), $t("general_update.error", { err: err }));
instance.println(
$t("TXT_CODE_general_update.update"),
$t("TXT_CODE_general_update.error", { err: err })
);
}
}
async stop(instance: Instance): Promise<void> {
logger.info($t("general_update.terminateUpdate", { instanceUuid: instance.instanceUuid }));
instance.println(
$t("general_update.update"),
$t("general_update.terminateUpdate", { instanceUuid: instance.instanceUuid })
logger.info(
$t("TXT_CODE_general_update.terminateUpdate", { instanceUuid: instance.instanceUuid })
);
instance.println(
$t("TXT_CODE_general_update.update"),
$t("TXT_CODE_general_update.terminateUpdate", { instanceUuid: instance.instanceUuid })
);
instance.println(
$t("TXT_CODE_general_update.update"),
$t("TXT_CODE_general_update.killProcess")
);
instance.println($t("general_update.update"), $t("general_update.killProcess"));
killProcess(this.pid, this.process);
}
}

View File

@ -107,18 +107,18 @@ export default class PtyStartCommand extends InstanceCommand {
!instance.config.ie ||
!instance.config.oe
)
return instance.failure(new StartupError($t("pty_start.cmdErr")));
return instance.failure(new StartupError($t("TXT_CODE_pty_start.cmdErr")));
if (!fs.existsSync(instance.absoluteCwdPath()))
return instance.failure(new StartupError($t("pty_start.cwdNotExist")));
return instance.failure(new StartupError($t("TXT_CODE_pty_start.cwdNotExist")));
if (!path.isAbsolute(path.normalize(instance.config.cwd)))
return instance.failure(new StartupError($t("pty_start.mustAbsolutePath")));
return instance.failure(new StartupError($t("TXT_CODE_pty_start.mustAbsolutePath")));
// PTY mode correctness check
logger.info($t("pty_start.startPty", { source: source }));
logger.info($t("TXT_CODE_pty_start.startPty", { source: source }));
let checkPtyEnv = true;
if (!fs.existsSync(PTY_PATH)) {
instance.println("ERROR", $t("pty_start.startErr"));
instance.println("ERROR", $t("TXT_CODE_pty_start.startErr"));
checkPtyEnv = false;
}
@ -145,7 +145,7 @@ export default class PtyStartCommand extends InstanceCommand {
}
if (commandList.length === 0)
return instance.failure(new StartupError($t("pty_start.cmdEmpty")));
return instance.failure(new StartupError($t("TXT_CODE_pty_start.cmdEmpty")));
const ptyParameter = [
"-dir",
instance.config.cwd,
@ -159,12 +159,12 @@ export default class PtyStartCommand extends InstanceCommand {
];
logger.info("----------------");
logger.info($t("pty_start.sourceRequest", { source: source }));
logger.info($t("pty_start.instanceUuid", { instanceUuid: instance.instanceUuid }));
logger.info($t("pty_start.startCmd", { cmd: commandList.join(" ") }));
logger.info($t("pty_start.ptyPath", { path: PTY_PATH }));
logger.info($t("pty_start.ptyParams", { param: ptyParameter.join(" ") }));
logger.info($t("pty_start.ptyCwd", { cwd: instance.config.cwd }));
logger.info($t("TXT_CODE_pty_start.sourceRequest", { source: source }));
logger.info($t("TXT_CODE_pty_start.instanceUuid", { instanceUuid: instance.instanceUuid }));
logger.info($t("TXT_CODE_pty_start.startCmd", { cmd: commandList.join(" ") }));
logger.info($t("TXT_CODE_pty_start.ptyPath", { path: PTY_PATH }));
logger.info($t("TXT_CODE_pty_start.ptyParams", { param: ptyParameter.join(" ") }));
logger.info($t("TXT_CODE_pty_start.ptyCwd", { cwd: instance.config.cwd }));
logger.info("----------------");
// create pty child process
@ -179,13 +179,13 @@ export default class PtyStartCommand extends InstanceCommand {
if (!subProcess || !subProcess.pid) {
instance.println(
"ERROR",
$t("pty_start.pidErr", {
$t("TXT_CODE_pty_start.pidErr", {
startCommand: instance.config.startCommand,
path: PTY_PATH,
params: JSON.stringify(ptyParameter)
})
);
throw new StartupError($t("pty_start.instanceStartErr"));
throw new StartupError($t("TXT_CODE_pty_start.instanceStartErr"));
}
// create process adapter
@ -198,24 +198,24 @@ export default class PtyStartCommand extends InstanceCommand {
if (subProcess.exitCode !== null || processAdapter.pid == null || processAdapter.pid === 0) {
instance.println(
"ERROR",
$t("pty_start.pidErr", {
$t("TXT_CODE_pty_start.pidErr", {
startCommand: instance.config.startCommand,
path: PTY_PATH,
params: JSON.stringify(ptyParameter)
})
);
throw new StartupError($t("pty_start.instanceStartErr"));
throw new StartupError($t("TXT_CODE_pty_start.instanceStartErr"));
}
// generate open event
instance.started(processAdapter);
logger.info(
$t("pty_start.startSuccess", {
$t("TXT_CODE_pty_start.startSuccess", {
instanceUuid: instance.instanceUuid,
pid: ptySubProcessCfg.pid
})
);
instance.println("INFO", $t("pty_start.startEmulatedTerminal"));
instance.println("INFO", $t("TXT_CODE_pty_start.startEmulatedTerminal"));
}
}

View File

@ -12,10 +12,10 @@ export default class PtyStopCommand extends InstanceCommand {
let stopCommand = instance.config.stopCommand;
if (instance.status() === Instance.STATUS_STOP || !instance.process)
return instance.failure(new Error($t("pty_stop.notRunning")));
return instance.failure(new Error($t("TXT_CODE_pty_stop.notRunning")));
instance.status(Instance.STATUS_STOPPING);
instance.println("INFO", $t("pty_stop.execCmd", { stopCommand: stopCommand }));
instance.println("INFO", $t("TXT_CODE_pty_stop.execCmd", { stopCommand: stopCommand }));
const stopCommandList = stopCommand.split("\n");
for (const stopCommandColumn of stopCommandList) {
@ -33,7 +33,7 @@ export default class PtyStopCommand extends InstanceCommand {
instance.status() === Instance.STATUS_STOPPING &&
instance.startCount === cacheStartCount
) {
instance.println("ERROR", $t("pty_stop.stopErr"));
instance.println("ERROR", $t("TXT_CODE_pty_stop.stopErr"));
instance.status(Instance.STATUS_RUNNING);
}
}, 1000 * 60 * 10);

View File

@ -30,7 +30,7 @@ export default class StartCommand extends InstanceCommand {
async exec(instance: Instance) {
if (instance.status() !== Instance.STATUS_STOP)
return instance.failure(new StartupError($t("start.instanceNotDown")));
return instance.failure(new StartupError($t("TXT_CODE_start.instanceNotDown")));
try {
instance.setLock(true);
instance.status(Instance.STATUS_STARTING);
@ -41,14 +41,14 @@ export default class StartCommand extends InstanceCommand {
if (endTime) {
const currentTime = new Date().getTime();
if (endTime <= currentTime) {
throw new Error($t("start.instanceMaturity"));
throw new Error($t("TXT_CODE_start.instanceMaturity"));
}
}
const currentTimestamp = new Date().getTime();
instance.startTimestamp = currentTimestamp;
instance.println("INFO", $t("start.startInstance"));
instance.println("INFO", $t("TXT_CODE_start.startInstance"));
// prevent the dead-loop from starting
await this.sleep();

View File

@ -59,17 +59,17 @@ export default class OpenFrpTask implements ILifeCycleTask {
if (!fs.existsSync(OpenFrpTask.FRP_EXE_PATH)) {
const tmpTask = setInterval(() => {
instance.println("FRP", $t("frp.installing"));
instance.println("FRP", $t("TXT_CODE_frp.installing"));
}, 2000);
try {
await downloadFileToLocalFile(
OpenFrpTask.FRP_DOWNLOAD_ADDR + OpenFrpTask.FRP_EXE_NAME,
OpenFrpTask.FRP_EXE_PATH
);
instance.println("FRP", $t("frp.done"));
instance.println("FRP", $t("TXT_CODE_frp.done"));
} catch (error) {
logger.error($t("frp.downloadErr"), error);
instance.println("ERROR", $t("frp.downloadErr") + `: ${error}`);
logger.error($t("TXT_CODE_frp.downloadErr"), error);
instance.println("ERROR", $t("TXT_CODE_frp.downloadErr") + `: ${error}`);
fs.remove(OpenFrpTask.FRP_EXE_PATH, () => {});
return;
} finally {

View File

@ -66,7 +66,7 @@ export default class Instance extends EventEmitter {
constructor(instanceUuid: string, config: InstanceConfig) {
super();
if (!instanceUuid || !config) throw new Error($t("instanceConf.initInstanceErr"));
if (!instanceUuid || !config) throw new Error($t("TXT_CODE_instanceConf.initInstanceErr"));
// Basic information
this.instanceStatus = Instance.STATUS_STOP;
@ -86,14 +86,14 @@ export default class Instance extends EventEmitter {
// If the instance type changes, default commands and lifecycle events must be reset
if (cfg?.type && cfg?.type != this.config.type) {
if (this.status() != Instance.STATUS_STOP)
throw new Error($t("instanceConf.cantModifyInstanceType"));
throw new Error($t("TXT_CODE_instanceConf.cantModifyInstanceType"));
configureEntityParams(this.config, cfg, "type", String);
this.forceExec(new FunctionDispatcher());
}
// If the process type changes, the default commands and lifecycle events must be reset
if (cfg?.processType && cfg?.processType !== this.config.processType) {
if (this.status() != Instance.STATUS_STOP)
throw new Error($t("instanceConf.cantModifyProcessType"));
throw new Error($t("TXT_CODE_instanceConf.cantModifyProcessType"));
configureEntityParams(this.config, cfg, "processType", String);
this.forceExec(new FunctionDispatcher());
}
@ -103,9 +103,9 @@ export default class Instance extends EventEmitter {
cfg?.terminalOption?.pty !== this.config.terminalOption.pty
) {
if (this.status() != Instance.STATUS_STOP)
throw new Error($t("instanceConf.cantModifyPtyModel"));
throw new Error($t("TXT_CODE_instanceConf.cantModifyPtyModel"));
if (!fs.existsSync(PTY_PATH) && cfg?.terminalOption?.pty === true)
throw new Error($t("instanceConf.ptyNotExist", { path: PTY_PATH }));
throw new Error($t("TXT_CODE_instanceConf.ptyNotExist", { path: PTY_PATH }));
configureEntityParams(this.config.terminalOption, cfg.terminalOption, "pty", Boolean);
this.forceExec(new FunctionDispatcher());
}
@ -183,8 +183,10 @@ export default class Instance extends EventEmitter {
// Execute the corresponding command for this instance
async execCommand(command: InstanceCommand) {
if (this.lock) throw new Error($t("instanceConf.instanceLock", { info: command.info }));
if (this.status() == Instance.STATUS_BUSY) throw new Error($t("instanceConf.instanceBusy"));
if (this.lock)
throw new Error($t("TXT_CODE_instanceConf.instanceLock", { info: command.info }));
if (this.status() == Instance.STATUS_BUSY)
throw new Error($t("TXT_CODE_instanceConf.instanceBusy"));
return await command.exec(this);
}
@ -243,10 +245,13 @@ export default class Instance extends EventEmitter {
if (!this.config.eventTask.ignore) {
this.forceExec(new StartCommand("Event Task: Auto Restart"))
.then(() => {
this.println($t("instanceConf.info"), $t("instanceConf.autoRestart"));
this.println($t("TXT_CODE_instanceConf.info"), $t("TXT_CODE_instanceConf.autoRestart"));
})
.catch((err) => {
this.println($t("instanceConf.error"), $t("instanceConf.autoRestartErr", { err: err }));
this.println(
$t("TXT_CODE_instanceConf.error"),
$t("TXT_CODE_instanceConf.autoRestartErr", { err: err })
);
});
}
this.config.eventTask.ignore = false;
@ -256,7 +261,7 @@ export default class Instance extends EventEmitter {
const currentTimestamp = new Date().getTime();
const startThreshold = 6 * 1000;
if (currentTimestamp - this.startTimestamp < startThreshold) {
this.println("ERROR", $t("instanceConf.instantExit"));
this.println("ERROR", $t("TXT_CODE_instanceConf.instantExit"));
}
}

View File

@ -19,7 +19,7 @@ export class PresetCommandManager {
async execPreset(action: string, p?: any) {
const cmd = this.preset.get(action);
if (!cmd) throw new Error($t("preset.actionErr", { action: action }));
if (!cmd) throw new Error($t("TXT_CODE_preset.actionErr", { action: action }));
return await cmd.exec(this.self, p);
}

View File

@ -67,7 +67,7 @@ export class ProcessConfig {
text = object.toString();
}
if (!text && this.iProcessConfig.type !== "txt")
throw new Error($t("process_config.writEmpty"));
throw new Error($t("TXT_CODE_process_config.writEmpty"));
fs.writeFileSync(this.iProcessConfig.path, text, { encoding: CONFIG_FILE_ENCODE });
}

View File

@ -8,6 +8,6 @@ export default class MinecraftUpdateCommand extends InstanceCommand {
}
async exec(instance: Instance) {
console.log($t("mc_update.updateInstance"));
console.log($t("TXT_CODE_mc_update.updateInstance"));
}
}

View File

@ -179,7 +179,7 @@ routerApp.on("instance/forward", (ctx, data) => {
// InstanceSubsystem.getInstance(targetInstanceUuid);
if (isforward) {
logger.info(
$t("Instance_router.requestIO", {
$t("TXT_CODE_Instance_router.requestIO", {
id: ctx.socket.id,
targetInstanceUuid: targetInstanceUuid
})
@ -187,7 +187,7 @@ routerApp.on("instance/forward", (ctx, data) => {
InstanceSubsystem.forward(targetInstanceUuid, ctx.socket);
} else {
logger.info(
$t("Instance_router.cancelIO", {
$t("TXT_CODE_Instance_router.cancelIO", {
id: ctx.socket.id,
targetInstanceUuid: targetInstanceUuid
})
@ -210,7 +210,10 @@ routerApp.on("instance/open", async (ctx, data) => {
if (!disableResponse) protocol.msg(ctx, "instance/open", { instanceUuid });
} catch (err) {
if (!disableResponse) {
logger.error($t("Instance_router.openInstanceErr", { instanceUuid: instanceUuid }), err);
logger.error(
$t("TXT_CODE_Instance_router.openInstanceErr", { instanceUuid: instanceUuid }),
err
);
protocol.error(ctx, "instance/open", { instanceUuid: instanceUuid, err: err.message });
}
}
@ -299,7 +302,7 @@ routerApp.on("instance/asynchronous", (ctx, data) => {
const instance = InstanceSubsystem.getInstance(instanceUuid);
logger.info(
$t("Instance_router.performTasks", {
$t("TXT_CODE_Instance_router.performTasks", {
id: ctx.socket.id,
uuid: instanceUuid,
taskName: taskName
@ -312,7 +315,7 @@ routerApp.on("instance/asynchronous", (ctx, data) => {
.then(() => {})
.catch((err) => {
logger.error(
$t("Instance_router.performTasksErr", {
$t("TXT_CODE_Instance_router.performTasksErr", {
uuid: instance.instanceUuid,
taskName: taskName,
err: err
@ -353,7 +356,11 @@ routerApp.on("instance/stop_asynchronous", (ctx, data) => {
.then(() => {})
.catch((err) => {});
} else {
return protocol.error(ctx, "instance/stop_asynchronous", $t("Instance_router.taskEmpty"));
return protocol.error(
ctx,
"instance/stop_asynchronous",
$t("TXT_CODE_Instance_router.taskEmpty")
);
}
protocol.response(ctx, true);
@ -418,7 +425,7 @@ routerApp.on("instance/process_config/file", (ctx, data) => {
try {
const instance = InstanceSubsystem.getInstance(instanceUuid);
const fileManager = new FileManager(instance.absoluteCwdPath());
if (!fileManager.check(fileName)) throw new Error($t("Instance_router.accessFileErr"));
if (!fileManager.check(fileName)) throw new Error($t("TXT_CODE_Instance_router.accessFileErr"));
const filePath = path.normalize(path.join(instance.absoluteCwdPath(), fileName));
const processConfig = new ProcessConfig({
fileName: fileName,
@ -449,7 +456,7 @@ routerApp.on("instance/outputlog", async (ctx, data) => {
const text = await fs.readFile(filePath, { encoding: "utf-8" });
return protocol.response(ctx, text);
}
protocol.responseError(ctx, new Error($t("Instance_router.terminalLogNotExist")), {
protocol.responseError(ctx, new Error($t("TXT_CODE_Instance_router.terminalLogNotExist")), {
notPrintErr: true
});
} catch (err) {

View File

@ -28,7 +28,11 @@ routerApp.use(async (event, ctx, _, next) => {
return await next();
}
logger.warn(
$t("auth_router.notAccess", { id: socket.id, address: socket.handshake.address, event: event })
$t("TXT_CODE_auth_router.notAccess", {
id: socket.id,
address: socket.handshake.address,
event: event
})
);
return protocol.error(ctx, "error", IGNORE);
});
@ -51,7 +55,10 @@ routerApp.on("auth", (ctx, data) => {
if (data === globalConfiguration.config.key) {
// The authentication is passed, and the registered session is a trusted session
logger.info(
$t("auth_router.access", { id: ctx.socket.id, address: ctx.socket.handshake.address })
$t("TXT_CODE_auth_router.access", {
id: ctx.socket.id,
address: ctx.socket.handshake.address
})
);
loginSuccessful(ctx, data);
protocol.msg(ctx, "auth", true);
@ -67,7 +74,10 @@ routerApp.on("connection", (ctx) => {
if (!session.login) {
ctx.socket.disconnect();
logger.info(
$t("auth_router.disconnect", { id: ctx.socket.id, address: ctx.socket.handshake.address })
$t("TXT_CODE_auth_router.disconnect", {
id: ctx.socket.id,
address: ctx.socket.handshake.address
})
);
}
}, AUTH_TIMEOUT);

View File

@ -15,7 +15,7 @@ routerApp.on("environment/images", async (ctx, data) => {
const result = await docker.listImages();
protocol.response(ctx, result);
} catch (error) {
protocol.responseError(ctx, $t("environment_router.dockerInfoErr"));
protocol.responseError(ctx, $t("TXT_CODE_environment_router.dockerInfoErr"));
}
});
@ -57,7 +57,11 @@ routerApp.on("environment/new_image", async (ctx, data) => {
await fs.writeFile(dockerFilepath, dockerFileText, { encoding: "utf-8" });
logger.info(
$t("environment_router.crateImage", { name: name, tag: tag, dockerFileText: dockerFileText })
$t("TXT_CODE_environment_router.crateImage", {
name: name,
tag: tag,
dockerFileText: dockerFileText
})
);
// pre-response
@ -67,9 +71,11 @@ routerApp.on("environment/new_image", async (ctx, data) => {
const dockerImageName = `${name}:${tag}`;
try {
await new DockerManager().startBuildImage(dockerFileDir, dockerImageName);
logger.info($t("environment_router.crateSuccess", { name: name, tag: tag }));
logger.info($t("TXT_CODE_environment_router.crateSuccess", { name: name, tag: tag }));
} catch (error) {
logger.info($t("environment_router.crateErr", { name: name, tag: tag, error: error }));
logger.info(
$t("TXT_CODE_environment_router.crateErr", { name: name, tag: tag, error: error })
);
}
} catch (error) {
protocol.responseError(ctx, error);
@ -83,7 +89,7 @@ routerApp.on("environment/del_image", async (ctx, data) => {
const docker = new DockerManager().getDocker();
const image = docker.getImage(imageId);
if (image) {
logger.info($t("environment_router.delImage", { imageId: imageId }));
logger.info($t("TXT_CODE_environment_router.delImage", { imageId: imageId }));
await image.remove();
} else {
throw new Error("Image does not exist");

View File

@ -19,7 +19,7 @@ routerApp.use((event, ctx, data, next) => {
if (!InstanceSubsystem.exists(instanceUuid)) {
return protocol.error(ctx, event, {
instanceUuid: instanceUuid,
err: $t("file_router.instanceNotExist", { instanceUuid: instanceUuid })
err: $t("TXT_CODE_file_router.instanceNotExist", { instanceUuid: instanceUuid })
});
}
}
@ -164,7 +164,10 @@ routerApp.on("file/compress", async (ctx, data) => {
const instance = InstanceSubsystem.getInstance(data.instanceUuid);
if (instance.info.fileLock >= maxFileTask) {
throw new Error(
$t("file_router.unzipLimit", { maxFileTask: maxFileTask, fileLock: instance.info.fileLock })
$t("TXT_CODE_file_router.unzipLimit", {
maxFileTask: maxFileTask,
fileLock: instance.info.fileLock
})
);
}
// Statistics of the number of tasks in a single instance file and the number of tasks in the entire daemon process

View File

@ -24,9 +24,9 @@ router.get("/download/:key/:fileName", async (ctx) => {
const mission = missionPassport.getMission(key, "download");
if (!mission) throw new Error((ctx.body = "Access denied: No task found"));
const instance = InstanceSubsystem.getInstance(mission.parameter.instanceUuid);
if (!instance) throw new Error($t("http_router.instanceNotExist"));
if (!instance) throw new Error($t("TXT_CODE_http_router.instanceNotExist"));
if (!FileManager.checkFileName(paramsFileName))
throw new Error($t("http_router.fileNameNotSpec"));
throw new Error($t("TXT_CODE_http_router.fileNameNotSpec"));
const cwd = instance.config.cwd;
const fileRelativePath = mission.parameter.fileName;
@ -43,7 +43,7 @@ router.get("/download/:key/:fileName", async (ctx) => {
ctx.set("Content-Type", "application/octet-stream");
await send(ctx, fileName, { root: fileDir + "/", hidden: true });
} catch (error) {
ctx.body = $t("http_router.downloadErr", { error: error.message });
ctx.body = $t("TXT_CODE_http_router.downloadErr", { error: error.message });
ctx.status = 500;
} finally {
missionPassport.deleteMission(key);
@ -96,7 +96,7 @@ router.post("/upload/:key", async (ctx) => {
});
return (ctx.body = "OK");
}
ctx.body = $t("http_router.updateErr");
ctx.body = $t("TXT_CODE_http_router.updateErr");
ctx.status = 500;
} catch (error) {
ctx.body = error.message;

View File

@ -16,7 +16,7 @@ routerApp.on("passport/register", (ctx, data) => {
const count = data.count;
const start = new Date().getTime();
const end = start + ONE_HOUR_TIME * TASK_MAX_TIME;
if (!name || !password) throw new Error($t("passport_router.registerErr"));
if (!name || !password) throw new Error($t("TXT_CODE_passport_router.registerErr"));
missionPassport.registerMission(password, {
name,
parameter,

View File

@ -27,15 +27,18 @@ routerApp.on("stream/auth", (ctx, data) => {
try {
const password = data.password;
const mission = missionPassport.getMission(password, "stream_channel");
if (!mission) throw new Error($t("stream_router.taskNotExist"));
if (!mission) throw new Error($t("TXT_CODE_stream_router.taskNotExist"));
// The instance UUID parameter must come from the task parameter and cannot be used directly
const instance = InstanceSubsystem.getInstance(mission.parameter.instanceUuid);
if (!instance) throw new Error($t("stream_router.instanceNotExist"));
if (!instance) throw new Error($t("TXT_CODE_stream_router.instanceNotExist"));
// Add the data stream authentication ID
logger.info(
$t("stream_router.authSuccess", { id: ctx.socket.id, address: ctx.socket.handshake.address })
$t("TXT_CODE_stream_router.authSuccess", {
id: ctx.socket.id,
address: ctx.socket.handshake.address
})
);
ctx.session.id = ctx.socket.id;
ctx.session.login = true;
@ -48,7 +51,7 @@ routerApp.on("stream/auth", (ctx, data) => {
// Start forwarding output stream data to this Socket
InstanceSubsystem.forward(instance.instanceUuid, ctx.socket);
logger.info(
$t("stream_router.establishConnection", {
$t("TXT_CODE_stream_router.establishConnection", {
id: ctx.socket.id,
address: ctx.socket.handshake.address,
uuid: instance.instanceUuid
@ -59,7 +62,7 @@ routerApp.on("stream/auth", (ctx, data) => {
ctx.socket.on("disconnect", () => {
InstanceSubsystem.stopForward(instance.instanceUuid, ctx.socket);
logger.info(
$t("stream_router.disconnect", {
$t("TXT_CODE_stream_router.disconnect", {
id: ctx.socket.id,
address: ctx.socket.handshake.address,
uuid: instance.instanceUuid

View File

@ -68,7 +68,7 @@ export class QuickInstallTask extends AsyncTask {
try {
let result = await this.download();
result = await fileManager.promiseUnzip(this.TMP_ZIP_NAME, ".", "UTF-8");
if (!result) throw new Error($t("quick_install.unzipError"));
if (!result) throw new Error($t("TXT_CODE_quick_install.unzipError"));
const config = JSON.parse(await fileManager.readFile(this.ZIP_CONFIG_JSON)) as InstanceConfig;
if (config.startCommand && config.startCommand.includes("{{java}}")) {

View File

@ -5,7 +5,8 @@ import FileManager from "./system_file";
export function getFileManager(instanceUuid: string) {
// Initialize a file manager for the instance, and assign codes, restrictions, etc.
const instance = InstanceSubsystem.getInstance(instanceUuid);
if (!instance) throw new Error($t("file_router_service.instanceNotExit", { uuid: instanceUuid }));
if (!instance)
throw new Error($t("TXT_CODE_file_router_service.instanceNotExit", { uuid: instanceUuid }));
const fileCode = instance.config?.fileCode;
const cwd = instance.config.cwd;
return new FileManager(cwd, fileCode);

View File

@ -15,7 +15,7 @@ function ptyChmod() {
fs.chmodSync(PTY_PATH, 0o755);
return true;
} catch (error) {
logger.warn($t("install.changeModeErr", { path: PTY_PATH }));
logger.warn($t("TXT_CODE_install.changeModeErr", { path: PTY_PATH }));
fs.remove(PTY_PATH, () => {});
return false;
}
@ -25,7 +25,7 @@ async function installPty(url: string): Promise<boolean> {
if (!fs.existsSync(PTY_DIR_PATH)) fs.mkdirsSync(PTY_DIR_PATH);
if (fs.existsSync(PTY_PATH) && fs.statSync(PTY_PATH)?.size > 1024) {
if (!ptyChmod()) throw new Error("ptyChmod error");
logger.info($t("install.ptySupport"));
logger.info($t("TXT_CODE_install.ptySupport"));
return true;
}
await downloadFileToLocalFile(url, PTY_PATH);
@ -39,14 +39,14 @@ export function initDependent() {
function setup(index = 0) {
installPty(ptyUrls[index])
.then(() => {
logger.info($t("install.installed"));
logger.info($t("install.guide"));
logger.info($t("TXT_CODE_install.installed"));
logger.info($t("TXT_CODE_install.guide"));
ptyChmod();
})
.catch((err: Error) => {
fs.remove(PTY_PATH, () => {});
if (index === ptyUrls.length - 1) {
logger.warn($t("install.installErr"));
logger.warn($t("TXT_CODE_install.installErr"));
logger.warn(err.message);
return;
}

View File

@ -75,7 +75,7 @@ function systemInfoReport() {
)}MB` + ` CPU: ${toInt(info.cpuUsage * 100)}%`;
const selfInfo = `Heap: ${toInt(self.heapUsed / MB_SIZE)}MB/${toInt(self.heapTotal / MB_SIZE)}MB`;
const selfInfo2 = `RSS: ${toInt(self.rss / MB_SIZE)}MB`;
const logTip = $t("app.sysinfo");
const logTip = $t("TXT_CODE_app.sysinfo");
loggerSysInfo.info([`[${logTip}]`, sysInfo, selfInfo, selfInfo2].join(" "));
}

View File

@ -52,7 +52,7 @@ export function responseError(
if (!config?.notPrintErr)
logger.warn(
$t("protocol.socketErr", {
$t("TXT_CODE_protocol.socketErr", {
id: ctx.socket.id,
address: ctx.socket.handshake.address,
event: ctx.event
@ -73,7 +73,7 @@ export function error(ctx: RouterContext, event: string, err: any) {
if (err.toString().includes(IGNORE)) return ctx.socket.emit(ctx.event, packet);
logger.warn(
$t("protocol.socketErr", {
$t("TXT_CODE_protocol.socketErr", {
id: ctx.socket.id,
address: ctx.socket.handshake.address,
event: ctx.event

View File

@ -82,4 +82,4 @@ import "../routers/stream_router";
import "../routers/environment_router";
import "../routers/schedule_router";
logger.info($t("router.initComplete"));
logger.info($t("TXT_CODE_router.initComplete"));

View File

@ -7,7 +7,7 @@ import { globalConfiguration } from "../entity/config";
import { processWrapper } from "../common/process_tools";
import os from "os";
const ERROR_MSG_01 = $t("system_file.illegalAccess");
const ERROR_MSG_01 = $t("TXT_CODE_system_file.illegalAccess");
const MAX_EDIT_SIZE = 1024 * 1024 * 4;
interface IFile {
@ -184,7 +184,7 @@ export default class FileManager {
const fileInfo = fs.statSync(path);
const MAX_ZIP_GB = globalConfiguration.config.maxZipFileSize;
if (fileInfo.size > 1024 * 1024 * 1024 * MAX_ZIP_GB)
throw new Error($t("system_file.unzipLimit", { max: MAX_ZIP_GB }));
throw new Error($t("TXT_CODE_system_file.unzipLimit", { max: MAX_ZIP_GB }));
}
unzip(sourceZip: string, destDir: string, code?: string) {
@ -213,7 +213,7 @@ export default class FileManager {
}
}
if (totalSize > MAX_TOTAL_FIELS_SIZE)
throw new Error($t("system_file.unzipLimit", { max: MAX_ZIP_GB }));
throw new Error($t("TXT_CODE_system_file.unzipLimit", { max: MAX_ZIP_GB }));
compress(sourceZipPath, filesPath, code)
.then((v) => {
callback(null, v);
@ -246,7 +246,7 @@ export default class FileManager {
const absPath = this.toAbsolutePath(target);
const info = fs.statSync(absPath);
if (info.size > MAX_EDIT_SIZE) {
throw new Error($t("system_file.execLimit"));
throw new Error($t("TXT_CODE_system_file.execLimit"));
}
return await this.readFile(target);
} else {

View File

@ -50,7 +50,7 @@ class InstanceSubsystem extends EventEmitter {
.exec(new StartCommand())
.then(() => {
logger.info(
$t("system_instance.autoStart", {
$t("TXT_CODE_system_instance.autoStart", {
name: instance.config.nickname,
uuid: instance.instanceUuid
})
@ -58,7 +58,7 @@ class InstanceSubsystem extends EventEmitter {
})
.catch((reason) => {
logger.error(
$t("system_instance.autoStartErr", {
$t("TXT_CODE_system_instance.autoStartErr", {
name: instance.config.nickname,
uuid: instance.instanceUuid,
reason: reason
@ -89,9 +89,9 @@ class InstanceSubsystem extends EventEmitter {
this.addInstance(instance);
} catch (error) {
logger.error(
$t("system_instance.readInstanceFailed", { uuid: uuid, error: error.message })
$t("TXT_CODE_system_instance.readInstanceFailed", { uuid: uuid, error: error.message })
);
logger.error($t("system_instance.checkConf", { uuid: uuid }));
logger.error($t("TXT_CODE_system_instance.checkConf", { uuid: uuid }));
}
});
@ -133,7 +133,7 @@ class InstanceSubsystem extends EventEmitter {
}
addInstance(instance: Instance) {
if (instance.instanceUuid == null) throw new Error($t("system_instance.uuidEmpty"));
if (instance.instanceUuid == null) throw new Error($t("TXT_CODE_system_instance.uuidEmpty"));
if (this.instances.has(instance.instanceUuid)) {
throw new Error(`The application instance ${instance.instanceUuid} already exists.`);
}

View File

@ -78,14 +78,17 @@ class InstanceControlSubsystem {
this.taskMap.set(key, []);
}
if (this.taskMap.get(key)?.length >= 8)
throw new Error($t("system_instance_control.execLimit"));
throw new Error($t("TXT_CODE_system_instance_control.execLimit"));
if (!this.checkTask(key, task.name))
throw new Error($t("system_instance_control.existRepeatTask"));
throw new Error($t("TXT_CODE_system_instance_control.existRepeatTask"));
if (!FileManager.checkFileName(task.name))
throw new Error($t("system_instance_control.illegalName"));
throw new Error($t("TXT_CODE_system_instance_control.illegalName"));
if (needStore)
logger.info(
$t("system_instance_control.crateTask", { name: task.name, task: JSON.stringify(task) })
$t("TXT_CODE_system_instance_control.crateTask", {
name: task.name,
task: JSON.stringify(task)
})
);
let job: IScheduleJob;
@ -114,7 +117,10 @@ class InstanceControlSubsystem {
checkIndex.forEach((item) => {
if (isNaN(Number(timeArray[item])) && Number(timeArray[item]) >= 0) {
throw new Error(
$t("system_instance_control.crateTaskErr", { name: task.name, timeArray: timeArray })
$t("TXT_CODE_system_instance_control.crateTaskErr", {
name: task.name,
timeArray: timeArray
})
);
}
});
@ -136,7 +142,8 @@ class InstanceControlSubsystem {
if (needStore) {
StorageSubsystem.store("TaskConfig", `${key}_${newTask.config.name}`, newTask.config);
}
if (needStore) logger.info($t("system_instance_control.crateSuccess", { name: task.name }));
if (needStore)
logger.info($t("TXT_CODE_system_instance_control.crateSuccess", { name: task.name }));
}
public listScheduleJob(instanceUuid: string) {
@ -185,7 +192,7 @@ class InstanceControlSubsystem {
}
} catch (error) {
logger.error(
$t("system_instance_control.execCmdErr", {
$t("TXT_CODE_system_instance_control.execCmdErr", {
uuid: task.instanceUuid,
name: task.name,
error: error

View File

@ -15,7 +15,7 @@ const rl = readline.createInterface({
output: process.stdout
});
console.log($t("ui.help"));
console.log($t("TXT_CODE_ui.help"));
function stdin() {
rl.question("> ", async (answer) => {

View File

@ -15,7 +15,7 @@ export function initVersionManager() {
}
}
} catch (error) {
logger.error($t("version.versionDetectErr"), error);
logger.error($t("TXT_CODE_version.versionDetectErr"), error);
}
}

View File

@ -31,7 +31,7 @@ module.exports = {
const parser = this.parser;
const content = fs.readFileSync(file.path, enc);
let newCode = content;
parser.parseFuncFromString(content, { list: ["t"] }, (key, options) => {
parser.parseFuncFromString(content, { list: ["t", "$t"] }, (key, options) => {
if (String(key).includes(FN_KEY)) {
return;
}

View File

@ -28,263 +28,203 @@
"TXT_CODE_b5c7b82d": "设置",
"TXT_CODE_a0451c97": "取消",
"TXT_CODE_d507abff": "确定",
"app": {
"developInfo": "无法启动,此项目是 MCSManager 开发人员所用项目,普通用户不可直接运行。\n请前往 https://mcsmanager.com/ 了解最新的安装方式。\n如果您要以开发模式运行请创建 publicsrc/public 目录并放置前端静态文件再重新运行。",
"panelStarted": "控制面板端已启动",
"reference": "项目参考: https://github.com/mcsmanager",
"host": "访问地址: http://localhost:{{port}}",
"portTip": "软件公网访问需开放端口 {{port}} 与守护进程端口",
"exitTip": "你可以使用 Ctrl+C 快捷键即可关闭程序",
"httpSetupError": "HTTP/Socket 服务启动错误,可能是端口被占用,权限不足或网卡设备不可用。",
"welcome": "欢迎使用 MCSManager 守护进程",
"instanceLoad": "所有应用实例已加载,总计 {{n}} 个",
"instanceLoadError": "读取本地实例文件失败:",
"sessionConnect": "会话 {{ip}} {{uuid}} 已连接",
"sessionDisconnect": "会话 {{ip}} {{uuid}} 已断开",
"started": "守护进程现已成功启动",
"doc": "参考文档https://docs.mcsmanager.com/",
"addr": "访问地址http://<IP地址>:{{port}}/ 或 ws://<IP地址>:{{port}}",
"configPathTip": "配置文件data/Config/global.json",
"password": "访问密钥:{{key}}",
"passwordTip": "密钥作为唯一认证方式,请使用 MCSManager 面板的节点功能连接程序",
"sysinfo": "资源报告"
},
"common": {
"title": "标题",
"_7zip": "[7zip 压缩任务]",
"_7unzip": "[7zip 解压任务]",
"killProcess": "进程 {{pid}} 已使用系统指令强制终止进程",
"uuidIrregular": "UUID {{uuid}} 不符合规范"
},
"command": {
"quotes": "错误的命令双引号,无法找到成对双引号,如需使用单个双引号请使用 {quotes} 符号",
"errLen": "错误的命令长度,请确保命令格式正确",
"instanceNotOpen": "命令执行失败,因为实例实际进程不存在"
},
"instance": {
"dirEmpty": "启动命令,输入输出编码或工作目录为空值",
"dirNoE": "工作目录并不存在",
"invalidCpu": "非法的CPU核心指定 {{v}}",
"invalidContainerName": "非法的容器名 {{v}}",
"successful": "实例 {{v}} 启动成功"
},
"start": {
"instanceNotDown": "实例未处于关闭状态,无法再进行启动",
"instanceMaturity": "实例使用到期时间已到,无法再启动实例",
"startInstance": "正在准备启动实例..."
},
"restart": {
"start": "重启实例计划开始执行",
"error1": "重启实例状态错误,实例已被启动过,上次状态的重启计划取消",
"error2": "重启实例状态错误,实例状态应该为停止中状态,现在变为正在运行,重启计划取消",
"restarting": "检测到服务器已停止,正在重启实例..."
},
"general_start": {
"instanceConfigErr": "启动命令,输入输出编码或工作目录为空值",
"cwdPathNotExist": "工作目录并不存在",
"cmdEmpty": "无法启动实例,启动命令为空",
"startInstance": "会话 {{source}}: 请求开启实例.",
"instanceUuid": "实例标识符: [{{uuid}}]",
"startCmd": "启动命令: {{cmdList}}",
"cwd": "工作目录: {{cwd}}",
"pidErr": "检测到实例进程/容器启动失败PID 为空),其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,如 Java 环境等。\n\n原生启动命令\n{{startCommand}}\n\n启动命令解析体:\n程序{{commandExeFile}}\n参数{{commandParameters}}\n\n请将此信息报告给管理员技术人员或自行排查故障。",
"startErr": "实例启动失败,请检查启动命令,主机环境和配置文件等",
"startSuccess": "实例 {{instanceUuid}} 成功启动 PID: {{pid}}",
"startOrdinaryTerminal": "应用实例已运行,您可以在底部的命令输入框发送命令,如果您需要支持 CtrlTab 等快捷键等高级控制台功能,请前往终端设置开启仿真终端功能"
},
"general_stop": {
"notRunning": "实例未处于运行中状态,无法进行停止.",
"execCmd": "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 ^Cstopend 等",
"stopErr": "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。"
},
"general_update": {
"statusErr_notStop": "实例状态不正确,无法执行更新任务,必须停止实例",
"statusErr_otherProgress": "实例状态不正确,有其他任务正在运行中",
"readyUpdate": "实例 {{instanceUuid}} 正在准备进行更新操作...",
"updateCmd": "实例 {{instanceUuid}} 执行更新命令如下:",
"cmdFormatErr": "更新命令格式错误,请联系管理员",
"err": "Error",
"updateFailed": "更新失败,更新命令启动失败,请联系管理员",
"update": "更新",
"updateSuccess": "更新成功!",
"updateErr": "更新程序结束,但结果不正确,可能文件更新损坏或网络不畅通",
"error": "更新错误: {{err}}",
"terminateUpdate": "用户请求终止实例 {{instanceUuid}} 的 update 异步任务",
"killProcess": "正在强制杀死任务进程..."
},
"pty_start": {
"cmdErr": "启动命令,输入输出编码或工作目录为空值",
"cwdNotExist": "工作目录并不存在",
"startPty": "会话 {{source}}: 请求开启实例,模式为仿真终端",
"startErr": "仿真终端模式失败,可能是依赖程序不存在,已自动降级到普通终端模式...",
"notSupportPty": "仿真终端模式失败,无法支持的架构或系统,已自动降级到普通终端模式...",
"cmdEmpty": "无法启动实例,启动命令为空",
"sourceRequest": "会话 {{source}}: 请求开启实例.",
"instanceUuid": "实例标识符: [{{instanceUuid}}]",
"startCmd": "启动命令: {{cmd}}",
"ptyPath": "PTY 路径: {{path}}",
"ptyParams": "PTY 参数: {{param}}",
"ptyCwd": "工作目录: {{cwd}}",
"pidErr": "检测到实例进程/容器启动失败PID 为空),其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,如 Java 环境等。\n\n原生启动命令\n{{startCommand}}\n\n仿真终端中转命令:\n程序{{path}}\n参数{{params}}\n\n请将此信息报告给管理员技术人员或自行排查故障。\n如果您认为是面板仿真终端导致的问题请在左侧终端设置中关闭“仿真终端”选项我们将会采用原始输入输出流的方式监听程序。",
"instanceStartErr": "实例启动失败,请检查启动命令,主机环境和配置文件等",
"startSuccess": "实例 {{instanceUuid}} 成功启动 PID: {{pid}}",
"startEmulatedTerminal": "仿真终端模式已生效,您可以直接在终端内直接输入内容并使用 CtrlTab 等功能键",
"mustAbsolutePath": "仿真终端启动工作目录必须使用绝对路径,请前往实例设置界面重新设置工作路径为绝对路径"
},
"pty_stop": {
"notRunning": "实例未处于运行中状态,无法进行停止.",
"execCmd": "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 exitstopend 等",
"stopErr": "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。"
},
"instanceConf": {
"initInstanceErr": "初始化实例失败,唯一标识符或配置参数为空",
"cantModifyInstanceType": "正在运行时无法修改此实例类型",
"cantModifyProcessType": "正在运行时无法修改此实例进程类型",
"cantModifyPtyModel": "正在运行时无法修改PTY模式",
"ptyNotExist": "无法启用仿真终端,因为 {{path}} 附属程序不存在,您可以联系管理员重启 Daemon 程序得以重新安装(仅 Linux",
"instanceLock": "此 {{info}} 操作无法执行,因为实例处于锁定状态,请稍后再试.",
"instanceBusy": "当前实例正处于忙碌状态,无法执行任何操作.",
"info": "信息",
"error": "错误",
"autoRestart": "检测到实例关闭,根据主动事件机制,自动重启指令已发出...",
"autoRestartErr": "自动重启错误: {{err}}",
"instantExit": "检测到实例启动后在极短的时间内退出,原因可能是您的启动命令错误或配置文件错误。"
},
"preset": { "actionErr": "预设命令 {{action}} 不可用" },
"process_config": { "writEmpty": "写入内容为空,可能是配置文件类型不支持" },
"mc_update": { "updateInstance": "更新实例....." },
"auth_router": {
"notAccess": "会话 {{id}}({{address}}) 试图无权限访问 {{event}} 现已阻止.",
"illegalAccess": "非法访问",
"access": "会话 {{id}}({{address}}) 验证身份成功",
"disconnect": "会话 {{id}}({{address}}) 因长时间未验证身份而断开连接"
},
"environment_router": {
"dockerInfoErr": "无法获取镜像信息请确保您已正确安装Docker环境",
"crateImage": "守护进程正在创建镜像 {{name}}:{{tag}} DockerFile 如下:\n{{dockerFileText}}\n",
"crateSuccess": "创建镜像 {{name}}:{{tag}} 完毕",
"crateErr": "创建镜像 {{name}}:{{tag}} 错误:{{error}}",
"delImage": "守护进程正在删除镜像 {{imageId}}"
},
"file_router": {
"instanceNotExist": "实例 {{instanceUuid}} 不存在",
"unzipLimit": "超出最大同时解压缩任务量,最大准许{{maxFileTask}}个,目前有{{fileLock}}个任务正在进行,请耐心等待"
},
"http_router": {
"instanceNotExist": "实例不存在",
"fileNameNotSpec": "用户文件下载名不符合规范",
"downloadErr": "下载出错: {{error}}",
"updateErr": "未知原因: 上传失败"
},
"Instance_router": {
"requestIO": "会话 {{id}} 请求转发实例 {{targetInstanceUuid}} IO 流",
"cancelIO": "会话 {{id}} 请求取消转发实例 {{targetInstanceUuid}} IO 流",
"openInstanceErr": "实例{{instanceUuid}}启动时错误: ",
"performTasks": "会话 {{id}} 要求实例 {{uuid}} 执行异步 {{taskName}} 异步任务",
"performTasksErr": "实例 {{uuid}} {{taskName}} 异步任务执行异常: {{err}}",
"taskEmpty": "无异步任务正在运行",
"accessFileErr": "文件不存在或路径错误,文件访问被拒绝",
"terminalLogNotExist": "终端日志文件不存在"
},
"passport_router": { "registerErr": "不可定义任务名或密钥为空" },
"stream_router": {
"IGNOREAccess": "非法访问",
"taskNotExist": "任务不存在",
"instanceNotExist": "实例不存在",
"authSuccess": "会话 {{id}} {{address}} 数据流通道身份验证成功",
"establishConnection": "会话 {{id}} {{address}} 已与 {{uuid}} 建立数据通道",
"disconnect": "会话 {{id}} {{address}} 已与 {{uuid}} 断开数据通道",
"unauthorizedAccess": "非法访问"
},
"file_router_service": { "instanceNotExit": "实例 {{uuid}} 不存在" },
"install": {
"ptyNotSupportSystem": "仿真终端只能支持 Windows/Linux x86_64 架构,已自动降级为普通终端",
"ptySupport": "识别到可选依赖库安装,仿真终端功能已可用",
"skipInstall": "检测到系统不是 Linux 系统,自动跳过依赖库安装",
"installed": "可选依赖程序已自动安装,仿真终端和部分高级功能已自动启用",
"guide": "依赖程序参考https://github.com/mcsmanager/pty",
"changeModeErr": "修改文件 {{path}} 权限失败,请手动设置其为 chmod 755 以上",
"installErr": "安装可选依赖库失败,全仿真终端和部分可选功能将无法使用,不影响正常功能,将在下次启动时再尝试安装"
},
"protocol": { "socketErr": "会话 {{id}}({{address}})/{{event}} 响应数据时异常:\n" },
"router": {
"user": {
"invalidUserName": "非法的用户名格式",
"invalidPassword": "非法的密码格式",
"existsUserName": "用户名已经被占用",
"deleteFailure": "无法完成用户数据删除",
"passwordCheck": "密码不规范必须为拥有大小写字母数字长度在9到36之间",
"installed": "管理员账号已经创建,不可重复创建"
},
"instance": { "createError": "创建实例失败" },
"file": { "off": "管理员已限制全部用户使用文件管理功能" },
"schedule": { "invalidName": "非法的计划任务名" },
"login": {
"ban": "身份验证次数过多,您的 IP 地址已被锁定 10 分钟",
"nameOrPassError": "账号或密码错误",
"init": "[安装面板] 正在初始化面板管理员账号: {{userName}}",
"installed": "面板已安装,无法重新安装,请备份并删除 data 文件夹以实现全新安装"
},
"initComplete": "所有功能模块与权限防火墙已初始化完毕"
},
"system_file": {
"illegalAccess": "非法访问路径",
"unzipLimit": "文件解压缩只支持最大 {{max}}GB 文件的解压缩,如需改变上限请前往 data/Config/global.json 文件",
"execLimit": "超出最大文件编辑限制"
},
"system_instance_control": {
"execLimit": "无法继续创建计划任务,以达到上限",
"existRepeatTask": "已存在重复的任务",
"illegalName": "非法的计划名,仅支持下划线,数字,字母和部分本地语言",
"crateTask": "创建计划任务 {{name}}:\n{{task}}",
"crateTaskErr": "计划任务创建错误,不正确的时间表达式: \n{{name}}: {{timeArray}}\n请尝试删除 data/TaskConfig/{{name}}.json 文件解决此问题",
"crateSuccess": "创建计划任务 {{name}} 完毕",
"execCmdErr": "实例 {{uuid}} 计划任务 {{name}} 执行错误: \n {{error}}"
},
"system_instance": {
"autoStart": "实例 {{name}} {{uuid}} 自动启动指令已发出",
"autoStartErr": "实例 {{name}} {{uuid}} 自动启动时错误: {{reason}}",
"readInstanceFailed": "读取 {{uuid}} 应用实例失败: {{error}}",
"checkConf": "请检查或删除文件data/InstanceConfig/{{uuid}}.json",
"uuidEmpty": "无法新增某实例因为实例UUID为空"
},
"ui": { "help": "[终端] 守护进程拥有基本的交互功能,请输入\"help\"查看更多信息" },
"version": { "versionDetectErr": "版本检查失败" },
"quick_install": {
"unzipError": "解压文件失败",
"hiperError": "网络映射进程已存在,不可重复启动!"
},
"frp": {
"downloadErr": "下载 FRP 应用程序失败,无法正常启动 FRP 内网映射程序。",
"installing": "正在同时下载并安装 FRP 内网映射程序,稍后我们将自动启动映射功能...",
"done": "FRP 内网映射程序安装完毕,您可以从左上角查看映射状态,如果没有显示,则有可能是杀毒软件拦截,文件权限不足,或者 FRP 密钥错误。"
},
"permission": {
"forbidden": "权限不足",
"forbiddenTokenError": "令牌(Token)验证失败,拒绝访问",
"xmlhttprequestError": "无法找到请求头 x-requested-with: xmlhttprequest",
"apiError": "密钥不正确",
"forbiddenInstance": "[Forbidden] [中间件] 参数不正确或非法访问实例",
"tooFast": "请求速度过快,请稍后再进行操作"
},
"systemRemoteService": {
"nodeCount": "远程节点数:{{n}}",
"loadDaemonTitle": "正在尝试读取本地守护进程 {{localKeyFilePath}}",
"autoCheckDaemon": "检测到本地守护进程,正在自动获取密钥和端口...",
"error": "无法自动获取本地守护进程配置文件,请前往面板手动连接守护进程,前往 https://docs.mcsmanager.com/ 了解更多。"
},
"systemUser": { "userCount": "本地用户数:{{n}}" },
"daemonInfo": {
"connect": "远程节点 {{- v}} 已连接",
"disconnect": "远程节点 {{- v}} 已断开",
"connectError": "连接远程节点错误:{{- v}} ",
"authSuccess": "远程节点 {{- v}} 密钥验证通过",
"authFailure": "远程节点 {{- v}} 密钥验证拒绝",
"authError": "远程节点 {{- v}} 密钥验证错误",
"closed": "主动断开远程节点 {{- v}} ",
"resetConnect": "用户发起重连已可用状态的远程节点,正在重置连接通道",
"replaceConnect": "用户发起重复连接请求,现进行重置连接配置",
"tryConnect": "正在尝试连接远程节点",
"setLanguage": "设置节点语言"
}
"TXT_CODE_app.developInfo": "无法启动,此项目是 MCSManager 开发人员所用项目,普通用户不可直接运行。\n请前往 https://mcsmanager.com/ 了解最新的安装方式。\n如果您要以开发模式运行请创建 publicsrc/public 目录并放置前端静态文件再重新运行。",
"TXT_CODE_app.panelStarted": "控制面板端已启动",
"TXT_CODE_app.reference": "项目参考: https://github.com/mcsmanager",
"TXT_CODE_app.host": "访问地址: http://localhost:{{port}}",
"TXT_CODE_app.portTip": "软件公网访问需开放端口 {{port}} 与守护进程端口",
"TXT_CODE_app.exitTip": "你可以使用 Ctrl+C 快捷键即可关闭程序",
"TXT_CODE_app.httpSetupError": "HTTP/Socket 服务启动错误,可能是端口被占用,权限不足或网卡设备不可用。",
"TXT_CODE_app.welcome": "欢迎使用 MCSManager 守护进程",
"TXT_CODE_app.instanceLoad": "所有应用实例已加载,总计 {{n}} 个",
"TXT_CODE_app.instanceLoadError": "读取本地实例文件失败:",
"TXT_CODE_app.sessionConnect": "会话 {{ip}} {{uuid}} 已连接",
"TXT_CODE_app.sessionDisconnect": "会话 {{ip}} {{uuid}} 已断开",
"TXT_CODE_app.started": "守护进程现已成功启动",
"TXT_CODE_app.doc": "参考文档https://docs.mcsmanager.com/",
"TXT_CODE_app.addr": "访问地址http://<IP地址>:{{port}}/ 或 ws://<IP地址>:{{port}}",
"TXT_CODE_app.configPathTip": "配置文件data/Config/global.json",
"TXT_CODE_app.password": "访问密钥:{{key}}",
"TXT_CODE_app.passwordTip": "密钥作为唯一认证方式,请使用 MCSManager 面板的节点功能连接程序",
"TXT_CODE_app.sysinfo": "资源报告",
"TXT_CODE_common.title": "标题",
"TXT_CODE_common._7zip": "[7zip 压缩任务]",
"TXT_CODE_common._7unzip": "[7zip 解压任务]",
"TXT_CODE_common.killProcess": "进程 {{pid}} 已使用系统指令强制终止进程",
"TXT_CODE_common.uuidIrregular": "UUID {{uuid}} 不符合规范",
"TXT_CODE_command.quotes": "错误的命令双引号,无法找到成对双引号,如需使用单个双引号请使用 {quotes} 符号",
"TXT_CODE_command.errLen": "错误的命令长度,请确保命令格式正确",
"TXT_CODE_command.instanceNotOpen": "命令执行失败,因为实例实际进程不存在",
"TXT_CODE_instance.dirEmpty": "启动命令,输入输出编码或工作目录为空值",
"TXT_CODE_instance.dirNoE": "工作目录并不存在",
"TXT_CODE_instance.invalidCpu": "非法的CPU核心指定 {{v}}",
"TXT_CODE_instance.invalidContainerName": "非法的容器名 {{v}}",
"TXT_CODE_instance.successful": "实例 {{v}} 启动成功",
"TXT_CODE_start.instanceNotDown": "实例未处于关闭状态,无法再进行启动",
"TXT_CODE_start.instanceMaturity": "实例使用到期时间已到,无法再启动实例",
"TXT_CODE_start.startInstance": "正在准备启动实例...",
"TXT_CODE_restart.start": "重启实例计划开始执行",
"TXT_CODE_restart.error1": "重启实例状态错误,实例已被启动过,上次状态的重启计划取消",
"TXT_CODE_restart.error2": "重启实例状态错误,实例状态应该为停止中状态,现在变为正在运行,重启计划取消",
"TXT_CODE_restart.restarting": "检测到服务器已停止,正在重启实例...",
"TXT_CODE_general_start.instanceConfigErr": "启动命令,输入输出编码或工作目录为空值",
"TXT_CODE_general_start.cwdPathNotExist": "工作目录并不存在",
"TXT_CODE_general_start.cmdEmpty": "无法启动实例,启动命令为空",
"TXT_CODE_general_start.startInstance": "会话 {{source}}: 请求开启实例.",
"TXT_CODE_general_start.instanceUuid": "实例标识符: [{{uuid}}]",
"TXT_CODE_general_start.startCmd": "启动命令: {{cmdList}}",
"TXT_CODE_general_start.cwd": "工作目录: {{cwd}}",
"TXT_CODE_general_start.pidErr": "检测到实例进程/容器启动失败PID 为空),其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,如 Java 环境等。\n\n原生启动命令\n{{startCommand}}\n\n启动命令解析体:\n程序{{commandExeFile}}\n参数{{commandParameters}}\n\n请将此信息报告给管理员技术人员或自行排查故障。",
"TXT_CODE_general_start.startErr": "实例启动失败,请检查启动命令,主机环境和配置文件等",
"TXT_CODE_general_start.startSuccess": "实例 {{instanceUuid}} 成功启动 PID: {{pid}}",
"TXT_CODE_general_start.startOrdinaryTerminal": "应用实例已运行,您可以在底部的命令输入框发送命令,如果您需要支持 CtrlTab 等快捷键等高级控制台功能,请前往终端设置开启仿真终端功能",
"TXT_CODE_general_stop.notRunning": "实例未处于运行中状态,无法进行停止.",
"TXT_CODE_general_stop.execCmd": "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 ^Cstopend 等",
"TXT_CODE_general_stop.stopErr": "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。",
"TXT_CODE_general_update.statusErr_notStop": "实例状态不正确,无法执行更新任务,必须停止实例",
"TXT_CODE_general_update.statusErr_otherProgress": "实例状态不正确,有其他任务正在运行中",
"TXT_CODE_general_update.readyUpdate": "实例 {{instanceUuid}} 正在准备进行更新操作...",
"TXT_CODE_general_update.updateCmd": "实例 {{instanceUuid}} 执行更新命令如下:",
"TXT_CODE_general_update.cmdFormatErr": "更新命令格式错误,请联系管理员",
"TXT_CODE_general_update.err": "Error",
"TXT_CODE_general_update.updateFailed": "更新失败,更新命令启动失败,请联系管理员",
"TXT_CODE_general_update.update": "更新",
"TXT_CODE_general_update.updateSuccess": "更新成功!",
"TXT_CODE_general_update.updateErr": "更新程序结束,但结果不正确,可能文件更新损坏或网络不畅通",
"TXT_CODE_general_update.error": "更新错误: {{err}}",
"TXT_CODE_general_update.terminateUpdate": "用户请求终止实例 {{instanceUuid}} 的 update 异步任务",
"TXT_CODE_general_update.killProcess": "正在强制杀死任务进程...",
"TXT_CODE_pty_start.cmdErr": "启动命令,输入输出编码或工作目录为空值",
"TXT_CODE_pty_start.cwdNotExist": "工作目录并不存在",
"TXT_CODE_pty_start.startPty": "会话 {{source}}: 请求开启实例,模式为仿真终端",
"TXT_CODE_pty_start.startErr": "仿真终端模式失败,可能是依赖程序不存在,已自动降级到普通终端模式...",
"TXT_CODE_pty_start.notSupportPty": "仿真终端模式失败,无法支持的架构或系统,已自动降级到普通终端模式...",
"TXT_CODE_pty_start.cmdEmpty": "无法启动实例,启动命令为空",
"TXT_CODE_pty_start.sourceRequest": "会话 {{source}}: 请求开启实例.",
"TXT_CODE_pty_start.instanceUuid": "实例标识符: [{{instanceUuid}}]",
"TXT_CODE_pty_start.startCmd": "启动命令: {{cmd}}",
"TXT_CODE_pty_start.ptyPath": "PTY 路径: {{path}}",
"TXT_CODE_pty_start.ptyParams": "PTY 参数: {{param}}",
"TXT_CODE_pty_start.ptyCwd": "工作目录: {{cwd}}",
"TXT_CODE_pty_start.pidErr": "检测到实例进程/容器启动失败PID 为空),其可能的原因是:\n1. 实例启动命令编写错误,请前往实例设置界面检查启动命令与参数。\n2. 系统主机环境不正确或缺少环境,如 Java 环境等。\n\n原生启动命令\n{{startCommand}}\n\n仿真终端中转命令:\n程序{{path}}\n参数{{params}}\n\n请将此信息报告给管理员技术人员或自行排查故障。\n如果您认为是面板仿真终端导致的问题请在左侧终端设置中关闭“仿真终端”选项我们将会采用原始输入输出流的方式监听程序。",
"TXT_CODE_pty_start.instanceStartErr": "实例启动失败,请检查启动命令,主机环境和配置文件等",
"TXT_CODE_pty_start.startSuccess": "实例 {{instanceUuid}} 成功启动 PID: {{pid}}",
"TXT_CODE_pty_start.startEmulatedTerminal": "仿真终端模式已生效,您可以直接在终端内直接输入内容并使用 CtrlTab 等功能键",
"TXT_CODE_pty_start.mustAbsolutePath": "仿真终端启动工作目录必须使用绝对路径,请前往实例设置界面重新设置工作路径为绝对路径",
"TXT_CODE_pty_stop.notRunning": "实例未处于运行中状态,无法进行停止.",
"TXT_CODE_pty_stop.execCmd": "已执行预设的关闭命令:{{stopCommand}}\n如果无法关闭实例请前往实例设置更改关闭实例的正确命令比如 exitstopend 等",
"TXT_CODE_pty_stop.stopErr": "关闭命令已发出但长时间未能关闭实例,可能是实例关闭命令错误或实例进程假死导致,现在将恢复到运行中状态,可使用强制终止指令结束进程。",
"TXT_CODE_instanceConf.initInstanceErr": "初始化实例失败,唯一标识符或配置参数为空",
"TXT_CODE_instanceConf.cantModifyInstanceType": "正在运行时无法修改此实例类型",
"TXT_CODE_instanceConf.cantModifyProcessType": "正在运行时无法修改此实例进程类型",
"TXT_CODE_instanceConf.cantModifyPtyModel": "正在运行时无法修改PTY模式",
"TXT_CODE_instanceConf.ptyNotExist": "无法启用仿真终端,因为 {{path}} 附属程序不存在,您可以联系管理员重启 Daemon 程序得以重新安装(仅 Linux",
"TXT_CODE_instanceConf.instanceLock": "此 {{info}} 操作无法执行,因为实例处于锁定状态,请稍后再试.",
"TXT_CODE_instanceConf.instanceBusy": "当前实例正处于忙碌状态,无法执行任何操作.",
"TXT_CODE_instanceConf.info": "信息",
"TXT_CODE_instanceConf.error": "错误",
"TXT_CODE_instanceConf.autoRestart": "检测到实例关闭,根据主动事件机制,自动重启指令已发出...",
"TXT_CODE_instanceConf.autoRestartErr": "自动重启错误: {{err}}",
"TXT_CODE_instanceConf.instantExit": "检测到实例启动后在极短的时间内退出,原因可能是您的启动命令错误或配置文件错误。",
"TXT_CODE_preset.actionErr": "预设命令 {{action}} 不可用",
"TXT_CODE_process_config.writEmpty": "写入内容为空,可能是配置文件类型不支持",
"TXT_CODE_mc_update.updateInstance": "更新实例.....",
"TXT_CODE_auth_router.notAccess": "会话 {{id}}({{address}}) 试图无权限访问 {{event}} 现已阻止.",
"TXT_CODE_auth_router.illegalAccess": "非法访问",
"TXT_CODE_auth_router.access": "会话 {{id}}({{address}}) 验证身份成功",
"TXT_CODE_auth_router.disconnect": "会话 {{id}}({{address}}) 因长时间未验证身份而断开连接",
"TXT_CODE_environment_router.dockerInfoErr": "无法获取镜像信息请确保您已正确安装Docker环境",
"TXT_CODE_environment_router.crateImage": "守护进程正在创建镜像 {{name}}:{{tag}} DockerFile 如下:\n{{dockerFileText}}\n",
"TXT_CODE_environment_router.crateSuccess": "创建镜像 {{name}}:{{tag}} 完毕",
"TXT_CODE_environment_router.crateErr": "创建镜像 {{name}}:{{tag}} 错误:{{error}}",
"TXT_CODE_environment_router.delImage": "守护进程正在删除镜像 {{imageId}}",
"TXT_CODE_file_router.instanceNotExist": "实例 {{instanceUuid}} 不存在",
"TXT_CODE_file_router.unzipLimit": "超出最大同时解压缩任务量,最大准许{{maxFileTask}}个,目前有{{fileLock}}个任务正在进行,请耐心等待",
"TXT_CODE_http_router.instanceNotExist": "实例不存在",
"TXT_CODE_http_router.fileNameNotSpec": "用户文件下载名不符合规范",
"TXT_CODE_http_router.downloadErr": "下载出错: {{error}}",
"TXT_CODE_http_router.updateErr": "未知原因: 上传失败",
"TXT_CODE_Instance_router.requestIO": "会话 {{id}} 请求转发实例 {{targetInstanceUuid}} IO 流",
"TXT_CODE_Instance_router.cancelIO": "会话 {{id}} 请求取消转发实例 {{targetInstanceUuid}} IO 流",
"TXT_CODE_Instance_router.openInstanceErr": "实例{{instanceUuid}}启动时错误: ",
"TXT_CODE_Instance_router.performTasks": "会话 {{id}} 要求实例 {{uuid}} 执行异步 {{taskName}} 异步任务",
"TXT_CODE_Instance_router.performTasksErr": "实例 {{uuid}} {{taskName}} 异步任务执行异常: {{err}}",
"TXT_CODE_Instance_router.taskEmpty": "无异步任务正在运行",
"TXT_CODE_Instance_router.accessFileErr": "文件不存在或路径错误,文件访问被拒绝",
"TXT_CODE_Instance_router.terminalLogNotExist": "终端日志文件不存在",
"TXT_CODE_passport_router.registerErr": "不可定义任务名或密钥为空",
"TXT_CODE_stream_router.IGNOREAccess": "非法访问",
"TXT_CODE_stream_router.taskNotExist": "任务不存在",
"TXT_CODE_stream_router.instanceNotExist": "实例不存在",
"TXT_CODE_stream_router.authSuccess": "会话 {{id}} {{address}} 数据流通道身份验证成功",
"TXT_CODE_stream_router.establishConnection": "会话 {{id}} {{address}} 已与 {{uuid}} 建立数据通道",
"TXT_CODE_stream_router.disconnect": "会话 {{id}} {{address}} 已与 {{uuid}} 断开数据通道",
"TXT_CODE_stream_router.unauthorizedAccess": "非法访问",
"TXT_CODE_file_router_service.instanceNotExit": "实例 {{uuid}} 不存在",
"TXT_CODE_install.ptyNotSupportSystem": "仿真终端只能支持 Windows/Linux x86_64 架构,已自动降级为普通终端",
"TXT_CODE_install.ptySupport": "识别到可选依赖库安装,仿真终端功能已可用",
"TXT_CODE_install.skipInstall": "检测到系统不是 Linux 系统,自动跳过依赖库安装",
"TXT_CODE_install.installed": "可选依赖程序已自动安装,仿真终端和部分高级功能已自动启用",
"TXT_CODE_install.guide": "依赖程序参考https://github.com/mcsmanager/pty",
"TXT_CODE_install.changeModeErr": "修改文件 {{path}} 权限失败,请手动设置其为 chmod 755 以上",
"TXT_CODE_install.installErr": "安装可选依赖库失败,全仿真终端和部分可选功能将无法使用,不影响正常功能,将在下次启动时再尝试安装",
"TXT_CODE_protocol.socketErr": "会话 {{id}}({{address}})/{{event}} 响应数据时异常:\n",
"TXT_CODE_router.user.invalidUserName": "非法的用户名格式",
"TXT_CODE_router.user.invalidPassword": "非法的密码格式",
"TXT_CODE_router.user.existsUserName": "用户名已经被占用",
"TXT_CODE_router.user.deleteFailure": "无法完成用户数据删除",
"TXT_CODE_router.user.passwordCheck": "密码不规范必须为拥有大小写字母数字长度在9到36之间",
"TXT_CODE_router.user.installed": "管理员账号已经创建,不可重复创建",
"TXT_CODE_router.instance.createError": "创建实例失败",
"TXT_CODE_router.file.off": "管理员已限制全部用户使用文件管理功能",
"TXT_CODE_router.schedule.invalidName": "非法的计划任务名",
"TXT_CODE_router.login.ban": "身份验证次数过多,您的 IP 地址已被锁定 10 分钟",
"TXT_CODE_router.login.nameOrPassError": "账号或密码错误",
"TXT_CODE_router.login.init": "[安装面板] 正在初始化面板管理员账号: {{userName}}",
"TXT_CODE_router.login.installed": "面板已安装,无法重新安装,请备份并删除 data 文件夹以实现全新安装",
"TXT_CODE_router.initComplete": "所有功能模块与权限防火墙已初始化完毕",
"TXT_CODE_system_file.illegalAccess": "非法访问路径",
"TXT_CODE_system_file.unzipLimit": "文件解压缩只支持最大 {{max}}GB 文件的解压缩,如需改变上限请前往 data/Config/global.json 文件",
"TXT_CODE_system_file.execLimit": "超出最大文件编辑限制",
"TXT_CODE_system_instance_control.execLimit": "无法继续创建计划任务,以达到上限",
"TXT_CODE_system_instance_control.existRepeatTask": "已存在重复的任务",
"TXT_CODE_system_instance_control.illegalName": "非法的计划名,仅支持下划线,数字,字母和部分本地语言",
"TXT_CODE_system_instance_control.crateTask": "创建计划任务 {{name}}:\n{{task}}",
"TXT_CODE_system_instance_control.crateTaskErr": "计划任务创建错误,不正确的时间表达式: \n{{name}}: {{timeArray}}\n请尝试删除 data/TaskConfig/{{name}}.json 文件解决此问题",
"TXT_CODE_system_instance_control.crateSuccess": "创建计划任务 {{name}} 完毕",
"TXT_CODE_system_instance_control.execCmdErr": "实例 {{uuid}} 计划任务 {{name}} 执行错误: \n {{error}}",
"TXT_CODE_system_instance.autoStart": "实例 {{name}} {{uuid}} 自动启动指令已发出",
"TXT_CODE_system_instance.autoStartErr": "实例 {{name}} {{uuid}} 自动启动时错误: {{reason}}",
"TXT_CODE_system_instance.readInstanceFailed": "读取 {{uuid}} 应用实例失败: {{error}}",
"TXT_CODE_system_instance.checkConf": "请检查或删除文件data/InstanceConfig/{{uuid}}.json",
"TXT_CODE_system_instance.uuidEmpty": "无法新增某实例因为实例UUID为空",
"TXT_CODE_ui.help": "[终端] 守护进程拥有基本的交互功能,请输入\"help\"查看更多信息",
"TXT_CODE_version.versionDetectErr": "版本检查失败",
"TXT_CODE_quick_install.unzipError": "解压文件失败",
"TXT_CODE_quick_install.hiperError": "网络映射进程已存在,不可重复启动!",
"TXT_CODE_frp.downloadErr": "下载 FRP 应用程序失败,无法正常启动 FRP 内网映射程序。",
"TXT_CODE_frp.installing": "正在同时下载并安装 FRP 内网映射程序,稍后我们将自动启动映射功能...",
"TXT_CODE_frp.done": "FRP 内网映射程序安装完毕,您可以从左上角查看映射状态,如果没有显示,则有可能是杀毒软件拦截,文件权限不足,或者 FRP 密钥错误。",
"TXT_CODE_permission.forbidden": "权限不足",
"TXT_CODE_permission.forbiddenTokenError": "令牌(Token)验证失败,拒绝访问",
"TXT_CODE_permission.xmlhttprequestError": "无法找到请求头 x-requested-with: xmlhttprequest",
"TXT_CODE_permission.apiError": "密钥不正确",
"TXT_CODE_permission.forbiddenInstance": "[Forbidden] [中间件] 参数不正确或非法访问实例",
"TXT_CODE_permission.tooFast": "请求速度过快,请稍后再进行操作",
"TXT_CODE_systemRemoteService.nodeCount": "远程节点数:{{n}}",
"TXT_CODE_systemRemoteService.loadDaemonTitle": "正在尝试读取本地守护进程 {{localKeyFilePath}}",
"TXT_CODE_systemRemoteService.autoCheckDaemon": "检测到本地守护进程,正在自动获取密钥和端口...",
"TXT_CODE_systemRemoteService.error": "无法自动获取本地守护进程配置文件,请前往面板手动连接守护进程,前往 https://docs.mcsmanager.com/ 了解更多。",
"TXT_CODE_systemUser.userCount": "本地用户数:{{n}}",
"TXT_CODE_daemonInfo.connect": "远程节点 {{- v}} 已连接",
"TXT_CODE_daemonInfo.disconnect": "远程节点 {{- v}} 已断开",
"TXT_CODE_daemonInfo.connectError": "连接远程节点错误:{{- v}} ",
"TXT_CODE_daemonInfo.authSuccess": "远程节点 {{- v}} 密钥验证通过",
"TXT_CODE_daemonInfo.authFailure": "远程节点 {{- v}} 密钥验证拒绝",
"TXT_CODE_daemonInfo.authError": "远程节点 {{- v}} 密钥验证错误",
"TXT_CODE_daemonInfo.closed": "主动断开远程节点 {{- v}} ",
"TXT_CODE_daemonInfo.resetConnect": "用户发起重连已可用状态的远程节点,正在重置连接通道",
"TXT_CODE_daemonInfo.replaceConnect": "用户发起重复连接请求,现进行重置连接配置",
"TXT_CODE_daemonInfo.tryConnect": "正在尝试连接远程节点",
"TXT_CODE_daemonInfo.setLanguage": "设置节点语言"
}

View File

@ -34,7 +34,7 @@ function setupHttp(koaApp: Koa, port: number, host?: string) {
const httpServer = http.createServer(koaApp.callback());
httpServer.on("error", (err) => {
logger.error($t("app.httpSetupError"));
logger.error($t("TXT_CODE_app.httpSetupError"));
logger.error(err);
process.exit(1);
});
@ -44,11 +44,11 @@ function setupHttp(koaApp: Koa, port: number, host?: string) {
httpServer.listen(port, host);
logger.info("==================================");
logger.info($t("app.panelStarted"));
logger.info($t("app.reference"));
logger.info($t("app.host", { port }));
logger.info($t("app.portTip", { port }));
logger.info($t("app.exitTip", { port }));
logger.info($t("TXT_CODE_app.panelStarted"));
logger.info($t("TXT_CODE_app.reference"));
logger.info($t("TXT_CODE_app.host", { port }));
logger.info($t("TXT_CODE_app.portTip", { port }));
logger.info($t("TXT_CODE_app.exitTip", { port }));
logger.info("==================================");
// if (os.platform() == "win32") {
@ -106,7 +106,7 @@ _ / / / / /___ ____/ /_ / / / / /_/ /_ / / / /_/ /_ /_/ // __/ /
// Development environment detection before startup
// if (!fs.existsSync(path.join(__dirname, "public"))) {
// console.log($t("app.developInfo"));
// console.log($t("TXT_CODE_app.developInfo"));
// process.exit(0);
// }

View File

@ -30,26 +30,26 @@ export default class RemoteService {
const daemonInfo = `[${this.uuid}] [${addr}/${this.config.remarks}]`;
if (this.available) {
logger.info(`${$t("daemonInfo.resetConnect")}:${daemonInfo}`);
logger.info(`${$t("TXT_CODE_daemonInfo.resetConnect")}:${daemonInfo}`);
this.disconnect();
}
// prevent duplicate registration of events
if (this.socket && this.socket.hasListeners("connect")) {
logger.info(`${$t("daemonInfo.replaceConnect")}:${daemonInfo}`);
logger.info(`${$t("TXT_CODE_daemonInfo.replaceConnect")}:${daemonInfo}`);
return this.refreshReconnect();
}
logger.info(`${$t("daemonInfo.tryConnect")}:${daemonInfo}`);
logger.info(`${$t("TXT_CODE_daemonInfo.tryConnect")}:${daemonInfo}`);
this.socket = io(addr, this.config.connectOpts);
// register built-in events
this.socket.on("connect", async () => {
logger.info($t("daemonInfo.connect", { v: daemonInfo }));
logger.info($t("TXT_CODE_daemonInfo.connect", { v: daemonInfo }));
await this.onConnect();
});
this.socket.on("disconnect", async () => {
logger.info($t("daemonInfo.disconnect", { v: daemonInfo }));
logger.info($t("TXT_CODE_daemonInfo.disconnect", { v: daemonInfo }));
await this.onDisconnect();
});
this.socket.on("connect_error", async (error: string) => {
@ -60,7 +60,7 @@ export default class RemoteService {
public async setLanguage(language?: string) {
if (!language) language = i18next.language;
logger.info(
`${$t("daemonInfo.setLanguage")} (${this.config.ip}:${this.config.port}/${
`${$t("TXT_CODE_daemonInfo.setLanguage")} (${this.config.ip}:${this.config.port}/${
this.config.remarks
}) language: ${language}`
);
@ -80,14 +80,14 @@ export default class RemoteService {
if (res === true) {
this.available = true;
await this.setLanguage();
logger.info($t("daemonInfo.authSuccess", { v: daemonInfo }));
logger.info($t("TXT_CODE_daemonInfo.authSuccess", { v: daemonInfo }));
return true;
}
this.available = false;
logger.warn($t("daemonInfo.authFailure", { v: daemonInfo }));
logger.warn($t("TXT_CODE_daemonInfo.authFailure", { v: daemonInfo }));
return false;
} catch (error) {
logger.warn($t("daemonInfo.authError", { v: daemonInfo }));
logger.warn($t("TXT_CODE_daemonInfo.authError", { v: daemonInfo }));
logger.warn(error);
return false;
}
@ -109,7 +109,7 @@ export default class RemoteService {
disconnect() {
if (this.socket) {
const daemonInfo = `[${this.uuid}] [${this.config.ip}:${this.config.port}]`;
logger.info($t("daemonInfo.closed", { v: daemonInfo }));
logger.info($t("TXT_CODE_daemonInfo.closed", { v: daemonInfo }));
this.socket.removeAllListeners();
this.socket.disconnect();
this.socket.close();

View File

@ -23,27 +23,27 @@ function requestSpeedLimit(ctx: Koa.ParameterizedContext) {
// Failed callback
function verificationFailed(ctx: Koa.ParameterizedContext) {
ctx.status = 403;
ctx.body = `[Forbidden] ${$t("permission.forbidden")}`;
ctx.body = `[Forbidden] ${$t("TXT_CODE_permission.forbidden")}`;
}
function tokenError(ctx: Koa.ParameterizedContext) {
ctx.status = 403;
ctx.body = `[Forbidden] ${$t("permission.forbiddenTokenError")}`;
ctx.body = `[Forbidden] ${$t("TXT_CODE_permission.forbiddenTokenError")}`;
}
function ajaxError(ctx: Koa.ParameterizedContext) {
ctx.status = 403;
ctx.body = `[Forbidden] ${$t("permission.xmlhttprequestError")}`;
ctx.body = `[Forbidden] ${$t("TXT_CODE_permission.xmlhttprequestError")}`;
}
function apiError(ctx: Koa.ParameterizedContext) {
ctx.status = 403;
ctx.body = `[Forbidden] ${$t("permission.apiError")}`;
ctx.body = `[Forbidden] ${$t("TXT_CODE_permission.apiError")}`;
}
function tooFast(ctx: Koa.ParameterizedContext) {
ctx.status = 500;
ctx.body = `[TooFast] ${$t("permission.tooFast")}`;
ctx.body = `[TooFast] ${$t("TXT_CODE_permission.tooFast")}`;
}
interface IPermissionCfg {

View File

@ -17,8 +17,10 @@ router.post(
const userName = String(ctx.request.body.username);
const passWord = String(ctx.request.body.password);
const permission = Number(ctx.request.body.permission);
if (!userSystem.validatePassword(passWord)) throw new Error($t("router.user.invalidPassword"));
if (userSystem.existUserName(userName)) throw new Error($t("router.user.existsUserName"));
if (!userSystem.validatePassword(passWord))
throw new Error($t("TXT_CODE_router.user.invalidPassword"));
if (userSystem.existUserName(userName))
throw new Error($t("TXT_CODE_router.user.existsUserName"));
ctx.body = await register(ctx, userName, passWord, permission);
}
);
@ -32,7 +34,7 @@ router.del("/", permission({ level: 10 }), async (ctx: Koa.ParameterizedContext)
}
ctx.body = true;
} catch (error) {
ctx.throw(500, $t("router.user.deleteFailure") as string);
ctx.throw(500, $t("TXT_CODE_router.user.deleteFailure") as string);
}
});

View File

@ -65,7 +65,7 @@ router.post(
const remoteService = RemoteServiceSubsystem.getInstance(serviceUuid);
const result = await new RemoteRequest(remoteService).request("instance/new", config);
const newInstanceUuid = result.instanceUuid;
if (!newInstanceUuid) throw new Error($t("router.instance.createError"));
if (!newInstanceUuid) throw new Error($t("TXT_CODE_router.instance.createError"));
// Send a cross-end file upload task to the daemon
const addr = `${remoteService.config.ip}:${remoteService.config.port}`;
const password = timeUuid();

View File

@ -12,7 +12,7 @@ router.put("/", permission({ level: 10 }), async (ctx: Koa.ParameterizedContext)
const { uuid, config } = ctx.request.body;
const { passWord } = config;
if (passWord && !userSystem.validatePassword(passWord))
throw new Error($t("router.user.passwordCheck"));
throw new Error($t("TXT_CODE_router.user.passwordCheck"));
try {
await userSystem.edit(uuid, config);
ctx.body = true;

View File

@ -18,7 +18,7 @@ router.use(async (ctx, next) => {
await next();
} else {
ctx.status = 403;
ctx.body = $t("permission.forbiddenInstance");
ctx.body = $t("TXT_CODE_permission.forbiddenInstance");
}
});

View File

@ -16,14 +16,14 @@ router.use(async (ctx, next) => {
const userUuid = getUserUuid(ctx);
if (systemConfig.canFileManager === false && getUserPermission(ctx) < 10) {
ctx.status = 403;
ctx.body = new Error($t("router.file.off"));
ctx.body = new Error($t("TXT_CODE_router.file.off"));
return;
}
if (isHaveInstanceByUuid(userUuid, serviceUuid, instanceUuid)) {
await next();
} else {
ctx.status = 403;
ctx.body = $t("permission.forbiddenInstance");
ctx.body = $t("TXT_CODE_permission.forbiddenInstance");
}
});

View File

@ -120,7 +120,8 @@ router.put(
if (userUuid) {
const config = ctx.request.body;
const { passWord, isInit } = config;
if (!userSystem.validatePassword(passWord)) throw new Error($t("router.user.passwordCheck"));
if (!userSystem.validatePassword(passWord))
throw new Error($t("TXT_CODE_router.user.passwordCheck"));
await userSystem.edit(userUuid, { passWord, isInit });
ctx.body = true;
}

View File

@ -18,7 +18,7 @@ router.use(async (ctx, next) => {
await next();
} else {
ctx.status = 403;
ctx.body = $t("permission.forbiddenInstance");
ctx.body = $t("TXT_CODE_permission.forbiddenInstance");
}
});
@ -63,7 +63,7 @@ router.post(
// Scheduled task name needs file name format check
const name = String(task.name);
FILENAME_BLACKLIST.forEach((ch) => {
if (name.includes(ch)) throw new Error($t("router.schedule.invalidName"));
if (name.includes(ch)) throw new Error($t("TXT_CODE_router.schedule.invalidName"));
});
ctx.body = await new RemoteRequest(RemoteServiceSubsystem.getInstance(serviceUuid)).request(

View File

@ -23,7 +23,7 @@ router.use(async (ctx, next) => {
await next();
} else {
ctx.status = 403;
ctx.body = $t("permission.forbiddenInstance");
ctx.body = $t("TXT_CODE_permission.forbiddenInstance");
}
});

View File

@ -21,13 +21,13 @@ router.post(
async (ctx: Koa.ParameterizedContext) => {
const userName = String(ctx.request.body.username);
const passWord = String(ctx.request.body.password);
if (!checkBanIp(ctx)) throw new Error($t("router.login.ban"));
if (!checkBanIp(ctx)) throw new Error($t("TXT_CODE_router.login.ban"));
if (check(ctx)) return (ctx.body = "Logined");
let token = login(ctx, userName, passWord);
if (token) {
ctx.body = true;
} else {
throw new Error($t("router.login.nameOrPassError"));
throw new Error($t("TXT_CODE_router.login.nameOrPassError"));
}
}
);
@ -82,8 +82,9 @@ router.all(
const userName = ctx.request.body.username;
const passWord = ctx.request.body.password;
if (userSystem.objects.size === 0) {
if (!userSystem.validatePassword(passWord)) throw new Error($t("router.user.passwordCheck"));
logger.info($t("router.login.init", { userName }));
if (!userSystem.validatePassword(passWord))
throw new Error($t("TXT_CODE_router.user.passwordCheck"));
logger.info($t("TXT_CODE_router.login.init", { userName }));
await userSystem.create({
userName,
passWord,
@ -92,7 +93,7 @@ router.all(
login(ctx, userName, passWord);
return (ctx.body = true);
}
throw new Error($t("router.user.installed"));
throw new Error($t("TXT_CODE_router.user.installed"));
}
);

View File

@ -30,7 +30,7 @@ class RemoteServiceSubsystem extends UniversalRemoteSubsystem<RemoteService> {
await this.initConnectLocalhost("");
}
logger.info($t("systemRemoteService.nodeCount", { n: this.services.size }));
logger.info($t("TXT_CODE_systemRemoteService.nodeCount", { n: this.services.size }));
// Register for periodic connection status checks
setInterval(() => this.connectionStatusCheckTask(), 1000 * 60);
@ -89,9 +89,9 @@ class RemoteServiceSubsystem extends UniversalRemoteSubsystem<RemoteService> {
const localKeyFilePath = path.normalize(
path.join(process.cwd(), "../daemon/data/Config/global.json")
);
logger.info($t("systemRemoteService.loadDaemonTitle", { localKeyFilePath }));
logger.info($t("TXT_CODE_systemRemoteService.loadDaemonTitle", { localKeyFilePath }));
if (fs.existsSync(localKeyFilePath)) {
logger.info($t("systemRemoteService.autoCheckDaemon"));
logger.info($t("TXT_CODE_systemRemoteService.autoCheckDaemon"));
const localDaemonConfig = JSON.parse(
fs.readFileSync(localKeyFilePath, { encoding: "utf-8" })
);
@ -102,7 +102,7 @@ class RemoteServiceSubsystem extends UniversalRemoteSubsystem<RemoteService> {
const port = 24444;
return await this.registerRemoteService({ apiKey: key, port, ip });
}
logger.warn($t("systemRemoteService.error"));
logger.warn($t("TXT_CODE_systemRemoteService.error"));
// After 5 seconds, determine whether the daemon has been connected until a daemon is connected
setTimeout(() => {

View File

@ -16,7 +16,7 @@ class UserSubsystem {
const user = (await Storage.getStorage().load("User", User, uuid)) as User;
this.objects.set(uuid, user);
}
logger.info($t("systemUser.userCount", { n: this.objects.size }));
logger.info($t("TXT_CODE_systemUser.userCount", { n: this.objects.size }));
}
async create(config: IUser): Promise<User> {