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