修复默认歌单显示

This commit is contained in:
2025-03-31 18:35:08 +08:00
parent 03c9bfe761
commit 21e9e0fa27
4 changed files with 16 additions and 21 deletions

View File

@@ -195,7 +195,7 @@ export type ExtractConfigData<
* @param items 一个只读的配置项定义数组。 * @param items 一个只读的配置项定义数组。
* @returns 类型被保留的同一个只读数组。 * @returns 类型被保留的同一个只读数组。
*/ */
export function defineItems< export function defineTemplateConfig<
const Items extends readonly ConfigItemDefinition[] // 使用 'const' 泛型进行推断 const Items extends readonly ConfigItemDefinition[] // 使用 'const' 泛型进行推断
>(items: Items): Items { >(items: Items): Items {
// 如果需要,可以在此处添加基本的运行时验证。 // 如果需要,可以在此处添加基本的运行时验证。

View File

@@ -78,7 +78,7 @@ import { computed, onMounted, ref, watch } from 'vue';
if (componentType.value) { if (componentType.value) {
return SongListTemplateMap[componentType.value]; return SongListTemplateMap[componentType.value];
} }
return undefined; return SongListTemplateMap[''];
}); });
const currentConfig = ref(); const currentConfig = ref();
watch( watch(

View File

@@ -1,13 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { isDarkMode } from '@/Utils' import { isDarkMode } from '@/Utils';
import { useAccount } from '@/api/account' import { useAccount } from '@/api/account';
import { ResponseUserIndexModel, UserInfo } from '@/api/api-models' import { ResponseUserIndexModel, UserInfo } from '@/api/api-models';
import { QueryGetAPI } from '@/api/query' import { QueryGetAPI } from '@/api/query';
import SimpleVideoCard from '@/components/SimpleVideoCard.vue' import SimpleVideoCard from '@/components/SimpleVideoCard.vue';
import { TemplateConfig } from '@/data/VTsuruTypes' import { defineTemplateConfig, ExtractConfigData } from '@/data/VTsuruTypes';
import { USER_INDEX_API_URL } from '@/data/constants' import { USER_INDEX_API_URL } from '@/data/constants';
import { NAlert, NAvatar, NButton, NCard, NDivider, NFlex, NSpace, NText, useMessage } from 'naive-ui' import { NAvatar, NButton, NCard, NDivider, NFlex, NSpace, NText, useMessage } from 'naive-ui';
import { ref } from 'vue' import { ref } from 'vue';
defineExpose({ Config, DefaultConfig }) defineExpose({ Config, DefaultConfig })
const width = window.innerWidth const width = window.innerWidth
@@ -46,13 +46,9 @@ function navigate(url: string) {
</script> </script>
<script lang="ts"> <script lang="ts">
export type ConfigType = { export type ConfigType = ExtractConfigData<typeof Config>
test: string
}
export const DefaultConfig = {} as ConfigType export const DefaultConfig = {} as ConfigType
export const Config: TemplateConfig<ConfigType> = { export const Config = defineTemplateConfig([
name: 'Template.Index.Simple',
items: [
{ {
name: '封面', name: '封面',
type: 'image', type: 'image',
@@ -64,8 +60,7 @@ export const Config: TemplateConfig<ConfigType> = {
type: 'string', type: 'string',
key: 'test', key: 'test',
}, },
], ])
}
</script> </script>
<template> <template>

View File

@@ -2,7 +2,7 @@
import { computed, h, ref, watch } from 'vue'; // Import computed and watch import { computed, h, ref, watch } from 'vue'; // Import computed and watch
import { getUserAvatarUrl, isDarkMode } from '@/Utils'; import { getUserAvatarUrl, isDarkMode } from '@/Utils';
import { SongListConfigTypeWithConfig } from '@/data/TemplateTypes'; import { SongListConfigTypeWithConfig } from '@/data/TemplateTypes';
import { defineItems, ExtractConfigData } from '@/data/VTsuruTypes'; import { defineTemplateConfig, ExtractConfigData } from '@/data/VTsuruTypes';
import { FILE_BASE_URL } from '@/data/constants'; import { FILE_BASE_URL } from '@/data/constants';
import { NButton, NFlex, NIcon, NInput, NInputGroup, NInputGroupLabel, NTag, NTooltip, NSelect } from 'naive-ui'; // Import NSelect import { NButton, NFlex, NIcon, NInput, NInputGroup, NInputGroupLabel, NTag, NTooltip, NSelect } from 'naive-ui'; // Import NSelect
import bilibili from '@/svgs/bilibili.svg'; import bilibili from '@/svgs/bilibili.svg';
@@ -216,7 +216,7 @@
export type TraditionalConfigType = ExtractConfigData<typeof Config>; export type TraditionalConfigType = ExtractConfigData<typeof Config>;
export const DefaultConfig = {} as TraditionalConfigType; export const DefaultConfig = {} as TraditionalConfigType;
export const Config = defineItems([ export const Config = defineTemplateConfig([
{ {
name: '背景', name: '背景',
type: 'image', type: 'image',