mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-03-25 16:50:22 +08:00
feat: edit cmd settings
This commit is contained in:
parent
b5aae32f08
commit
57cc3ddd4f
@ -22,7 +22,8 @@ export const useAppStateStore = createGlobalState(() => {
|
||||
canFileManager: false,
|
||||
allowUsePreset: false,
|
||||
businessMode: false,
|
||||
businessId: ""
|
||||
businessId: "",
|
||||
allowEditCmdOnDocker: false
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -76,6 +76,7 @@ export interface Settings {
|
||||
allowUsePreset: boolean;
|
||||
businessMode: boolean;
|
||||
businessId: string;
|
||||
allowEditCmdOnDocker: boolean;
|
||||
}
|
||||
|
||||
export interface ImageInfo {
|
||||
@ -246,5 +247,6 @@ export interface PanelStatus {
|
||||
allowUsePreset: boolean;
|
||||
businessMode: boolean;
|
||||
businessId: string;
|
||||
allowEditCmdOnDocker: boolean;
|
||||
};
|
||||
}
|
||||
|
@ -387,6 +387,29 @@ onMounted(async () => {
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">
|
||||
{{ t("TXT_CODE_a583cae4") }}
|
||||
</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
<a-typography-text type="secondary">
|
||||
{{ t("TXT_CODE_bfbdf579") }}
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
<a-select
|
||||
v-model:value.prop="(formData as any).allowEditCmdOnDocker"
|
||||
style="max-width: 320px"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="item in allYesNo"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
>
|
||||
{{ item.label }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">
|
||||
{{ t("TXT_CODE_adab942e") }}
|
||||
|
@ -167,7 +167,10 @@ const btns = computed(() => {
|
||||
{
|
||||
title: t("TXT_CODE_4f34fc28"),
|
||||
icon: AppstoreAddOutlined,
|
||||
condition: () => !isAdmin.value,
|
||||
condition: () =>
|
||||
!isAdmin.value &&
|
||||
instanceInfo.value?.config.processType === "docker" &&
|
||||
state.settings.allowEditCmdOnDocker,
|
||||
click: () => {
|
||||
instanceFundamentalDetailDialog.value?.openDialog();
|
||||
}
|
||||
|
@ -2551,5 +2551,7 @@
|
||||
"TXT_CODE_ae566b56": "Optimizes the suffocation check by selectively skipping the check in a way that still appears vanilla. This should be left enabled on most servers, but is provided as a configuration option if the vanilla deviation is undesirable.",
|
||||
"TXT_CODE_c6d3bd8": "MC Pufferfish",
|
||||
"TXT_CODE_eee2a47f": "Image preview",
|
||||
"TXT_CODE_66f38b2e": "Normal users can only modify part of the settings"
|
||||
"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"
|
||||
}
|
||||
|
@ -2022,5 +2022,7 @@
|
||||
"TXT_CODE_1548649e": "编辑计划任务",
|
||||
"TXT_CODE_c6d3bd8": "MC Pufferfish",
|
||||
"TXT_CODE_eee2a47f": "图像预览",
|
||||
"TXT_CODE_66f38b2e": "普通用户仅可修改部分设置"
|
||||
"TXT_CODE_66f38b2e": "普通用户仅可修改部分设置",
|
||||
"TXT_CODE_a583cae4": "准许普通用户编辑启动命令",
|
||||
"TXT_CODE_bfbdf579": "该功能允许普通用户编辑 Docker 实例的“启动”和“更新”命令"
|
||||
}
|
||||
|
@ -57,4 +57,7 @@ export default class SystemConfig {
|
||||
businessMode = false;
|
||||
|
||||
businessId = "";
|
||||
|
||||
// Whether to allow users to edit the start & update command of Docker instances
|
||||
allowEditCmdOnDocker = false;
|
||||
}
|
||||
|
@ -431,13 +431,24 @@ router.put(
|
||||
instanceUuid
|
||||
});
|
||||
|
||||
const isCmdChanged = (cmd: string | null, instanceCmd: string) => cmd !== instanceCmd;
|
||||
const hasPermission = isTopPermissionByUuid(getUserUuid(ctx));
|
||||
|
||||
if (
|
||||
(startCommand || updateCommand) &&
|
||||
instance.config.processType !== "docker" &&
|
||||
(startCommand !== instance.config.startCommand ||
|
||||
updateCommand !== instance.config.updateCommand)
|
||||
)
|
||||
return verificationFailed(ctx);
|
||||
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?.allowEditCmdOnDocker &&
|
||||
!hasPermission
|
||||
)
|
||||
return verificationFailed(ctx);
|
||||
}
|
||||
|
||||
const result = await new RemoteRequest(remoteService).request("instance/update", {
|
||||
instanceUuid,
|
||||
|
@ -79,7 +79,8 @@ router.all(
|
||||
canFileManager: systemConfig?.canFileManager || false,
|
||||
allowUsePreset: systemConfig?.allowUsePreset || false,
|
||||
businessMode: systemConfig?.businessMode || false,
|
||||
businessId: systemConfig?.businessId || null
|
||||
businessId: systemConfig?.businessId || null,
|
||||
allowEditCmdOnDocker: systemConfig?.allowEditCmdOnDocker || false
|
||||
} as Partial<SystemConfig>
|
||||
};
|
||||
}
|
||||
|
@ -53,12 +53,15 @@ router.put("/setting", permission({ level: ROLE.ADMIN }), async (ctx) => {
|
||||
if (config.presetPackAddr != null) systemConfig.presetPackAddr = String(config.presetPackAddr);
|
||||
if (config.businessMode != null) systemConfig.businessMode = Boolean(config.businessMode);
|
||||
if (config.businessId != null) systemConfig.businessId = String(config.businessId);
|
||||
if (config.allowEditCmdOnDocker != null)
|
||||
systemConfig.allowEditCmdOnDocker = Boolean(config.allowEditCmdOnDocker);
|
||||
if (config.language != null) {
|
||||
logger.warn($t("TXT_CODE_e29a9317"), config.language);
|
||||
systemConfig.language = String(config.language);
|
||||
await i18next.changeLanguage(systemConfig.language.toLowerCase());
|
||||
remoteService.changeDaemonLanguage(systemConfig.language);
|
||||
}
|
||||
|
||||
saveSystemConfig(systemConfig);
|
||||
ctx.body = "OK";
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user