fix: fix issue with ubind license restart docker (#8836)

This commit is contained in:
CityFun 2025-05-26 18:24:18 +08:00 committed by GitHub
parent 5d25f972ee
commit 7bcfa78573
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 20 deletions

View file

@ -146,13 +146,14 @@ type Upgrade struct {
}
type ProxyUpdate struct {
ProxyUrl string `json:"proxyUrl"`
ProxyType string `json:"proxyType"`
ProxyPort string `json:"proxyPort"`
ProxyUser string `json:"proxyUser"`
ProxyPasswd string `json:"proxyPasswd"`
ProxyPasswdKeep string `json:"proxyPasswdKeep"`
ProxyDocker bool `json:"proxyDocker"`
ProxyUrl string `json:"proxyUrl"`
ProxyType string `json:"proxyType"`
ProxyPort string `json:"proxyPort"`
ProxyUser string `json:"proxyUser"`
ProxyPasswd string `json:"proxyPasswd"`
ProxyPasswdKeep string `json:"proxyPasswdKeep"`
ProxyDocker bool `json:"proxyDocker"`
WithDockerRestart bool `json:"withDockerRestart"`
}
type CleanData struct {

View file

@ -1,4 +1,5 @@
import { DateTimeFormats } from '@intlify/core-base';
import { b } from 'vite/dist/node/types.d-aGj9QkWt';
export namespace Setting {
export interface SettingInfo {
@ -83,6 +84,7 @@ export namespace Setting {
proxyUser: string;
proxyPasswd: string;
proxyPasswdKeep: string;
withDockerRestart: boolean;
}
export interface ApiConfig {
apiInterfaceStatus: string;
@ -238,4 +240,16 @@ export namespace Setting {
isBound: boolean;
name: string;
}
export interface LicenseBind {
nodeID: number;
licenseID: number;
syncList: string;
withRestartDocker: boolean;
}
export interface LicenseUnbind {
id: number;
force: boolean;
withRestartDocker: boolean;
}
}

View file

@ -28,11 +28,11 @@ export const getMasterLicenseStatus = () => {
export const syncLicense = (id: number) => {
return http.post(`/core/licenses/sync`, { id: id });
};
export const bindLicense = (id: number, nodeID: number, syncList: string) => {
return http.post(`/core/licenses/bind`, { nodeID: nodeID, licenseID: id, syncList: syncList }, TimeoutEnum.T_60S);
export const bindLicense = (params: Setting.LicenseBind) => {
return http.post(`/core/licenses/bind`, params, TimeoutEnum.T_60S);
};
export const unbindLicense = (id: number, force: boolean) => {
return http.post(`/core/licenses/unbind`, { id: id, force: force }, TimeoutEnum.T_60S);
export const unbindLicense = (params: Setting.LicenseUnbind) => {
return http.post(`/core/licenses/unbind`, params, TimeoutEnum.T_60S);
};
export const changeBind = (id: number, nodeIDs: Array<number>) => {
return http.post(`/core/licenses/bind/free`, { licenseID: id, nodeIDs: nodeIDs }, TimeoutEnum.T_60S);

View file

@ -66,7 +66,7 @@ const licenseName = ref();
const freeNodes = ref([]);
const dockerProxyRef = ref();
const withDockerRestart = ref(true);
const withDockerRestart = ref(false);
const form = reactive({
nodeID: null,
@ -95,7 +95,13 @@ const onBind = async (formEl: FormInstance | undefined) => {
const submit = async () => {
loading.value = true;
await bindLicense(form.licenseID, form.nodeID, form.syncList)
console.log(withDockerRestart.value);
await bindLicense({
licenseID: form.licenseID,
nodeID: form.nodeID,
syncList: form.syncList,
withRestartDocker: withDockerRestart.value,
})
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));

View file

@ -189,7 +189,11 @@ const onUnbind = async (row: any) => {
};
const submitUnbind = async () => {
loading.value = true;
await unbindLicense(unbindRow.value.id, forceUnbind.value)
await unbindLicense({
id: unbindRow.value.id,
force: forceUnbind.value,
withRestartDocker: withDockerRestart.value,
})
.then(() => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));

View file

@ -64,6 +64,7 @@
</DrawerPro>
<ConfirmDialog ref="confirmDialogRef" @confirm="onSubmit" />
<DockerProxyDialog ref="dockerProxyRef" @submit="onSubmit" v-model:with-docker-restart="withDockerRestart" />
</template>
<script lang="ts" setup>
@ -76,6 +77,7 @@ import { updateProxy } from '@/api/modules/setting';
import { GlobalStore } from '@/store';
import { storeToRefs } from 'pinia';
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import DockerProxyDialog from '@/components/docker-proxy/dialog.vue';
const globalStore = GlobalStore();
const emit = defineEmits<{ (e: 'search'): void }>();
@ -103,6 +105,8 @@ const form = reactive({
proxyPasswdKeepItem: false,
proxyDocker: false,
});
const withDockerRestart = ref(false);
const dockerProxyRef = ref();
interface DialogProps {
url: string;
@ -146,6 +150,7 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
proxyPasswd: isClose ? '' : form.proxyPasswd,
proxyPasswdKeep: '',
proxyDocker: isClose ? false : form.proxyDocker,
withDockerRestart: false,
};
if (!isClose) {
params.proxyPasswdKeep = form.proxyPasswdKeepItem ? 'Enable' : 'Disable';
@ -154,12 +159,9 @@ const submitChangePassword = async (formEl: FormInstance | undefined) => {
params.proxyUrl = form.proxyType + '://' + form.proxyUrl;
}
if (isMasterProductPro.value && (params.proxyDocker || proxyDockerVisible.value)) {
let confirmParams = {
header: i18n.global.t('setting.confDockerProxy'),
operationInfo: i18n.global.t('setting.restartNowHelper'),
submitInputInfo: i18n.global.t('setting.restartNow'),
};
confirmDialogRef.value!.acceptParams(confirmParams);
dockerProxyRef.value.acceptParams({
syncList: 'SyncSystemProxy',
});
} else {
loading.value = true;
await updateProxy(params)
@ -188,6 +190,7 @@ const onSubmit = async () => {
proxyPasswd: isClose ? '' : form.proxyPasswd,
proxyPasswdKeep: '',
proxyDocker: isClose ? false : form.proxyDocker,
withDockerRestart: withDockerRestart.value,
};
if (!isClose) {
params.proxyPasswdKeep = form.proxyPasswdKeepItem ? 'Enable' : 'Disable';