fix: Add existence check when restarting Docker (#10926)

Refs  #10890
This commit is contained in:
ssongliu 2025-11-12 10:24:42 +08:00 committed by GitHub
parent 944463e9a8
commit 4aca66c417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View file

@ -89,6 +89,7 @@ import DockerRestart from '@/components/docker-proxy/docker-restart.vue';
import { MsgSuccess } from '@/utils/message';
import { ElMessageBox } from 'element-plus';
import { ref } from 'vue';
import { loadDockerStatus } from '@/api/modules/container';
const props = defineProps({
currentTab: String,
@ -107,10 +108,12 @@ const onPing = ref('Disable');
const oldStatus = ref();
const dockerRef = ref();
const operation = ref('restart');
const dockerStatus = ref();
const withDockerRestart = ref(false);
const acceptParams = (): void => {
loadBaseInfo(true);
loadDocker();
};
const emit = defineEmits(['search', 'update:is-active', 'update:loading', 'update:maskShow', 'update:name']);
@ -140,6 +143,11 @@ const loadBaseInfo = async (search: boolean) => {
});
};
const loadDocker = async () => {
const res = await loadDockerStatus();
dockerStatus.value = res.data.isExist;
};
const loadInitMsg = () => {
switch (props.currentTab) {
case 'base':
@ -201,7 +209,7 @@ const onUnBind = async () => {
const onOperate = async (op: string) => {
operation.value = op;
if (baseInfo.value.name === 'iptables') {
if (baseInfo.value.name === 'iptables' || !dockerStatus.value) {
emit('update:loading', true);
emit('update:maskShow', true);
await operateFire(operation.value, false)

View file

@ -78,6 +78,7 @@ import { GlobalStore } from '@/store';
import { storeToRefs } from 'pinia';
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import DockerProxyDialog from '@/components/docker-proxy/dialog.vue';
import { loadDockerStatus } from '@/api/modules/container';
const globalStore = GlobalStore();
const emit = defineEmits<{ (e: 'search'): void }>();
@ -105,6 +106,7 @@ const form = reactive({
proxyPasswdKeepItem: false,
proxyDocker: false,
});
const dockerStatus = ref();
const withDockerRestart = ref(false);
const dockerProxyRef = ref();
@ -135,6 +137,12 @@ const acceptParams = (params: DialogProps): void => {
proxyDockerVisible.value = params.proxyDocker !== '';
proxyVisible.value = true;
form.proxyPasswdKeepItem = params.passwdKeep === 'Enable';
loadDocker();
};
const loadDocker = async () => {
const res = await loadDockerStatus();
dockerStatus.value = res.data.isExist;
};
const submitChangePassword = async (formEl: FormInstance | undefined) => {
@ -158,7 +166,7 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
if (form.proxyType === 'http' || form.proxyType === 'https') {
params.proxyUrl = form.proxyUrl;
}
if (isMasterProductPro.value && (params.proxyDocker || proxyDockerVisible.value)) {
if (dockerStatus.value && isMasterProductPro.value && (params.proxyDocker || proxyDockerVisible.value)) {
dockerProxyRef.value.acceptParams({
syncList: 'SyncSystemProxy',
open: true,