mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-03-25 16:50:22 +08:00
commit
3579fe529f
@ -13,6 +13,7 @@ import { INSTANCE_TYPE_TRANSLATION } from "@/hooks/useInstance";
|
||||
import { Dayjs } from "dayjs";
|
||||
import _ from "lodash";
|
||||
import { dayjsToTimestamp, timestampToDayjs } from "../../../tools/time";
|
||||
import { useDockerEnvEditDialog } from "@/components/fc";
|
||||
|
||||
interface FormDetail extends InstanceDetail {
|
||||
dayjsEndTime?: Dayjs;
|
||||
@ -96,6 +97,21 @@ const encodeFormData = () => {
|
||||
throw new Error("Ref Options is null");
|
||||
};
|
||||
|
||||
const handleEditDockerEnv = async () => {
|
||||
if (!options.value?.config) return;
|
||||
|
||||
const envs = options.value.config.docker.env?.map((v) => {
|
||||
const tmp = v.split("=");
|
||||
return {
|
||||
label: tmp[0] || "",
|
||||
value: tmp[1] || ""
|
||||
};
|
||||
});
|
||||
const result = await useDockerEnvEditDialog(envs);
|
||||
const envsArray = result.map((v) => `${v.label}=${v.value}`);
|
||||
options.value.config.docker.env = envsArray;
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
@ -217,7 +233,7 @@ defineExpose({
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :offset="0">
|
||||
<a-col :xs="24" :lg="18" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("TXT_CODE_bb0b9711") }}</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
@ -236,6 +252,22 @@ defineExpose({
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :lg="6" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("TXT_CODE_b916a8dc") }}</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
|
||||
{{ t("TXT_CODE_33ce1c5c") }}
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
<a-input-group compact>
|
||||
<a-button type="default" @click="handleEditDockerEnv">
|
||||
{{ t("TXT_CODE_ad207008") }}
|
||||
</a-button>
|
||||
</a-input-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
|
@ -2552,8 +2552,8 @@
|
||||
"TXT_CODE_c6d3bd8": "MC Pufferfish",
|
||||
"TXT_CODE_eee2a47f": "Image preview",
|
||||
"TXT_CODE_66f38b2e": "Normal users can only modify part of the settings",
|
||||
"TXT_CODE_a583cae4": "Allow normal users to edit the startup command",
|
||||
"TXT_CODE_bfbdf579": "This feature allows normal users to edit the 'start' and 'update' commands of Docker instances",
|
||||
"TXT_CODE_a583cae4": "Allow normal users to edit instance advanced configuration",
|
||||
"TXT_CODE_bfbdf579": "This feature allows ordinary users to edit the configuration of Docker instances such as the \"start\" and \"update\" commands",
|
||||
"TXT_CODE_36cae384": "You are using a private IP address",
|
||||
"TXT_CODE_ea6e5e5e": "This node may not work properly when accessing the panel using a public IP address",
|
||||
"TXT_CODE_678164d7": "You can find the node ID in the 'Node List' section of the merchant console"
|
||||
|
@ -2552,8 +2552,8 @@
|
||||
"TXT_CODE_c6d3bd8": "MC Pufferfish",
|
||||
"TXT_CODE_eee2a47f": "图像预览",
|
||||
"TXT_CODE_66f38b2e": "普通用户仅可修改部分设置",
|
||||
"TXT_CODE_a583cae4": "准许普通用户编辑启动命令",
|
||||
"TXT_CODE_bfbdf579": "该功能允许普通用户编辑 Docker 实例的“启动”和“更新”命令",
|
||||
"TXT_CODE_a583cae4": "准许普通用户编辑实例高级配置",
|
||||
"TXT_CODE_bfbdf579": "该功能允许普通用户编辑 Docker 实例的“启动”和“更新”命令等配置",
|
||||
"TXT_CODE_36cae384": "你正使用私有 IP 地址",
|
||||
"TXT_CODE_ea6e5e5e": "使用公网地址访问面板时该节点可能无法正常工作",
|
||||
"TXT_CODE_678164d7": "在 “商家控制台 - 节点列表” 中可以找到节点ID"
|
||||
|
@ -2552,8 +2552,8 @@
|
||||
"TXT_CODE_c6d3bd8": "MC Pufferfish",
|
||||
"TXT_CODE_eee2a47f": "圖片預覽",
|
||||
"TXT_CODE_66f38b2e": "使用者只能修改部分設定",
|
||||
"TXT_CODE_a583cae4": "允許使用者編輯啟動指令",
|
||||
"TXT_CODE_bfbdf579": "該功能允許使用者編輯 Docker 伺服器的「啟動」和「更新」指令",
|
||||
"TXT_CODE_a583cae4": "允許使用者編輯實例高級設定",
|
||||
"TXT_CODE_bfbdf579": "該功能允許使用者編輯 Docker 伺服器的「啟動」和「更新」指令等設定",
|
||||
"TXT_CODE_36cae384": "你正使用虛擬 IP 位址",
|
||||
"TXT_CODE_ea6e5e5e": "使用公共 ip 存取面板時該節點可能無法正常運作",
|
||||
"TXT_CODE_678164d7": "在「商家控制台 - 節點清單」中可以找到節點ID"
|
||||
|
@ -13,6 +13,7 @@ import { ROLE } from "../entity/user";
|
||||
import axios from "axios";
|
||||
import { systemConfig } from "../setting";
|
||||
import { IQuickStartTemplate } from "common/global";
|
||||
import { checkInstanceAdvancedParams } from "../service/instance_service";
|
||||
|
||||
const router = new Router({ prefix: "/protected_instance" });
|
||||
|
||||
@ -422,33 +423,11 @@ router.put(
|
||||
const ie = !isEmpty(config.ie) ? toText(config?.ie) : null;
|
||||
const fileCode = toText(config.fileCode);
|
||||
const stopCommand = config.stopCommand ? toText(config.stopCommand) : null;
|
||||
const startCommand = toText(config.startCommand);
|
||||
const updateCommand = toText(config.updateCommand);
|
||||
|
||||
const remoteService = RemoteServiceSubsystem.getInstance(daemonId || "");
|
||||
const isTopPermission = isTopPermissionByUuid(getUserUuid(ctx));
|
||||
|
||||
const instance = await new RemoteRequest(remoteService).request("instance/detail", {
|
||||
instanceUuid
|
||||
});
|
||||
|
||||
const isCmdChanged = (cmd: string | null, instanceCmd: string) => cmd !== instanceCmd;
|
||||
const hasPermission = isTopPermissionByUuid(getUserUuid(ctx));
|
||||
|
||||
if (
|
||||
(startCommand || updateCommand) &&
|
||||
isCmdChanged(startCommand, instance.config.startCommand) &&
|
||||
isCmdChanged(updateCommand, instance.config.updateCommand)
|
||||
) {
|
||||
if (instance.config.processType !== "docker" && !hasPermission)
|
||||
return verificationFailed(ctx);
|
||||
|
||||
if (
|
||||
instance.config.processType === "docker" &&
|
||||
!systemConfig?.allowChangeCmd &&
|
||||
!hasPermission
|
||||
)
|
||||
return verificationFailed(ctx);
|
||||
}
|
||||
let advancedConfig = {};
|
||||
advancedConfig = checkInstanceAdvancedParams(config, isTopPermission);
|
||||
|
||||
const result = await new RemoteRequest(remoteService).request("instance/update", {
|
||||
instanceUuid,
|
||||
@ -467,8 +446,7 @@ router.put(
|
||||
enableRcon,
|
||||
tag: instanceTags,
|
||||
fileCode,
|
||||
startCommand: startCommand ?? instance.startCommand,
|
||||
updateCommand: updateCommand ?? instance.updateCommand
|
||||
...advancedConfig
|
||||
}
|
||||
});
|
||||
ctx.body = result;
|
||||
|
@ -2,6 +2,9 @@ import userSystem from "../service/user_service";
|
||||
import RemoteServiceSubsystem from "../service/remote_service";
|
||||
import RemoteRequest from "../service/remote_command";
|
||||
import { t } from "i18next";
|
||||
import { systemConfig } from "../setting";
|
||||
import { isEmpty, toText } from "common/dist";
|
||||
import { IGlobalInstanceConfig } from "common/global";
|
||||
|
||||
export enum INSTANCE_STATUS {
|
||||
BUSY = -1,
|
||||
@ -136,3 +139,27 @@ export async function getInstancesByUuid(
|
||||
token: ""
|
||||
};
|
||||
}
|
||||
|
||||
export function checkInstanceAdvancedParams(
|
||||
config: IGlobalInstanceConfig,
|
||||
isTopPermission: boolean = false
|
||||
) {
|
||||
const canChangeCmd = systemConfig?.allowChangeCmd;
|
||||
if (!isTopPermission) {
|
||||
if (!canChangeCmd) return {};
|
||||
if (config.processType !== "docker") return {};
|
||||
}
|
||||
|
||||
const startCommand = toText(config.startCommand);
|
||||
const updateCommand = toText(config.updateCommand);
|
||||
const dockerEnv =
|
||||
!isEmpty(config.docker.env) && Array.isArray(config.docker.env) ? config.docker.env : [];
|
||||
|
||||
return {
|
||||
startCommand,
|
||||
updateCommand,
|
||||
docker: {
|
||||
env: dockerEnv
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user