网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
@using Dpz.Core.WebMore.Helper.Icons

@if (Filename == "loading...")
{
    <img src="https://dpangzi.com/icons/loading.gif" alt="loading"/>
}
else if (!string.IsNullOrEmpty(Filename))
{
    var icon = MatchIcon();
    <img src="https://dpangzi.com/icons/@(icon).svg" alt="@icon"/>
}

@code {

    [Parameter]
    public bool IsFolder { get; set; }

    [Parameter]
    public string Filename { get; set; } = "";
    
    string MatchIcon()
    {
        var name = Filename.ToLower();
        var languageIcons = MaterialIcon.GetLanguageIcons();
        var fileIcons = MaterialIcon.GetFileIcons();
        var folderIcons = MaterialIcon.GetFolderIcons();
        
        var folderIcon = folderIcons.FirstOrDefault(x => x.FolderNames.Contains(name));
        if (folderIcon != null)
            return folderIcon.Name;
        
        
        var fileIcon = fileIcons.FirstOrDefault(x => x.FileNames.Contains(name));
        if (fileIcon != null)
            return fileIcon.Name;
        
        
        var index = name.LastIndexOf('.');
        if (index >= 0)
        {
            var expandName = name[(index + 1)..];
            var fileIcon2 = fileIcons.FirstOrDefault(x => x.FileExtensions.Contains(expandName));
            if (fileIcon2 != null)
                return fileIcon2.Name;
            
            var languageIcon = languageIcons.FirstOrDefault(x => x.Ids.Contains(expandName));
            if (languageIcon != null)
                return languageIcon.Icon.Name;
        }
        
        return IsFolder ? "folder" : "file";
    }
}
loading