diff --git a/src/components/common/env-dynamic-input.vue b/src/components/common/env-dynamic-input.vue new file mode 100644 index 0000000..8c08d86 --- /dev/null +++ b/src/components/common/env-dynamic-input.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/components/common/mounts-dynamic-input.vue b/src/components/common/mounts-dynamic-input.vue new file mode 100644 index 0000000..8c08d86 --- /dev/null +++ b/src/components/common/mounts-dynamic-input.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index e6d0f7a..32a1703 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -1373,10 +1373,30 @@ declare namespace Api { nanoCpus: number; memory: number; env: string; + envs: { key: string; value: string | number | boolean; type: string }[]; labels: string; network: string; }>; + type MountsConfig = CommonType.RecordNullable<{ + /** volume/bind */ + mountType: string; + sourceDir: string; + containerDir: string; + mode: string; + }>; + + type EnvConfig = { + name: string; + value: string | number | boolean; + type: string; + }; + + type LabelsConfig = CommonType.RecordNullable<{ + name: string; + value: string; + }>; + type AutoRemove = 0 | 1; /** 0不重启 1一直重启 2失败后重启(默认重启3次) 3未手动停止则重启 */ diff --git a/src/views/docker/config/modules/publish-config-operate-drawer.vue b/src/views/docker/config/modules/publish-config-operate-drawer.vue index d8587f5..d6e7246 100644 --- a/src/views/docker/config/modules/publish-config-operate-drawer.vue +++ b/src/views/docker/config/modules/publish-config-operate-drawer.vue @@ -3,13 +3,8 @@ import { computed, reactive, ref, watch } from 'vue'; import { useNaiveForm } from '@/hooks/common/form'; import { $t } from '@/locales'; import { publishConfigAutoRemoveOptions, restartPolicyOptions } from '@/constants/business'; -import { - fetchAddPublishConfig, - fetchEditPublishConfig, - fetchGetPartitionTableList, - fetchNetworkList -} from '@/service/api'; -import { translateOptions2 } from '@/utils/common'; +import { fetchAddPublishConfig, fetchEditPublishConfig, fetchNetworkList } from '@/service/api'; +import { parseContent, translateOptions2 } from '@/utils/common'; defineOptions({ name: 'PublishOperateDrawer' @@ -61,6 +56,7 @@ type Model = Pick< | 'nanoCpus' | 'memory' | 'env' + | 'envs' | 'labels' | 'network' >; @@ -82,6 +78,7 @@ function createDefaultModel(): Model { memory: 0, network: 'none', env: '', + envs: [], labels: '' }; } @@ -128,6 +125,15 @@ function closeDrawer() { } async function handleSubmit() { + formRef.value + ?.validate(errors => { + if (!errors) { + model.env = JSON.stringify(parseContent(model.envs) || {}); + close(); + } + }) + .catch(() => window.$message?.warning('请检查表单信息')); + await validate(); // request if (props.operateType === 'add') { @@ -145,6 +151,7 @@ async function handleSubmit() { memory, network, env, + envs, labels } = model; const { error } = await fetchAddPublishConfig({ @@ -161,6 +168,7 @@ async function handleSubmit() { memory, network, env, + envs, labels }); if (error) return; @@ -180,6 +188,7 @@ async function handleSubmit() { memory, network, env, + envs, labels } = model; const { error } = await fetchEditPublishConfig({ @@ -196,6 +205,7 @@ async function handleSubmit() { memory, network, env, + envs, labels }); if (error) return; @@ -293,6 +303,12 @@ watch(visible, () => { :options="translateOptions2(networkList)" /> + + + + + +