mirror of
https://github.com/rustfs/console.git
synced 2026-09-18 08:46:23 +08:00
fix: creact Object suffix
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
<n-modal :show="show" @update:show="(val: boolean) => $emit('update:show', val)" size="huge">
|
||||
<n-card class="max-w-screen-md">
|
||||
<template #header>
|
||||
<div style="display:flex; justify-content: space-between; align-items:center;">
|
||||
<span>{{ t('New Form', { type: displayType }) }}</span>
|
||||
<n-button size="small" ghost @click="closeModal">{{ t('Close') }}</n-button>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center">
|
||||
<span>{{ t("New Form", { type: displayType }) }}</span>
|
||||
<n-button size="small" ghost @click="closeModal">{{ t("Close") }}</n-button>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex flex-col gap-4">
|
||||
@@ -14,7 +14,7 @@
|
||||
</div> -->
|
||||
|
||||
<n-alert title="" type="info">
|
||||
{{ t('Overwrite Warning') }}
|
||||
{{ t("Overwrite Warning") }}
|
||||
</n-alert>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
@@ -22,7 +22,9 @@
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center gap-4">
|
||||
<n-button type="primary" :disabled="objectKey.trim().length < 1" @click="handlePutObject">{{ t('Create') }}</n-button>
|
||||
<n-button type="primary" :disabled="objectKey.trim().length < 1" @click="handlePutObject">
|
||||
{{ t("Create") }}
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</n-card>
|
||||
@@ -30,33 +32,36 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { joinRelativeURL } from 'ufo'
|
||||
import { computed, defineEmits, defineProps } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { joinRelativeURL } from "ufo";
|
||||
import { computed, defineEmits, defineProps } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n()
|
||||
const emit = defineEmits(['update:show'])
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(["update:show"]);
|
||||
|
||||
const props = defineProps<{ show: boolean; bucketName: string; prefix: string, asPrefix?: boolean }>()
|
||||
const props = defineProps<{ show: boolean; bucketName: string; prefix: string; asPrefix?: boolean }>();
|
||||
|
||||
const closeModal = () => emit('update:show', false)
|
||||
const closeModal = () => emit("update:show", false);
|
||||
|
||||
const displayType = computed(() => props.asPrefix ? t('New Folder') : t('New File'))
|
||||
const displayType = computed(() => (props.asPrefix ? t("New Folder") : t("New File")));
|
||||
|
||||
const objectKey = ref('')
|
||||
const objectKey = ref("");
|
||||
|
||||
const { putObject } = useObject({ bucket: props.bucketName })
|
||||
const { putObject } = useObject({ bucket: props.bucketName });
|
||||
|
||||
const $message = useMessage()
|
||||
const $message = useMessage();
|
||||
|
||||
const handlePutObject = () => {
|
||||
const suffix = props.asPrefix ? '/' : ''
|
||||
putObject(joinRelativeURL(props.prefix, objectKey.value, suffix), '').then(() => {
|
||||
emit('update:show', false)
|
||||
objectKey.value = ''
|
||||
$message.success(t('Create Success'))
|
||||
}).catch((e) => {
|
||||
$message.error(e.message)
|
||||
})
|
||||
}
|
||||
const suffix = props.asPrefix ? "/" : "";
|
||||
const cleanedKey = objectKey.value.replace(/^\/+|\/+$/g, ""); // 移除开头和结尾的 `/`
|
||||
putObject(joinRelativeURL(props.prefix, cleanedKey, suffix), "")
|
||||
.then(() => {
|
||||
emit("update:show", false);
|
||||
objectKey.value = "";
|
||||
$message.success(t("Create Success"));
|
||||
})
|
||||
.catch((e) => {
|
||||
$message.error(e.message);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user