mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-11 18:10:49 +08:00
添加自定义存储选项,更新存储卡组件以支持关闭事件,并完善国际化文本
This commit is contained in:
@@ -31,6 +31,12 @@ export const storageOptions = [
|
||||
icon: 'mdi-server-network-outline',
|
||||
remote: true,
|
||||
},
|
||||
{
|
||||
title: i18n.global.t('storage.custom'),
|
||||
value: 'custom',
|
||||
icon: 'mdi-cog-outline',
|
||||
remote: true,
|
||||
},
|
||||
]
|
||||
|
||||
export const storageDict = storageOptions.reduce((dict, item) => {
|
||||
|
||||
@@ -28,7 +28,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
// 定义事件
|
||||
const emit = defineEmits(['done'])
|
||||
const emit = defineEmits(['done', 'close'])
|
||||
|
||||
// 提示信息
|
||||
const $toast = useToast()
|
||||
@@ -130,21 +130,32 @@ function handleDone() {
|
||||
|
||||
// 根据存储类型获取文本
|
||||
function getStorageTypeText(type: string) {
|
||||
return storageOptions.find((option) => option.value === type)?.title
|
||||
return storageOptions.find(option => option.value === type)?.title
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryStorage()
|
||||
})
|
||||
|
||||
// 关闭
|
||||
function onClose() {
|
||||
emit('close')
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<VCard variant="tonal" @click="openStorageDialog">
|
||||
<VDialogCloseBtn v-if="storage.type == 'custom'" @click="onClose" />
|
||||
<VCardText class="flex justify-space-between align-center gap-3">
|
||||
<div class="align-self-start flex-1">
|
||||
<h5 class="text-h6 mb-1">{{ getStorageTypeText(storage.type) }}</h5>
|
||||
<div class="mb-3 text-sm" v-if="total">{{ formatBytes(used, 1) }} / {{ formatBytes(total, 1) }}</div>
|
||||
<div v-else-if="isNullOrEmptyObject(storage.config)">{{ t('storage.notConfigured') }}</div>
|
||||
<template v-if="storage.type != 'custom'">
|
||||
<div class="mb-3 text-sm" v-if="total">{{ formatBytes(used, 1) }} / {{ formatBytes(total, 1) }}</div>
|
||||
<div v-else-if="isNullOrEmptyObject(storage.config)">{{ t('storage.notConfigured') }}</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="mb-3 text-sm">{{ t('storage.custom') }}</div>
|
||||
</template>
|
||||
</div>
|
||||
<VImg :src="getIcon" cover class="mt-5" max-width="3rem" min-width="3rem" />
|
||||
</VCardText>
|
||||
|
||||
@@ -735,6 +735,7 @@ export default {
|
||||
u115: '115 Cloud',
|
||||
rclone: 'RClone',
|
||||
alist: 'AList',
|
||||
custom: 'Custom',
|
||||
},
|
||||
filterRules: {
|
||||
specSub: 'Special Subtitle',
|
||||
|
||||
@@ -732,6 +732,7 @@ export default {
|
||||
u115: '115网盘',
|
||||
rclone: 'RClone',
|
||||
alist: 'AList',
|
||||
custom: '自定义',
|
||||
},
|
||||
filterRules: {
|
||||
specSub: '特效字幕',
|
||||
|
||||
@@ -733,6 +733,7 @@ export default {
|
||||
u115: '115網盤',
|
||||
rclone: 'RClone',
|
||||
alist: 'AList',
|
||||
custom: '自定義',
|
||||
},
|
||||
|
||||
filterRules: {
|
||||
|
||||
@@ -174,6 +174,23 @@ async function loadMediaCategories() {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加存储
|
||||
function addStorage() {
|
||||
storages.value.push({
|
||||
name: '自定义存储',
|
||||
type: 'custom',
|
||||
config: {},
|
||||
})
|
||||
}
|
||||
|
||||
// 移除存储
|
||||
function removeStorage(storage: StorageConf) {
|
||||
const index = storages.value.indexOf(storage)
|
||||
if (index > -1) {
|
||||
storages.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 保存设置
|
||||
async function saveSystemSettings(value: any) {
|
||||
try {
|
||||
@@ -212,7 +229,7 @@ onMounted(() => {
|
||||
:component-data="{ 'class': 'grid gap-3 grid-app-card' }"
|
||||
>
|
||||
<template #item="{ element }">
|
||||
<StorageCard :storage="element" @done="updatedStorage" />
|
||||
<StorageCard :storage="element" @done="updatedStorage" @close="removeStorage(element)" />
|
||||
</template>
|
||||
</draggable>
|
||||
</VCardText>
|
||||
@@ -220,6 +237,9 @@ onMounted(() => {
|
||||
<VForm @submit.prevent="() => {}">
|
||||
<div class="d-flex flex-wrap gap-4 mt-4">
|
||||
<VBtn type="submit" class="me-2" @click="saveStorages"> {{ t('common.save') }} </VBtn>
|
||||
<VBtn color="success" variant="tonal" @click="addStorage">
|
||||
<VIcon icon="mdi-plus" />
|
||||
</VBtn>
|
||||
</div>
|
||||
</VForm>
|
||||
</VCardText>
|
||||
|
||||
Reference in New Issue
Block a user