/** * Helper for image manipulation and image-related utility functions * */import { BaseItemDto, BaseItemKind, BaseItemPerson, ImageType} from '@jellyfin/sdk/lib/generated-client';import { useRemote } from '@/composables';import { getShapeFromItemType, isPerson, CardShapes } from '@/utils/items';export interface ImageUrlInfo { url?: string; blurhash?: string;}const excludedBlurhashTypes = Object.freeze( new Set<ImageType>([ImageType.Logo]));/** * Gets the tag of the image of an specific item and type. * * @param item - The item object. * @param type - The type of the image requested. * @param [index=0] - Index of the Backdrop image (when ImageType equals to 'Backdrop'). * @param [checkParent=true] - Looks for tag/image type for the parent if the passed item doesn't have the ImageType requested * @returns Returns the tag, undefined if the specific ImageType doesn't exist. */export function getImageTag( item: BaseItemDto | BaseItemPerson, type: ImageType, index = 0, checkParent = true): string | undefined { if (isPerson(item)) { return item.PrimaryImageTag && type === ImageType.Primary ? item.PrimaryImageTag : undefined; } if (item.ImageTags?.[type]) { return item.ImageTags?.[type]; } else if (type === ImageType.Backdrop && item.BackdropImageTags?.[index]) { return item.BackdropImageTags[index]; } if (checkParent) { switch (type) { case ImageType.Primary: { return ( item.AlbumPrimaryImageTag || item.ChannelPrimaryImageTag || item.ParentPrimaryImageTag || undefined ); } case ImageType.Art: { return item.ParentArtImageTag ?? undefined; } case ImageType.Backdrop: { return item.ParentBackdropImageTags?.[index] ?? undefined; } case ImageType.Logo: { return item.ParentLogoImageTag ?? undefined; } case ImageType.Thumb: { return item.ParentThumbImageTag ?? undefined; } } }}/** * Gets the itemId of the parent element. * * @param item - The item object. * @returns Returns the parent itemId, undefined if it doesn't exist. */export function getParentId(item: BaseItemDto): string | undefined { if (item.AlbumId) { return item.AlbumId; } else if (item.ChannelId) { return item.ChannelId; } else if (item.SeriesId) { return item.SeriesId; } else if (item.ParentArtItemId) { return item.ParentArtItemId; } else if (item.ParentPrimaryImageItemId) { return item.ParentPrimaryImageItemId; } else if (item.ParentThumbItemId) { return item.ParentThumbItemId; } else if (item.ParentBackdropItemId) { return item.ParentBackdropItemId; } else if (item.ParentLogoItemId) { return item.ParentLogoItemId; } else if (item.SeasonId) { return item.SeasonId; } else if (item.ParentId) { return item.ParentId; }}/** * Gets the blurhash string of an image given the item and the image type desired. * * @param item - The item object. * @param type - The type of the image requested. * @param [index=0] - Index of the Backdrop image (when ImageType equals to 'Backdrop'). * @param [checkParent=true] - Checks for the parent's images blurhash (in case the provided item doesn't have it) * @returns Returns the tag, undefined if the specific ImageType doesn't exist. */export function getBlurhash( item: BaseItemDto | BaseItemPerson, type: ImageType, index = 0, checkParent = true): string | undefined { if (item) { const tag = getImageTag(item, type, index, checkParent); if ( tag && !excludedBlurhashTypes.has(type) && item.ImageBlurHashes?.[type]?.[tag] ) { return item.ImageBlurHashes?.[type]?.[tag]; } }}/** * Returns the aspect ratio that should be use */export function getContainerAspectRatioForImageType( imageType?: ImageType): number { if (imageType === ImageType.Backdrop) { return 1.777_777_778; } return 0.666_666_667;}/** * Gets the desired aspect ratio based on card shape * @param shape * @returns */export function getDesiredAspect(shape: CardShapes): number { let aspectRatio; switch (shape) { case CardShapes.Portrait: { aspectRatio = 2 / 3; break; } case CardShapes.Thumb: { aspectRatio = 16 / 9; break; } case CardShapes.Banner: { aspectRatio = 1000 / 185; break; } default: { aspectRatio = 1; break; } } return aspectRatio;}/** * Generates the image information for a BaseItemDto or a BasePersonDto according to set priorities. * * @param item - Item to get image information for * @param [options] - Optional parameters for the function. * @param [options.shape] - Shape of the card or element, used to determine what kind of image to prefer * @param [options.preferThumb=false] - Prefer the Thumb images * @param [options.preferBanner=false] - Prefer the Banner images * @param [options.preferLogo=false] - Prefer the Logo images * @param [options.preferBackdrop=false] - Prefer the Backdrop images * @param [options.inheritThumb=false] - Inherit the thumb from parent items * @param [options.quality=90] - Sets the quality of the returned image * @param [options.width] - Sets the requested width of the image * @param [options.ratio=1] - Sets the device pixel ratio for the image, used for computing the real image size * @param [options.tag] - Sets a specific image tag to get, bypassing the automatic priorities. * @returns Information for the item, containing the full URL and blurhash. */export function getImageInfo(){}
comment test page
春江花月夜
春江潮水連海平,海上明月共潮生。 灩灩隨波千萬里,何處春江無月明! 江流宛轉遶芳甸,月照花林皆似霰。 空裏流霜不覺飛,汀上白沙看不見。 江天一色無纖塵,皎皎空中孤月輪。 江畔何人初見月?江畔何年初照人? 人生代代無窮已,江月年年祗相似。 不知江月待何人,但見長江送流水。 白雲一片去悠悠,青楓浦上不勝愁。 誰家今夜扁舟子?何處相思明月樓? 可憐樓上月徘徊,應照離人妝鏡台。
玉戶簾中卷不去,擣衣砧上拂還來。 此時相望不相聞,願逐月華流照君。 鴻雁長飛光不度,魚龍潛躍水成文。 昨夜閑潭夢落花,可憐春半不還家。 江水流春去欲盡,江潭落月復西斜。 斜月沉沉藏海霧,碣石瀟湘無限路。 不知乘月幾人歸,落月搖情滿江樹。
长代码
python test
这里是正文