style: Update grid-template-columns in grid-directory-card to use a minimum width of 24rem

This commit is contained in:
jxxghp
2024-07-24 18:05:51 +08:00
parent 2a916a099c
commit bd4975d180
5 changed files with 159 additions and 31 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+136 -25
View File
@@ -1,12 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { MediaDirectory } from '@/api/types' import type { TransferDirectoryConf } from '@/api/types'
import { VTextField } from 'vuetify/lib/components/index.mjs' import { VTextField } from 'vuetify/lib/components/index.mjs'
// 输入参数 // 输入参数
const props = defineProps({ const props = defineProps({
type: String, // download/library type: String, // download/library
directory: { directory: {
type: Object as PropType<MediaDirectory>, type: Object as PropType<TransferDirectoryConf>,
required: true, // 必填参数 required: true, // 必填参数
}, },
categories: { categories: {
@@ -17,8 +17,11 @@ const props = defineProps({
height: String, height: String,
}) })
// 路径 // 下载路径
const path = ref<string>('') const downloadPath = ref<string>('')
// 媒体库路径
const libraryPath = ref<string>('')
// 类型下拉字典 // 类型下拉字典
const typeItems = [ const typeItems = [
@@ -27,6 +30,37 @@ const typeItems = [
{ title: '电视剧', value: '电视剧' }, { title: '电视剧', value: '电视剧' },
] ]
// 存储下拉字典
const storageItems = [
{ title: '本地', value: 'local' },
{ title: '阿里云盘', value: 'alipan' },
{ title: '115网盘', value: 'u115' },
{ title: 'Rclone网盘', value: 'rclone' },
]
// 自动整理方式下拉字典
const transferSourceItems = [
{ title: '不自动整理', value: '' },
{ title: '下载器监控', value: 'downloader' },
{ title: '目录监控', value: 'monitor' },
]
// 整理方式下拉字典
const transferTypeItems = [
{ title: '复制', value: 'copy' },
{ title: '移动', value: 'move' },
{ title: '硬链接', value: 'link' },
{ title: '软链接', value: 'softlink' },
]
// 覆盖模式下拉字典
const overwriteModeItems = [
{ title: '从不', value: 'never' },
{ title: '总是', value: 'always' },
{ title: '按文件大小', value: 'size' },
{ title: '仅保留最新版本', value: 'latest' },
]
// 定义触发的自定义事件 // 定义触发的自定义事件
const emit = defineEmits(['close', 'changed', 'update:modelValue']) const emit = defineEmits(['close', 'changed', 'update:modelValue'])
@@ -35,10 +69,22 @@ function onClose() {
emit('close') emit('close')
} }
// 路径更新 // 下载路径更新
function updatePath(value: string) { function updateDownloadPath(value: string) {
path.value = value downloadPath.value = value
emit('update:modelValue', value) emit('update:modelValue', {
download: downloadPath.value,
library: libraryPath.value,
})
}
// 媒体库路径更新
function updateLibraryPath(value: string) {
libraryPath.value = value
emit('update:modelValue', {
download: downloadPath.value,
library: libraryPath.value,
})
} }
// 根据选中的媒体类型,获取对应的媒体类别 // 根据选中的媒体类型,获取对应的媒体类别
@@ -68,34 +114,99 @@ const getCategories = computed(() => {
<VCardText> <VCardText>
<VForm> <VForm>
<VRow> <VRow>
<VCol> <VCol cols="6">
<VPathField @update:modelValue="updatePath">
<template #activator="{ menuprops }">
<VTextField v-model="props.directory.path" v-bind="menuprops" variant="underlined" label="路径" />
</template>
</VPathField>
</VCol>
</VRow>
<VRow>
<VCol cols="4">
<VSelect <VSelect
v-model="props.directory.media_type" v-model="props.directory.media_type"
variant="underlined" variant="underlined"
:items="typeItems" :items="typeItems"
label="媒体类型" label="媒体类型"
@update:modelValue="props.directory.category = ''" @update:modelValue="props.directory.media_category = ''"
/> />
</VCol> </VCol>
<VCol> <VCol cols="6">
<VSelect v-model="props.directory.category" variant="underlined" :items="getCategories" label="媒体类别" /> <VSelect
v-model="props.directory.media_category"
variant="underlined"
:items="getCategories"
label="媒体类别"
/>
</VCol>
<VCol cols="4">
<VSelect v-model="props.directory.storage" variant="underlined" :items="storageItems" label="下载存储" />
</VCol>
<VCol cols="8">
<VPathField @update:modelValue="updateDownloadPath">
<template #activator="{ menuprops }">
<VTextField
v-model="props.directory.download_path"
v-bind="menuprops"
variant="underlined"
label="下载目录"
/>
</template>
</VPathField>
</VCol>
<VCol cols="6" v-if="!props.directory.media_type || props.directory.media_type === ''">
<VSwitch v-model="props.directory.download_type_folder" label="按类型分类"></VSwitch>
</VCol>
<VCol cols="6" v-if="!props.directory.media_category || props.directory.media_category === ''">
<VSwitch v-model="props.directory.download_category_folder" label="按类别分类"></VSwitch>
</VCol> </VCol>
</VRow> </VRow>
<VRow> <VRow>
<VCol v-if="!props.directory.category || props.directory.category === ''"> <VCol>
<VSwitch v-model="props.directory.auto_category" label="自动分类"></VSwitch> <VSelect
v-model="props.directory.monitor_type"
variant="underlined"
:items="transferSourceItems"
label="自动整理"
/>
</VCol> </VCol>
<VCol v-if="type === 'library'"> </VRow>
<VSwitch v-model="props.directory.scrape" label="刮削元数据"></VSwitch> <VDivider v-if="$props.directory.monitor_type" class="my-3 bg-primary" />
<VRow v-if="$props.directory.monitor_type">
<VCol cols="4">
<VSelect
v-model="props.directory.transfer_type"
variant="underlined"
:items="transferTypeItems"
label="整理方式"
/>
</VCol>
<VCol cols="8">
<VSelect
v-model="props.directory.overwrite_mode"
variant="underlined"
:items="overwriteModeItems"
label="覆盖模式"
/>
</VCol>
<VCol cols="4">
<VSelect v-model="props.directory.storage" variant="underlined" :items="storageItems" label="媒体库存储" />
</VCol>
<VCol cols="8">
<VPathField @update:modelValue="updateLibraryPath">
<template #activator="{ menuprops }">
<VTextField
v-model="props.directory.library_path"
v-bind="menuprops"
variant="underlined"
label="媒体库目录"
/>
</template>
</VPathField>
</VCol>
<VCol cols="6" v-if="!props.directory.media_type || props.directory.media_type === ''">
<VSwitch v-model="props.directory.library_type_folder" label="按类型分类"></VSwitch>
</VCol>
<VCol cols="6" v-if="!props.directory.media_category || props.directory.media_category === ''">
<VSwitch v-model="props.directory.library_category_folder" label="按类别分类"></VSwitch>
</VCol>
<VCol cols="6">
<VSwitch v-model="props.directory.renaming" label="智能重命名"></VSwitch>
</VCol>
<VCol cols="6">
<VSwitch v-model="props.directory.scraping" label="刮削元数据"></VSwitch>
</VCol> </VCol>
</VRow> </VRow>
</VForm> </VForm>
+4 -1
View File
@@ -4,6 +4,7 @@ import { formatBytes } from '@core/utils/formatters'
import storage_png from '@images/misc/storage.png' import storage_png from '@images/misc/storage.png'
import alipan_png from '@images/misc/alipan.webp' import alipan_png from '@images/misc/alipan.webp'
import u115_png from '@images/misc/u115.png' import u115_png from '@images/misc/u115.png'
import rclone_png from '@images/misc/rclone.png'
// 定义输入 // 定义输入
const props = defineProps({ const props = defineProps({
@@ -28,6 +29,8 @@ const getIcon = computed(() => {
return alipan_png return alipan_png
case 'u115': case 'u115':
return u115_png return u115_png
case 'rclone':
return rclone_png
default: default:
return storage_png return storage_png
} }
@@ -48,7 +51,7 @@ const usage = computed(() => {
<h4 class="text-h4">{{ formatBytes(available) }}</h4> <h4 class="text-h4">{{ formatBytes(available) }}</h4>
</div> </div>
</div> </div>
<VImg :src="getIcon" cover class="m-3" /> <VImg :src="getIcon" cover class="m-3" max-width="6rem" />
</VCardText> </VCardText>
</VCard> </VCard>
</template> </template>
+1 -1
View File
@@ -166,7 +166,7 @@
} }
.grid-directory-card { .grid-directory-card {
grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(24rem, 1fr));
padding-block-end: 1rem; padding-block-end: 1rem;
} }
+18 -4
View File
@@ -51,7 +51,14 @@ async function saveStorages() {
} }
// 查询目录 // 查询目录
async function loadDirectories() {} async function loadDirectories() {
try {
const result: { [key: string]: any } = await api.get('system/setting/Directories')
directories.value = result.data?.value ?? []
} catch (error) {
console.log(error)
}
}
// 保存目录 // 保存目录
async function saveDirectories() { async function saveDirectories() {
@@ -59,7 +66,15 @@ async function saveDirectories() {
} }
// 添加媒体库目录 // 添加媒体库目录
function addDirectory() {} function addDirectory() {
directories.value.push({
name: '新目录',
storage: 'local',
download_path: '',
priority: -1,
monitor_type: '',
})
}
// 调用API查询自动分类配置 // 调用API查询自动分类配置
async function loadMediaCategories() { async function loadMediaCategories() {
@@ -117,11 +132,10 @@ onMounted(() => {
item-key="pri" item-key="pri"
tag="div" tag="div"
@end="orderDirectoryCards" @end="orderDirectoryCards"
:component-data="{ 'class': 'grid gap-3 grid-app-card' }" :component-data="{ 'class': 'grid gap-3 grid-directory-card items-start' }"
> >
<template #item="{ element }"> <template #item="{ element }">
<DirectoryCard <DirectoryCard
type="library"
:directory="element" :directory="element"
:categories="mediaCategories" :categories="mediaCategories"
@update:modelValue="(value: string) => (element.path = value)" @update:modelValue="(value: string) => (element.path = value)"