From fa7705fd7671142e3089dea28da079f32b95b555 Mon Sep 17 00:00:00 2001 From: kils Date: Tue, 23 Apr 2024 20:21:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(storage):=20=E5=AD=98=E5=82=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20S3=20=E5=AD=98=E5=82=A8=E5=8A=9F=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20(#5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、S3存储管理功能及文件上传回显测试通过 2、修复S3协议存储无法编辑 3、对S3私钥配置信息脱密 --- src/views/system/storage/StorageAddModal.vue | 26 ++++++++++++++++---- src/views/system/storage/type.ts | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/views/system/storage/StorageAddModal.vue b/src/views/system/storage/StorageAddModal.vue index 97170d3..7fbfa4c 100644 --- a/src/views/system/storage/StorageAddModal.vue +++ b/src/views/system/storage/StorageAddModal.vue @@ -16,13 +16,18 @@ - + - + - + @@ -89,11 +94,13 @@ import { Message, type FormInstance } from '@arco-design/web-vue' import { useForm } from '@/hooks' import { useDict } from '@/hooks/app' import { useWindowSize } from '@vueuse/core' +import { encryptByRsa } from '@/utils/encrypt' const { width } = useWindowSize() const { storage_type_enum } = useDict('storage_type_enum') const dataId = ref('') +const updatedSecretKey = ref(false) const isUpdate = computed(() => !!dataId.value) const title = computed(() => (isUpdate.value ? '修改存储' : '新增存储')) const formRef = ref() @@ -113,6 +120,7 @@ const { form, resetForm } = useForm({ code: '', type: 2, accessKey: undefined, + secretKeyEncrypted: undefined, secretKey: undefined, endpoint: undefined, bucketName: undefined, @@ -146,16 +154,24 @@ const onUpdate = async (id: string) => { visible.value = true } +const updateSecretKey = () => { + updatedSecretKey.value = true +} + // 保存 const save = async () => { try { const isInvalid = await formRef.value?.validate() if (isInvalid) return false + const data = Object.assign({}, form) + if (data.type === 1) { + data.secretKey = updatedSecretKey.value ? encryptByRsa(form.secretKey) : form.secretKeyEncrypted + } if (isUpdate.value) { - await updateStorage(form, dataId.value) + await updateStorage(data, dataId.value) Message.success('修改成功') } else { - await addStorage(form) + await addStorage(data) Message.success('新增成功') } emit('save-success') diff --git a/src/views/system/storage/type.ts b/src/views/system/storage/type.ts index d329730..b315798 100644 --- a/src/views/system/storage/type.ts +++ b/src/views/system/storage/type.ts @@ -4,6 +4,7 @@ export interface StorageReq { type: number accessKey: string secretKey: string + secretKeyEncrypted: string endpoint: string bucketName: string domain: string