Skip to content

Commit

Permalink
fix(storage): 存储管理 S3 存储功能修复 (#5)
Browse files Browse the repository at this point in the history
1、S3存储管理功能及文件上传回显测试通过
2、修复S3协议存储无法编辑
3、对S3私钥配置信息脱密
  • Loading branch information
jskils authored Apr 23, 2024
1 parent 2987d3e commit fa7705f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/views/system/storage/StorageAddModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
<a-input v-model.trim="form.code" placeholder="请输入编码" :disabled="isUpdate" />
</a-form-item>
<a-form-item label="类型" field="type">
<a-select v-model.trim="form.type" :options="storage_type_enum" placeholder="请选择类型" />
<a-select v-model.trim="form.type" :options="storage_type_enum" placeholder="请选择类型" :disabled="isUpdate" />
</a-form-item>
<a-form-item v-if="form.type === 1" label="访问密钥" field="accessKey">
<a-input v-model.trim="form.accessKey" placeholder="请输入访问密钥" />
<a-input v-model.trim="form.accessKey" placeholder="请输入访问密钥" :max-length="255" />
</a-form-item>
<a-form-item v-if="form.type === 1" label="私有密钥" field="secretKey">
<a-input v-model.trim="form.secretKey" placeholder="请输入私有密钥" />
<a-input
v-model.trim="form.secretKey"
placeholder="请输入私有密钥"
:max-length="255"
@input="updateSecretKey"
/>
</a-form-item>
<a-form-item v-if="form.type === 1" label="终端节点" field="endpoint">
<a-input v-model.trim="form.endpoint" placeholder="请输入终端节点" />
Expand Down Expand Up @@ -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<FormInstance>()
Expand All @@ -113,6 +120,7 @@ const { form, resetForm } = useForm<StorageReq>({
code: '',
type: 2,
accessKey: undefined,
secretKeyEncrypted: undefined,
secretKey: undefined,
endpoint: undefined,
bucketName: undefined,
Expand Down Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions src/views/system/storage/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface StorageReq {
type: number
accessKey: string
secretKey: string
secretKeyEncrypted: string
endpoint: string
bucketName: string
domain: string
Expand Down

0 comments on commit fa7705f

Please sign in to comment.